Skip to content

Commit

Permalink
Merge branch 'boostorg:develop' into push_back
Browse files Browse the repository at this point in the history
  • Loading branch information
unixnme authored Dec 3, 2024
2 parents 433aa3a + cd59d32 commit 237dafa
Show file tree
Hide file tree
Showing 14 changed files with 354 additions and 176 deletions.
26 changes: 2 additions & 24 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,40 +64,18 @@ environment:
B2_CXXSTD: 14,17
B2_TOOLSET: msvc-14.1

- FLAVOR: clang-cl
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,14,17
B2_TOOLSET: clang-win

- FLAVOR: Visual Studio 2015, 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-12.0,msvc-14.0

- FLAVOR: Visual Studio 2008, 2010, 2012
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
B2_ADDRESS_MODEL: 32 # No 64bit support

- FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: 32
B2_CXXSTD: 03,11,14,1z
B2_CXXSTD: 11,14,1z
B2_TOOLSET: gcc

- FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 03,11,14,1z
B2_TOOLSET: gcc

- FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 03,11,14,17,2a
B2_CXXSTD: 11,14,1z
B2_TOOLSET: gcc

install:
Expand Down
310 changes: 218 additions & 92 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions Jamfile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Distributed under the [Boost Software License, Version 1.0](http://www.boost.org

### Properties

* C++03
* C++11
* Header-only

### Build Status

Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [![Build Status](https://github.com/boostorg/dynamic_bitset/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/dynamic_bitset/actions?query=branch:master) | [![Build status](https://ci.appveyor.com/api/projects/status/keyn57y5d3sl1gw5/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/dynamic_bitset.html)
[`develop`](https://github.com/boostorg/dynamic_bitset/tree/develop) | [![Build Status](https://github.com/boostorg/dynamic_bitset/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/dynamic_bitset/actions?query=branch:develop) | [![Build status](https://ci.appveyor.com/api/projects/status/keyn57y5d3sl1gw5/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)
[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [![Build Status](https://github.com/boostorg/dynamic_bitset/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/dynamic_bitset/actions?query=branch:master) | [![Build status](https://ci.appveyor.com/api/projects/status/n7bki5ka3v918r5r?svg=true)](https://ci.appveyor.com/project/cppalliance/dynamic-bitset) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://www.boost.org/doc/libs/master/libs/dynamic_bitset/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/dynamic_bitset.html)
[`develop`](https://github.com/boostorg/dynamic_bitset/tree/develop) | [![Build Status](https://github.com/boostorg/dynamic_bitset/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/dynamic_bitset/actions?query=branch:develop) | [![Build status](https://ci.appveyor.com/api/projects/status/n7bki5ka3v918r5r/branch/develop?svg=true)](https://ci.appveyor.com/project/cppalliance/dynamic-bitset/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](https://www.boost.org/doc/libs/develop/libs/dynamic_bitset/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)

### Directories

Expand Down
30 changes: 30 additions & 0 deletions build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# 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)

require-b2 5.2 ;

constant boost_dependencies :
/boost/assert//boost_assert
/boost/config//boost_config
/boost/container_hash//boost_container_hash
/boost/core//boost_core
/boost/integer//boost_integer
/boost/move//boost_move
/boost/static_assert//boost_static_assert
/boost/throw_exception//boost_throw_exception ;

project /boost/dynamic_bitset
: common-requirements
<include>include
;

explicit
[ alias boost_dynamic_bitset : : : : <library>$(boost_dependencies) ]
[ alias all : boost_dynamic_bitset example test ]
;

call-if : boost-library dynamic_bitset
;

10 changes: 10 additions & 0 deletions dynamic_bitset.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ <h3><a id ="synopsis">Synopsis</a></h3>
bool <a href="#intersects">intersects</a>(const dynamic_bitset&amp; a) const;

size_type <a href="#find_first">find_first</a>() const;
size_type <a href="#find_first_off">find_first</a>(size_type pos) const;
size_type <a href="#find_next">find_next</a>(size_type pos) const;

};
Expand Down Expand Up @@ -1373,6 +1374,15 @@ <h3><a id="member-functions">Member Functions</a></h3>
<b>Returns:</b> the lowest index <tt>i</tt> such as bit <tt>i</tt>
is set, or <tt>npos</tt> if <tt>*this</tt> has no on bits.

<hr />
<pre>
size_type <a id = "find_first_off">find_first</a>(size_type pos) const;
</pre>

<b>Returns:</b> the lowest index <tt>i</tt> greater or equal to
<tt>offset</tt> such as bit <tt>i</tt> is set, or <tt>npos</tt> if
no such index exists.

<hr />
<pre>
size_type <a id="find_next">find_next</a>(size_type pos) const;
Expand Down
9 changes: 6 additions & 3 deletions example/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
#
# -----------------------------------------------------------

exe timing_tests
: timing_tests.cpp
../../timer/build//boost_timer
project : requirements <library>/boost/dynamic_bitset//boost_dynamic_bitset ;

exe timing_tests
: timing_tests.cpp
/boost/timer//boost_timer
/boost/detail//boost_detail
;

exe example1
Expand Down
20 changes: 12 additions & 8 deletions include/boost/dynamic_bitset/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class dynamic_bitset

// lookup
size_type find_first() const;
size_type find_first(size_type pos) const;
size_type find_next(size_type pos) const;


Expand Down Expand Up @@ -1325,7 +1326,7 @@ to_ulong() const

// Check for overflows. This may be a performance burden on very
// large bitsets but is required by the specification, sorry
if (find_next(ulong_width - 1) != npos)
if (find_first(ulong_width) != npos)
BOOST_THROW_EXCEPTION(std::overflow_error("boost::dynamic_bitset::to_ulong overflow"));


Expand Down Expand Up @@ -1485,17 +1486,12 @@ dynamic_bitset<Block, Allocator>::find_first() const
return m_do_find_from(0);
}


template <typename Block, typename Allocator>
typename dynamic_bitset<Block, Allocator>::size_type
dynamic_bitset<Block, Allocator>::find_next(size_type pos) const
dynamic_bitset<Block, Allocator>::find_first(size_type pos) const
{

const size_type sz = size();
if (pos >= (sz-1) || sz == 0)
return npos;

++pos;
if (pos >= sz) return npos;

const size_type blk = block_index(pos);
const block_width_type ind = bit_index(pos);
Expand All @@ -1507,7 +1503,15 @@ dynamic_bitset<Block, Allocator>::find_next(size_type pos) const
pos + static_cast<size_type>(detail::lowest_bit(fore))
:
m_do_find_from(blk + 1);
}


template <typename Block, typename Allocator>
typename dynamic_bitset<Block, Allocator>::size_type
dynamic_bitset<Block, Allocator>::find_next(size_type pos) const
{
if (pos == npos) return npos;
return find_first(pos + 1);
}


Expand Down
2 changes: 1 addition & 1 deletion meta/libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"maintainers": [
"Jeremy Siek <jeremy.siek -at- gmail.com>"
],
"cxxstd": "03"
"cxxstd": "11"
}
18 changes: 13 additions & 5 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
#

import os ;
import testing ;

# import rules for testing conditional on config file variables
import ../../config/checks/config : requires ;
import-search /boost/config/checks ;
import config : requires ;

project : requirements <library>/boost/dynamic_bitset//boost_dynamic_bitset ;

test-suite dynamic_bitset :

[ run dyn_bitset_unit_tests1.cpp : : : <library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests2.cpp : : : <library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests3.cpp : : : <library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests1.cpp : : : <library>/boost/filesystem//boost_filesystem
<library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests2.cpp : : : <library>/boost/filesystem//boost_filesystem
<library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests3.cpp : : : <library>/boost/filesystem//boost_filesystem
<library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests4.cpp : : : <library>/boost/filesystem//boost_filesystem
<library>/boost/system//boost_system ]
[ run test_ambiguous_set.cpp ]
[ run test_lowest_bit.cpp ]

[ run test_boost_hash.cpp ]
[ run test_std_hash.cpp : : : [ requires cxx11_hdr_unordered_set ] ]
[ run test_std_hash.cpp : : : [ requires cxx11_hdr_unordered_set ] ]

[ compile-fail test_std_hash.cpp : [ requires cxx11_hdr_unordered_set ]
<define>BOOST_DYNAMIC_BITSET_NO_STD_HASH
Expand All @@ -36,6 +43,7 @@ if ! [ os.environ UBSAN_OPTIONS ]

[ run dyn_bitset_unit_tests5.cpp
: : : <define>_SCL_SECURE_NO_WARNINGS=1
<library>/boost/filesystem//boost_filesystem
<library>/boost/serialization//boost_serialization
<library>/boost/system//boost_system ]
;
Expand Down
28 changes: 14 additions & 14 deletions test/bitset_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,25 +967,25 @@ struct bitset_test {
BOOST_TEST(b.intersects(a) == have_intersection);
}

static void find_first(const Bitset& b)
static void find_first(const Bitset& b, typename Bitset::size_type offset = 0)
{
// find first non-null bit, if any
typename Bitset::size_type i = 0;
while (i < b.size() && b[i] == 0)
++i;

if (i == b.size())
BOOST_TEST(b.find_first() == Bitset::npos); // not found;
else {
BOOST_TEST(b.find_first() == i);
BOOST_TEST(b.test(i) == true);
}
// find first non-null bit from offset onwards, if any
typename Bitset::size_type i = offset;
while (i < b.size() && b[i] == 0)
++i;

if (i >= b.size())
BOOST_TEST(b.find_first(offset) == Bitset::npos); // not found;
else {
BOOST_TEST(b.find_first(offset) == i);
BOOST_TEST(b.test(i) == true);
}
}

static void find_next(const Bitset& b, typename Bitset::size_type prev)
static void find_pos(const Bitset& b, typename Bitset::size_type pos)
{
BOOST_TEST(next_bit_on(b, prev) == b.find_next(prev));
find_first(b, pos);
BOOST_TEST(next_bit_on(b, pos) == b.find_next(pos));
}

static void operator_equal(const Bitset& a, const Bitset& b)
Expand Down
22 changes: 22 additions & 0 deletions test/cmake_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021-2024 Alexander Grund
# 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

cmake_minimum_required(VERSION 3.5...3.16)

project(cmake_subdir_test LANGUAGES CXX)

# Those 2 should work the same
# while using find_package for the installed Boost avoids the need to manually specify dependencies
if(BOOST_CI_INSTALL_TEST)
find_package(boost_dynamic_bitset REQUIRED)
else()
set(BOOST_INCLUDE_LIBRARIES dynamic_bitset)
add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL)
endif()

add_executable(main main.cpp)
target_link_libraries(main Boost::dynamic_bitset)

enable_testing()
add_test(NAME main COMMAND main)
8 changes: 8 additions & 0 deletions test/cmake_test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <boost/dynamic_bitset.hpp>

int main()
{
const boost::dynamic_bitset<> db{3, 4};

return db[2] ? 0 : 1;
}
30 changes: 15 additions & 15 deletions test/dyn_bitset_unit_tests3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,26 +329,26 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
Tests::find_first(b);
}
//=====================================================================
// Test find_next
// Test find_next and offset find_first
{
// empty bitset
bitset_type b;

// check
Tests::find_next(b, 0);
Tests::find_next(b, 1);
Tests::find_next(b, 200);
Tests::find_next(b, b.npos);
Tests::find_pos(b, 0);
Tests::find_pos(b, 1);
Tests::find_pos(b, 200);
Tests::find_pos(b, b.npos);
}
{
// bitset of size 1 (find_next can never find)
bitset_type b(1, 1ul);

// check
Tests::find_next(b, 0);
Tests::find_next(b, 1);
Tests::find_next(b, 200);
Tests::find_next(b, b.npos);
Tests::find_pos(b, 0);
Tests::find_pos(b, 1);
Tests::find_pos(b, 200);
Tests::find_pos(b, b.npos);
}
{
// all-1s bitset
Expand All @@ -358,9 +358,9 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
// check
const typename bitset_type::size_type larger_than_size = 5 + b.size();
for(typename bitset_type::size_type i = 0; i <= larger_than_size; ++i) {
Tests::find_next(b, i);
Tests::find_pos(b, i);
}
Tests::find_next(b, b.npos);
Tests::find_pos(b, b.npos);
}
{
// a bitset with 1s at block boundary only
Expand All @@ -379,9 +379,9 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
// check
const typename bitset_type::size_type larger_than_size = 5 + b.size();
for (i = 0; i <= larger_than_size; ++i) {
Tests::find_next(b, i);
Tests::find_pos(b, i);
}
Tests::find_next(b, b.npos);
Tests::find_pos(b, b.npos);

}
{
Expand All @@ -397,9 +397,9 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
// check
const typename bitset_type::size_type larger_than_size = 5 + b.size();
for (i = 0; i <= larger_than_size; ++i) {
Tests::find_next(b, i);
Tests::find_pos(b, i);
}
Tests::find_next(b, b.npos);
Tests::find_pos(b, b.npos);

}
//=====================================================================
Expand Down

0 comments on commit 237dafa

Please sign in to comment.