mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-22 05:12:13 +00:00
Compare commits
202 Commits
boost-1.32
...
boost-1.83
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e20aa1462 | ||
|
|
d4be7a4fcb | ||
|
|
29e1d40e88 | ||
|
|
ccca25537a | ||
|
|
12be4b4464 | ||
|
|
b15fd0075f | ||
|
|
abd6417090 | ||
|
|
eb3f18086e | ||
|
|
c811f468cd | ||
|
|
709a03b9e2 | ||
|
|
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 | ||
|
|
4f54d83981 | ||
|
|
4cac68e762 | ||
|
|
d3eb4faf0c | ||
|
|
3f3662d39d | ||
|
|
184d1ba7ad | ||
|
|
5b39db5ba0 | ||
|
|
f4e49ff56f | ||
|
|
0c8640efb8 | ||
|
|
0ead484c37 | ||
|
|
6cafa21c6d | ||
|
|
dbfce8e174 | ||
|
|
684b6117dd | ||
|
|
572e9d78ff | ||
|
|
e49b08a289 | ||
|
|
d644c83b13 | ||
|
|
a50768c085 | ||
|
|
91895380c6 | ||
|
|
7259281f5b | ||
|
|
92af4f52e9 | ||
|
|
d86f4ebddb | ||
|
|
340822f979 | ||
|
|
1c5e30fe49 | ||
|
|
0f48010783 | ||
|
|
1d59cc4788 | ||
|
|
9879dd05b5 | ||
|
|
29ba0c22b1 | ||
|
|
8b7374b1db | ||
|
|
2091a4fd18 | ||
|
|
225064d355 | ||
|
|
b151c97fd2 | ||
|
|
a93174ddf9 | ||
|
|
1611aeb16a | ||
|
|
3229e26108 | ||
|
|
083c5e6214 | ||
|
|
18eb52ecee | ||
|
|
a3ea40d932 | ||
|
|
dd7cdc794e | ||
|
|
10195375ed | ||
|
|
9ed6f608a1 | ||
|
|
ba0ba59f24 | ||
|
|
bcc384b604 | ||
|
|
7b14895ec6 | ||
|
|
eb6004d98d | ||
|
|
f34a8a4b23 | ||
|
|
d19aeced56 | ||
|
|
5f4c0dc4d9 | ||
|
|
1b880102fe | ||
|
|
e8b37ccf10 | ||
|
|
e7aa32f5db | ||
|
|
86b177d3ee | ||
|
|
4c6825716f | ||
|
|
ac0baa94ee | ||
|
|
ae64496e98 | ||
|
|
0a1621f0e7 | ||
|
|
4d8b9b5c33 | ||
|
|
9fe813dd93 | ||
|
|
dd69fe8756 | ||
|
|
20df4eadc8 | ||
|
|
cccd1f74dc | ||
|
|
71a5cc6eeb | ||
|
|
c9fa6dbdd1 | ||
|
|
7186546f7d | ||
|
|
b82bfe4832 | ||
|
|
a257dead26 | ||
|
|
f44fbae9ba | ||
|
|
d6f1835fbb | ||
|
|
e6fc8e8ec9 | ||
|
|
734861bdac | ||
|
|
594140a081 | ||
|
|
59e99b9b45 | ||
|
|
f199a7f006 | ||
|
|
60f871da0c | ||
|
|
d77a2c4afa | ||
|
|
76d2f9d4d1 | ||
|
|
e3a2ca7276 | ||
|
|
38819630fd | ||
|
|
5c79c20827 | ||
|
|
6d0f9801f5 | ||
|
|
ed32df5ad2 | ||
|
|
da0b582703 | ||
|
|
622c8d8fd5 | ||
|
|
b7eedd0f46 | ||
|
|
16ca9cbb3c | ||
|
|
97d2bff3b6 | ||
|
|
a143af6e2f | ||
|
|
59825bc8db | ||
|
|
7d1144a461 | ||
|
|
c298ba0c5f | ||
|
|
4efeaee302 | ||
|
|
066e7dcf71 | ||
|
|
574f1dfe62 | ||
|
|
e953b16cee | ||
|
|
6b0d9627a8 | ||
|
|
180aa15c44 | ||
|
|
7ed46a6667 | ||
|
|
24d2081a73 | ||
|
|
f6ce97de67 | ||
|
|
7530a40476 | ||
|
|
c05a47b50d | ||
|
|
d09c7d2180 | ||
|
|
bddf77e5a4 | ||
|
|
d80a9dbdf8 | ||
|
|
15b61f694a | ||
|
|
eef25927d7 | ||
|
|
357e434387 | ||
|
|
a8998ae8a0 | ||
|
|
aa6053121c | ||
|
|
5d66eda2ac | ||
|
|
771e3d8779 | ||
|
|
d8b2330d42 | ||
|
|
61702fef06 | ||
|
|
1b7c462afe | ||
|
|
8a1da9667b | ||
|
|
6bf10f4ef0 | ||
|
|
717fb80e40 | ||
|
|
0999a9b907 | ||
|
|
4ae778ba4a | ||
|
|
c9dcc1de64 | ||
|
|
adc36a2b7f | ||
|
|
cc9b262cb9 | ||
|
|
a8c3c80888 | ||
|
|
3a04624801 | ||
|
|
ba7ccc50ae | ||
|
|
08357c3972 | ||
|
|
3e03a8d947 | ||
|
|
41e1f468d3 | ||
|
|
ae44c787e2 | ||
|
|
60375651d9 | ||
|
|
50ffc7be59 | ||
|
|
02f4b61f14 | ||
|
|
07b5b85dfe | ||
|
|
1170f90afb | ||
|
|
a0d66fd920 | ||
|
|
3e3d36c571 | ||
|
|
3be249a20e | ||
|
|
98917625dd | ||
|
|
5f1c39cb6c | ||
|
|
7c48bf04c2 | ||
|
|
109a0aef13 | ||
|
|
5995354ceb | ||
|
|
7f268666ad | ||
|
|
ecbc0c4262 | ||
|
|
184337e1cc | ||
|
|
2726ad0c3c | ||
|
|
30bd2e5bab | ||
|
|
38f7aa5d40 | ||
|
|
48aaaabed2 | ||
|
|
755fa101f8 | ||
|
|
9c0620b7f9 | ||
|
|
30b986e549 | ||
|
|
eb7f05d0c4 | ||
|
|
fff12b2c59 | ||
|
|
fb5e1d024d | ||
|
|
5e260f4364 | ||
|
|
896a792bec | ||
|
|
39f11e7cc0 | ||
|
|
b18fc5cd99 |
113
.appveyor.yml
Normal file
113
.appveyor.yml
Normal file
@@ -0,0 +1,113 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2017 - 2019 James E. King III
|
||||
# Copyright 2019 - 2021 Alexander Grund
|
||||
# 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:
|
||||
fast_finish: false
|
||||
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
|
||||
allow_failures:
|
||||
- MAYFAIL: true
|
||||
|
||||
environment:
|
||||
global:
|
||||
B2_CI_VERSION: 1
|
||||
GIT_FETCH_JOBS: 4
|
||||
# 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: 32,64
|
||||
B2_LINK: shared,static
|
||||
# B2_THREADING: threading=multi,single
|
||||
B2_VARIANT: release
|
||||
|
||||
matrix:
|
||||
- FLAVOR: Visual Studio 2017 C++2a Strict
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_CXXFLAGS: -permissive-
|
||||
B2_CXXSTD: 2a
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++14/17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_CXXSTD: 14,17
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: clang-cl
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 11,14,17
|
||||
B2_TOOLSET: clang-win
|
||||
|
||||
- FLAVOR: Visual Studio 2015, 2013
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_TOOLSET: msvc-12.0,msvc-14.0
|
||||
|
||||
- FLAVOR: Visual Studio 2008, 2010, 2012
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
B2_ADDRESS_MODEL: 32 # No 64bit support
|
||||
|
||||
- FLAVOR: cygwin (32-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
B2_ADDRESS_MODEL: 32
|
||||
B2_CXXSTD: 03,11,14,1z
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: cygwin (64-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 03,11,14,1z
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: mingw64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 03,11,14,17,2a
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
install:
|
||||
- git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned
|
||||
# Copy ci folder if not testing Boost.CI
|
||||
- if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci
|
||||
- rmdir /s /q C:\boost-ci-cloned
|
||||
- ci\appveyor\install.bat
|
||||
|
||||
build: off
|
||||
|
||||
test_script: ci\build.bat
|
||||
|
||||
31
.codecov.yml
Normal file
31
.codecov.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
# Copyright 2019 - 2021 Alexander Grund
|
||||
# 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)
|
||||
#
|
||||
# Sample codecov configuration file. Edit as required
|
||||
|
||||
codecov:
|
||||
max_report_age: off
|
||||
require_ci_to_pass: yes
|
||||
notify:
|
||||
# Increase this if you have multiple coverage collection jobs
|
||||
after_n_builds: 2
|
||||
wait_for_ci: yes
|
||||
|
||||
parsers:
|
||||
gcov:
|
||||
branch_detection:
|
||||
conditional: yes
|
||||
loop: yes
|
||||
method: no
|
||||
macro: no
|
||||
|
||||
# Change how pull request comments look
|
||||
comment:
|
||||
layout: "reach,diff,flags,files,footer"
|
||||
|
||||
# Ignore specific files or folders. Glob patterns are supported.
|
||||
# See https://docs.codecov.com/docs/ignoring-paths
|
||||
ignore:
|
||||
- libs/dynamic_bitset/test/
|
||||
- test/
|
||||
334
.github/workflows/ci.yml
vendored
Normal file
334
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
# Copyright 2021 Alexander Grund
|
||||
# Copyright 2022 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)
|
||||
---
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- bugfix/**
|
||||
- feature/**
|
||||
- fix/**
|
||||
- pr/**
|
||||
|
||||
concurrency:
|
||||
group: ${{format('{0}:{1}', github.repository, github.ref)}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GIT_FETCH_JOBS: 8
|
||||
NET_RETRY_COUNT: 5
|
||||
B2_CI_VERSION: 1
|
||||
B2_VARIANT: debug,release
|
||||
B2_LINK: shared,static
|
||||
LCOV_BRANCH_COVERAGE: 0
|
||||
CODECOV_NAME: Github Actions
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Linux, gcc
|
||||
- { compiler: gcc-4.8, cxxstd: '03,11', os: ubuntu-18.04 }
|
||||
- { compiler: gcc-5, cxxstd: '03,11,14,1z', os: ubuntu-18.04 }
|
||||
- { compiler: gcc-6, cxxstd: '03,11,14,17', os: ubuntu-18.04 }
|
||||
- { compiler: gcc-7, cxxstd: '03,11,14,17', os: ubuntu-18.04 }
|
||||
- { compiler: gcc-8, cxxstd: '03,11,14,17,2a', os: ubuntu-18.04 }
|
||||
- { compiler: gcc-9, cxxstd: '03,11,14,17,2a', os: ubuntu-18.04 }
|
||||
- { compiler: gcc-10, cxxstd: '03,11,14,17,20', os: ubuntu-20.04 }
|
||||
- { compiler: gcc-11, cxxstd: '03,11,14,17,20', os: ubuntu-20.04 }
|
||||
- { name: GCC w/ sanitizers, sanitize: yes,
|
||||
compiler: gcc-11, cxxstd: '03,11,14,17,20', os: ubuntu-20.04 }
|
||||
- { name: Collect coverage, coverage: yes,
|
||||
compiler: gcc-10, cxxstd: '03,11', os: ubuntu-20.04, install: 'g++-10-multilib', address-model: '32,64' }
|
||||
|
||||
# Linux, clang
|
||||
- { compiler: clang-3.5, cxxstd: '03,11', os: ubuntu-20.04, container: 'ubuntu:16.04' }
|
||||
- { compiler: clang-3.6, cxxstd: '03,11,14', os: ubuntu-20.04, container: 'ubuntu:16.04' }
|
||||
- { compiler: clang-3.7, cxxstd: '03,11,14', os: ubuntu-20.04, container: 'ubuntu:16.04' }
|
||||
- { compiler: clang-3.8, cxxstd: '03,11,14', os: ubuntu-20.04, container: 'ubuntu:16.04' }
|
||||
- { compiler: clang-3.9, cxxstd: '03,11,14', os: ubuntu-18.04 }
|
||||
- { compiler: clang-4.0, cxxstd: '03,11,14', os: ubuntu-18.04 }
|
||||
- { compiler: clang-5.0, cxxstd: '03,11,14,1z', os: ubuntu-18.04 }
|
||||
- { compiler: clang-6.0, cxxstd: '03,11,14,17', os: ubuntu-18.04 }
|
||||
- { compiler: clang-7, cxxstd: '03,11,14,17', os: ubuntu-18.04 }
|
||||
# Note: clang-8 does not fully support C++20, so it is not compatible with some libstdc++ versions in this mode
|
||||
- { compiler: clang-8, cxxstd: '03,11,14,17,2a', os: ubuntu-18.04, install: 'clang-8 g++-7', gcc_toolchain: 7 }
|
||||
- { compiler: clang-9, cxxstd: '03,11,14,17,2a', os: ubuntu-20.04 }
|
||||
- { compiler: clang-10, cxxstd: '03,11,14,17,20', os: ubuntu-20.04 }
|
||||
- { compiler: clang-11, cxxstd: '03,11,14,17,20', os: ubuntu-20.04 }
|
||||
- { name: Clang w/ valgrind, valgrind: yes,
|
||||
compiler: clang-12, cxxstd: '03,11,14,17,20', os: ubuntu-20.04, install: 'valgrind' }
|
||||
|
||||
# libc++
|
||||
- { compiler: clang-6.0, cxxstd: '03,11,14', os: ubuntu-18.04, stdlib: libc++, install: 'clang-6.0 libc++-dev libc++abi-dev' }
|
||||
- { compiler: clang-12, cxxstd: '03,11,14,17,20', os: ubuntu-20.04, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev' }
|
||||
- { name: Clang w/ sanitizers, sanitize: yes,
|
||||
compiler: clang-12, cxxstd: '03,11,14,17,20', os: ubuntu-20.04, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev' }
|
||||
|
||||
# OSX, clang
|
||||
- { compiler: clang, cxxstd: '03,11,14,17,2a', os: macos-10.15, sanitize: yes }
|
||||
|
||||
# Coverity Scan
|
||||
# requires two github secrets in repo to activate; see ci/github/coverity.sh
|
||||
# does not run on pull requests, only on pushes into develop and master
|
||||
- { name: Coverity, coverity: yes,
|
||||
compiler: clang-10, cxxstd: '17', os: ubuntu-20.04, ccache: no }
|
||||
|
||||
# multiarch (bigendian testing) - does not support coverage yet
|
||||
- { name: Big-endian, multiarch: yes,
|
||||
compiler: clang, cxxstd: '17', os: ubuntu-20.04, ccache: no, distro: fedora, edition: 34, arch: s390x }
|
||||
|
||||
|
||||
timeout-minutes: 120
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
env: {B2_USE_CCACHE: 1}
|
||||
|
||||
steps:
|
||||
- name: Setup environment
|
||||
run: |
|
||||
if [ -f "/etc/debian_version" ]; then
|
||||
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
fi
|
||||
if [ -n "${{matrix.container}}" ] && [ -f "/etc/debian_version" ]; then
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common
|
||||
# Need (newer) git
|
||||
for i in {1..${NET_RETRY_COUNT:-3}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y g++ python libpython-dev git
|
||||
fi
|
||||
# multiple job types are not compatible with ccache, they use "ccache: no" in the matrix
|
||||
if [[ "${{ matrix.ccache }}" == "no" ]]; then
|
||||
echo "B2_USE_CCACHE=0" >> $GITHUB_ENV
|
||||
fi
|
||||
if [[ "${{ matrix.valgrind }}" == "yes" ]]; then
|
||||
echo "B2_DEFINES=BOOST_NO_STRESS_TEST=1" >> $GITHUB_ENV
|
||||
echo "B2_TESTFLAGS=testing.launcher=valgrind" >> $GITHUB_ENV
|
||||
echo "B2_FLAGS=define=BOOST_USE_VALGRIND=1" >> $GITHUB_ENV
|
||||
echo "VALGRIND_OPTS=--error-exitcode=1" >> $GITHUB_ENV
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
# For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
|
||||
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
|
||||
|
||||
- name: Cache ccache
|
||||
uses: actions/cache@v3
|
||||
if: env.B2_USE_CCACHE
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}}
|
||||
restore-keys: |
|
||||
${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-
|
||||
${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}
|
||||
|
||||
- name: Fetch Boost.CI
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: boostorg/boost-ci
|
||||
ref: master
|
||||
path: boost-ci-cloned
|
||||
|
||||
- name: Get CI scripts folder
|
||||
run: |
|
||||
# Copy ci folder if not testing Boost.CI
|
||||
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
|
||||
rm -rf boost-ci-cloned
|
||||
|
||||
- name: Install packages
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
|
||||
SOURCES=(${{join(matrix.sources, ' ')}})
|
||||
# Add this by default
|
||||
SOURCES+=(ppa:ubuntu-toolchain-r/test)
|
||||
for key in "${SOURCE_KEYS[@]}"; do
|
||||
for i in {1..$NET_RETRY_COUNT}; do
|
||||
wget -O - "$key" | sudo apt-key add - && break || sleep 10
|
||||
done
|
||||
done
|
||||
for source in "${SOURCES[@]}"; do
|
||||
for i in {1..$NET_RETRY_COUNT}; do
|
||||
sudo add-apt-repository $source && break || sleep 10
|
||||
done
|
||||
done
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
if [[ -z "${{matrix.install}}" ]]; then
|
||||
pkgs="${{matrix.compiler}}"
|
||||
pkgs="${pkgs/gcc-/g++-}"
|
||||
else
|
||||
pkgs="${{matrix.install}}"
|
||||
fi
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
|
||||
|
||||
- name: Setup GCC Toolchain
|
||||
if: matrix.gcc_toolchain
|
||||
run: |
|
||||
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
|
||||
echo "GCC_TOOLCHAIN_ROOT=$GCC_TOOLCHAIN_ROOT" >> $GITHUB_ENV
|
||||
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT"
|
||||
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
|
||||
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
|
||||
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
|
||||
|
||||
- name: Setup multiarch
|
||||
if: matrix.multiarch
|
||||
run: |
|
||||
sudo apt-get install --no-install-recommends -y binfmt-support qemu-user-static
|
||||
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
git clone https://github.com/jeking3/bdde.git
|
||||
echo "$(pwd)/bdde/bin/linux" >> ${GITHUB_PATH}
|
||||
echo "BDDE_DISTRO=${{ matrix.distro }}" >> ${GITHUB_ENV}
|
||||
echo "BDDE_EDITION=${{ matrix.edition }}" >> ${GITHUB_ENV}
|
||||
echo "BDDE_ARCH=${{ matrix.arch }}" >> ${GITHUB_ENV}
|
||||
echo "B2_DEFINES=BOOST_NO_STRESS_TEST=1" >> ${GITHUB_ENV}
|
||||
echo "B2_WRAPPER=bdde" >> ${GITHUB_ENV}
|
||||
|
||||
- name: Setup Boost
|
||||
env:
|
||||
B2_ADDRESS_MODEL: ${{matrix.address-model}}
|
||||
B2_COMPILER: ${{matrix.compiler}}
|
||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
||||
B2_SANITIZE: ${{matrix.sanitize}}
|
||||
B2_STDLIB: ${{matrix.stdlib}}
|
||||
run: source ci/github/install.sh
|
||||
|
||||
- name: Setup coverage collection
|
||||
if: matrix.coverage
|
||||
run: ci/github/codecov.sh "setup"
|
||||
|
||||
- name: Run tests
|
||||
if: '!matrix.coverity'
|
||||
run: ci/build.sh
|
||||
|
||||
- name: Upload coverage
|
||||
if: matrix.coverage
|
||||
run: ci/codecov.sh "upload"
|
||||
|
||||
- name: Run coverity
|
||||
if: matrix.coverity && github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'master')
|
||||
run: ci/github/coverity.sh
|
||||
env:
|
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
|
||||
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
|
||||
windows:
|
||||
defaults:
|
||||
run:
|
||||
shell: cmd
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { toolset: msvc-14.2, cxxstd: '14,17,20', addrmd: '32,64', os: windows-2019 }
|
||||
- { name: Collect coverage, coverage: yes,
|
||||
toolset: msvc-14.3, cxxstd: '14,17,20', addrmd: '32,64', os: windows-2022 }
|
||||
- { toolset: gcc, cxxstd: '03,11,14,17,2a', addrmd: '64', os: windows-2019 }
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Fetch Boost.CI
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: boostorg/boost-ci
|
||||
ref: master
|
||||
path: boost-ci-cloned
|
||||
- name: Get CI scripts folder
|
||||
run: |
|
||||
REM Copy ci folder if not testing Boost.CI
|
||||
if "%GITHUB_REPOSITORY%" == "%GITHUB_REPOSITORY:boost-ci=%" xcopy /s /e /q /i /y boost-ci-cloned\ci .\ci
|
||||
rmdir /s /q boost-ci-cloned
|
||||
|
||||
- name: Setup Boost
|
||||
run: ci\github\install.bat
|
||||
|
||||
- name: Run tests
|
||||
if: '!matrix.coverage'
|
||||
run: ci\build.bat
|
||||
env:
|
||||
B2_TOOLSET: ${{matrix.toolset}}
|
||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
||||
B2_ADDRESS_MODEL: ${{matrix.addrmd}}
|
||||
|
||||
- name: Collect coverage
|
||||
shell: powershell
|
||||
if: matrix.coverage
|
||||
run: ci\opencppcoverage.ps1
|
||||
env:
|
||||
B2_TOOLSET: ${{matrix.toolset}}
|
||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
||||
B2_ADDRESS_MODEL: ${{matrix.addrmd}}
|
||||
|
||||
- name: Upload coverage
|
||||
if: matrix.coverage
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
files: __out/cobertura.xml
|
||||
|
||||
CMake:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-20.04, build_shared: ON, build_type: Release, generator: 'Unix Makefiles' }
|
||||
- { os: ubuntu-20.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' }
|
||||
- { os: windows-2019, build_shared: ON, build_type: Release, generator: 'Visual Studio 16 2019' }
|
||||
- { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' }
|
||||
|
||||
timeout-minutes: 120
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Fetch Boost.CI
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: boostorg/boost-ci
|
||||
ref: master
|
||||
path: boost-ci-cloned
|
||||
|
||||
- name: Get CI scripts folder
|
||||
run: |
|
||||
# Copy ci folder if not testing Boost.CI
|
||||
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
|
||||
rm -rf boost-ci-cloned
|
||||
|
||||
- name: Setup Boost
|
||||
env: {B2_DONT_BOOTSTRAP: 1}
|
||||
run: source ci/github/install.sh
|
||||
|
||||
- name: Run CMake
|
||||
run: |
|
||||
cd "$BOOST_ROOT"
|
||||
mkdir __build_cmake_test__ && cd __build_cmake_test__
|
||||
cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
|
||||
cmake --build . --config ${{matrix.build_type}}
|
||||
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()
|
||||
|
||||
30
Jamfile
30
Jamfile
@@ -1,21 +1,11 @@
|
||||
subproject libs/dynamic_bitset ;
|
||||
# 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)
|
||||
|
||||
unit-test dyn_bitset_unit_tests1
|
||||
: dyn_bitset_unit_tests1.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test dyn_bitset_unit_tests2
|
||||
: dyn_bitset_unit_tests2.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test dyn_bitset_unit_tests3
|
||||
: dyn_bitset_unit_tests3.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test dyn_bitset_unit_tests4
|
||||
: dyn_bitset_unit_tests4.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
# please order by name to ease maintenance
|
||||
build-project example ;
|
||||
build-project test ;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
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 ]
|
||||
;
|
||||
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 | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
|
||||
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
|
||||
[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [](https://github.com/boostorg/dynamic_bitset/actions?query=branch:master) | [](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://github.com/boostorg/dynamic_bitset/actions?query=branch:develop) | [](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.
|
||||
|
||||
1
doc/readme
Normal file
1
doc/readme
Normal file
@@ -0,0 +1 @@
|
||||
The documentation for the dynamic_bitset library is the top-level index.html file.
|
||||
1363
dynamic_bitset.html
1363
dynamic_bitset.html
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,26 @@
|
||||
exe timing_tests
|
||||
: timing_tests.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
# -----------------------------------------------------------
|
||||
# Copyright (c) 2002 Gennaro Prota
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
# -----------------------------------------------------------
|
||||
|
||||
exe timing_tests
|
||||
: timing_tests.cpp
|
||||
../../timer/build//boost_timer
|
||||
;
|
||||
|
||||
exe example1
|
||||
: example1.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe example2
|
||||
: example2.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe example3
|
||||
: example3.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
|
||||
@@ -3,23 +3,33 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Sample output:
|
||||
// 1
|
||||
// 1
|
||||
// 0
|
||||
// 0
|
||||
// 1
|
||||
|
||||
|
||||
// An example of setting and reading some bits. Note that operator[]
|
||||
// goes from the least-significant bit at 0 to the most significant
|
||||
// bit at size()-1. The operator<< for dynamic_bitset prints the
|
||||
// bitset from most-significant to least-significant, since that is
|
||||
// the format most people are used to reading.
|
||||
//
|
||||
// The output is:
|
||||
//
|
||||
// 11001
|
||||
// 10011
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
int main() {
|
||||
boost::dynamic_bitset<> x(5); // all 0's by default
|
||||
x[0] = 1;
|
||||
x[1] = 1;
|
||||
x[4] = 1;
|
||||
for (boost::dynamic_bitset<>::size_type i = 0; i < x.size(); ++i)
|
||||
std::cout << x[i];
|
||||
std::cout << "\n";
|
||||
std::cout << x << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::dynamic_bitset<> x(5); // all 0's by default
|
||||
x[0] = 1;
|
||||
x[1] = 1;
|
||||
x[4] = 1;
|
||||
for (boost::dynamic_bitset<>::size_type i = 0; i < x.size(); ++i)
|
||||
std::cout << x[i];
|
||||
std::cout << "\n";
|
||||
std::cout << x << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,27 +3,30 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Sample output:
|
||||
// Sample output:
|
||||
//
|
||||
// bits(0) = 00
|
||||
// bits(1) = 01
|
||||
// bits(2) = 10
|
||||
// bits(3) = 11
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
const boost::dynamic_bitset<> b0(2, 0ul);
|
||||
const boost::dynamic_bitset<> b0(2, 0ul);
|
||||
std::cout << "bits(0) = " << b0 << std::endl;
|
||||
|
||||
const boost::dynamic_bitset<> b1(2, 1ul);
|
||||
const boost::dynamic_bitset<> b1(2, 1ul);
|
||||
std::cout << "bits(1) = " << b1 << std::endl;
|
||||
|
||||
const boost::dynamic_bitset<> b2(2, 2ul);
|
||||
const boost::dynamic_bitset<> b2(2, 2ul);
|
||||
std::cout << "bits(2) = " << b2 << std::endl;
|
||||
|
||||
const boost::dynamic_bitset<> b3(2, 3ul);
|
||||
const boost::dynamic_bitset<> b3(2, 3ul);
|
||||
std::cout << "bits(3) = " << b3 << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,35 +1,71 @@
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2008 Gennaro Prota
|
||||
// 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)
|
||||
//
|
||||
// Sample output:
|
||||
// mask = 101010101010
|
||||
// Enter a 12-bit bitset in binary: 100110101101
|
||||
// x = 100110101101
|
||||
// As ulong: 2477
|
||||
// And with mask: 100010101000
|
||||
// Or with mask: 101110101111
|
||||
// Sample run:
|
||||
//
|
||||
// mask = 101010101010
|
||||
// x.size() = 0
|
||||
// Enter a bitset in binary: x = 100100010
|
||||
//
|
||||
// Input number: 100100010
|
||||
// x.size() is now: 9
|
||||
// As unsigned long: 290
|
||||
// Mask (possibly resized): 010101010
|
||||
// And with mask: 000100010
|
||||
// Or with mask: 110101010
|
||||
// Shifted left by 1: 001000100
|
||||
// Shifted right by 1: 010010001
|
||||
|
||||
|
||||
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
int main(int, char*[]) {
|
||||
const boost::dynamic_bitset<> mask(12, 2730ul);
|
||||
std::cout << "mask = " << mask << std::endl;
|
||||
int main()
|
||||
{
|
||||
boost::dynamic_bitset<> mask(12, 2730ul);
|
||||
std::cout << "mask = " << mask << std::endl;
|
||||
|
||||
boost::dynamic_bitset<> x(12);
|
||||
std::cout << "x.size()=" << x.size() << std::endl;
|
||||
boost::dynamic_bitset<> x;
|
||||
std::cout << "x.size() = " << x.size() << std::endl;
|
||||
|
||||
std::cout << "Enter a 12-bit bitset in binary: " << std::flush;
|
||||
if (std::cin >> x) {
|
||||
std::cout << "input number: " << x << std::endl;
|
||||
std::cout << "As unsigned long: " << x.to_ulong() << std::endl;
|
||||
std::cout << "And with mask: " << (x & mask) << std::endl;
|
||||
std::cout << "Or with mask: " << (x | mask) << std::endl;
|
||||
std::cout << "Shifted left: " << (x << 1) << std::endl;
|
||||
std::cout << "Shifted right: " << (x >> 1) << std::endl;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
std::cout << "Enter a bitset in binary: x = " << std::flush;
|
||||
if (std::cin >> x) {
|
||||
const std::size_t sz = x.size();
|
||||
std::cout << std::endl;
|
||||
std::cout << "Input number: " << x << std::endl;
|
||||
std::cout << "x.size() is now: " << sz << std::endl;
|
||||
|
||||
bool fits_in_ulong = true;
|
||||
unsigned long ul = 0;
|
||||
try {
|
||||
ul = x.to_ulong();
|
||||
} catch(std::overflow_error &) {
|
||||
fits_in_ulong = false;
|
||||
}
|
||||
|
||||
std::cout << "As unsigned long: ";
|
||||
if(fits_in_ulong) {
|
||||
std::cout << ul;
|
||||
} else {
|
||||
std::cout << "(overflow exception)";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
mask.resize(sz);
|
||||
|
||||
std::cout << "Mask (possibly resized): " << mask << std::endl;
|
||||
|
||||
std::cout << "And with mask: " << (x & mask) << std::endl;
|
||||
std::cout << "Or with mask: " << (x | mask) << std::endl;
|
||||
std::cout << "Shifted left by 1: " << (x << 1) << std::endl;
|
||||
std::cout << "Shifted right by 1: " << (x >> 1) << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// boost::dynamic_bitset timing tests
|
||||
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
//
|
||||
// Copyright (c) 2003-2004 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,6 +8,8 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// boost::dynamic_bitset timing tests
|
||||
//
|
||||
// NOTE:
|
||||
// ~~~~~
|
||||
// This is a preliminary, incomplete version.
|
||||
@@ -22,10 +23,15 @@
|
||||
// table in detail/dynamic_bitset.hpp and report any interesting
|
||||
// discovery on the list as well.
|
||||
|
||||
// You might also want to try both counting methods (by_bytes vs.
|
||||
// by_blocks) to see if the one that is selected automatically is
|
||||
// actually the fastest on your system.
|
||||
|
||||
//
|
||||
//
|
||||
// -----------------------------------------------------------------------//
|
||||
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#if defined (__STL_CONFIG_H) && !defined (__STL_USE_NEW_IOSTREAMS)
|
||||
@@ -43,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"
|
||||
|
||||
|
||||
@@ -53,9 +59,9 @@ namespace {
|
||||
// see http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00884.html
|
||||
//
|
||||
class boost_version {
|
||||
const int m_major;
|
||||
const int m_minor;
|
||||
const int m_subminor;
|
||||
int m_major;
|
||||
int m_minor;
|
||||
int m_subminor;
|
||||
|
||||
public:
|
||||
boost_version(unsigned long v = BOOST_VERSION):
|
||||
@@ -88,12 +94,15 @@ void prologue()
|
||||
template <typename T>
|
||||
void timing_test(T* = 0) // dummy parameter to workaround VC6
|
||||
{
|
||||
|
||||
const unsigned long num = 100000;
|
||||
#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,
|
||||
// to prevent the optimizer eliminating the call to
|
||||
// to prevent the optimizer from removing the call to
|
||||
// count() in the loop below.
|
||||
typename boost::dynamic_bitset<T>::size_type dummy = 0;
|
||||
|
||||
@@ -102,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";
|
||||
@@ -121,7 +127,6 @@ void timing_test(T* = 0) // dummy parameter to workaround VC6
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
prologue();
|
||||
|
||||
timing_test<unsigned char>();
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
// --------------------------------------------------
|
||||
//
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001 - 2002.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// See http://www.boost.org/libs/dynamic_bitset for documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
|
||||
#include <cstddef> // for std::size_t
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
//#include "boost/static_assert.hpp" // gps
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
||||
// ------- count function implementation --------------
|
||||
|
||||
namespace dynamic_bitset_count_impl {
|
||||
|
||||
typedef unsigned char byte_type;
|
||||
|
||||
enum mode { access_by_bytes, access_by_blocks };
|
||||
|
||||
template <mode> struct mode_to_type {};
|
||||
|
||||
// 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*/,
|
||||
mode_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,
|
||||
mode_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;
|
||||
}
|
||||
|
||||
|
||||
} // dynamic_bitset_count_impl
|
||||
// -------------------------------------------------------
|
||||
|
||||
|
||||
// Some library implementations simply return a dummy
|
||||
// value such as
|
||||
//
|
||||
// size_type(-1) / sizeof(T)
|
||||
//
|
||||
// from vector<>::max_size. This tries to get out more
|
||||
// meaningful info.
|
||||
//
|
||||
template <typename T>
|
||||
typename T::size_type vector_max_size_workaround(const T & v) {
|
||||
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
const typename allocator_type::size_type alloc_max =
|
||||
v.get_allocator().max_size();
|
||||
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 dynamic_bitset_allowed_block_type {
|
||||
enum { value = T(-1) > 0 }; // ensure T has no sign
|
||||
};
|
||||
|
||||
template <>
|
||||
struct dynamic_bitset_allowed_block_type<bool> {
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// --------------------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001 - 2002.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,8 +9,6 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// See http://www.boost.org/libs/dynamic_bitset for documentation.
|
||||
|
||||
#ifndef BOOST_DYNAMIC_BITSET_HPP
|
||||
#define BOOST_DYNAMIC_BITSET_HPP
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// --------------------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001 - 2002.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,9 +9,6 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// See http://www.boost.org/libs/dynamic_bitset for documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
|
||||
#define BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
|
||||
|
||||
@@ -23,19 +20,13 @@
|
||||
# define BOOST_OLD_IOSTREAMS
|
||||
#endif
|
||||
|
||||
// this should be in the config system some day
|
||||
// see http://lists.boost.org/MailArchives/boost/msg62291.php
|
||||
#define BOOST_DYNAMIC_BITSET_GNUC_VERSION ( __GNUC__ * 100 * 100 \
|
||||
+ __GNUC_MINOR__ * 100)
|
||||
|
||||
// workaround for gcc bug c++/8419 - gps
|
||||
|
||||
// no-op function to workaround gcc bug c++/8419
|
||||
//
|
||||
namespace boost { namespace detail {
|
||||
template <typename T> T make_non_const(T t) { return t; }
|
||||
}}
|
||||
|
||||
#if defined(__GNUC__) && BOOST_WORKAROUND(BOOST_DYNAMIC_BITSET_GNUC_VERSION, \
|
||||
BOOST_TESTED_AT(30300))
|
||||
#if defined(__GNUC__)
|
||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(expr) \
|
||||
(boost::detail::make_non_const(expr))
|
||||
#else
|
||||
@@ -43,12 +34,12 @@ 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
|
||||
|
||||
// if we can't use friends then private members are exposed
|
||||
// if we can't use friends then we simply expose private members
|
||||
//
|
||||
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
|
||||
#define BOOST_DYNAMIC_BITSET_PRIVATE public
|
||||
|
||||
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
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
// -------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
// lowest_bit.hpp
|
||||
//
|
||||
// Position of the lowest bit 'on'
|
||||
//
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
//
|
||||
// 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_LOWEST_BIT_HPP_GP_20030301
|
||||
#define BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||
|
||||
#include <cassert>
|
||||
#include "boost/pending/integer_log2.hpp"
|
||||
|
||||
#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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
46
include/boost/dynamic_bitset/serialization.hpp
Normal file
46
include/boost/dynamic_bitset/serialization.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2015 Seth Heeren
|
||||
//
|
||||
// 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_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||
#define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include <boost/core/nvp.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// implementation for optional zero-copy serialization support
|
||||
template <typename Block, typename Allocator>
|
||||
class dynamic_bitset<Block, Allocator>::serialize_impl
|
||||
{
|
||||
public:
|
||||
template <typename Ar>
|
||||
static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
|
||||
ar & boost::make_nvp("m_num_bits", bs.m_num_bits)
|
||||
& boost::make_nvp("m_bits", bs.m_bits);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// ADL hook to Boost Serialization library
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template <typename Ar, typename Block, typename Allocator>
|
||||
void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned version) {
|
||||
dynamic_bitset<Block, Allocator>::serialize_impl::serialize(ar, bs, version);
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// --------------------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001 - 2002.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||
// Copyright (c) 2003-2004 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,9 +9,6 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// See http://www.boost.org/libs/dynamic_bitset for documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_DYNAMIC_BITSET_FWD_HPP
|
||||
#define BOOST_DYNAMIC_BITSET_FWD_HPP
|
||||
|
||||
@@ -23,6 +20,6 @@ template <typename Block = unsigned long,
|
||||
typename Allocator = std::allocator<Block> >
|
||||
class dynamic_bitset;
|
||||
|
||||
} // namespace boost
|
||||
}
|
||||
|
||||
#endif // include guard
|
||||
|
||||
10
index.html
10
index.html
@@ -1,9 +1,15 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=dynamic_bitset.html">
|
||||
<meta http-equiv=refresh content="0; URL=dynamic_bitset.html">
|
||||
<title>Automatic redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="dynamic_bitset.html">dynamic_bitset.html</a>.
|
||||
<a href="dynamic_bitset.html">dynamic_bitset.html</a>. <hr>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
||||
17
meta/libraries.json
Normal file
17
meta/libraries.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"key": "dynamic_bitset",
|
||||
"name": "Dynamic Bitset",
|
||||
"authors": [
|
||||
"Jeremy Siek",
|
||||
"Chuck Allison"
|
||||
],
|
||||
"description": "The dynamic_bitset class represents a set of bits. It provides accesses to the value of individual bits via an operator[] and provides all of the bitwise operators that one can apply to builtin integers, such as operator& and operator<<. The number of bits in the set is specified at runtime via a parameter to the constructor of the dynamic_bitset.",
|
||||
"documentation": "dynamic_bitset.html",
|
||||
"category": [
|
||||
"Containers"
|
||||
],
|
||||
"maintainers": [
|
||||
"Jeremy Siek <jeremy.siek -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
42
test/Jamfile.v2
Normal file
42
test/Jamfile.v2
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright Vladimir Prus 2004
|
||||
#
|
||||
# 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 : : : <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
@@ -1,6 +1,11 @@
|
||||
// --------------------------------------------------------
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
//
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -8,17 +13,47 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/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/config/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <cstdlib>
|
||||
|
||||
template<class T>
|
||||
class minimal_allocator {
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
minimal_allocator() {}
|
||||
|
||||
template <typename U>
|
||||
minimal_allocator(const minimal_allocator<U>&) {}
|
||||
|
||||
T* allocate(std::size_t n) {
|
||||
void* p = std::malloc(sizeof(T) * n);
|
||||
if (!p) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
return static_cast<T*>(p);
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t) {
|
||||
std::free(p);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#define BOOST_BITSET_TEST_COUNT(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
|
||||
#include "boost/detail/workaround.hpp"
|
||||
// Codewarrior 8.3 for Win fails without this.
|
||||
// Thanks Howard Hinnant ;)
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
#pragma parse_func_templ off
|
||||
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
# pragma parse_func_templ off
|
||||
#endif
|
||||
|
||||
|
||||
@@ -51,50 +86,112 @@ void run_string_tests(const String& s
|
||||
|
||||
}
|
||||
|
||||
// tests the do-the-right-thing constructor dispatch
|
||||
template <typename Tests, typename T>
|
||||
void run_numeric_ctor_tests( BOOST_EXPLICIT_TEMPLATE_TYPE(Tests)
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) )
|
||||
{
|
||||
|
||||
const int bits_per_block = Tests::bits_per_block;
|
||||
const int width = std::numeric_limits<T>::digits;
|
||||
const T ma = (std::numeric_limits<T>::max)();
|
||||
const T mi = (std::numeric_limits<T>::min)();
|
||||
|
||||
int sizes[] = {
|
||||
0, 7*width/10, width, 13*width/10, 3*width,
|
||||
7*bits_per_block/10, bits_per_block, 13*bits_per_block/10, 3*bits_per_block
|
||||
};
|
||||
|
||||
const T numbers[] = {
|
||||
T(-1), T(-3), T(-8), T(-15), T(mi/2), T(mi),
|
||||
T(0), T(1), T(3), T(8), T(15), T(ma/2), T(ma)
|
||||
};
|
||||
|
||||
for (std::size_t s = 0; s < BOOST_BITSET_TEST_COUNT(sizes); ++s) {
|
||||
for (std::size_t n = 0; n < BOOST_BITSET_TEST_COUNT(numbers); ++n ) {
|
||||
|
||||
// can match ctor from ulong or templated one
|
||||
Tests::from_unsigned_long(sizes[s], numbers[n]);
|
||||
|
||||
typedef std::size_t compare_type;
|
||||
const compare_type sz = sizes[s];
|
||||
// this condition is to be sure that size is representable in T, so
|
||||
// that for signed T's we avoid implementation-defined behavior [if ma
|
||||
// is larger than what std::size_t can hold then this is ok for our
|
||||
// purposes: our sizes are anyhow < max(size_t)], which in turn could
|
||||
// make the first argument of from_unsigned_long() a small negative,
|
||||
// later converted to a very large unsigned. Example: signed 8-bit
|
||||
// char (CHAR_MAX=127), bits_per_block=64, sz = 192 > 127.
|
||||
const bool fits =
|
||||
sz <= static_cast<compare_type>(ma);
|
||||
|
||||
if (fits) {
|
||||
// can match templated ctor only (so we test dispatching)
|
||||
Tests::from_unsigned_long(static_cast<T>(sizes[s]), numbers[n]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename Block>
|
||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
{
|
||||
typedef boost::dynamic_bitset<Block> bitset_type;
|
||||
typedef bitset_test< bitset_type > Tests;
|
||||
typedef bitset_test<bitset_type> Tests;
|
||||
const int bits_per_block = bitset_type::bits_per_block;
|
||||
|
||||
const std::string long_string = get_long_string();
|
||||
const Block all_1s = static_cast<Block>(-1);
|
||||
|
||||
//=====================================================================
|
||||
// Test construction from unsigned long
|
||||
{
|
||||
const std::size_t ulong_width = std::numeric_limits<unsigned long>::digits;
|
||||
const unsigned long ulong_max =(std::numeric_limits<unsigned long>::max)();
|
||||
// NOTE:
|
||||
//
|
||||
// 1. keep this in sync with the numeric types supported
|
||||
// for constructor dispatch (of course)
|
||||
// 2. bool is tested separately; ugly and inelegant, but
|
||||
// we don't have much time to think of a better solution
|
||||
// which is likely to work on broken compilers
|
||||
//
|
||||
const int sizes[] = {
|
||||
0, 1, 3,
|
||||
7*bits_per_block/10, bits_per_block, 13*bits_per_block/10, 3*bits_per_block
|
||||
};
|
||||
|
||||
const bool values[] = { false, true };
|
||||
|
||||
unsigned long numbers[] = { 0, 1, 40247, ulong_max >> 1, ulong_max };
|
||||
const std::size_t array_count = sizeof(numbers) / sizeof(numbers[0]);
|
||||
|
||||
for (std::size_t i = 0; i < array_count; ++i) {
|
||||
unsigned long number = numbers[i];
|
||||
std::size_t n = 0;
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = std::size_t(0.7 * double(ulong_width));
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = 1 * ulong_width;
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = std::size_t(1.3 * double(ulong_width));
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = std::size_t(0.7 * double(bits_per_block));
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = 1 * bits_per_block;
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = std::size_t(1.3 * double(bits_per_block));
|
||||
Tests::from_unsigned_long(n, number);
|
||||
|
||||
n = 3 * bits_per_block;
|
||||
Tests::from_unsigned_long(n, number);
|
||||
for (std::size_t s = 0; s < BOOST_BITSET_TEST_COUNT(sizes); ++s) {
|
||||
for (std::size_t v = 0; v < BOOST_BITSET_TEST_COUNT(values); ++v) {
|
||||
Tests::from_unsigned_long(sizes[s], values[v]);
|
||||
Tests::from_unsigned_long(sizes[s] != 0, values[v]);
|
||||
}
|
||||
}
|
||||
|
||||
run_numeric_ctor_tests<Tests, char>();
|
||||
|
||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
run_numeric_ctor_tests<Tests, wchar_t>();
|
||||
#endif
|
||||
|
||||
run_numeric_ctor_tests<Tests, signed char>();
|
||||
run_numeric_ctor_tests<Tests, short int>();
|
||||
run_numeric_ctor_tests<Tests, int>();
|
||||
run_numeric_ctor_tests<Tests, long int>();
|
||||
|
||||
run_numeric_ctor_tests<Tests, unsigned char>();
|
||||
run_numeric_ctor_tests<Tests, unsigned short>();
|
||||
run_numeric_ctor_tests<Tests, unsigned int>();
|
||||
run_numeric_ctor_tests<Tests, unsigned long>();
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
run_numeric_ctor_tests<Tests, ::boost::long_long_type>();
|
||||
run_numeric_ctor_tests<Tests, ::boost::ulong_long_type>();
|
||||
#endif
|
||||
|
||||
}
|
||||
//=====================================================================
|
||||
// Test construction from a string
|
||||
@@ -110,7 +207,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
// one hand I should have better tests. On the other one
|
||||
// I don't want tests for dynamic_bitset to cope with locales,
|
||||
// ctype::widen, etc. (but that's what you deserve when you
|
||||
// don't separate concerns at the library level) - gps
|
||||
// don't separate concerns at the library level)
|
||||
//
|
||||
run_string_tests<Tests>(
|
||||
std::wstring(L"11111000000111111111010101010101010101010111111"));
|
||||
@@ -123,8 +220,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
|
||||
}
|
||||
//=====================================================================
|
||||
// Test construction from a block range
|
||||
// [gps - this comment is erroneous]
|
||||
// test from_block_range
|
||||
{
|
||||
std::vector<Block> blocks;
|
||||
Tests::from_block_range(blocks);
|
||||
@@ -133,7 +229,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
std::vector<Block> blocks(3);
|
||||
blocks[0] = static_cast<Block>(0);
|
||||
blocks[1] = static_cast<Block>(1);
|
||||
blocks[2] = ~Block(0);
|
||||
blocks[2] = all_1s;
|
||||
Tests::from_block_range(blocks);
|
||||
}
|
||||
{
|
||||
@@ -173,29 +269,70 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::copy_constructor(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test assignment operator
|
||||
// Test copy assignment operator
|
||||
{
|
||||
bitset_type a, b;
|
||||
Tests::assignment_operator(a, b);
|
||||
Tests::copy_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a(std::string("1")), b(std::string("0"));
|
||||
Tests::assignment_operator(a, b);
|
||||
Tests::copy_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a(long_string), b(long_string);
|
||||
Tests::assignment_operator(a, b);
|
||||
Tests::copy_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a;
|
||||
bitset_type b(long_string); // b greater than a, a empty
|
||||
Tests::assignment_operator(a, b);
|
||||
Tests::copy_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a(std::string("0"));
|
||||
bitset_type b(long_string); // b greater than a
|
||||
Tests::assignment_operator(a, b);
|
||||
Tests::copy_assignment_operator(a, b);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
//=====================================================================
|
||||
// Test move constructor
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::move_constructor(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::move_constructor(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::move_constructor(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test move assignment operator
|
||||
{
|
||||
bitset_type a, b;
|
||||
Tests::move_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a(std::string("1")), b(std::string("0"));
|
||||
Tests::move_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a(long_string), b(long_string);
|
||||
Tests::move_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a;
|
||||
bitset_type b(long_string); // b greater than a, a empty
|
||||
Tests::move_assignment_operator(a, b);
|
||||
}
|
||||
{
|
||||
bitset_type a(std::string("0"));
|
||||
bitset_type b(long_string); // b greater than a
|
||||
Tests::move_assignment_operator(a, b);
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
//=====================================================================
|
||||
// Test swap
|
||||
{
|
||||
@@ -248,6 +385,25 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::clear(a);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test pop back
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(std::string("01"));
|
||||
Tests::pop_back(a);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(std::string("10"));
|
||||
Tests::pop_back(a);
|
||||
}
|
||||
{
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 255ul);
|
||||
Tests::pop_back(a);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(long_string);
|
||||
Tests::pop_back(a);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test append bit
|
||||
{
|
||||
boost::dynamic_bitset<Block> a;
|
||||
@@ -305,7 +461,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
std::vector<Block> blocks(3);
|
||||
blocks[0] = static_cast<Block>(0);
|
||||
blocks[1] = static_cast<Block>(1);
|
||||
blocks[2] = ~Block(0);
|
||||
blocks[2] = all_1s;
|
||||
Tests::append_block_range(a, blocks);
|
||||
}
|
||||
{
|
||||
@@ -330,7 +486,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
std::vector<Block> blocks(3);
|
||||
blocks[0] = static_cast<Block>(0);
|
||||
blocks[1] = static_cast<Block>(1);
|
||||
blocks[2] = ~Block(0);
|
||||
blocks[2] = all_1s;
|
||||
Tests::append_block_range(a, blocks);
|
||||
}
|
||||
//=====================================================================
|
||||
@@ -353,10 +509,43 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
bit_vec[i] = long_string[n - 1 - i] == '0' ? 0 : 1;
|
||||
Tests::operator_bracket(b, bit_vec);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test at
|
||||
{
|
||||
boost::dynamic_bitset<Block> b1;
|
||||
std::vector<bool> bitvec1;
|
||||
Tests::at(b1, bitvec1);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
||||
std::vector<bool> bit_vec(1, true);
|
||||
Tests::at(b, bit_vec);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
std::size_t n = long_string.size();
|
||||
std::vector<bool> bit_vec(n);
|
||||
for (std::size_t i = 0; i < n; ++i)
|
||||
bit_vec[i] = long_string[n - 1 - i] == '0' ? 0 : 1;
|
||||
Tests::at(b, bit_vec);
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
typedef boost::dynamic_bitset<Block,
|
||||
minimal_allocator<Block> > Bitset;
|
||||
Bitset b;
|
||||
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>();
|
||||
@@ -366,5 +555,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// --------------------------------------------------------
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// -----------------------------------------------------------
|
||||
// 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
|
||||
@@ -8,10 +10,9 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
|
||||
template <typename Block>
|
||||
@@ -195,14 +196,51 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::set_one(b, 0, true);
|
||||
Tests::set_one(b, 0, false);
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::set_one(b, 0, true);
|
||||
Tests::set_one(b, 0, false);
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_one(b, long_string.size()/2, true);
|
||||
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()
|
||||
@@ -233,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;
|
||||
@@ -274,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>();
|
||||
@@ -287,5 +379,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// --------------------------------------------------------
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -8,17 +10,16 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/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) )
|
||||
{
|
||||
// a bunch of typedefs to have handy later on
|
||||
// a bunch of typedefs which will be handy later on
|
||||
typedef boost::dynamic_bitset<Block> bitset_type;
|
||||
typedef bitset_test<bitset_type> Tests;
|
||||
// typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
|
||||
@@ -30,7 +31,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
// Test b.empty()
|
||||
{
|
||||
bitset_type b;
|
||||
Tests::empty(b); // gps
|
||||
Tests::empty(b);
|
||||
}
|
||||
{
|
||||
bitset_type b(1, 1ul);
|
||||
@@ -52,9 +53,13 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::to_ulong(b);
|
||||
}
|
||||
{
|
||||
Block all_ones = ~Block(0);
|
||||
boost::dynamic_bitset<Block> b(bitset_type::bits_per_block,
|
||||
static_cast<unsigned long>(all_ones));
|
||||
static_cast<unsigned long>(-1));
|
||||
Tests::to_ulong(b);
|
||||
}
|
||||
{
|
||||
std::string str(ul_width - 1, '1');
|
||||
boost::dynamic_bitset<Block> b(str);
|
||||
Tests::to_ulong(b);
|
||||
}
|
||||
{
|
||||
@@ -90,6 +95,14 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::count(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
||||
Tests::count(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(8, 255ul);
|
||||
Tests::count(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::count(b);
|
||||
@@ -109,32 +122,103 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::size(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.capacity()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::capacity_test_one(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(100);
|
||||
Tests::capacity_test_two(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reserve()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::reserve_test_one(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(100);
|
||||
Tests::reserve_test_two(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.shrink_to_fit()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::shrink_to_fit_test_one(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(100);
|
||||
Tests::shrink_to_fit_test_two(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.all()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::all(b);
|
||||
Tests::all(~b);
|
||||
Tests::all(b.set());
|
||||
Tests::all(b.reset());
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::all(b);
|
||||
Tests::all(~b);
|
||||
Tests::all(b.set());
|
||||
Tests::all(b.reset());
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::all(b);
|
||||
Tests::all(~b);
|
||||
Tests::all(b.set());
|
||||
Tests::all(b.reset());
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.any()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::any(b);
|
||||
Tests::any(~b);
|
||||
Tests::any(b.set());
|
||||
Tests::any(b.reset());
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::any(b);
|
||||
Tests::any(~b);
|
||||
Tests::any(b.set());
|
||||
Tests::any(b.reset());
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::any(b);
|
||||
Tests::any(~b);
|
||||
Tests::any(b.set());
|
||||
Tests::any(b.reset());
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.none()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::none(b);
|
||||
Tests::none(~b);
|
||||
Tests::none(b.set());
|
||||
Tests::none(b.reset());
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::none(b);
|
||||
Tests::none(~b);
|
||||
Tests::none(b.set());
|
||||
Tests::none(b.reset());
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::none(b);
|
||||
Tests::none(~b);
|
||||
Tests::none(b.set());
|
||||
Tests::none(b.reset());
|
||||
}
|
||||
//=====================================================================
|
||||
// Test a.is_subset_of(b)
|
||||
@@ -388,6 +472,18 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
||||
Tests::operator_less_than(a, b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("11"));
|
||||
Tests::operator_less_than(a, b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(std::string("101")), b(std::string("11"));
|
||||
Tests::operator_less_than(a, b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("111"));
|
||||
Tests::operator_less_than(a, b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
||||
Tests::operator_less_than(a, b);
|
||||
@@ -402,7 +498,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
b[long_string.size()/2].flip();
|
||||
Tests::operator_less_than(a, b);
|
||||
}
|
||||
// check for consistency with ulong behaviour
|
||||
// check for consistency with ulong behaviour when the sizes are equal
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
|
||||
assert(a < b);
|
||||
@@ -415,6 +511,31 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
|
||||
assert(!(a < b));
|
||||
}
|
||||
// when the sizes are not equal lexicographic compare does not necessarily correspond to ulong behavior
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(4, 4ul), b(3, 5ul);
|
||||
assert(a < b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(3, 4ul), b(4, 5ul);
|
||||
assert(!(a < b));
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(4, 4ul), b(3, 4ul);
|
||||
assert(a < b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(3, 4ul), b(4, 4ul);
|
||||
assert(!(a < b));
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(4, 5ul), b(3, 4ul);
|
||||
assert(a < b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> a(3, 5ul), b(4, 4ul);
|
||||
assert(!(a < b));
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator<=
|
||||
{
|
||||
@@ -553,6 +674,23 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
Tests::test_bit(b, long_string.size()/2);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.test_set(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::test_set_bit(b, 0, true);
|
||||
Tests::test_set_bit(b, 0, false);
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::test_set_bit(b, 0, true);
|
||||
Tests::test_set_bit(b, 0, false);
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::test_set_bit(b, long_string.size() / 2, true);
|
||||
Tests::test_set_bit(b, long_string.size() / 2, false);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b << pos
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
@@ -660,8 +798,9 @@ 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>();
|
||||
@@ -671,5 +810,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// --------------------------------------------------------
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -10,24 +10,24 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <stdexcept> // for std::logic_error
|
||||
#include <cassert>
|
||||
#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.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.
|
||||
// Thanks Howard Hinnant ;)
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
#pragma parse_func_templ off
|
||||
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
# pragma parse_func_templ off
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,9 +42,15 @@ std::wstring widen_string( const std::string & str,
|
||||
std::wstring result;
|
||||
const std::string::size_type len = str.length();
|
||||
if(len != 0) {
|
||||
|
||||
typedef std::ctype<wchar_t> ct_type;
|
||||
typedef std::wstring::traits_type tr_type;
|
||||
const ct_type & ct = BOOST_USE_FACET(ct_type, loc);
|
||||
|
||||
result.resize(len);
|
||||
BOOST_USE_FACET(std::ctype<wchar_t>, loc)
|
||||
.widen(&str[0], 1 + &str[len-1], &result[0]);
|
||||
for (std::size_t i = 0; i < len; ++i)
|
||||
tr_type::assign(result[i], ct.widen(str[i]));
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -71,7 +77,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
std::ios::eofbit | std::ios::failbit
|
||||
};
|
||||
|
||||
std::string strings[] = {
|
||||
static std::string strings[] = {
|
||||
std::string(""),
|
||||
std::string("0"),
|
||||
std::string("1"),
|
||||
@@ -119,26 +125,27 @@ 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 - gps
|
||||
//NOTE: there are NO string stream tests
|
||||
}
|
||||
#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
|
||||
}
|
||||
@@ -163,28 +170,28 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
// a good "real life" test. Some characters, such as '\v' and '\f', are not
|
||||
// used exactly because they are the ones which will most likely give problems
|
||||
// on some systems (for instance '\f' could actually be written as a sequence
|
||||
// of new-lines, and we could never be able to read it back) [gps]
|
||||
// of new-lines, and we could never be able to read it back)
|
||||
//
|
||||
// Note how the bitset object is not initially empty. That helps checking
|
||||
// that it isn't erroneously clear()ed by operator>>.
|
||||
|
||||
|
||||
std::ios::iostate masks[] = {
|
||||
std::ios::goodbit,
|
||||
std::ios::eofbit,
|
||||
std::ios::failbit,
|
||||
std::ios::eofbit | std::ios::failbit
|
||||
};
|
||||
std::ios::goodbit,
|
||||
std::ios::eofbit,
|
||||
std::ios::failbit,
|
||||
std::ios::eofbit | std::ios::failbit
|
||||
};
|
||||
|
||||
const std::string spaces = "\t\n "; //"\t\n\v\f ";
|
||||
|
||||
const std::string long_string = get_long_string();
|
||||
/*const*/ std::string strings[] = {
|
||||
/*const*/ static std::string strings[] = {
|
||||
// NOTE: "const" gives the usual problems with Borland
|
||||
// (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
|
||||
@@ -251,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]);
|
||||
@@ -276,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);
|
||||
@@ -315,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>();
|
||||
@@ -325,5 +334,5 @@ test_main(int, char*[])
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
112
test/dyn_bitset_unit_tests5.cpp
Normal file
112
test/dyn_bitset_unit_tests5.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
//
|
||||
// Copyright (c) 2015 Seth Heeren
|
||||
//
|
||||
// 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"
|
||||
#if !defined (BOOST_NO_STRINGSTREAM)
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include <boost/dynamic_bitset/serialization.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
|
||||
// Codewarrior 8.3 for Win fails without this.
|
||||
// Thanks Howard Hinnant ;)
|
||||
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
# pragma parse_func_templ off
|
||||
#endif
|
||||
|
||||
|
||||
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
|
||||
# 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>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
template <typename Block>
|
||||
struct SerializableType {
|
||||
boost::dynamic_bitset<Block> x;
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive> void serialize(Archive &ar, const unsigned int) {
|
||||
ar & BOOST_SERIALIZATION_NVP(x);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Block, typename IArchive, typename OArchive>
|
||||
void test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
{
|
||||
SerializableType<Block> a;
|
||||
|
||||
for (int i=0; i<128; ++i)
|
||||
a.x.resize(11*i, i%2);
|
||||
|
||||
#if !defined (BOOST_NO_STRINGSTREAM)
|
||||
std::stringstream ss;
|
||||
|
||||
// test serialization
|
||||
{
|
||||
OArchive oa(ss);
|
||||
oa << BOOST_SERIALIZATION_NVP(a);
|
||||
}
|
||||
|
||||
// test de-serialization
|
||||
{
|
||||
IArchive ia(ss);
|
||||
SerializableType<Block> b;
|
||||
ia >> BOOST_SERIALIZATION_NVP(b);
|
||||
|
||||
assert(a.x == b.x);
|
||||
}
|
||||
#else
|
||||
# error "TODO implement file-based test path?"
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Block>
|
||||
void test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
|
||||
test_serialization<Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive>();
|
||||
}
|
||||
|
||||
template <typename Block>
|
||||
void test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
|
||||
test_serialization<Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive>();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Block>
|
||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
{
|
||||
test_binary_archive<Block>();
|
||||
test_xml_archive<Block>();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
run_test_cases<unsigned char>();
|
||||
run_test_cases<unsigned short>();
|
||||
run_test_cases<unsigned int>();
|
||||
run_test_cases<unsigned long>();
|
||||
# ifdef BOOST_HAS_LONG_LONG
|
||||
run_test_cases< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
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