mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-19 04:12:09 +00:00
cleanup pending and detail headers
This commit is contained in:
@@ -14,16 +14,16 @@
|
||||
#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||
#define BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||
|
||||
#include <assert.h>
|
||||
#include "boost/integer/integer_log2.hpp"
|
||||
|
||||
#include "boost/assert.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
int lowest_bit(T x) {
|
||||
|
||||
assert(x >= 1); // PRE
|
||||
BOOST_ASSERT(x >= 1); // PRE
|
||||
|
||||
// clear all bits on except the rightmost one,
|
||||
// then calculate the logarithm base 2
|
||||
@@ -32,7 +32,7 @@ namespace boost {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
#endif
|
||||
|
||||
#include "boost/dynamic_bitset_fwd.hpp"
|
||||
#include "boost/detail/dynamic_bitset.hpp"
|
||||
#include "boost/dynamic_bitset/detail/dynamic_bitset.hpp"
|
||||
#include "boost/dynamic_bitset/detail/lowest_bit.hpp"
|
||||
#include "boost/detail/iterator.hpp" // used to implement append(Iter, Iter)
|
||||
#include "boost/move/move.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/pending/lowest_bit.hpp"
|
||||
#include "boost/static_assert.hpp"
|
||||
#include "boost/utility/addressof.hpp"
|
||||
#include "boost/detail/no_exceptions_support.hpp"
|
||||
@@ -1434,7 +1434,6 @@ bool dynamic_bitset<Block, Allocator>::intersects(const dynamic_bitset & b) cons
|
||||
// --------------------------------
|
||||
// lookup
|
||||
|
||||
|
||||
// look for the first bit "on", starting
|
||||
// from the block with index first_block
|
||||
//
|
||||
@@ -1451,8 +1450,7 @@ dynamic_bitset<Block, Allocator>::m_do_find_from(size_type first_block) const
|
||||
if (i >= num_blocks())
|
||||
return npos; // not found
|
||||
|
||||
return i * bits_per_block + static_cast<size_type>(boost::lowest_bit(m_bits[i]));
|
||||
|
||||
return i * bits_per_block + static_cast<size_type>(detail::lowest_bit(m_bits[i]));
|
||||
}
|
||||
|
||||
|
||||
@@ -1482,7 +1480,7 @@ dynamic_bitset<Block, Allocator>::find_next(size_type pos) const
|
||||
const Block fore = m_bits[blk] >> ind;
|
||||
|
||||
return fore?
|
||||
pos + static_cast<size_type>(lowest_bit(fore))
|
||||
pos + static_cast<size_type>(detail::lowest_bit(fore))
|
||||
:
|
||||
m_do_find_from(blk + 1);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ test-suite dynamic_bitset :
|
||||
[ run dyn_bitset_unit_tests3.cpp : : : <library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests4.cpp : : : <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/system//boost_system ]
|
||||
[ run test_lowest_bit.cpp ]
|
||||
;
|
||||
|
||||
# due to https://github.com/boostorg/serialization/issues/108
|
||||
|
||||
28
test/test_lowest_bit.cpp
Normal file
28
test/test_lowest_bit.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright (C) 2018 James E. King III
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/dynamic_bitset/detail/lowest_bit.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
for (boost::int32_t i = 1; i < 32; ++i) {
|
||||
BOOST_TEST_EQ(i, boost::detail::lowest_bit(1u << i));
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ(2, boost::detail::lowest_bit(123456788));
|
||||
BOOST_TEST_EQ(30, boost::detail::lowest_bit(static_cast<boost::int64_t>(1507208177123328)));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user