annotate DEPENDENCIES/generic/include/boost/pending/lowest_bit.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // -----------------------------------------------------------
Chris@16 2 // lowest_bit.hpp
Chris@16 3 //
Chris@16 4 // Position of the lowest bit 'on'
Chris@16 5 //
Chris@16 6 // Copyright (c) 2003-2004, 2008 Gennaro Prota
Chris@16 7 //
Chris@16 8 // Distributed under the Boost Software License, Version 1.0.
Chris@16 9 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 10 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 11 //
Chris@16 12 // -----------------------------------------------------------
Chris@16 13
Chris@16 14 #ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
Chris@16 15 #define BOOST_LOWEST_BIT_HPP_GP_20030301
Chris@16 16
Chris@16 17 #include <assert.h>
Chris@16 18 #include "boost/pending/integer_log2.hpp"
Chris@16 19
Chris@16 20
Chris@16 21 namespace boost {
Chris@16 22
Chris@16 23 template <typename T>
Chris@16 24 int lowest_bit(T x) {
Chris@16 25
Chris@16 26 assert(x >= 1); // PRE
Chris@16 27
Chris@16 28 // clear all bits on except the rightmost one,
Chris@16 29 // then calculate the logarithm base 2
Chris@16 30 //
Chris@16 31 return boost::integer_log2<T>( x - ( x & (x-1) ) );
Chris@16 32
Chris@16 33 }
Chris@16 34
Chris@16 35
Chris@16 36 }
Chris@16 37
Chris@16 38
Chris@16 39 #endif // include guard