1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/pending/lowest_bit.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,39 @@
1.4 +// -------------------------------------
1.5 +// lowest_bit.hpp
1.6 +//
1.7 +// Position of the lowest bit 'on'
1.8 +//
1.9 +// (C) Copyright Gennaro Prota 2003 - 2004.
1.10 +//
1.11 +// Distributed under the Boost Software License, Version 1.0.
1.12 +// (See accompanying file LICENSE_1_0.txt or copy at
1.13 +// http://www.boost.org/LICENSE_1_0.txt)
1.14 +//
1.15 +// ------------------------------------------------------
1.16 +
1.17 +#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
1.18 +#define BOOST_LOWEST_BIT_HPP_GP_20030301
1.19 +
1.20 +#include <cassert>
1.21 +#include "boost/pending/integer_log2.hpp"
1.22 +
1.23 +
1.24 +namespace boost {
1.25 +
1.26 + template <typename T>
1.27 + int lowest_bit(T x) {
1.28 +
1.29 + assert(x >= 1); // PRE
1.30 +
1.31 + // clear all bits on except the rightmost one,
1.32 + // then calculate the logarithm base 2
1.33 + //
1.34 + return boost::integer_log2<T>( x - ( x & (x-1) ) );
1.35 +
1.36 + }
1.37 +
1.38 +
1.39 +}
1.40 +
1.41 +
1.42 +#endif // include guard