mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-22 05:12:13 +00:00
Compare commits
35 Commits
boost-1.68
...
boost-1.78
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d85403b9 | ||
|
|
296f902453 | ||
|
|
a16a1c3afa | ||
|
|
66a956b114 | ||
|
|
b59fc97a67 | ||
|
|
4a38853898 | ||
|
|
54b15ad171 | ||
|
|
ffff25ac00 | ||
|
|
3e0107909b | ||
|
|
8359a80feb | ||
|
|
db5da12bcd | ||
|
|
ab192ca5f1 | ||
|
|
26918f80d5 | ||
|
|
229bced733 | ||
|
|
ccb380a1bc | ||
|
|
4de44e9112 | ||
|
|
3f650f50c3 | ||
|
|
b64e20079c | ||
|
|
83bdf5a335 | ||
|
|
c747bec057 | ||
|
|
f506b99f70 | ||
|
|
1b8b128f29 | ||
|
|
91625cece1 | ||
|
|
a580c496fa | ||
|
|
1ca15c5fcd | ||
|
|
512ac37529 | ||
|
|
8e265c49f8 | ||
|
|
a449a11a80 | ||
|
|
a0735943f2 | ||
|
|
8fe1db1b08 | ||
|
|
d7d6555f85 | ||
|
|
a90fe08934 | ||
|
|
b944aa3008 | ||
|
|
759af5e853 | ||
|
|
7b6379a356 |
41
.drone.star
Normal file
41
.drone.star
Normal file
@@ -0,0 +1,41 @@
|
||||
# Use, modification, and distribution are
|
||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE.txt)
|
||||
#
|
||||
# Copyright Rene Rivera 2020.
|
||||
|
||||
# For Drone CI we use the Starlark scripting language to reduce duplication.
|
||||
# As the yaml syntax for Drone CI is rather limited.
|
||||
#
|
||||
#
|
||||
globalenv={'B2_VARIANT': 'variant=release'}
|
||||
linuxglobalimage="cppalliance/droneubuntu1604:1"
|
||||
windowsglobalimage="cppalliance/dronevs2019"
|
||||
|
||||
def main(ctx):
|
||||
return [
|
||||
linux_cxx("B2_TOOLSET=gcc-4.8 B2_CXXSTD=03,11 Job 0", "g++-4.8", packages="g++-4.8", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'B2_TOOLSET': 'gcc-4.8', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=gcc-4.9 B2_CXXSTD=03,11 Job 1", "g++-4.9", packages="g++-4.9", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'B2_TOOLSET': 'gcc-4.9', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=gcc-5 B2_CXXSTD=03,11 Job 2", "g++-5", packages="g++-5", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-5', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=gcc-6 B2_CXXSTD=11,14 Job 3", "g++-6", packages="g++-6", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-6', 'B2_CXXSTD': '11,14', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=gcc-7 B2_CXXSTD=14,17 Job 4", "g++-7", packages="g++-7", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-7', 'B2_CXXSTD': '14,17', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=gcc-8 B2_CXXSTD=17,2a Job 5", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=gcc-9 B2_CXXSTD=17,2a Job 6", "g++-9", packages="g++-9", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-9', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-3.8 B2_CXXSTD=03,11 Job 7", "clang++-3.8", packages="clang-3.8 libstdc++-6-dev", llvm_os="xenial", llvm_ver="3.8", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'B2_TOOLSET': 'clang-3.8', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-4.0 B2_CXXSTD=11,14 Job 8", "clang++-4.0", packages="clang-4.0 libstdc++-6-dev", llvm_os="xenial", llvm_ver="4.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-4.0', 'B2_CXXSTD': '11,14', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-5.0 B2_CXXSTD=11,14 Job 9", "clang++-5.0", packages="clang-5.0 libstdc++-7-dev", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-5.0', 'B2_CXXSTD': '11,14', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-6.0 B2_CXXSTD=14,17 Job 10", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXSTD': '14,17', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-7 B2_CXXSTD=17,2a Job 11", "clang++-7", packages="clang-7 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="7", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-7', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-8 B2_CXXSTD=17,2a Job 12", "clang++-8", packages="clang-8 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-8', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
|
||||
linux_cxx("B2_TOOLSET=clang-6.0 B2_CXXSTD=03,11,14 Job 13", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': '-stdlib=libc++', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
|
||||
osx_cxx("B2_TOOLSET=clang B2_CXXSTD=03,11,17 Job 14", "g++", packages="", buildtype="boost", buildscript="drone", environment={'B2_TOOLSET': 'clang', 'B2_CXXSTD': '03,11,17', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
|
||||
linux_cxx("COMMENT=codecov.io B2_CXXSTD=03,11 B2_TOOLSET Job 15", "g++-8", packages="g++-8", buildtype="b5847f804b-0fcaf592f9", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'codecov.io', 'B2_CXXSTD': '03,11', 'B2_TOOLSET': 'gcc-8', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
|
||||
linux_cxx("COMMENT=asan B2_VARIANT=variant=debug B2_TOOL Job 16", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'asan', 'B2_VARIANT': 'variant=debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': 'address-sanitizer=norecover', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'DRONE_EXTRA_PRIVILEGED': 'True', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv, privileged=True),
|
||||
linux_cxx("COMMENT=tsan B2_VARIANT=variant=debug B2_TOOL Job 17", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'tsan', 'B2_VARIANT': 'variant=debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': 'thread-sanitizer=norecover', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'DRONE_JOB_UUID': '0716d9708d'}, globalenv=globalenv),
|
||||
linux_cxx("COMMENT=ubsan B2_VARIANT=variant=debug B2_TOO Job 18", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'variant=debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': 'undefined-sanitizer=norecover', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': 'linkflags=-fuse-ld=gold', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'DRONE_JOB_UUID': '9e6a55b6b4'}, globalenv=globalenv),
|
||||
linux_cxx("COMMENT=valgrind B2_TOOLSET=clang-6.0 B2_CXXS Job 19", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="b5847f804b-db180b7bd2", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'valgrind', 'B2_TOOLSET': 'clang-6.0', 'B2_CXXSTD': '03,11,14', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'B2_VARIANT': 'variant=debug', 'B2_TESTFLAGS': 'testing.launcher=valgrind', 'VALGRIND_OPTS': '--error-exitcode=1', 'DRONE_JOB_UUID': 'b3f0c7f6bb'}, globalenv=globalenv),
|
||||
linux_cxx("COMMENT=Coverity Scan B2_TOOLSET=clang Job 20", "g++", packages="binutils-gold gdb libc6-dbg", buildtype="b5847f804b-cce9827eb5", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'Coverity Scan', 'B2_TOOLSET': 'clang', 'DRONE_JOB_UUID': '91032ad7bb'}, globalenv=globalenv),
|
||||
]
|
||||
|
||||
# from https://github.com/boostorg/boost-ci
|
||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")
|
||||
106
.drone/drone.sh
Executable file
106
.drone/drone.sh
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2020 Rene Rivera, Sam Darwin
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set -e
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export DRONE_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
||||
export GIT_COMMIT=$DRONE_COMMIT
|
||||
export REPO_NAME=$DRONE_REPO
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
if [ "$DRONE_JOB_BUILDTYPE" == "boost" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/build.sh
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "b5847f804b-0fcaf592f9" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/codecov.sh
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "b5847f804b-db180b7bd2" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/valgrind.sh
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "b5847f804b-cce9827eb5" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$DRONE_BRANCH" = "develop" -o "$DRONE_BRANCH" = "master" \) -a "$DRONE_BUILD_EVENT" = "push" ] ; then
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/coverity.sh
|
||||
fi
|
||||
|
||||
fi
|
||||
525
.github/workflows/ci.yml
vendored
Normal file
525
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
name: GitHub Actions CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- githubactions*
|
||||
- feature/**
|
||||
- fix/**
|
||||
- pr/**
|
||||
|
||||
env:
|
||||
B2_VARIANT: variant=release
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: "B2_TOOLSET=gcc-4.8 B2_CXXSTD=03,11 Job 0"
|
||||
buildtype: "boost"
|
||||
packages: "g++-4.8"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
container: "ubuntu:14.04"
|
||||
cxx: "g++-4.8"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-4.8"
|
||||
b2_cxxstd: "03,11"
|
||||
- name: "B2_TOOLSET=gcc-4.9 B2_CXXSTD=03,11 Job 1"
|
||||
buildtype: "boost"
|
||||
packages: "g++-4.9"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-4.9"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-4.9"
|
||||
b2_cxxstd: "03,11"
|
||||
- name: "B2_TOOLSET=gcc-5 B2_CXXSTD=03,11 Job 2"
|
||||
buildtype: "boost"
|
||||
packages: "g++-5"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-5"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-5"
|
||||
b2_cxxstd: "03,11"
|
||||
- name: "B2_TOOLSET=gcc-6 B2_CXXSTD=11,14 Job 3"
|
||||
buildtype: "boost"
|
||||
packages: "g++-6"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-6"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-6"
|
||||
b2_cxxstd: "11,14"
|
||||
- name: "B2_TOOLSET=gcc-7 B2_CXXSTD=14,17 Job 4"
|
||||
buildtype: "boost"
|
||||
packages: "g++-7"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-7"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-7"
|
||||
b2_cxxstd: "14,17"
|
||||
- name: "B2_TOOLSET=gcc-8 B2_CXXSTD=17,2a Job 5"
|
||||
buildtype: "boost"
|
||||
packages: "g++-8"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-8"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-8"
|
||||
b2_cxxstd: "17,2a"
|
||||
- name: "B2_TOOLSET=gcc-9 B2_CXXSTD=17,2a Job 6"
|
||||
buildtype: "boost"
|
||||
packages: "g++-9"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-9"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
b2_toolset: "gcc-9"
|
||||
b2_cxxstd: "17,2a"
|
||||
- name: "B2_TOOLSET=clang-3.8 B2_CXXSTD=03,11 Job 7"
|
||||
buildtype: "boost"
|
||||
packages: "clang-3.8 libstdc++-6-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
container: "ubuntu:14.04"
|
||||
cxx: "clang++-3.8"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "3.8"
|
||||
b2_toolset: "clang-3.8"
|
||||
b2_cxxstd: "03,11"
|
||||
- name: "B2_TOOLSET=clang-4.0 B2_CXXSTD=11,14 Job 8"
|
||||
buildtype: "boost"
|
||||
packages: "clang-4.0 libstdc++-6-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-4.0"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "4.0"
|
||||
b2_toolset: "clang-4.0"
|
||||
b2_cxxstd: "11,14"
|
||||
- name: "B2_TOOLSET=clang-5.0 B2_CXXSTD=11,14 Job 9"
|
||||
buildtype: "boost"
|
||||
packages: "clang-5.0 libstdc++-7-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-5.0"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "5.0"
|
||||
b2_toolset: "clang-5.0"
|
||||
b2_cxxstd: "11,14"
|
||||
- name: "B2_TOOLSET=clang-6.0 B2_CXXSTD=14,17 Job 10"
|
||||
buildtype: "boost"
|
||||
packages: "clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-6.0"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "6.0"
|
||||
b2_toolset: "clang-6.0"
|
||||
b2_cxxstd: "14,17"
|
||||
- name: "B2_TOOLSET=clang-7 B2_CXXSTD=17,2a Job 11"
|
||||
buildtype: "boost"
|
||||
packages: "clang-7 libc6-dbg libc++-dev libstdc++-8-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-7"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "7"
|
||||
b2_toolset: "clang-7"
|
||||
b2_cxxstd: "17,2a"
|
||||
- name: "B2_TOOLSET=clang-8 B2_CXXSTD=17,2a Job 12"
|
||||
buildtype: "boost"
|
||||
packages: "clang-8 libc6-dbg libc++-dev libstdc++-8-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-8"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "8"
|
||||
b2_toolset: "clang-8"
|
||||
b2_cxxstd: "17,2a"
|
||||
- name: "B2_TOOLSET=clang-6.0 B2_CXXSTD=03,11,14 Job 13"
|
||||
buildtype: "boost"
|
||||
packages: "clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-6.0"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "6.0"
|
||||
b2_toolset: "clang-6.0"
|
||||
b2_cxxstd: "03,11,14"
|
||||
b2_cxxflags: "-stdlib=libc++"
|
||||
- name: "COMMENT=codecov.io B2_CXXSTD=03,11 B2_TOOLSET Job 15"
|
||||
buildtype: "b5847f804b-0fcaf592f9"
|
||||
packages: "g++-8"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-8"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
comment: "codecov.io"
|
||||
b2_cxxstd: "03,11"
|
||||
b2_toolset: "gcc-8"
|
||||
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
|
||||
- name: "COMMENT=asan B2_VARIANT=variant=debug B2_TOOL Job 16"
|
||||
buildtype: "boost"
|
||||
packages: "g++-8"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-8"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
comment: "asan"
|
||||
b2_variant: "variant=debug"
|
||||
b2_toolset: "gcc-8"
|
||||
b2_cxxstd: "03,11,14"
|
||||
b2_cxxflags: "address-sanitizer=norecover"
|
||||
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
|
||||
- name: "COMMENT=tsan B2_VARIANT=variant=debug B2_TOOL Job 17"
|
||||
buildtype: "boost"
|
||||
packages: "g++-8"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-8"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
comment: "tsan"
|
||||
b2_variant: "variant=debug"
|
||||
b2_toolset: "gcc-8"
|
||||
b2_cxxstd: "03,11,14"
|
||||
b2_cxxflags: "thread-sanitizer=norecover"
|
||||
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
|
||||
- name: "COMMENT=ubsan B2_VARIANT=variant=debug B2_TOO Job 18"
|
||||
buildtype: "boost"
|
||||
packages: "g++-8"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++-8"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
comment: "ubsan"
|
||||
b2_variant: "variant=debug"
|
||||
b2_toolset: "gcc-8"
|
||||
b2_cxxstd: "03,11,14"
|
||||
b2_cxxflags: "undefined-sanitizer=norecover"
|
||||
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
|
||||
b2_linkflags: "linkflags=-fuse-ld=gold"
|
||||
ubsan_options: "print_stacktrace=1"
|
||||
- name: "COMMENT=valgrind B2_TOOLSET=clang-6.0 B2_CXXS Job 19"
|
||||
buildtype: "b5847f804b-db180b7bd2"
|
||||
packages: "clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "clang++-6.0"
|
||||
sources: ""
|
||||
llvm_os: "xenial"
|
||||
llvm_ver: "6.0"
|
||||
comment: "valgrind"
|
||||
b2_toolset: "clang-6.0"
|
||||
b2_cxxstd: "03,11,14"
|
||||
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
|
||||
b2_variant: "variant=debug"
|
||||
b2_testflags: "testing.launcher=valgrind"
|
||||
valgrind_opts: "--error-exitcode=1"
|
||||
- name: "COMMENT=Coverity Scan B2_TOOLSET=clang Job 20"
|
||||
buildtype: "b5847f804b-cce9827eb5"
|
||||
packages: "binutils-gold gdb libc6-dbg"
|
||||
packages_to_remove: ""
|
||||
os: "ubuntu-16.04"
|
||||
cxx: "g++"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
comment: "Coverity Scan"
|
||||
b2_toolset: "clang"
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ${{ matrix.container }}
|
||||
|
||||
steps:
|
||||
- name: Check if running in container
|
||||
if: matrix.container != ''
|
||||
run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV
|
||||
- name: If running in container, upgrade packages
|
||||
if: matrix.container != ''
|
||||
run: |
|
||||
sudo apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python python-pip ruby cpio gcc-multilib g++-multilib pkgconf python3 python3-pip ccache libpython-dev
|
||||
sudo apt-add-repository ppa:git-core/ppa
|
||||
sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git
|
||||
sudo python -m pip install --upgrade pip==20.3.4
|
||||
sudo /usr/local/bin/pip install cmake
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: linux
|
||||
shell: bash
|
||||
env:
|
||||
CXX: ${{ matrix.cxx }}
|
||||
SOURCES: ${{ matrix.sources }}
|
||||
LLVM_OS: ${{ matrix.llvm_os }}
|
||||
LLVM_VER: ${{ matrix.llvm_ver }}
|
||||
PACKAGES: ${{ matrix.packages }}
|
||||
PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }}
|
||||
JOB_BUILDTYPE: ${{ matrix.buildtype }}
|
||||
B2_TOOLSET: ${{ matrix.b2_toolset }}
|
||||
B2_CXXSTD: ${{ matrix.b2_cxxstd }}
|
||||
B2_CXXFLAGS: ${{ matrix.b2_cxxflags }}
|
||||
COMMENT: ${{ matrix.comment }}
|
||||
B2_DEFINES: ${{ matrix.b2_defines }}
|
||||
B2_VARIANT: ${{ matrix.b2_variant }}
|
||||
B2_LINKFLAGS: ${{ matrix.b2_linkflags }}
|
||||
UBSAN_OPTIONS: ${{ matrix.ubsan_options }}
|
||||
B2_TESTFLAGS: ${{ matrix.b2_testflags }}
|
||||
VALGRIND_OPTS: ${{ matrix.valgrind_opts }}
|
||||
TRAVIS_BRANCH: ${{ github.base_ref }}
|
||||
TRAVIS_OS_NAME: "linux"
|
||||
run: |
|
||||
echo '==================================> SETUP'
|
||||
echo '==================================> PACKAGES'
|
||||
set -e
|
||||
if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi
|
||||
echo ">>>>> APT: REPO.."
|
||||
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
|
||||
|
||||
if test -n "${LLVM_OS}" ; then
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
if test -n "${LLVM_VER}" ; then
|
||||
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main"
|
||||
else
|
||||
# Snapshot (i.e. trunk) build of clang
|
||||
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main"
|
||||
fi
|
||||
fi
|
||||
echo ">>>>> APT: UPDATE.."
|
||||
sudo -E apt-get -o Acquire::Retries=3 update
|
||||
if test -n "${SOURCES}" ; then
|
||||
echo ">>>>> APT: INSTALL SOURCES.."
|
||||
for SOURCE in $SOURCES; do
|
||||
sudo -E apt-add-repository ppa:$SOURCE
|
||||
done
|
||||
fi
|
||||
echo ">>>>> APT: INSTALL ${PACKAGES}.."
|
||||
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES}
|
||||
|
||||
echo '==================================> INSTALL AND COMPILE'
|
||||
set -e
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
|
||||
export VCS_COMMIT_ID=$GITHUB_SHA
|
||||
export GIT_COMMIT=$GITHUB_SHA
|
||||
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
|
||||
export USER=$(whoami)
|
||||
export CC=${CC:-gcc}
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
if [ "$JOB_BUILDTYPE" == "boost" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/build.sh
|
||||
|
||||
elif [ "$JOB_BUILDTYPE" == "b5847f804b-0fcaf592f9" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/codecov.sh
|
||||
|
||||
elif [ "$JOB_BUILDTYPE" == "b5847f804b-db180b7bd2" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/valgrind.sh
|
||||
|
||||
elif [ "$JOB_BUILDTYPE" == "b5847f804b-cce9827eb5" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$TRAVIS_BRANCH" = "develop" -o "$TRAVIS_BRANCH" = "master" \) -a \("$GITHUB_EVENT_NAME" = "push" -o "$GITHUB_EVENT_NAME" = "cron" \) ] ; then
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/coverity.sh
|
||||
fi
|
||||
|
||||
fi
|
||||
osx:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: "B2_TOOLSET=clang B2_CXXSTD=03,11,17 Job 14"
|
||||
buildtype: "boost"
|
||||
packages: ""
|
||||
os: "macos-10.15"
|
||||
cxx: "g++"
|
||||
sources: ""
|
||||
llvm_os: ""
|
||||
llvm_ver: ""
|
||||
xcode_version: 11.7
|
||||
b2_toolset: "clang"
|
||||
b2_cxxstd: "03,11,17"
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set DEVELOPER_DIR
|
||||
if: matrix.xcode_version != ''
|
||||
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
|
||||
- name: Test DEVELOPER_DIR
|
||||
run: echo $DEVELOPER_DIR
|
||||
|
||||
- name: "osx"
|
||||
shell: bash
|
||||
env:
|
||||
CXX: ${{ matrix.cxx }}
|
||||
SOURCES: ${{ matrix.sources }}
|
||||
LLVM_OS: ${{ matrix.llvm_os }}
|
||||
LLVM_VER: ${{ matrix.llvm_ver }}
|
||||
PACKAGES: ${{ matrix.packages }}
|
||||
JOB_BUILDTYPE: ${{ matrix.buildtype }}
|
||||
B2_TOOLSET: ${{ matrix.b2_toolset }}
|
||||
B2_CXXSTD: ${{ matrix.b2_cxxstd }}
|
||||
B2_CXXFLAGS: ${{ matrix.b2_cxxflags }}
|
||||
COMMENT: ${{ matrix.comment }}
|
||||
B2_DEFINES: ${{ matrix.b2_defines }}
|
||||
B2_VARIANT: ${{ matrix.b2_variant }}
|
||||
B2_LINKFLAGS: ${{ matrix.b2_linkflags }}
|
||||
UBSAN_OPTIONS: ${{ matrix.ubsan_options }}
|
||||
B2_TESTFLAGS: ${{ matrix.b2_testflags }}
|
||||
VALGRIND_OPTS: ${{ matrix.valgrind_opts }}
|
||||
TRAVIS_BRANCH: ${{ github.base_ref }}
|
||||
TRAVIS_OS_NAME: "osx"
|
||||
run: |
|
||||
echo '==================================> SETUP'
|
||||
set -e
|
||||
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck
|
||||
echo '==================================> PACKAGES'
|
||||
echo '==================================> INSTALL AND COMPILE'
|
||||
set -e
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
|
||||
export VCS_COMMIT_ID=$GITHUB_SHA
|
||||
export GIT_COMMIT=$GITHUB_SHA
|
||||
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
|
||||
export USER=$(whoami)
|
||||
export CC=${CC:-gcc}
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
if [ "$JOB_BUILDTYPE" == "boost" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/build.sh
|
||||
|
||||
fi
|
||||
216
.travis.yml
Normal file
216
.travis.yml
Normal file
@@ -0,0 +1,216 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2017 - 2019 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/boostorg/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.
|
||||
|
||||
dist: xenial
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
global:
|
||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||
# - B2_ADDRESS_MODEL=address-model=64,32
|
||||
# - B2_LINK=link=shared,static
|
||||
# - B2_THREADING=threading=multi,single
|
||||
- B2_VARIANT=variant=release
|
||||
|
||||
install:
|
||||
- git clone https://github.com/boostorg/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:
|
||||
- master
|
||||
- develop
|
||||
- /bugfix\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
- /pr\/.*/
|
||||
|
||||
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-38: &clang-38 { apt: { packages: [ "clang-3.8",
|
||||
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
|
||||
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
|
||||
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
|
||||
"libc6-dbg",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-7: &clang-7 { apt: { packages: [ "clang-7",
|
||||
"libc6-dbg",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-8: &clang-8 { apt: { packages: [ "clang-8",
|
||||
"libc6-dbg",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
|
||||
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
|
||||
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" ] } }
|
||||
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
|
||||
jobs:
|
||||
allow_failures:
|
||||
- env:
|
||||
- COPY="all the environment settings from your job"
|
||||
|
||||
include:
|
||||
# libstdc++
|
||||
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=03,11" ], addons: *gcc-48 }
|
||||
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=03,11" ], addons: *gcc-49 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=03,11" ], addons: *gcc-5 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17,2a" ], addons: *gcc-8 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17,2a" ], addons: *gcc-9 }
|
||||
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=03,11" ], addons: *clang-38 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17,2a" ], addons: *clang-7 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17,2a" ], addons: *clang-8 }
|
||||
|
||||
# libc++
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=03,11,14",
|
||||
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
|
||||
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=03,11,17" ] }
|
||||
|
||||
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following:
|
||||
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
|
||||
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=codecov.io
|
||||
- B2_CXXSTD=03,11
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-8
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/codecov.sh
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=asan
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_CXXFLAGS="address-sanitizer=norecover"
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=tsan
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_CXXFLAGS="thread-sanitizer=norecover"
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=ubsan
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_CXXFLAGS="undefined-sanitizer=norecover"
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
# https://github.com/boostorg/build/issues/451 using the gold linker to work around an issue
|
||||
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
|
||||
- UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=valgrind
|
||||
- B2_TOOLSET=clang-6.0
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TESTFLAGS=testing.launcher=valgrind
|
||||
- VALGRIND_OPTS=--error-exitcode=1
|
||||
addons: *clang-6
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/valgrind.sh
|
||||
|
||||
# - os: linux
|
||||
# env:
|
||||
# - COMMENT=cppcheck
|
||||
# script:
|
||||
# - cd $BOOST_ROOT/libs/$SELF
|
||||
# - ci/travis/cppcheck.sh
|
||||
|
||||
#################### 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"
|
||||
- B2_TOOLSET=clang
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/coverity.sh
|
||||
|
||||
notifications:
|
||||
email:
|
||||
false
|
||||
32
CMakeLists.txt
Normal file
32
CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# Generated by `boostdep --cmake dynamic_bitset`
|
||||
# Copyright 2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(boost_dynamic_bitset VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_dynamic_bitset INTERFACE)
|
||||
add_library(Boost::dynamic_bitset ALIAS boost_dynamic_bitset)
|
||||
|
||||
target_include_directories(boost_dynamic_bitset INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_dynamic_bitset
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::integer
|
||||
Boost::move
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
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.
|
||||
|
||||
147
appveyor.yml
Normal file
147
appveyor.yml
Normal file
@@ -0,0 +1,147 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright (C) 2017 - 2019 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/boostorg/boost-ci/
|
||||
#
|
||||
# Instructions for customizing this script for your library:
|
||||
#
|
||||
# 1. Customize the compilers and language levels you want.
|
||||
# 2. If you have more 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:
|
||||
- master
|
||||
- develop
|
||||
- /bugfix\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
- /pr\/.*/
|
||||
|
||||
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
|
||||
|
||||
matrix:
|
||||
- FLAVOR: Visual Studio 2019
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXFLAGS: cxxflags=-permissive-
|
||||
B2_CXXSTD: latest # 2a
|
||||
B2_TOOLSET: msvc-14.2
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++2a Strict
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXFLAGS: cxxflags=-permissive-
|
||||
B2_CXXSTD: latest # 2a
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 17
|
||||
B2_TOOLSET: msvc-14.1
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++14 (Default)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64,32
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: clang-cl
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 11
|
||||
B2_TOOLSET: clang-win
|
||||
|
||||
- FLAVOR: Visual Studio 2015 C++14 (Default)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_ADDRESS_MODEL: address-model=64,32
|
||||
B2_TOOLSET: msvc-14.0
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: Visual Studio 2010, 2012, 2013
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_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
|
||||
B2_CXXSTD: 03,11
|
||||
# https://github.com/boostorg/test/issues/144
|
||||
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
|
||||
B2_THREADING: threadapi=pthread
|
||||
B2_TOOLSET: gcc
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: cygwin (64-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 11,17
|
||||
# https://github.com/boostorg/test/issues/144
|
||||
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
|
||||
B2_THREADING: threadapi=pthread
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: mingw32
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ARCH: i686
|
||||
B2_ADDRESS_MODEL: address-model=32
|
||||
B2_CXXSTD: 03,11
|
||||
SCRIPT: ci\appveyor\mingw.bat
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: mingw64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ARCH: x86_64
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 11,17
|
||||
B2_DEFINES: define=__USE_ISOC99
|
||||
SCRIPT: ci\appveyor\mingw.bat
|
||||
|
||||
install:
|
||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||
- git clone https://github.com/boostorg/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 B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
|
||||
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
|
||||
# Echo the complete build command to the build log
|
||||
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_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:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_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
|
||||
@@ -90,7 +91,7 @@ constructor of the <tt>dynamic_bitset</tt>.</p>
|
||||
|
||||
<p>The <tt>dynamic_bitset</tt> class is nearly identical to the
|
||||
<a href=
|
||||
"http://www.sgi.com/tech/stl/bitset.html"><tt>std::bitset</tt></a>
|
||||
"https://boost.org/sgi/stl/bitset.html"><tt>std::bitset</tt></a>
|
||||
class. The difference is that the size of the
|
||||
<tt>dynamic_bitset</tt> (the number of bits) is specified at
|
||||
run-time during the construction of a <tt>dynamic_bitset</tt>
|
||||
@@ -143,8 +144,11 @@ public:
|
||||
|
||||
typedef bool <a href="#const_reference">const_reference</a>;
|
||||
|
||||
<a href=
|
||||
"#cons0">dynamic_bitset</a>();
|
||||
|
||||
explicit <a href=
|
||||
"#cons1">dynamic_bitset</a>(const Allocator& alloc = Allocator());
|
||||
"#cons1">dynamic_bitset</a>(const Allocator& alloc);
|
||||
|
||||
explicit <a href=
|
||||
"#cons2">dynamic_bitset</a>(size_type num_bits, unsigned long value = 0,
|
||||
@@ -197,10 +201,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;
|
||||
@@ -336,7 +343,7 @@ input/output and some bitwise operations).
|
||||
<h3><a id="rationale">Rationale</a></h3>
|
||||
<p>
|
||||
<tt>dynamic_bitset</tt> is not a <a href=
|
||||
"http://www.sgi.com/tech/stl/Container.html">Container</a> and
|
||||
"https://boost.org/sgi/stl/Container.html">Container</a> and
|
||||
does not provide iterators for the following reason:
|
||||
</p>
|
||||
|
||||
@@ -351,7 +358,7 @@ people try to use iterators from <tt>std::vector<bool></tt>
|
||||
with a Standard algorithm such as <tt>std::search</tt>. The
|
||||
<tt>std::search</tt> requirements say that the iterator must be a
|
||||
<a href=
|
||||
"http://www.sgi.com/tech/stl/ForwardIterator.html">Forward
|
||||
"https://boost.org/sgi/stl/ForwardIterator.html">Forward
|
||||
Iterator</a>, but the <tt>std::vector<bool>::iterator</tt>
|
||||
does not meet this requirement because of the proxy reference.
|
||||
Depending on the implementation, they may or not be a compile
|
||||
@@ -363,7 +370,7 @@ by not pretending to be a container.</li>
|
||||
|
||||
<p>Some people prefer the name "toggle" to "flip". The name
|
||||
"flip" was chosen because that is the name used in <a href=
|
||||
"http://www.sgi.com/tech/stl/bitset.html"><tt>std::bitset</tt></a>.
|
||||
"https://boost.org/sgi/stl/bitset.html"><tt>std::bitset</tt></a>.
|
||||
In fact, most of the function names for <tt>dynamic_bitset</tt>
|
||||
were chosen for this reason.</p>
|
||||
|
||||
@@ -405,13 +412,13 @@ in the header <a href=
|
||||
</table>
|
||||
<h3><a id="concepts-modeled">Concepts Modeled</a></h3>
|
||||
<a href=
|
||||
"http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, <a
|
||||
"https://boost.org/sgi/stl/Assignable.html">Assignable</a>, <a
|
||||
href=
|
||||
"http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
|
||||
"https://boost.org/sgi/stl/DefaultConstructible.html">Default
|
||||
Constructible</a>, <a href=
|
||||
"http://www.sgi.com/tech/stl/EqualityComparable.html">Equality
|
||||
"https://boost.org/sgi/stl/EqualityComparable.html">Equality
|
||||
Comparable</a>, <a href=
|
||||
"http://www.sgi.com/tech/stl/LessThanComparable.html">LessThan
|
||||
"https://boost.org/sgi/stl/LessThanComparable.html">LessThan
|
||||
Comparable</a>.
|
||||
|
||||
<h3><a id="type-requirements">Type requirements</a></h3>
|
||||
@@ -566,19 +573,30 @@ The maximum value of <tt>size_type</tt>.
|
||||
<hr />
|
||||
<pre>
|
||||
<a id=
|
||||
"cons1">dynamic_bitset</a>(const Allocator& alloc = Allocator())
|
||||
"cons0">dynamic_bitset</a>()
|
||||
</pre>
|
||||
|
||||
<b>Effects:</b> Constructs a bitset of size zero. The allocator
|
||||
for this bitset is a default-constructed object of type
|
||||
<tt>Allocator</tt>.<br />
|
||||
<b>Postconditions:</b> <tt>this->size() == 0</tt>.<br />
|
||||
<b>Throws:</b> Nothing unless the default constructor of
|
||||
<tt>Allocator</tt> throws an exception.<br />
|
||||
(Required by <a href=
|
||||
"https://boost.org/sgi/stl/DefaultConstructible.html">Default
|
||||
Constructible</a>.)
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
<a id=
|
||||
"cons1">dynamic_bitset</a>(const Allocator& alloc)
|
||||
</pre>
|
||||
|
||||
<b>Effects:</b> Constructs a bitset of size zero. A copy of the
|
||||
<tt>alloc</tt> object will be used in subsequent bitset
|
||||
operations such as <tt>resize</tt> to allocate memory.<br />
|
||||
<b>Postconditions:</b> <tt>this->size() == 0</tt>.<br />
|
||||
<b>Throws:</b> An allocation error if memory is exhausted
|
||||
(<tt>std::bad_alloc</tt> if
|
||||
<tt>Allocator=std::allocator</tt>).<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
|
||||
Constructible</a>.)
|
||||
<b>Throws:</b> nothing.
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
@@ -633,7 +651,7 @@ allocator in <tt>x</tt>. <br />
|
||||
(<tt>std::bad_alloc</tt> if
|
||||
<tt>Allocator=std::allocator</tt>).<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>.)
|
||||
"https://boost.org/sgi/stl/Assignable.html">Assignable</a>.)
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
@@ -716,7 +734,7 @@ position <tt>(b * bits_per_block + i)</tt> in the bitset (where
|
||||
<br />
|
||||
<b>Requires:</b> <tt>BlockInputIterator</tt> must be either an
|
||||
integral type or a model of <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">Input
|
||||
"https://boost.org/sgi/stl/InputIterator.html">Input
|
||||
Iterator</a> whose <tt>value_type</tt> is the same type as
|
||||
<tt>Block</tt>.<br /> <b>Throws:</b> An allocation error if
|
||||
memory is exhausted (<tt>std::bad_alloc</tt> if
|
||||
@@ -727,11 +745,11 @@ memory is exhausted (<tt>std::bad_alloc</tt> if
|
||||
template<typename Char, typename Traits, typename Alloc>
|
||||
explicit
|
||||
<a id="cons3">dynamic_bitset</a>(const <a href=
|
||||
"http://www.sgi.com/tech/stl/basic_string.html">std::basic_string</a><Char,Traits,Alloc>& s,
|
||||
"https://boost.org/sgi/stl/basic_string.html">std::basic_string</a><Char,Traits,Alloc>& s,
|
||||
typename std::basic_string<CharT, Traits, Alloc>::size_type pos = 0,
|
||||
typename std::basic_string<CharT, Traits, Alloc>::size_type n = <a
|
||||
href=
|
||||
"http://www.sgi.com/tech/stl/basic_string.html">std::basic_string</a><Char,Traits,Alloc>::npos,
|
||||
"https://boost.org/sgi/stl/basic_string.html">std::basic_string</a><Char,Traits,Alloc>::npos,
|
||||
const Allocator& alloc = Allocator())
|
||||
</pre>
|
||||
|
||||
@@ -790,7 +808,7 @@ dynamic_bitset& <a id=
|
||||
<b>Returns:</b> <tt>*this</tt>.<br />
|
||||
<b>Throws:</b> nothing. <br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>.)
|
||||
"https://boost.org/sgi/stl/Assignable.html">Assignable</a>.)
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
@@ -893,7 +911,7 @@ for (; first != last; ++first)
|
||||
|
||||
<b>Requires:</b> The <tt>BlockInputIterator</tt> type must be a
|
||||
model of <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">Input
|
||||
"https://boost.org/sgi/stl/InputIterator.html">Input
|
||||
Iterator</a> and the <tt>value_type</tt> must be the same type as
|
||||
<tt>Block</tt>.<br />
|
||||
<b>Throws:</b> An allocation error if memory is exhausted
|
||||
@@ -1062,6 +1080,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 +1104,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 +1124,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)
|
||||
@@ -1323,7 +1374,7 @@ rhs.size()</tt> and if for all <tt>i</tt> in the range
|
||||
returns <tt>false</tt>.<br />
|
||||
<b>Throws:</b> nothing.<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/EqualityComparable.html">Equality
|
||||
"https://boost.org/sgi/stl/EqualityComparable.html">Equality
|
||||
Comparable</a>.)
|
||||
|
||||
<hr />
|
||||
@@ -1335,7 +1386,7 @@ bool <a id=
|
||||
<b>Returns:</b> <tt>!((*this) == rhs)</tt><br />
|
||||
<b>Throws:</b> nothing.<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/EqualityComparable.html">Equality
|
||||
"https://boost.org/sgi/stl/EqualityComparable.html">Equality
|
||||
Comparable</a>.)
|
||||
|
||||
<hr />
|
||||
@@ -1347,11 +1398,11 @@ bool <a id=
|
||||
<b>Returns:</b> <tt>true</tt> if this bitset is lexicographically
|
||||
less than <tt>rhs</tt>, and returns <tt>false</tt> otherwise.
|
||||
(See the description of <a href=
|
||||
"http://www.sgi.com/tech/stl/lexicographical_compare.html">lexicographical_compare</a>
|
||||
"https://boost.org/sgi/stl/lexicographical_compare.html">lexicographical_compare</a>
|
||||
for a definition of lexicographic ordering). <br />
|
||||
<b>Throws:</b> nothing.<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than
|
||||
"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
|
||||
Comparable</a>.)
|
||||
|
||||
<hr />
|
||||
@@ -1364,7 +1415,7 @@ bool <a id=
|
||||
rhs)</tt><br />
|
||||
<b>Throws:</b> nothing.<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than
|
||||
"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
|
||||
Comparable</a>.)
|
||||
|
||||
<hr />
|
||||
@@ -1376,7 +1427,7 @@ bool <a id=
|
||||
<b>Returns:</b> <tt>(*this) < rhs || (*this) == rhs</tt><br />
|
||||
<b>Throws:</b> nothing.<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than
|
||||
"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
|
||||
Comparable</a>.)
|
||||
|
||||
<hr />
|
||||
@@ -1388,7 +1439,7 @@ bool <a id=
|
||||
<b>Returns:</b> <tt>(*this) > rhs || (*this) == rhs</tt><br />
|
||||
<b>Throws:</b> nothing.<br />
|
||||
(Required by <a href=
|
||||
"http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than
|
||||
"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
|
||||
Comparable</a>.)
|
||||
|
||||
<hr />
|
||||
@@ -1448,7 +1499,7 @@ template <typename CharT, typename Alloc>
|
||||
void <a id=
|
||||
"to_string">to_string</a>(const dynamic_bitset<Block, Allocator>& b,
|
||||
<a href=
|
||||
"http://www.sgi.com/tech/stl/basic_string.html">std::basic_string</a><Char,Traits,Alloc>& s)
|
||||
"https://boost.org/sgi/stl/basic_string.html">std::basic_string</a><Char,Traits,Alloc>& s)
|
||||
</pre>
|
||||
|
||||
<b>Effects:</b> Copies a representation of <tt>b</tt> into the
|
||||
@@ -1486,7 +1537,7 @@ block <tt>bval</tt> written, the bit <tt>(bval >> i) &
|
||||
+ i)</tt> in the bitset.<br />
|
||||
<b>Requires:</b> The type <tt>BlockOutputIterator</tt> must be a
|
||||
model of <a href=
|
||||
"http://www.sgi.com/tech/stl/OutputIterator.html">Output
|
||||
"https://boost.org/sgi/stl/OutputIterator.html">Output
|
||||
Iterator</a> and its <tt>value_type</tt> must be the same type as
|
||||
<tt>Block</tt>. Further, the size of the output range must be
|
||||
greater or equal <tt>b.num_blocks()</tt>.
|
||||
@@ -1502,7 +1553,7 @@ void <a id=
|
||||
<b>Effects:</b> Reads blocks from the iterator range into the
|
||||
bitset. <br />
|
||||
<b>Requires:</b> The type <tt>BlockIterator</tt> must be a model
|
||||
of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input
|
||||
of <a href="https://boost.org/sgi/stl/InputIterator.html">Input
|
||||
Iterator</a> and its <tt>value_type</tt> must be the same type as
|
||||
<tt>Block</tt>. The size of the iterator range must be less or
|
||||
equal to <tt>b.num_blocks()</tt>.
|
||||
@@ -1686,9 +1737,9 @@ nested class <tt>reference</tt>.
|
||||
<h3><a id="see-also">See also</a></h3>
|
||||
|
||||
<tt><a href=
|
||||
"http://www.sgi.com/tech/stl/bitset.html">std::bitset</a></tt>,
|
||||
"https://boost.org/sgi/stl/bitset.html">std::bitset</a></tt>,
|
||||
<tt><a href=
|
||||
"http://www.sgi.com/tech/stl/Vector.html">std::vector</a></tt>,
|
||||
"https://boost.org/sgi/stl/Vector.html">std::vector</a></tt>,
|
||||
|
||||
<h3><a id="acknowledgements">Acknowledgements</a></h3>
|
||||
|
||||
@@ -1718,7 +1769,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>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
exe timing_tests
|
||||
: timing_tests.cpp
|
||||
../../timer/build//boost_timer
|
||||
;
|
||||
|
||||
exe example1
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
#include "boost/cstdlib.hpp"
|
||||
#include "boost/version.hpp"
|
||||
#include "boost/timer.hpp"
|
||||
#include "boost/timer/timer.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
|
||||
|
||||
@@ -94,8 +94,11 @@ void prologue()
|
||||
template <typename T>
|
||||
void timing_test(T* = 0) // dummy parameter to workaround VC6
|
||||
{
|
||||
|
||||
#ifndef BOOST_NO_STRESS_TEST
|
||||
const unsigned long num = 30 * 100000;
|
||||
#else
|
||||
const unsigned long num = 30 * 1000;
|
||||
#endif
|
||||
|
||||
|
||||
// This variable is printed at the end of the test,
|
||||
@@ -108,16 +111,13 @@ void timing_test(T* = 0) // dummy parameter to workaround VC6
|
||||
std::cout << "--------------------------------------------------\n";
|
||||
|
||||
{
|
||||
boost::timer time;
|
||||
boost::timer::auto_cpu_timer time;
|
||||
|
||||
const typename boost::dynamic_bitset<T>::size_type sz = 5000;
|
||||
for (unsigned long i = 0; i < num; ++i) {
|
||||
boost::dynamic_bitset<T> bs(sz, i);
|
||||
dummy += bs.count();
|
||||
}
|
||||
|
||||
const double elaps = time.elapsed();
|
||||
std::cout << "Elapsed: " << elaps << '\n';
|
||||
}
|
||||
|
||||
std::cout << "(total count: " << dummy << ")\n\n";
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
namespace dynamic_bitset_impl {
|
||||
|
||||
// Gives (read-)access to the object representation
|
||||
// of an object of type T (3.9p4). CANNOT be used
|
||||
// on a base sub-object
|
||||
//
|
||||
template <typename T>
|
||||
inline const unsigned char * object_representation (T* p)
|
||||
{
|
||||
return static_cast<const unsigned char *>(static_cast<const void *>(p));
|
||||
}
|
||||
|
||||
template<typename T, int amount, int width /* = default */>
|
||||
struct shifter
|
||||
{
|
||||
static void left_shift(T & v) {
|
||||
amount >= width ? (v = 0)
|
||||
: (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount));
|
||||
}
|
||||
};
|
||||
|
||||
// ------- count function implementation --------------
|
||||
|
||||
typedef unsigned char byte_type;
|
||||
|
||||
// These two entities
|
||||
//
|
||||
// enum mode { access_by_bytes, access_by_blocks };
|
||||
// template <mode> struct mode_to_type {};
|
||||
//
|
||||
// were removed, since the regression logs (as of 24 Aug 2008)
|
||||
// showed that several compilers had troubles with recognizing
|
||||
//
|
||||
// const mode m = access_by_bytes
|
||||
//
|
||||
// as a constant expression
|
||||
//
|
||||
// * So, we'll use bool, instead of enum *.
|
||||
//
|
||||
template <bool value>
|
||||
struct value_to_type
|
||||
{
|
||||
value_to_type() {}
|
||||
};
|
||||
const bool access_by_bytes = true;
|
||||
const bool access_by_blocks = false;
|
||||
|
||||
|
||||
// the table: wrapped in a class template, so
|
||||
// that it is only instantiated if/when needed
|
||||
//
|
||||
template <bool dummy_name = true>
|
||||
struct count_table { static const byte_type table[]; };
|
||||
|
||||
template <>
|
||||
struct count_table<false> { /* no table */ };
|
||||
|
||||
|
||||
const unsigned int table_width = 8;
|
||||
template <bool b>
|
||||
const byte_type count_table<b>::table[] =
|
||||
{
|
||||
// Automatically generated by GPTableGen.exe v.1.0
|
||||
//
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
||||
};
|
||||
|
||||
|
||||
// overload for access by bytes
|
||||
//
|
||||
|
||||
template <typename Iterator>
|
||||
inline std::size_t do_count(Iterator first, std::size_t length,
|
||||
int /*dummy param*/,
|
||||
value_to_type<access_by_bytes>* )
|
||||
{
|
||||
std::size_t num = 0;
|
||||
if (length)
|
||||
{
|
||||
const byte_type * p = object_representation(&*first);
|
||||
length *= sizeof(*first);
|
||||
|
||||
do {
|
||||
num += count_table<>::table[*p];
|
||||
++p;
|
||||
--length;
|
||||
|
||||
} while (length);
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
// overload for access by blocks
|
||||
//
|
||||
template <typename Iterator, typename ValueType>
|
||||
inline std::size_t do_count(Iterator first, std::size_t length, ValueType,
|
||||
value_to_type<access_by_blocks>*)
|
||||
{
|
||||
std::size_t num = 0;
|
||||
while (length){
|
||||
|
||||
ValueType value = *first;
|
||||
while (value) {
|
||||
num += count_table<>::table[value & ((1u<<table_width) - 1)];
|
||||
value >>= table_width;
|
||||
}
|
||||
|
||||
++first;
|
||||
--length;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
|
||||
// Some library implementations simply return a dummy
|
||||
// value such as
|
||||
//
|
||||
// size_type(-1) / sizeof(T)
|
||||
//
|
||||
// from vector<>::max_size. This tries to get more
|
||||
// meaningful info.
|
||||
//
|
||||
template <typename T>
|
||||
inline typename T::size_type vector_max_size_workaround(const T & v)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
const allocator_type& alloc = v.get_allocator();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef std::allocator_traits<allocator_type> allocator_traits;
|
||||
|
||||
const typename allocator_traits::size_type alloc_max =
|
||||
allocator_traits::max_size(alloc);
|
||||
#else
|
||||
const typename allocator_type::size_type alloc_max = alloc.max_size();
|
||||
#endif
|
||||
|
||||
const typename T::size_type container_max = v.max_size();
|
||||
|
||||
return alloc_max < container_max ? alloc_max : container_max;
|
||||
}
|
||||
|
||||
// for static_asserts
|
||||
template <typename T>
|
||||
struct allowed_block_type {
|
||||
enum { value = T(-1) > 0 }; // ensure T has no sign
|
||||
};
|
||||
|
||||
template <>
|
||||
struct allowed_block_type<bool> {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct is_numeric {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
# define BOOST_dynamic_bitset_is_numeric(x) \
|
||||
template<> \
|
||||
struct is_numeric< x > { \
|
||||
enum { value = true }; \
|
||||
} /**/
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric(bool);
|
||||
BOOST_dynamic_bitset_is_numeric(char);
|
||||
|
||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
BOOST_dynamic_bitset_is_numeric(wchar_t);
|
||||
#endif
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric(signed char);
|
||||
BOOST_dynamic_bitset_is_numeric(short int);
|
||||
BOOST_dynamic_bitset_is_numeric(int);
|
||||
BOOST_dynamic_bitset_is_numeric(long int);
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned char);
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned short);
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned int);
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned long);
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
BOOST_dynamic_bitset_is_numeric(::boost::long_long_type);
|
||||
BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type);
|
||||
#endif
|
||||
|
||||
// intentionally omitted
|
||||
//BOOST_dynamic_bitset_is_numeric(float);
|
||||
//BOOST_dynamic_bitset_is_numeric(double);
|
||||
//BOOST_dynamic_bitset_is_numeric(long double);
|
||||
|
||||
#undef BOOST_dynamic_bitset_is_numeric
|
||||
|
||||
} // dynamic_bitset_impl
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace boost { namespace detail {
|
||||
#endif
|
||||
|
||||
//
|
||||
#if (defined __BORLANDC__ && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))) \
|
||||
#if (defined BOOST_BORLANDC && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))) \
|
||||
|| (defined BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
|
||||
#endif
|
||||
|
||||
307
include/boost/dynamic_bitset/detail/dynamic_bitset.hpp
Normal file
307
include/boost/dynamic_bitset/detail/dynamic_bitset.hpp
Normal file
@@ -0,0 +1,307 @@
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
// Copyright (c) 2019 Andrey Semashev
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include <boost/core/allocator_access.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 {
|
||||
|
||||
namespace detail {
|
||||
namespace dynamic_bitset_impl {
|
||||
|
||||
template<class T>
|
||||
struct max_limit {
|
||||
BOOST_STATIC_CONSTEXPR T value = static_cast<T>(-1);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR_OR_CONST T max_limit<T>::value;
|
||||
|
||||
// Gives (read-)access to the object representation
|
||||
// of an object of type T (3.9p4). CANNOT be used
|
||||
// on a base sub-object
|
||||
//
|
||||
template <typename T>
|
||||
inline const unsigned char * object_representation (T* p)
|
||||
{
|
||||
return static_cast<const unsigned char *>(static_cast<const void *>(p));
|
||||
}
|
||||
|
||||
template<typename T, int amount, int width /* = default */>
|
||||
struct shifter
|
||||
{
|
||||
static void left_shift(T & v) {
|
||||
amount >= width ? (v = 0)
|
||||
: (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount));
|
||||
}
|
||||
};
|
||||
|
||||
// ------- count function implementation --------------
|
||||
|
||||
typedef unsigned char byte_type;
|
||||
|
||||
// These two entities
|
||||
//
|
||||
// enum mode { access_by_bytes, access_by_blocks };
|
||||
// template <mode> struct mode_to_type {};
|
||||
//
|
||||
// were removed, since the regression logs (as of 24 Aug 2008)
|
||||
// showed that several compilers had troubles with recognizing
|
||||
//
|
||||
// const mode m = access_by_bytes
|
||||
//
|
||||
// as a constant expression
|
||||
//
|
||||
// * So, we'll use bool, instead of enum *.
|
||||
//
|
||||
template <bool value>
|
||||
struct value_to_type
|
||||
{
|
||||
value_to_type() {}
|
||||
};
|
||||
const bool access_by_bytes = true;
|
||||
const bool access_by_blocks = false;
|
||||
|
||||
|
||||
// the table: wrapped in a class template, so
|
||||
// that it is only instantiated if/when needed
|
||||
//
|
||||
template <bool dummy_name = true>
|
||||
struct count_table { static const byte_type table[]; };
|
||||
|
||||
template <>
|
||||
struct count_table<false> { /* no table */ };
|
||||
|
||||
|
||||
const unsigned int table_width = 8;
|
||||
template <bool b>
|
||||
const byte_type count_table<b>::table[] =
|
||||
{
|
||||
// Automatically generated by GPTableGen.exe v.1.0
|
||||
//
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
||||
};
|
||||
|
||||
|
||||
// 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 = 0u;
|
||||
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))) \
|
||||
&& (defined(__POPCNT__) || defined(__AVX__))
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned __int64>(unsigned __int64 value) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_M_X64)
|
||||
return static_cast<std::size_t>(__popcnt64(value));
|
||||
#else
|
||||
return static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value))) + static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value >> 32)));
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
|
||||
|
||||
// Note: gcc builtins are implemented by compiler runtime when the target CPU may not support the necessary instructions
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<unsigned int>(__builtin_popcount(static_cast<unsigned int>(value)));
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<unsigned int>(__builtin_popcount(value));
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<unsigned long>(unsigned long value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<unsigned int>(__builtin_popcountl(value));
|
||||
}
|
||||
|
||||
template <>
|
||||
BOOST_FORCEINLINE std::size_t popcount<boost::ulong_long_type>(boost::ulong_long_type value) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<unsigned int>(__builtin_popcountll(value));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// overload for access by blocks
|
||||
//
|
||||
template <typename Iterator, typename ValueType>
|
||||
inline std::size_t do_count(Iterator first, std::size_t length, ValueType,
|
||||
value_to_type<access_by_blocks>*)
|
||||
{
|
||||
std::size_t num1 = 0u, num2 = 0u;
|
||||
while (length >= 2u) {
|
||||
num1 += popcount<ValueType>(*first);
|
||||
++first;
|
||||
num2 += popcount<ValueType>(*first);
|
||||
++first;
|
||||
length -= 2u;
|
||||
}
|
||||
|
||||
if (length > 0u)
|
||||
num1 += popcount<ValueType>(*first);
|
||||
|
||||
return num1 + num2;
|
||||
}
|
||||
|
||||
// overload for access by bytes
|
||||
//
|
||||
template <typename Iterator>
|
||||
inline std::size_t do_count(Iterator first, std::size_t length,
|
||||
int /*dummy param*/,
|
||||
value_to_type<access_by_bytes>*)
|
||||
{
|
||||
if (length > 0u) {
|
||||
const byte_type* p = object_representation(&*first);
|
||||
length *= sizeof(*first);
|
||||
|
||||
return do_count(p, length, static_cast<byte_type>(0u),
|
||||
static_cast< value_to_type<access_by_blocks>* >(0));
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
|
||||
// Some library implementations simply return a dummy
|
||||
// value such as
|
||||
//
|
||||
// size_type(-1) / sizeof(T)
|
||||
//
|
||||
// from vector<>::max_size. This tries to get more
|
||||
// meaningful info.
|
||||
//
|
||||
template <typename T>
|
||||
inline typename T::size_type vector_max_size_workaround(const T & v)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
const allocator_type& alloc = v.get_allocator();
|
||||
|
||||
typename boost::allocator_size_type<allocator_type>::type alloc_max =
|
||||
boost::allocator_max_size(alloc);
|
||||
|
||||
const typename T::size_type container_max = v.max_size();
|
||||
|
||||
return alloc_max < container_max ? alloc_max : container_max;
|
||||
}
|
||||
|
||||
// for static_asserts
|
||||
template <typename T>
|
||||
struct allowed_block_type {
|
||||
enum { value = T(-1) > 0 }; // ensure T has no sign
|
||||
};
|
||||
|
||||
template <>
|
||||
struct allowed_block_type<bool> {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct is_numeric {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
# define BOOST_dynamic_bitset_is_numeric(x) \
|
||||
template<> \
|
||||
struct is_numeric< x > { \
|
||||
enum { value = true }; \
|
||||
} /**/
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric(bool);
|
||||
BOOST_dynamic_bitset_is_numeric(char);
|
||||
|
||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
BOOST_dynamic_bitset_is_numeric(wchar_t);
|
||||
#endif
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric(signed char);
|
||||
BOOST_dynamic_bitset_is_numeric(short int);
|
||||
BOOST_dynamic_bitset_is_numeric(int);
|
||||
BOOST_dynamic_bitset_is_numeric(long int);
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned char);
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned short);
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned int);
|
||||
BOOST_dynamic_bitset_is_numeric(unsigned long);
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
BOOST_dynamic_bitset_is_numeric(::boost::long_long_type);
|
||||
BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type);
|
||||
#endif
|
||||
|
||||
// intentionally omitted
|
||||
//BOOST_dynamic_bitset_is_numeric(float);
|
||||
//BOOST_dynamic_bitset_is_numeric(double);
|
||||
//BOOST_dynamic_bitset_is_numeric(long double);
|
||||
|
||||
#undef BOOST_dynamic_bitset_is_numeric
|
||||
|
||||
} // dynamic_bitset_impl
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -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
|
||||
@@ -21,6 +23,7 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <iterator> // used to implement append(Iter, Iter)
|
||||
#include <vector>
|
||||
#include <climits> // for CHAR_BIT
|
||||
|
||||
@@ -39,15 +42,15 @@
|
||||
#endif
|
||||
|
||||
#include "boost/dynamic_bitset_fwd.hpp"
|
||||
#include "boost/detail/dynamic_bitset.hpp"
|
||||
#include "boost/detail/iterator.hpp" // used to implement append(Iter, Iter)
|
||||
#include "boost/dynamic_bitset/detail/dynamic_bitset.hpp"
|
||||
#include "boost/dynamic_bitset/detail/lowest_bit.hpp"
|
||||
#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"
|
||||
#include "boost/core/addressof.hpp"
|
||||
#include "boost/core/no_exceptions_support.hpp"
|
||||
#include "boost/throw_exception.hpp"
|
||||
#include "boost/functional/hash/hash.hpp"
|
||||
|
||||
|
||||
namespace boost {
|
||||
@@ -125,8 +128,10 @@ public:
|
||||
typedef bool const_reference;
|
||||
|
||||
// constructors, etc.
|
||||
dynamic_bitset() : m_num_bits(0) {}
|
||||
|
||||
explicit
|
||||
dynamic_bitset(const Allocator& alloc = Allocator());
|
||||
dynamic_bitset(const Allocator& alloc);
|
||||
|
||||
explicit
|
||||
dynamic_bitset(size_type num_bits, unsigned long value = 0,
|
||||
@@ -242,7 +247,7 @@ public:
|
||||
{
|
||||
assert(first != last);
|
||||
block_width_type r = count_extra_bits();
|
||||
std::size_t d = boost::detail::distance(first, last);
|
||||
std::size_t d = std::distance(first, last);
|
||||
m_bits.reserve(num_blocks() + d);
|
||||
if (r == 0) {
|
||||
for( ; first != last; ++first)
|
||||
@@ -262,7 +267,7 @@ public:
|
||||
void append(BlockInputIterator first, BlockInputIterator last) // strong guarantee
|
||||
{
|
||||
if (first != last) {
|
||||
typename detail::iterator_traits<BlockInputIterator>::iterator_category cat;
|
||||
typename std::iterator_traits<BlockInputIterator>::iterator_category cat;
|
||||
m_append(first, last, cat);
|
||||
}
|
||||
}
|
||||
@@ -279,10 +284,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;
|
||||
@@ -349,7 +357,8 @@ public:
|
||||
template <typename B, typename A, typename stringT>
|
||||
friend void to_string_helper(const dynamic_bitset<B, A> & b, stringT & s, bool dump_all);
|
||||
|
||||
|
||||
template <typename B, typename A>
|
||||
friend std::size_t hash_value(const dynamic_bitset<B, A>& a);
|
||||
#endif
|
||||
|
||||
public:
|
||||
@@ -360,15 +369,64 @@ 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;
|
||||
|
||||
static bool m_not_empty(Block x){ return x != Block(0); };
|
||||
size_type m_do_find_from(size_type first_block) const;
|
||||
|
||||
block_width_type count_extra_bits() const BOOST_NOEXCEPT { return bit_index(size()); }
|
||||
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)
|
||||
? detail::dynamic_bitset_impl::max_limit<Block>::value
|
||||
: ((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 detail::dynamic_bitset_impl::max_limit<Block>::value;
|
||||
}
|
||||
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,
|
||||
@@ -707,7 +765,7 @@ resize(size_type num_bits, bool value) // strong guarantee
|
||||
const size_type old_num_blocks = num_blocks();
|
||||
const size_type required_blocks = calc_num_blocks(num_bits);
|
||||
|
||||
const block_type v = value? ~Block(0) : Block(0);
|
||||
const block_type v = value? detail::dynamic_bitset_impl::max_limit<Block>::value : Block(0);
|
||||
|
||||
if (required_blocks != old_num_blocks) {
|
||||
m_bits.resize(required_blocks, v); // s.g. (copy)
|
||||
@@ -959,6 +1017,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)
|
||||
@@ -977,11 +1046,18 @@ template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::set()
|
||||
{
|
||||
std::fill(m_bits.begin(), m_bits.end(), static_cast<Block>(~0));
|
||||
std::fill(m_bits.begin(), m_bits.end(), detail::dynamic_bitset_impl::max_limit<Block>::value);
|
||||
m_zero_unused_bits();
|
||||
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 +1082,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)
|
||||
@@ -1056,7 +1139,7 @@ bool dynamic_bitset<Block, Allocator>::all() const
|
||||
}
|
||||
|
||||
const block_width_type extra_bits = count_extra_bits();
|
||||
block_type const all_ones = static_cast<Block>(~0);
|
||||
block_type const all_ones = detail::dynamic_bitset_impl::max_limit<Block>::value;
|
||||
|
||||
if (extra_bits == 0) {
|
||||
for (size_type i = 0, e = num_blocks(); i < e; ++i) {
|
||||
@@ -1125,7 +1208,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,25 +1439,22 @@ 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
|
||||
//
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
typename dynamic_bitset<Block, Allocator>::size_type
|
||||
dynamic_bitset<Block, Allocator>::m_do_find_from(size_type first_block) const
|
||||
{
|
||||
size_type i = first_block;
|
||||
|
||||
// skip null blocks
|
||||
while (i < num_blocks() && m_bits[i] == 0)
|
||||
++i;
|
||||
size_type i = std::distance(m_bits.begin(),
|
||||
std::find_if(m_bits.begin() + first_block, m_bits.end(), m_not_empty) );
|
||||
|
||||
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 +1484,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);
|
||||
|
||||
@@ -1536,6 +1626,17 @@ inline bool operator>=(const dynamic_bitset<Block, Allocator>& a,
|
||||
return !(a < b);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// hash operations
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
inline std::size_t hash_value(const dynamic_bitset<Block, Allocator>& a)
|
||||
{
|
||||
std::size_t res = hash_value(a.m_num_bits);
|
||||
boost::hash_combine(res, a.m_bits);
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stream operations
|
||||
|
||||
@@ -1925,6 +2026,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.
|
||||
@@ -1949,7 +2107,7 @@ bool dynamic_bitset<Block, Allocator>::m_check_invariants() const
|
||||
{
|
||||
const block_width_type extra_bits = count_extra_bits();
|
||||
if (extra_bits > 0) {
|
||||
const block_type mask = block_type(~0) << extra_bits;
|
||||
const block_type mask = detail::dynamic_bitset_impl::max_limit<Block>::value << extra_bits;
|
||||
if ((m_highest_block() & mask) != 0)
|
||||
return false;
|
||||
}
|
||||
@@ -1963,8 +2121,26 @@ bool dynamic_bitset<Block, Allocator>::m_check_invariants() const
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#undef BOOST_BITSET_CHAR
|
||||
|
||||
// std::hash support
|
||||
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) && !defined(BOOST_DYNAMIC_BITSET_NO_STD_HASH)
|
||||
#include <functional>
|
||||
namespace std
|
||||
{
|
||||
template<typename Block, typename Allocator>
|
||||
struct hash< boost::dynamic_bitset<Block, Allocator> >
|
||||
{
|
||||
typedef boost::dynamic_bitset<Block, Allocator> argument_type;
|
||||
typedef std::size_t result_type;
|
||||
result_type operator()(const argument_type& a) const BOOST_NOEXCEPT
|
||||
{
|
||||
boost::hash<argument_type> hasher;
|
||||
return hasher(a);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // include guard
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/core/nvp.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace boost {
|
||||
public:
|
||||
template <typename Ar>
|
||||
static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
|
||||
ar & serialization::make_nvp("m_num_bits", bs.m_num_bits)
|
||||
& serialization::make_nvp("m_bits", bs.m_bits);
|
||||
ar & boost::make_nvp("m_num_bits", bs.m_num_bits)
|
||||
& boost::make_nvp("m_bits", bs.m_bits);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -12,5 +12,6 @@
|
||||
],
|
||||
"maintainers": [
|
||||
"Jeremy Siek <jeremy.siek -at- gmail.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
||||
@@ -4,13 +4,39 @@
|
||||
# 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 ;
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
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 ]
|
||||
|
||||
[ run test_boost_hash.cpp ]
|
||||
[ 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
|
||||
: test_std_hash_disabled ]
|
||||
;
|
||||
|
||||
# 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 ]
|
||||
;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -14,11 +14,11 @@
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <cstdlib>
|
||||
@@ -517,10 +517,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
bitset_test<Bitset>::max_size(b);
|
||||
}
|
||||
#endif
|
||||
// Test copy-initialize with default constructor
|
||||
{
|
||||
boost::dynamic_bitset<Block> b[1] = {};
|
||||
(void)b;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
test_main(int, char*[])
|
||||
main()
|
||||
{
|
||||
run_test_cases<unsigned char>();
|
||||
run_test_cases<unsigned short>();
|
||||
@@ -530,5 +535,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -10,8 +11,8 @@
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
|
||||
template <typename Block>
|
||||
@@ -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,10 +339,37 @@ 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
|
||||
test_main(int, char*[])
|
||||
main()
|
||||
{
|
||||
run_test_cases<unsigned char>();
|
||||
run_test_cases<unsigned short>();
|
||||
@@ -290,5 +379,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
template <typename Block>
|
||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
@@ -800,7 +800,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
|
||||
|
||||
int
|
||||
test_main(int, char*[])
|
||||
main()
|
||||
{
|
||||
run_test_cases<unsigned char>();
|
||||
run_test_cases<unsigned short>();
|
||||
@@ -810,5 +810,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
#include <stdexcept> // for std::logic_error
|
||||
#include <assert.h>
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/config.hpp>
|
||||
#if !defined (BOOST_NO_STRINGSTREAM)
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
|
||||
// Codewarrior 8.3 for Win fails without this.
|
||||
@@ -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
|
||||
}
|
||||
@@ -190,7 +191,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
// (in Tests::stream_extractor instantiation)
|
||||
|
||||
|
||||
#if !(defined __BORLANDC__ \
|
||||
#if !(defined BOOST_BORLANDC \
|
||||
&& BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)))
|
||||
// Borland 5.5.1 with RW library crashes
|
||||
// empty string
|
||||
@@ -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);
|
||||
@@ -321,7 +324,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
|
||||
|
||||
int
|
||||
test_main(int, char*[])
|
||||
main()
|
||||
{
|
||||
run_test_cases<unsigned char>();
|
||||
run_test_cases<unsigned short>();
|
||||
@@ -331,5 +334,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#endif
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/dynamic_bitset/serialization.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include <boost/dynamic_bitset/serialization.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
|
||||
// Codewarrior 8.3 for Win fails without this.
|
||||
@@ -31,6 +31,7 @@
|
||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
@@ -97,7 +98,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
test_xml_archive<Block>();
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
int main()
|
||||
{
|
||||
run_test_cases<unsigned char>();
|
||||
run_test_cases<unsigned short>();
|
||||
@@ -107,5 +108,5 @@ int test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
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/core/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();
|
||||
}
|
||||
47
test/test_boost_hash.cpp
Normal file
47
test/test_boost_hash.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright (C) 2019 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/config.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <set>
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
typedef boost::dynamic_bitset<unsigned long> bitset_type;
|
||||
const std::string long_string =
|
||||
"01001110101110110101011010000000000011110101101111111111";
|
||||
const std::string long_string_prime_begin =
|
||||
"11001110101110110101011010000000000011110101101111111111";
|
||||
const std::string long_string_prime_end =
|
||||
"01001110101110110101011010000000000011110101101111111110";
|
||||
|
||||
bitset_type zeroes(long_string.size(), 0);
|
||||
bitset_type stuff (long_string);
|
||||
bitset_type stupb (long_string_prime_begin);
|
||||
bitset_type stupe (long_string_prime_end);
|
||||
bitset_type ones (long_string.size(), 1);
|
||||
|
||||
boost::hash<bitset_type> bitset_hasher;
|
||||
std::set<std::size_t> results;
|
||||
results.insert(bitset_hasher(zeroes));
|
||||
results.insert(bitset_hasher(stuff));
|
||||
results.insert(bitset_hasher(stupb));
|
||||
results.insert(bitset_hasher(stupe));
|
||||
results.insert(bitset_hasher(ones));
|
||||
|
||||
// if any hash is identical to another there will be less than 5
|
||||
BOOST_TEST_EQ(results.size(), 5);
|
||||
|
||||
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/core/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();
|
||||
}
|
||||
39
test/test_std_hash.cpp
Normal file
39
test/test_std_hash.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Copyright (C) 2019 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/config.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <unordered_set>
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
typedef boost::dynamic_bitset<unsigned long> bitset_type;
|
||||
const std::string long_string =
|
||||
"01001110101110110101011010000000000011110101101111111111";
|
||||
|
||||
bitset_type zeroes(long_string.size(), 0);
|
||||
bitset_type stuff (long_string);
|
||||
bitset_type ones (long_string.size(), 1);
|
||||
|
||||
std::unordered_set<bitset_type> bitsets;
|
||||
bitsets.insert(zeroes);
|
||||
bitsets.insert(stuff);
|
||||
bitsets.insert(ones);
|
||||
|
||||
BOOST_TEST_EQ(bitsets.size(), 3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user