mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-22 17:22:13 +00:00
Compare commits
12 Commits
boost-1.68
...
boost-1.69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a580c496fa | ||
|
|
1ca15c5fcd | ||
|
|
512ac37529 | ||
|
|
8e265c49f8 | ||
|
|
a449a11a80 | ||
|
|
a0735943f2 | ||
|
|
8fe1db1b08 | ||
|
|
d7d6555f85 | ||
|
|
a90fe08934 | ||
|
|
b944aa3008 | ||
|
|
759af5e853 | ||
|
|
7b6379a356 |
175
.travis.yml
Normal file
175
.travis.yml
Normal file
@@ -0,0 +1,175 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2017, 2018 James E. King III
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#
|
||||
# Generic Travis CI build script for boostorg repositories
|
||||
# See: https://github.com/jeking3/boost-ci
|
||||
#
|
||||
# Instructions for customizing this script for your library:
|
||||
#
|
||||
# 1. Customize the compilers and language levels you want in the 'jobs'.
|
||||
# 2. If you have more than include/, src/, test/, example/, examples/, or
|
||||
# tools/ directories, modify your Travis CI project and add the environment
|
||||
# variable DEPINST. For example if your build uses code in "bench/" and
|
||||
# "fog/" directories, then set DEPINST to the following:
|
||||
# --include bench --include fog
|
||||
# 3. If you want to enable Coverity Scan, you need to provide the environment
|
||||
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
|
||||
# your github settings.
|
||||
# 4. Enable pull request builds in your boostorg/<library> account.
|
||||
#
|
||||
# That's it - the scripts will do everything else for you.
|
||||
|
||||
sudo: false
|
||||
dist: trusty
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
global:
|
||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||
# to use the default for a given environment, comment it out; recommend you build debug and release however..
|
||||
# - B2_ADDRESS_MODEL=address-model=64,32
|
||||
# - B2_LINK=link=shared,static
|
||||
# - B2_THREADING=threading=multi,single
|
||||
- B2_VARIANT=variant=release,debug
|
||||
|
||||
install:
|
||||
- git clone https://github.com/jeking3/boost-ci.git boost-ci
|
||||
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
- source ci/travis/install.sh
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- binutils-gold
|
||||
- gdb
|
||||
- libc6-dbg
|
||||
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- master
|
||||
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/build.sh
|
||||
|
||||
#
|
||||
# Default toolsets in Ubuntu
|
||||
#
|
||||
# trusty xenial bionic
|
||||
# 14.04 16.04 18.04
|
||||
# ------ ------ ------
|
||||
# clang 3.4 3.8 6.0
|
||||
# gcc 4.8.2 5.3.1 7.3.0
|
||||
#
|
||||
|
||||
anchors:
|
||||
clang-34: &clang-34 { apt: { packages: [ "clang-3.4" ], sources: [ "llvm-toolchain-trusty-3.4" ] } }
|
||||
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
|
||||
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-trusty-3.8",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
|
||||
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-trusty-4.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
|
||||
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-trusty-5.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev",
|
||||
"valgrind" ], sources: [ "llvm-toolchain-trusty-6.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
gcc-44: &gcc-44 { apt: { packages: [ "g++-4.4" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-46: &gcc-46 { apt: { packages: [ "g++-4.6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
|
||||
jobs:
|
||||
allow_failures:
|
||||
- env:
|
||||
- COPY="all the environment settings from your job"
|
||||
|
||||
include:
|
||||
# libstdc++
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-4.4", "CXXSTD=98,0x" ], addons: *gcc-44 }
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-4.6", "CXXSTD=03,0x" ], addons: *gcc-46 }
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-4.8", "CXXSTD=03,11" ], addons: *gcc-48 }
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-5", "CXXSTD=03,11" ], addons: *gcc-5 }
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-6", "CXXSTD=03,11,14" ], addons: *gcc-6 }
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-7", "CXXSTD=03,11,14,17" ], addons: *gcc-7 }
|
||||
- { os: "linux", env: [ "TOOLSET=gcc-8", "CXXSTD=03,11,14,17,2a" ], addons: *gcc-8 }
|
||||
- { os: "linux", env: [ "TOOLSET=clang-3.4", "CXXSTD=03,11" ], addons: *clang-34 }
|
||||
- { os: "linux", env: [ "TOOLSET=clang-3.8", "CXXSTD=03,11,14" ], addons: *clang-38 }
|
||||
- { os: "linux", env: [ "TOOLSET=clang-4.0", "CXXSTD=03,11,14" ], addons: *clang-4 }
|
||||
- { os: "linux", env: [ "TOOLSET=clang-5.0", "CXXSTD=03,11,14,17" ], addons: *clang-5 }
|
||||
- { os: "linux", env: [ "TOOLSET=clang-6.0", "CXXSTD=03,11,14,17,2a" ], addons: *clang-6 }
|
||||
# libc++
|
||||
- { os: "linux", env: [ "TOOLSET=clang-6.0", "CXXSTD=03,11,14,17,2a",
|
||||
"CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
|
||||
# the rvm environment on osx is taking over basic commands like "cd" and breaking things!
|
||||
# - { os: "osx" , env: [ "COMMENT=libc++",
|
||||
# "TOOLSET=clang", "CXXSTD=03,11,14" ] }
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=codecov.io
|
||||
- TOOLSET=gcc-7
|
||||
- DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-7
|
||||
script:
|
||||
- pushd /tmp && git clone https://github.com/linux-test-project/lcov.git && export PATH=/tmp/lcov/bin:$PATH && which lcov && lcov --version && popd
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/codecov.sh
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=cppcheck
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/cppcheck.sh
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=ubsan
|
||||
- B2_VARIANT=variant=debug
|
||||
- TOOLSET=gcc-8
|
||||
- CXXSTD=03,11,14,17,2a
|
||||
- DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
- CXXFLAGS="cxxflags=-fno-omit-frame-pointer cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined"
|
||||
- LINKFLAGS="linkflags=-fsanitize=undefined linkflags=-fno-sanitize-recover=undefined linkflags=-fuse-ld=gold"
|
||||
- UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=valgrind
|
||||
- TOOLSET=clang-6.0
|
||||
- CXXSTD=03,11,14,17,2a
|
||||
- DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
- B2_VARIANT=variant=debug
|
||||
- TESTFLAGS=testing.launcher=valgrind
|
||||
- VALGRIND_OPTS=--error-exitcode=1
|
||||
addons: *clang-6
|
||||
|
||||
#################### Jobs to run on pushes to master, develop ###################
|
||||
|
||||
# Coverity Scan
|
||||
- os: linux
|
||||
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
|
||||
env:
|
||||
- COMMENT="Coverity Scan"
|
||||
- TOOLSET=gcc-7
|
||||
addons: *gcc-7
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/coverity.sh
|
||||
|
||||
notifications:
|
||||
email:
|
||||
false
|
||||
14
Jamfile
14
Jamfile
@@ -1,3 +1,11 @@
|
||||
# Empty Jamfile because the super project still expects one to appear here.
|
||||
# Can be deleted once 'status/Jamfile.v2' has been updated in the super
|
||||
# project.
|
||||
# Boost.DynamicBitset Library Jamfile
|
||||
#
|
||||
# Copyright (c) 2018 James E. King III
|
||||
#
|
||||
# Use, modification, and distribution are subject to 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)
|
||||
|
||||
# please order by name to ease maintenance
|
||||
build-project example ;
|
||||
build-project test ;
|
||||
|
||||
23
LICENSE
Normal file
23
LICENSE
Normal file
@@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
34
README.md
Normal file
34
README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
DynamicBitset, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is similar to std::bitset however the size is specified at run-time instead of at compile-time.
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
### Properties
|
||||
|
||||
* C++03
|
||||
* Header-only
|
||||
|
||||
### Build Status
|
||||
|
||||
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
|
||||
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
|
||||
[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [](https://travis-ci.org/boostorg/dynamic_bitset) | [](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/master) | [](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master)| [](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [](http://www.boost.org/doc/libs/master/doc/html/dynamic_bitset.html) | [](http://www.boost.org/development/tests/master/developer/dynamic_bitset.html)
|
||||
[`develop`](https://github.com/boostorg/dynamic_bitset/tree/develop) | [](https://travis-ci.org/boostorg/dynamic_bitset) | [](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/develop) | [](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop) | [](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [](http://www.boost.org/doc/libs/develop/doc/html/dynamic_bitset.html) | [](http://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)
|
||||
|
||||
### Directories
|
||||
|
||||
| Name | Purpose |
|
||||
| ----------- | ------------------------------ |
|
||||
| `example` | examples |
|
||||
| `doc` | documentation |
|
||||
| `include` | headers |
|
||||
| `test` | unit tests |
|
||||
|
||||
### More information
|
||||
|
||||
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-dynamic_bitset)
|
||||
* [Report bugs](https://github.com/boostorg/dynamic_bitset/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
|
||||
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
||||
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[dynamic_bitset]` tag at the beginning of the subject line.
|
||||
|
||||
126
appveyor.yml
Normal file
126
appveyor.yml
Normal file
@@ -0,0 +1,126 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright (C) 2017, 2018 James E. King III
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#
|
||||
# Generic Appveyor build script for boostorg repositories
|
||||
# See: https://github.com/jeking3/boost-ci/
|
||||
#
|
||||
# Instructions for customizing this script for your library:
|
||||
#
|
||||
# 1. Customize the compilers and language levels you want.
|
||||
# 2. If you have move than include/, src/, test/, example/, examples/,
|
||||
# benchmark/ or tools/ directories, set the environment variable DEPINST.
|
||||
# For example if your build uses code in "bench/" and "fog/" directories:
|
||||
# - DEPINST: --include bench --include fog
|
||||
# 3. Enable pull request builds in your boostorg/<library> account.
|
||||
#
|
||||
# That's it - the script will do everything else for you.
|
||||
#
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- master
|
||||
|
||||
matrix:
|
||||
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
|
||||
allow_failures:
|
||||
- MAYFAIL: true
|
||||
|
||||
environment:
|
||||
global:
|
||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||
# to use the default for a given environment, comment it out; recommend you build debug and release however:
|
||||
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
|
||||
# libraries that care about this exercise it in their Jamfiles...
|
||||
# B2_ADDRESS_MODEL: address-model=64,32
|
||||
# B2_LINK: link=shared,static
|
||||
# B2_THREADING: threading=multi,single
|
||||
B2_VARIANT: variant=release,debug
|
||||
|
||||
matrix:
|
||||
- FLAVOR: Visual Studio 2017 C++2a Strict
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
CXXFLAGS: cxxflags=-permissive-
|
||||
CXXSTD: latest # 2a
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
CXXSTD: 17
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++14 (Default)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
B2_ADDRESS_MODEL: address-model=64,32
|
||||
|
||||
- FLAVOR: Visual Studio 2015 C++14 (Default)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
B2_ADDRESS_MODEL: address-model=64,32
|
||||
|
||||
- FLAVOR: Visual Studio 2010, 2012, 2013
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
|
||||
|
||||
- FLAVOR: cygwin (32-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
B2_ADDRESS_MODEL: address-model=32
|
||||
CXXSTD: 03,11
|
||||
# https://github.com/boostorg/test/issues/144
|
||||
DEFINES: define=_POSIX_C_SOURCE=200112L
|
||||
THREADING: threadapi=pthread
|
||||
TOOLSET: gcc
|
||||
|
||||
- FLAVOR: cygwin (64-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
CXXSTD: 11,17
|
||||
# https://github.com/boostorg/test/issues/144
|
||||
DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
|
||||
THREADING: threadapi=pthread
|
||||
TOOLSET: gcc
|
||||
|
||||
- FLAVOR: mingw32
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ARCH: i686
|
||||
B2_ADDRESS_MODEL: address-model=32
|
||||
CXXSTD: 03,11
|
||||
SCRIPT: ci\appveyor\mingw.bat
|
||||
|
||||
- FLAVOR: mingw64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ARCH: x86_64
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
CXXSTD: 11,17
|
||||
DEFINES: define=__USE_ISOC99
|
||||
SCRIPT: ci\appveyor\mingw.bat
|
||||
|
||||
install:
|
||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||
- git clone https://github.com/jeking3/boost-ci.git C:\boost-ci
|
||||
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
|
||||
- ci\appveyor\install.bat
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
# The definition of TOOLCXX omits CXXSTD= if it was not defined above
|
||||
- IF NOT DEFINED CXXSTD (SET TOOLCXX=toolset=%TOOLSET%) ELSE (SET TOOLCXX=toolset=%TOOLSET% cxxstd=%CXXSTD%)
|
||||
# Echo the complete build command to the build log
|
||||
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %TOOLCXX% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
||||
# Now go build...
|
||||
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %TOOLCXX% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
||||
@@ -8,6 +8,7 @@
|
||||
Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
Copyright (c) 2014 Ahmed Charles
|
||||
Copyright (c) 2014 Riccardo Marcangelo
|
||||
Copyright (c) 2018 Evgeny Shulgin
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -197,10 +198,13 @@ public:
|
||||
dynamic_bitset <a href="#op-sl">operator<<</a>(size_type n) const;
|
||||
dynamic_bitset <a href="#op-sr">operator>></a>(size_type n) const;
|
||||
|
||||
dynamic_bitset& <a href="#set3">set</a>(size_type n, size_type len, bool val);
|
||||
dynamic_bitset& <a href="#set2">set</a>(size_type n, bool val = true);
|
||||
dynamic_bitset& <a href="#set1">set</a>();
|
||||
dynamic_bitset& <a href="#reset3">reset</a>(size_type n, size_type len);
|
||||
dynamic_bitset& <a href="#reset2">reset</a>(size_type n);
|
||||
dynamic_bitset& <a href="#reset1">reset</a>();
|
||||
dynamic_bitset& <a href="#flip3">flip</a>(size_type n, size_type len);
|
||||
dynamic_bitset& <a href="#flip2">flip</a>(size_type n);
|
||||
dynamic_bitset& <a href="#flip1">flip</a>();
|
||||
bool <a href="#test">test</a>(size_type n) const;
|
||||
@@ -1062,6 +1066,18 @@ dynamic_bitset& <a id="reset1">reset</a>()
|
||||
<b>Returns:</b> <tt>*this</tt><br />
|
||||
<b>Throws:</b> nothing.
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
dynamic_bitset& <a id=
|
||||
"set3">set</a>(size_type n, size_type len, bool val);
|
||||
</pre>
|
||||
|
||||
<b>Precondition:</b> <tt>n + len < this->size()</tt>.<br />
|
||||
<b>Effects:</b> Sets every bit indexed from <tt>n</tt> to
|
||||
<tt>n + len - 1</tt> inclusively if <tt>val</tt> is <tt>true</tt>, and
|
||||
clears them if <tt>val</tt> is <tt>false</tt>. <br />
|
||||
<b>Returns:</b> <tt>*this</tt>
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
dynamic_bitset& <a id=
|
||||
@@ -1074,6 +1090,17 @@ dynamic_bitset& <a id=
|
||||
<tt>false</tt>. <br />
|
||||
<b>Returns:</b> <tt>*this</tt>
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
dynamic_bitset& <a id=
|
||||
"reset3">reset</a>(size_type n, size_type len);
|
||||
</pre>
|
||||
|
||||
<b>Precondition:</b> <tt>n + len < this->size()</tt>.<br />
|
||||
<b>Effects:</b> Clears every bit indexed from <tt>n</tt> to
|
||||
<tt>n + len - 1</tt> inclusively.<br />
|
||||
<b>Returns:</b> <tt>*this</tt>
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
dynamic_bitset& <a id="reset2">reset</a>(size_type n)
|
||||
@@ -1083,6 +1110,16 @@ dynamic_bitset& <a id="reset2">reset</a>(size_type n)
|
||||
<b>Effects:</b> Clears bit <tt>n</tt>.<br />
|
||||
<b>Returns:</b> <tt>*this</tt>
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
dynamic_bitset& <a id="flip3">flip</a>(size_type n, size_type len)
|
||||
</pre>
|
||||
|
||||
<b>Precondition:</b> <tt>n + len < this->size()</tt>.<br />
|
||||
<b>Effects:</b> Flips every bit indexed from <tt>n</tt> to
|
||||
<tt>n + len - 1</tt> inclusively.<br />
|
||||
<b>Returns:</b> <tt>*this</tt>
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
dynamic_bitset& <a id="flip2">flip</a>(size_type n)
|
||||
@@ -1718,7 +1755,7 @@ href="mailto:cda@freshsources.com">cda@freshsources.com</a>)<br
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Copyright © 2014</td>
|
||||
<td>Glen Fernandes (<a href="mailto:glenfe@live.com">glenfe@live.com</a>)</td>
|
||||
<td>Glen Fernandes (<a href="mailto:glenjofe@gmail.com">glenjofe@gmail.com</a>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Copyright © 2014</td>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
//
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// glenfe at live dot com
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -20,6 +20,9 @@
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
|
||||
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -125,6 +128,61 @@ namespace boost {
|
||||
}
|
||||
|
||||
|
||||
// Some platforms have fast popcount operation, that allow us to implement
|
||||
// counting bits much more efficiently
|
||||
//
|
||||
template <typename ValueType>
|
||||
BOOST_FORCEINLINE std::size_t popcount(ValueType value) BOOST_NOEXCEPT
|
||||
{
|
||||
std::size_t num = 0;
|
||||
while (value) {
|
||||
num += count_table<>::table[value & ((1u<<table_width) - 1)];
|
||||
value >>= table_width;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<std::size_t>(__popcnt16(value));
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<std::size_t>(__popcnt(value));
|
||||
}
|
||||
|
||||
#ifdef _M_X64
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned __int64>(unsigned __int64 value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<std::size_t>(__popcnt64(value));
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcount(value);
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned long>(unsigned long value) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcountl(value);
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<boost::ulong_long_type>(boost::ulong_long_type value) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcountll(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
// overload for access by blocks
|
||||
//
|
||||
template <typename Iterator, typename ValueType>
|
||||
@@ -133,13 +191,7 @@ namespace boost {
|
||||
{
|
||||
std::size_t num = 0;
|
||||
while (length){
|
||||
|
||||
ValueType value = *first;
|
||||
while (value) {
|
||||
num += count_table<>::table[value & ((1u<<table_width) - 1)];
|
||||
value >>= table_width;
|
||||
}
|
||||
|
||||
num += popcount<ValueType>(*first);
|
||||
++first;
|
||||
--length;
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
//
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// glenfe at live dot com
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -39,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"
|
||||
@@ -279,10 +281,13 @@ public:
|
||||
dynamic_bitset operator>>(size_type n) const;
|
||||
|
||||
// basic bit operations
|
||||
dynamic_bitset& set(size_type n, size_type len, bool val /* = true */); // default would make it ambiguous
|
||||
dynamic_bitset& set(size_type n, bool val = true);
|
||||
dynamic_bitset& set();
|
||||
dynamic_bitset& reset(size_type n, size_type len);
|
||||
dynamic_bitset& reset(size_type n);
|
||||
dynamic_bitset& reset();
|
||||
dynamic_bitset& flip(size_type n, size_type len);
|
||||
dynamic_bitset& flip(size_type n);
|
||||
dynamic_bitset& flip();
|
||||
bool test(size_type n) const;
|
||||
@@ -360,6 +365,9 @@ public:
|
||||
private:
|
||||
BOOST_STATIC_CONSTANT(block_width_type, ulong_width = std::numeric_limits<unsigned long>::digits);
|
||||
|
||||
dynamic_bitset& range_operation(size_type pos, size_type len,
|
||||
Block (*partial_block_operation)(Block, size_type, size_type),
|
||||
Block (*full_block_operation)(Block));
|
||||
void m_zero_unused_bits();
|
||||
bool m_check_invariants() const;
|
||||
|
||||
@@ -369,6 +377,51 @@ private:
|
||||
static size_type block_index(size_type pos) BOOST_NOEXCEPT { return pos / bits_per_block; }
|
||||
static block_width_type bit_index(size_type pos) BOOST_NOEXCEPT { return static_cast<block_width_type>(pos % bits_per_block); }
|
||||
static Block bit_mask(size_type pos) BOOST_NOEXCEPT { return Block(1) << bit_index(pos); }
|
||||
static Block bit_mask(size_type first, size_type last) BOOST_NOEXCEPT
|
||||
{
|
||||
Block res = (last == bits_per_block - 1)
|
||||
? static_cast<Block>(~0)
|
||||
: ((Block(1) << (last + 1)) - 1);
|
||||
res ^= (Block(1) << first) - 1;
|
||||
return res;
|
||||
}
|
||||
static Block set_block_bits(Block block, size_type first,
|
||||
size_type last, bool val) BOOST_NOEXCEPT
|
||||
{
|
||||
if (val)
|
||||
return block | bit_mask(first, last);
|
||||
else
|
||||
return block & static_cast<Block>(~bit_mask(first, last));
|
||||
}
|
||||
|
||||
// Functions for operations on ranges
|
||||
inline static Block set_block_partial(Block block, size_type first,
|
||||
size_type last) BOOST_NOEXCEPT
|
||||
{
|
||||
return set_block_bits(block, first, last, true);
|
||||
}
|
||||
inline static Block set_block_full(Block) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<Block>(~0);
|
||||
}
|
||||
inline static Block reset_block_partial(Block block, size_type first,
|
||||
size_type last) BOOST_NOEXCEPT
|
||||
{
|
||||
return set_block_bits(block, first, last, false);
|
||||
}
|
||||
inline static Block reset_block_full(Block) BOOST_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
inline static Block flip_block_partial(Block block, size_type first,
|
||||
size_type last) BOOST_NOEXCEPT
|
||||
{
|
||||
return block ^ bit_mask(first, last);
|
||||
}
|
||||
inline static Block flip_block_full(Block block) BOOST_NOEXCEPT
|
||||
{
|
||||
return ~block;
|
||||
}
|
||||
|
||||
template <typename CharT, typename Traits, typename Alloc>
|
||||
void init_from_string(const std::basic_string<CharT, Traits, Alloc>& s,
|
||||
@@ -959,6 +1012,17 @@ dynamic_bitset<Block, Allocator>::operator>>(size_type n) const
|
||||
//-----------------------------------------------------------------------------
|
||||
// basic bit operations
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::set(size_type pos,
|
||||
size_type len, bool val)
|
||||
{
|
||||
if (val)
|
||||
return range_operation(pos, len, set_block_partial, set_block_full);
|
||||
else
|
||||
return range_operation(pos, len, reset_block_partial, reset_block_full);
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::set(size_type pos, bool val)
|
||||
@@ -982,6 +1046,13 @@ dynamic_bitset<Block, Allocator>::set()
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
inline dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::reset(size_type pos, size_type len)
|
||||
{
|
||||
return range_operation(pos, len, reset_block_partial, reset_block_full);
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::reset(size_type pos)
|
||||
@@ -1006,6 +1077,13 @@ dynamic_bitset<Block, Allocator>::reset()
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::flip(size_type pos, size_type len)
|
||||
{
|
||||
return range_operation(pos, len, flip_block_partial, flip_block_full);
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::flip(size_type pos)
|
||||
@@ -1125,7 +1203,17 @@ dynamic_bitset<Block, Allocator>::count() const BOOST_NOEXCEPT
|
||||
|
||||
enum { enough_table_width = table_width >= CHAR_BIT };
|
||||
|
||||
enum { mode = (no_padding && enough_table_width)
|
||||
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
|
||||
// Windows popcount is effective starting from the unsigned short type
|
||||
enum { uneffective_popcount = sizeof(Block) < sizeof(unsigned short) };
|
||||
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
|
||||
// GCC popcount is effective starting from the unsigned int type
|
||||
enum { uneffective_popcount = sizeof(Block) < sizeof(unsigned int) };
|
||||
#else
|
||||
enum { uneffective_popcount = true };
|
||||
#endif
|
||||
|
||||
enum { mode = (no_padding && enough_table_width && uneffective_popcount)
|
||||
? access_by_bytes
|
||||
: access_by_blocks };
|
||||
|
||||
@@ -1346,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
|
||||
//
|
||||
@@ -1363,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]));
|
||||
}
|
||||
|
||||
|
||||
@@ -1394,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);
|
||||
|
||||
@@ -1925,6 +2011,63 @@ inline const Block& dynamic_bitset<Block, Allocator>::m_highest_block() const
|
||||
return m_bits.back();
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>& dynamic_bitset<Block, Allocator>::range_operation(
|
||||
size_type pos, size_type len,
|
||||
Block (*partial_block_operation)(Block, size_type, size_type),
|
||||
Block (*full_block_operation)(Block))
|
||||
{
|
||||
assert(pos + len <= m_num_bits);
|
||||
|
||||
// Do nothing in case of zero length
|
||||
if (!len)
|
||||
return *this;
|
||||
|
||||
// Use an additional asserts in order to detect size_type overflow
|
||||
// For example: pos = 10, len = size_type_limit - 2, pos + len = 7
|
||||
// In case of overflow, 'pos + len' is always smaller than 'len'
|
||||
assert(pos + len >= len);
|
||||
|
||||
// Start and end blocks of the [pos; pos + len - 1] sequence
|
||||
const size_type first_block = block_index(pos);
|
||||
const size_type last_block = block_index(pos + len - 1);
|
||||
|
||||
const size_type first_bit_index = bit_index(pos);
|
||||
const size_type last_bit_index = bit_index(pos + len - 1);
|
||||
|
||||
if (first_block == last_block) {
|
||||
// Filling only a sub-block of a block
|
||||
m_bits[first_block] = partial_block_operation(m_bits[first_block],
|
||||
first_bit_index, last_bit_index);
|
||||
} else {
|
||||
// Check if the corner blocks won't be fully filled with 'val'
|
||||
const size_type first_block_shift = bit_index(pos) ? 1 : 0;
|
||||
const size_type last_block_shift = (bit_index(pos + len - 1)
|
||||
== bits_per_block - 1) ? 0 : 1;
|
||||
|
||||
// Blocks that will be filled with ~0 or 0 at once
|
||||
const size_type first_full_block = first_block + first_block_shift;
|
||||
const size_type last_full_block = last_block - last_block_shift;
|
||||
|
||||
for (size_type i = first_full_block; i <= last_full_block; ++i) {
|
||||
m_bits[i] = full_block_operation(m_bits[i]);
|
||||
}
|
||||
|
||||
// Fill the first block from the 'first' bit index to the end
|
||||
if (first_block_shift) {
|
||||
m_bits[first_block] = partial_block_operation(m_bits[first_block],
|
||||
first_bit_index, bits_per_block - 1);
|
||||
}
|
||||
|
||||
// Fill the last block from the start to the 'last' bit index
|
||||
if (last_block_shift) {
|
||||
m_bits[last_block] = partial_block_operation(m_bits[last_block],
|
||||
0, last_bit_index);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// If size() is not a multiple of bits_per_block
|
||||
// then not all the bits in the last block are used.
|
||||
|
||||
@@ -4,13 +4,29 @@
|
||||
# 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)
|
||||
#
|
||||
|
||||
import os ;
|
||||
|
||||
test-suite dynamic_bitset :
|
||||
|
||||
[ run dyn_bitset_unit_tests1.cpp ]
|
||||
[ run dyn_bitset_unit_tests2.cpp ]
|
||||
[ run dyn_bitset_unit_tests3.cpp ]
|
||||
[ run dyn_bitset_unit_tests4.cpp ]
|
||||
[ run dyn_bitset_unit_tests5.cpp /boost/serialization//boost_serialization
|
||||
: : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
|
||||
[ 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_tests4.cpp : : : <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/system//boost_system ]
|
||||
[ run test_ambiguous_set.cpp ]
|
||||
[ run test_lowest_bit.cpp ]
|
||||
;
|
||||
|
||||
# due to https://github.com/boostorg/serialization/issues/108
|
||||
if ! [ os.environ UBSAN_OPTIONS ]
|
||||
{
|
||||
test-suite dynamic_bitset_serialization :
|
||||
|
||||
[ run dyn_bitset_unit_tests5.cpp
|
||||
: : : <define>_SCL_SECURE_NO_WARNINGS=1
|
||||
<library>/boost/serialization//boost_serialization
|
||||
<library>/boost/system//boost_system ]
|
||||
;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -27,10 +28,12 @@
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
template <typename Block>
|
||||
inline bool nth_bit(Block num, std::size_t n)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef __BORLANDC__
|
||||
// Borland deduces Block as a const qualified type,
|
||||
// and thus finds numeric_limits<Block> to be zero :(
|
||||
@@ -40,8 +43,9 @@ inline bool nth_bit(Block num, std::size_t n)
|
||||
#else
|
||||
int block_width = std::numeric_limits<Block>::digits;
|
||||
#endif
|
||||
|
||||
assert(n < (std::size_t) block_width);
|
||||
#endif
|
||||
|
||||
return (num >> n) & 1;
|
||||
}
|
||||
|
||||
@@ -61,10 +65,27 @@ std::string get_long_string()
|
||||
return std::string(p);
|
||||
}
|
||||
|
||||
const char * test_file_name()
|
||||
class scoped_temp_file
|
||||
{
|
||||
return "boost_dynamic_bitset_tests";
|
||||
}
|
||||
public:
|
||||
scoped_temp_file()
|
||||
: m_path(boost::filesystem::unique_path())
|
||||
{
|
||||
}
|
||||
|
||||
~scoped_temp_file()
|
||||
{
|
||||
boost::filesystem::remove(m_path);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
private:
|
||||
boost::filesystem::path m_path;
|
||||
};
|
||||
|
||||
#if defined BOOST_OLD_IOSTREAMS || defined BOOST_NO_STD_LOCALE
|
||||
template <typename Stream>
|
||||
@@ -599,6 +620,22 @@ struct bitset_test {
|
||||
}
|
||||
}
|
||||
|
||||
static void set_segment(const Bitset& b, std::size_t pos,
|
||||
std::size_t len, bool value)
|
||||
{
|
||||
Bitset lhs(b);
|
||||
std::size_t N = lhs.size();
|
||||
Bitset prev(lhs);
|
||||
lhs.set(pos, len, value);
|
||||
for (std::size_t I = 0; I < N; ++I)
|
||||
{
|
||||
if (I < pos || I >= pos + len)
|
||||
BOOST_CHECK(lhs[I] == prev[I]);
|
||||
else
|
||||
BOOST_CHECK(lhs[I] == value);
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_all(const Bitset& b)
|
||||
{
|
||||
Bitset lhs(b);
|
||||
@@ -627,6 +664,22 @@ struct bitset_test {
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_segment(const Bitset& b, std::size_t pos,
|
||||
std::size_t len)
|
||||
{
|
||||
Bitset lhs(b);
|
||||
std::size_t N = lhs.size();
|
||||
Bitset prev(lhs);
|
||||
lhs.reset(pos, len);
|
||||
for (std::size_t I = 0; I < N; ++I)
|
||||
{
|
||||
if (I < pos || I >= pos + len)
|
||||
BOOST_CHECK(lhs[I] == prev[I]);
|
||||
else
|
||||
BOOST_CHECK(!lhs[I]);
|
||||
}
|
||||
}
|
||||
|
||||
static void operator_flip(const Bitset& b)
|
||||
{
|
||||
Bitset lhs(b);
|
||||
@@ -664,6 +717,22 @@ struct bitset_test {
|
||||
}
|
||||
}
|
||||
|
||||
static void flip_segment(const Bitset& b, std::size_t pos,
|
||||
std::size_t len)
|
||||
{
|
||||
Bitset lhs(b);
|
||||
std::size_t N = lhs.size();
|
||||
Bitset prev(lhs);
|
||||
lhs.flip(pos, len);
|
||||
for (std::size_t I = 0; I < N; ++I)
|
||||
{
|
||||
if (I < pos || I >= pos + len)
|
||||
BOOST_CHECK(lhs[I] == prev[I]);
|
||||
else
|
||||
BOOST_CHECK(lhs[I] != prev[I]);
|
||||
}
|
||||
}
|
||||
|
||||
// empty
|
||||
static void empty(const Bitset& b)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
//
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// glenfe at live dot com
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -208,6 +209,40 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::set_one(b, long_string.size()/2, false);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.set(pos, len)
|
||||
{ // case size is 1
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::set_segment(b, 0, 1, true);
|
||||
Tests::set_segment(b, 0, 1, false);
|
||||
}
|
||||
{ // case fill the whole set
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_segment(b, 0, b.size(), true);
|
||||
Tests::set_segment(b, 0, b.size(), false);
|
||||
}
|
||||
{ // case pos = size / 4, len = size / 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_segment(b, b.size() / 4, b.size() / 2, true);
|
||||
Tests::set_segment(b, b.size() / 4, b.size() / 2, false);
|
||||
}
|
||||
{ // case pos = block_size / 2, len = size - block_size
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block, true);
|
||||
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block, false);
|
||||
}
|
||||
{ // case pos = 1, len = size - 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_segment(b, 1, b.size() - 2, true);
|
||||
Tests::set_segment(b, 1, b.size() - 2, false);
|
||||
}
|
||||
{ // case pos = 3, len = 7
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_segment(b, 3, 7, true);
|
||||
Tests::set_segment(b, 3, 7, false);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reset()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
@@ -236,6 +271,33 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::reset_one(b, long_string.size()/2);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reset(pos, len)
|
||||
{ // case size is 1
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::reset_segment(b, 0, 1);
|
||||
}
|
||||
{ // case fill the whole set
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::reset_segment(b, 0, b.size());
|
||||
}
|
||||
{ // case pos = size / 4, len = size / 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::reset_segment(b, b.size() / 4, b.size() / 2);
|
||||
}
|
||||
{ // case pos = block_size / 2, len = size - block_size
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::reset_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
|
||||
}
|
||||
{ // case pos = 1, len = size - 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::reset_segment(b, 1, b.size() - 2);
|
||||
}
|
||||
{ // case pos = 3, len = 7
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::reset_segment(b, 3, 7);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test ~b
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
@@ -277,6 +339,33 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_one(b, long_string.size()/2);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip(pos, len)
|
||||
{ // case size is 1
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::flip_segment(b, 0, 1);
|
||||
}
|
||||
{ // case fill the whole set
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_segment(b, 0, b.size());
|
||||
}
|
||||
{ // case pos = size / 4, len = size / 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_segment(b, b.size() / 4, b.size() / 2);
|
||||
}
|
||||
{ // case pos = block_size / 2, len = size - block_size
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
|
||||
}
|
||||
{ // case pos = 1, len = size - 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_segment(b, 1, b.size() - 2);
|
||||
}
|
||||
{ // case pos = 3, len = 7
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_segment(b, 3, 7);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -125,13 +125,13 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
}
|
||||
{
|
||||
// test 1a - file stream
|
||||
scoped_temp_file stf;
|
||||
bitset_type b(strings[si]);
|
||||
std::ofstream file(test_file_name(), std::ios::trunc);
|
||||
std::ofstream file(stf.path().string().c_str(), std::ios::trunc);
|
||||
file.width(w);
|
||||
file.fill(fill_chars[ci]);
|
||||
file.exceptions(masks[mi]);
|
||||
Tests::stream_inserter(b, file, test_file_name());
|
||||
|
||||
Tests::stream_inserter(b, file, stf.path().string().c_str());
|
||||
}
|
||||
{
|
||||
//NOTE: there are NO string stream tests
|
||||
@@ -139,12 +139,13 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
#if !defined (BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS)
|
||||
{
|
||||
// test 1b - wide file stream
|
||||
scoped_temp_file stf;
|
||||
bitset_type b(strings[si]);
|
||||
std::wofstream file(test_file_name());
|
||||
std::wofstream file(stf.path().string().c_str());
|
||||
file.width(w);
|
||||
file.fill(fill_chars[ci]);
|
||||
file.exceptions(masks[mi]);
|
||||
Tests::stream_inserter(b, file, test_file_name());
|
||||
Tests::stream_inserter(b, file, stf.path().string().c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -257,13 +258,14 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
}
|
||||
// test 1a - (narrow) file stream
|
||||
{
|
||||
scoped_temp_file stf;
|
||||
bitset_type b(1, 255ul);
|
||||
{
|
||||
std::ofstream f(test_file_name());
|
||||
std::ofstream f(stf.path().string().c_str());
|
||||
f << strings[si];
|
||||
}
|
||||
|
||||
std::ifstream f(test_file_name());
|
||||
std::ifstream f(stf.path().string().c_str());
|
||||
f.width(w);
|
||||
f.exceptions(masks[mi]);
|
||||
Tests::stream_extractor(b, f, strings[si]);
|
||||
@@ -282,14 +284,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
#if !defined(BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS)
|
||||
// test 1b - wchar_t file stream
|
||||
{
|
||||
scoped_temp_file stf;
|
||||
std::wstring wstr = widen_string(strings[si]);
|
||||
bitset_type b(1, 255ul);
|
||||
{
|
||||
std::basic_ofstream<wchar_t> of(test_file_name());
|
||||
std::basic_ofstream<wchar_t> of(stf.path().string().c_str());
|
||||
of << wstr;
|
||||
}
|
||||
|
||||
std::basic_ifstream<wchar_t> f(test_file_name());
|
||||
std::basic_ifstream<wchar_t> f(stf.path().string().c_str());
|
||||
f.width(w);
|
||||
f.exceptions(masks[mi]);
|
||||
Tests::stream_extractor(b, f, wstr);
|
||||
|
||||
30
test/test_ambiguous_set.cpp
Normal file
30
test/test_ambiguous_set.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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/dynamic_bitset.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
boost::dynamic_bitset<> x(5); // all 0's by default
|
||||
x.set(1, 2);
|
||||
x.set(3, 1, true);
|
||||
x.set(2, 1, false);
|
||||
BOOST_TEST(!x.test(0));
|
||||
BOOST_TEST( x.test(1));
|
||||
BOOST_TEST(!x.test(2));
|
||||
BOOST_TEST( x.test(3));
|
||||
BOOST_TEST(!x.test(4));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
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