mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-20 04:32:12 +00:00
Compare commits
108 Commits
boost-1.72
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66690c41d1 | ||
|
|
e475e3052f | ||
|
|
7f2d9b405f | ||
|
|
472fcfe7f8 | ||
|
|
224c1cf590 | ||
|
|
6c69d92398 | ||
|
|
91b957bbbb | ||
|
|
ad9b1a439e | ||
|
|
06d510fca2 | ||
|
|
f01dcbe60b | ||
|
|
757939f082 | ||
|
|
4fee7e5a77 | ||
|
|
31504199cd | ||
|
|
2357cd92b7 | ||
|
|
a5398355ac | ||
|
|
43ba4c9ca4 | ||
|
|
e9d0f7ff0e | ||
|
|
8da24d5377 | ||
|
|
71f8a37dc0 | ||
|
|
32dca8ac20 | ||
|
|
f684596b1d | ||
|
|
da2768d346 | ||
|
|
2928206d63 | ||
|
|
c6f94b52ca | ||
|
|
367790225b | ||
|
|
fea6e4eecb | ||
|
|
26c9b60e36 | ||
|
|
2675e65ce8 | ||
|
|
04b105c78f | ||
|
|
d0f0182b3c | ||
|
|
db21469d77 | ||
|
|
0ae6dd4e0e | ||
|
|
6477f68fb3 | ||
|
|
a35c951953 | ||
|
|
499916234e | ||
|
|
459df8c817 | ||
|
|
0a95b0295a | ||
|
|
f33ec5bda7 | ||
|
|
ad57ed3f34 | ||
|
|
3d4661e2a8 | ||
|
|
d4edc53c02 | ||
|
|
4f25dff8b2 | ||
|
|
bb4ac379f9 | ||
|
|
060efe9166 | ||
|
|
8d2b37a8f8 | ||
|
|
cc2e543137 | ||
|
|
7ee158b972 | ||
|
|
4339073d77 | ||
|
|
3bf84c9233 | ||
|
|
702192bf52 | ||
|
|
2f497d44d7 | ||
|
|
ff6fc1f065 | ||
|
|
96fad2cc08 | ||
|
|
c6ecae2129 | ||
|
|
a1fe5493c7 | ||
|
|
b6a3959648 | ||
|
|
3aad037ed1 | ||
|
|
a6096f898e | ||
|
|
c6e1912392 | ||
|
|
b1e431c8e4 | ||
|
|
ec4fce5d3e | ||
|
|
c560925513 | ||
|
|
79ebe76301 | ||
|
|
6c7c6618e6 | ||
|
|
2852d27363 | ||
|
|
179d719c92 | ||
|
|
688a99f54a | ||
|
|
b96250c3c6 | ||
|
|
d6eb91388f | ||
|
|
41d08970cd | ||
|
|
cd59d325d3 | ||
|
|
34f55c74b1 | ||
|
|
b33c19e05c | ||
|
|
b3c78809c0 | ||
|
|
3347ea317c | ||
|
|
8ad7522ca0 | ||
|
|
4eada1889f | ||
|
|
9f5a992ffa | ||
|
|
0b9a081d97 | ||
|
|
053fadace9 | ||
|
|
2cbf3ad7d8 | ||
|
|
3bb682db62 | ||
|
|
76b4bba9c2 | ||
|
|
11d94f6794 | ||
|
|
0231a500ed | ||
|
|
7939bf7ae6 | ||
|
|
1eed20166e | ||
|
|
1e9aa506d0 | ||
|
|
8e20aa1462 | ||
|
|
d4be7a4fcb | ||
|
|
29e1d40e88 | ||
|
|
ccca25537a | ||
|
|
12be4b4464 | ||
|
|
b15fd0075f | ||
|
|
abd6417090 | ||
|
|
eb3f18086e | ||
|
|
c811f468cd | ||
|
|
709a03b9e2 | ||
|
|
11d85403b9 | ||
|
|
296f902453 | ||
|
|
a16a1c3afa | ||
|
|
66a956b114 | ||
|
|
b59fc97a67 | ||
|
|
4a38853898 | ||
|
|
54b15ad171 | ||
|
|
ffff25ac00 | ||
|
|
3e0107909b | ||
|
|
8359a80feb |
97
.appveyor.yml
Normal file
97
.appveyor.yml
Normal file
@@ -0,0 +1,97 @@
|
||||
# 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\/.*/
|
||||
|
||||
skip_commits:
|
||||
files:
|
||||
- LICENSE
|
||||
- meta/*
|
||||
- README.md
|
||||
|
||||
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: cygwin (32-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
B2_ADDRESS_MODEL: 32
|
||||
B2_CXXSTD: 11,14,1z
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: cygwin (64-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 11,14,1z
|
||||
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
|
||||
|
||||
168
.clang-format
Normal file
168
.clang-format
Normal file
@@ -0,0 +1,168 @@
|
||||
# ============================================================================
|
||||
# Copyright 2025 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)
|
||||
# ============================================================================
|
||||
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignArrayOfStructures: Left
|
||||
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
|
||||
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
|
||||
AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
|
||||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: AlignAfterOperator
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: AllDefinitions
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AttributeMacros: [ ]
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: true
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: true
|
||||
BreakInheritanceList: BeforeComma
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 0
|
||||
CommentPragmas: ''
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: Always
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: false
|
||||
ForEachMacros: [ ]
|
||||
IfMacros: [ ]
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: 'top_level_namespace.hpp'
|
||||
Priority: 0
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 1
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: ''
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: false
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: Wrapped
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Middle
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: true
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceAroundPointerQualifiers: Both
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Always
|
||||
SpacesInConditionalStatement: true
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: true
|
||||
SpacesInSquareBrackets: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros: [ ]
|
||||
StatementMacros: [ ]
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros: [ ]
|
||||
|
||||
# Local Variables:
|
||||
# mode: yaml
|
||||
# End:
|
||||
# vim: set ft=yaml:
|
||||
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/
|
||||
111
.github/workflows/ci.yml
vendored
Normal file
111
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
#
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
# Copyright 2021-2024 Alexander Grund
|
||||
# Copyright 2022-2025 James E. King III
|
||||
# Copyright 2023 Alan de Freitas
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
# This workflow uses the Boost.CI reusable workflow which builds a variety of
|
||||
# configurations of your project, runs tests, and generates code coverage reports.
|
||||
#
|
||||
# To use it, copy this file into your repository as `.github/workflows/ci.yml` and
|
||||
# customize it appropriately.
|
||||
#
|
||||
---
|
||||
name: Boost.CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- bugfix/**
|
||||
- feature/**
|
||||
- fix/**
|
||||
- pr/**
|
||||
- experiments/**
|
||||
paths-ignore:
|
||||
- LICENSE
|
||||
- meta/**
|
||||
- README.md
|
||||
|
||||
jobs:
|
||||
call-boost-ci:
|
||||
name: Run Boost.CI
|
||||
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
|
||||
with:
|
||||
# These compilers fail.
|
||||
exclude_compiler: 'clang-3.5,clang-3.6,clang-3.7,clang-3.8,gcc-4.8,gcc-4.9'
|
||||
secrets:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
|
||||
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
|
||||
antora:
|
||||
name: Antora docs
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- { name: Windows, os: windows-latest }
|
||||
- { name: Ubuntu, os: ubuntu-latest }
|
||||
- { name: macOS, os: macos-latest }
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Install packages
|
||||
uses: alandefreitas/cpp-actions/package-install@v1.8.8
|
||||
with:
|
||||
apt-get: git cmake
|
||||
|
||||
- name: Clone Boost.DynamicBitset
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Clone Boost
|
||||
uses: alandefreitas/cpp-actions/boost-clone@v1.8.8
|
||||
id: boost-clone
|
||||
with:
|
||||
branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }}
|
||||
boost-dir: ../boost-source
|
||||
scan-modules-dir: .
|
||||
scan-modules-ignore: dynamic_bitset
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Setup Ninja
|
||||
if: runner.os == 'Windows'
|
||||
uses: seanmiddleditch/gha-setup-ninja@v5
|
||||
|
||||
- name: Build Antora docs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config --global --add safe.directory "$(pwd)"
|
||||
|
||||
cd ..
|
||||
BOOST_SRC_DIR="$(pwd)/boost-source"
|
||||
export BOOST_SRC_DIR
|
||||
|
||||
cd dynamic_bitset
|
||||
cd doc
|
||||
bash ./build_docs.sh
|
||||
|
||||
# Antora returns zero even if it fails, so we check if the site directory exists.
|
||||
if [ ! -d "build/site" ]
|
||||
then
|
||||
echo "Antora build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Create Antora docs artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: antora-docs-${{ matrix.name }}
|
||||
path: doc/build/site
|
||||
216
.travis.yml
216
.travis.yml
@@ -1,216 +0,0 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2017 - 2019 James E. King III
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#
|
||||
# Generic Travis CI build script for boostorg repositories
|
||||
# See: https://github.com/boostorg/boost-ci
|
||||
#
|
||||
# Instructions for customizing this script for your library:
|
||||
#
|
||||
# 1. Customize the compilers and language levels you want in the 'jobs'.
|
||||
# 2. If you have more than include/, src/, test/, example/, examples/, or
|
||||
# tools/ directories, modify your Travis CI project and add the environment
|
||||
# variable DEPINST. For example if your build uses code in "bench/" and
|
||||
# "fog/" directories, then set DEPINST to the following:
|
||||
# --include bench --include fog
|
||||
# 3. If you want to enable Coverity Scan, you need to provide the environment
|
||||
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
|
||||
# your github settings.
|
||||
# 4. Enable pull request builds in your boostorg/<library> account.
|
||||
#
|
||||
# That's it - the scripts will do everything else for you.
|
||||
|
||||
dist: xenial
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
global:
|
||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||
# - B2_ADDRESS_MODEL=address-model=64,32
|
||||
# - B2_LINK=link=shared,static
|
||||
# - B2_THREADING=threading=multi,single
|
||||
- B2_VARIANT=variant=release
|
||||
|
||||
install:
|
||||
- git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||
- source ci/travis/install.sh
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- binutils-gold
|
||||
- gdb
|
||||
- libc6-dbg
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /bugfix\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
- /pr\/.*/
|
||||
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/build.sh
|
||||
|
||||
#
|
||||
# Default toolsets in Ubuntu
|
||||
#
|
||||
# trusty xenial bionic
|
||||
# 14.04 16.04 18.04
|
||||
# ------ ------ ------
|
||||
# clang 3.4 3.8 6.0
|
||||
# gcc 4.8.2 5.3.1 7.3.0
|
||||
#
|
||||
|
||||
anchors:
|
||||
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
|
||||
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
|
||||
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
|
||||
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
|
||||
"libc6-dbg",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-7: &clang-7 { apt: { packages: [ "clang-7",
|
||||
"libc6-dbg",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
clang-8: &clang-8 { apt: { packages: [ "clang-8",
|
||||
"libc6-dbg",
|
||||
"libc++-dev",
|
||||
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
|
||||
"ubuntu-toolchain-r-test" ] } }
|
||||
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
|
||||
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
|
||||
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||
|
||||
jobs:
|
||||
allow_failures:
|
||||
- env:
|
||||
- COPY="all the environment settings from your job"
|
||||
|
||||
include:
|
||||
# libstdc++
|
||||
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=03,11" ], addons: *gcc-48 }
|
||||
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=03,11" ], addons: *gcc-49 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=03,11" ], addons: *gcc-5 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17,2a" ], addons: *gcc-8 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17,2a" ], addons: *gcc-9 }
|
||||
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=03,11" ], addons: *clang-38 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17,2a" ], addons: *clang-7 }
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17,2a" ], addons: *clang-8 }
|
||||
|
||||
# libc++
|
||||
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=03,11,14",
|
||||
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
|
||||
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=03,11,17" ] }
|
||||
|
||||
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following:
|
||||
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
|
||||
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=codecov.io
|
||||
- B2_CXXSTD=03,11
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-8
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/codecov.sh
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=asan
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_CXXFLAGS="address-sanitizer=norecover"
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=tsan
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_CXXFLAGS="thread-sanitizer=norecover"
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=ubsan
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TOOLSET=gcc-8
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_CXXFLAGS="undefined-sanitizer=norecover"
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
# https://github.com/boostorg/build/issues/451 using the gold linker to work around an issue
|
||||
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
|
||||
- UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons: *gcc-8
|
||||
|
||||
- os: linux
|
||||
env:
|
||||
- COMMENT=valgrind
|
||||
- B2_TOOLSET=clang-6.0
|
||||
- B2_CXXSTD=03,11,14
|
||||
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||
- B2_VARIANT=variant=debug
|
||||
- B2_TESTFLAGS=testing.launcher=valgrind
|
||||
- VALGRIND_OPTS=--error-exitcode=1
|
||||
addons: *clang-6
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/valgrind.sh
|
||||
|
||||
# - os: linux
|
||||
# env:
|
||||
# - COMMENT=cppcheck
|
||||
# script:
|
||||
# - cd $BOOST_ROOT/libs/$SELF
|
||||
# - ci/travis/cppcheck.sh
|
||||
|
||||
#################### Jobs to run on pushes to master, develop ###################
|
||||
|
||||
# Coverity Scan
|
||||
- os: linux
|
||||
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
|
||||
env:
|
||||
- COMMENT="Coverity Scan"
|
||||
- B2_TOOLSET=clang
|
||||
script:
|
||||
- cd $BOOST_ROOT/libs/$SELF
|
||||
- ci/travis/coverity.sh
|
||||
|
||||
notifications:
|
||||
email:
|
||||
false
|
||||
@@ -1,25 +1,55 @@
|
||||
# Copyright 2019 Sam Day
|
||||
# Generated by `boostdep --cmake dynamic_bitset`
|
||||
# Copyright 2020 Peter Dimov
|
||||
# Copyright 2025 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
|
||||
#
|
||||
# NOTE: CMake support for Boost.dynamic_bitset is currently experimental at best
|
||||
# and the interface is likely to change in the future
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(BoostDynamicBitset LANGUAGES CXX)
|
||||
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
|
||||
if (NOT DYNAMIC_BITSET_MRDOCS_BUILD)
|
||||
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
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
if (DYNAMIC_BITSET_MRDOCS_BUILD)
|
||||
set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
|
||||
|
||||
# Create a temporary source file that includes boost/dynamic_bitset.hpp.
|
||||
set(TEMP_CPP_FILE "${CMAKE_CURRENT_BINARY_DIR}/dynamic_bitset_for_mrdocs.cpp")
|
||||
file(WRITE ${TEMP_CPP_FILE} "// This file is generated automatically by CMake\n\n")
|
||||
file(APPEND ${TEMP_CPP_FILE} "#include \"boost/dynamic_bitset.hpp\"\n")
|
||||
|
||||
# Create a custom target for MrDocs.
|
||||
add_library(dynamic_bitset_mrdocs_target ${TEMP_CPP_FILE})
|
||||
|
||||
# Set any other target properties here.
|
||||
target_include_directories(dynamic_bitset_mrdocs_target PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_link_libraries(dynamic_bitset_mrdocs_target PRIVATE boost_dynamic_bitset)
|
||||
file(GLOB BOOST_MODULE_PATHS "$ENV{BOOST_SRC_DIR}/libs/*/include")
|
||||
target_include_directories(dynamic_bitset_mrdocs_target PRIVATE ${BOOST_MODULE_PATHS})
|
||||
|
||||
# Don't create any other targets.
|
||||
return()
|
||||
endif()
|
||||
|
||||
11
Jamfile
11
Jamfile
@@ -1,11 +0,0 @@
|
||||
# Boost.DynamicBitset Library Jamfile
|
||||
#
|
||||
# Copyright (c) 2018 James E. King III
|
||||
#
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# please order by name to ease maintenance
|
||||
build-project example ;
|
||||
build-project test ;
|
||||
35
README.md
35
README.md
@@ -1,34 +1,25 @@
|
||||
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.
|
||||
DynamicBitset, part of the [Boost C++ Libraries](https://github.com/boostorg), is a bit vector similar to std::bitset but dynamically resizable.
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
||||
Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
### Properties
|
||||
|
||||
* C++03
|
||||
* C++11
|
||||
* Header-only
|
||||
|
||||
### Build Status
|
||||
### Build status
|
||||
|
||||
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
|
||||
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
|
||||
[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [](https://travis-ci.org/boostorg/dynamic_bitset) | [](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/master) | [](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master)| [](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [](http://www.boost.org/doc/libs/master/doc/html/dynamic_bitset.html) | [](http://www.boost.org/development/tests/master/developer/dynamic_bitset.html)
|
||||
[`develop`](https://github.com/boostorg/dynamic_bitset/tree/develop) | [](https://travis-ci.org/boostorg/dynamic_bitset) | [](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/develop) | [](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop) | [](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [](http://www.boost.org/doc/libs/develop/doc/html/dynamic_bitset.html) | [](http://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)
|
||||
|
||||
### Directories
|
||||
|
||||
| Name | Purpose |
|
||||
| ----------- | ------------------------------ |
|
||||
| `example` | examples |
|
||||
| `doc` | documentation |
|
||||
| `include` | headers |
|
||||
| `test` | unit tests |
|
||||
<!-- boost-ci/tools/makebadges.sh --project dynamic_bitset --appveyor n7bki5ka3v918r5r --codecov PVG5jth1ez --coverity 16167 -->
|
||||
| Branch | GitHub Actions | AppVeyor | Coverity Scan | Codecov | 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/cppalliance/dynamic-bitset/branch/master) | [](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [](https://codecov.io/gh/boostorg/dynamic_bitset/tree/master) | [](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [](https://www.boost.org/doc/libs/master/libs/dynamic_bitset) | [](https://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/cppalliance/dynamic-bitset/branch/develop) | [](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [](https://codecov.io/gh/boostorg/dynamic_bitset/tree/develop) | [](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [](https://www.boost.org/doc/libs/develop/libs/dynamic_bitset) | [](https://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)
|
||||
|
||||
### 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.
|
||||
|
||||
* [Ask questions](https://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 the 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 the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||
* Discussions about the library are held on the [Boost developers mailing list](https://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](https://www.boost.org/community/policy.html) before posting, and add the `[dynamic_bitset]` tag at the beginning of the subject line.
|
||||
|
||||
147
appveyor.yml
147
appveyor.yml
@@ -1,147 +0,0 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright (C) 2017 - 2019 James E. King III
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#
|
||||
# Generic Appveyor build script for boostorg repositories
|
||||
# See: https://github.com/boostorg/boost-ci/
|
||||
#
|
||||
# Instructions for customizing this script for your library:
|
||||
#
|
||||
# 1. Customize the compilers and language levels you want.
|
||||
# 2. If you have more than include/, src/, test/, example/, examples/,
|
||||
# benchmark/ or tools/ directories, set the environment variable DEPINST.
|
||||
# For example if your build uses code in "bench/" and "fog/" directories:
|
||||
# - DEPINST: --include bench --include fog
|
||||
# 3. Enable pull request builds in your boostorg/<library> account.
|
||||
#
|
||||
# That's it - the script will do everything else for you.
|
||||
#
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /bugfix\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
- /pr\/.*/
|
||||
|
||||
matrix:
|
||||
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
|
||||
allow_failures:
|
||||
- MAYFAIL: true
|
||||
|
||||
environment:
|
||||
global:
|
||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||
# to use the default for a given environment, comment it out; recommend you build debug and release however:
|
||||
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
|
||||
# libraries that care about this exercise it in their Jamfiles...
|
||||
# B2_ADDRESS_MODEL: address-model=64,32
|
||||
# B2_LINK: link=shared,static
|
||||
# B2_THREADING: threading=multi,single
|
||||
B2_VARIANT: variant=release
|
||||
|
||||
matrix:
|
||||
- FLAVOR: Visual Studio 2019
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXFLAGS: cxxflags=-permissive-
|
||||
B2_CXXSTD: latest # 2a
|
||||
B2_TOOLSET: msvc-14.2
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++2a Strict
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXFLAGS: cxxflags=-permissive-
|
||||
B2_CXXSTD: latest # 2a
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 17
|
||||
B2_TOOLSET: msvc-14.1
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++14 (Default)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64,32
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: clang-cl
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 11
|
||||
B2_TOOLSET: clang-win
|
||||
|
||||
- FLAVOR: Visual Studio 2015 C++14 (Default)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_ADDRESS_MODEL: address-model=64,32
|
||||
B2_TOOLSET: msvc-14.0
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: Visual Studio 2010, 2012, 2013
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
|
||||
|
||||
- FLAVOR: cygwin (32-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
B2_ADDRESS_MODEL: address-model=32
|
||||
B2_CXXSTD: 03,11
|
||||
# https://github.com/boostorg/test/issues/144
|
||||
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
|
||||
B2_THREADING: threadapi=pthread
|
||||
B2_TOOLSET: gcc
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: cygwin (64-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 11,17
|
||||
# https://github.com/boostorg/test/issues/144
|
||||
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
|
||||
B2_THREADING: threadapi=pthread
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: mingw32
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ARCH: i686
|
||||
B2_ADDRESS_MODEL: address-model=32
|
||||
B2_CXXSTD: 03,11
|
||||
SCRIPT: ci\appveyor\mingw.bat
|
||||
B2_VARIANT: variant=debug
|
||||
|
||||
- FLAVOR: mingw64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ARCH: x86_64
|
||||
B2_ADDRESS_MODEL: address-model=64
|
||||
B2_CXXSTD: 11,17
|
||||
B2_DEFINES: define=__USE_ISOC99
|
||||
SCRIPT: ci\appveyor\mingw.bat
|
||||
|
||||
install:
|
||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||
- git clone https://github.com/boostorg/boost-ci.git C:\boost-ci
|
||||
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
|
||||
- ci\appveyor\install.bat
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
# The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
|
||||
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
|
||||
# Echo the complete build command to the build log
|
||||
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
||||
# Now go build...
|
||||
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
||||
30
build.jam
Normal file
30
build.jam
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/container_hash//boost_container_hash
|
||||
/boost/core//boost_core
|
||||
/boost/integer//boost_integer
|
||||
/boost/move//boost_move
|
||||
/boost/static_assert//boost_static_assert
|
||||
/boost/throw_exception//boost_throw_exception ;
|
||||
|
||||
project /boost/dynamic_bitset
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_dynamic_bitset : : : : <library>$(boost_dependencies) ]
|
||||
[ alias all : boost_dynamic_bitset example test ]
|
||||
;
|
||||
|
||||
call-if : boost-library dynamic_bitset
|
||||
;
|
||||
|
||||
21
doc/antora.yml
Normal file
21
doc/antora.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
# ============================================================================
|
||||
# Copyright 2025 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)
|
||||
# ============================================================================
|
||||
|
||||
name: dynamic_bitset
|
||||
version: ~
|
||||
title: Boost.DynamicBitset
|
||||
start_page: index.adoc
|
||||
asciidoc:
|
||||
attributes:
|
||||
source-language: asciidoc@
|
||||
table-caption: false
|
||||
nav:
|
||||
- modules/ROOT/nav.adoc
|
||||
ext:
|
||||
cpp-reference:
|
||||
config: doc/mrdocs.yml
|
||||
28
doc/build_docs.sh
Executable file
28
doc/build_docs.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#! /bin/sh --
|
||||
# ============================================================================
|
||||
# Copyright 2023 Alan de Freitas.
|
||||
# Copyright 2025 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)
|
||||
# ============================================================================
|
||||
|
||||
set -eu
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo "No playbook supplied, using default playbook."
|
||||
PLAYBOOK="local-playbook.yml"
|
||||
else
|
||||
PLAYBOOK=$1
|
||||
fi
|
||||
|
||||
echo "Installing npm dependencies..."
|
||||
npm ci
|
||||
|
||||
echo "Building docs in custom dir..."
|
||||
PATH="$(pwd)/node_modules/.bin:${PATH}"
|
||||
export PATH
|
||||
npx antora --clean --fetch "$PLAYBOOK" --stacktrace --log-level all
|
||||
echo "Done"
|
||||
56
doc/local-playbook.yml
Normal file
56
doc/local-playbook.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
# ============================================================================
|
||||
# Copyright 2023 Alan de Freitas.
|
||||
# Copyright 2025 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)
|
||||
# ============================================================================
|
||||
#
|
||||
# An antora playbook used for local development.
|
||||
# The playbook includes Boost.DynamicBitset as its only component.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
site:
|
||||
title: Boost.DynamicBitset
|
||||
url: https://antora.cppalliance.org/develop/lib/doc
|
||||
start_page: dynamic_bitset::index.adoc
|
||||
robots: allow
|
||||
keys:
|
||||
repo_url: 'https://github.com/boostorg/dynamic_bitset'
|
||||
|
||||
content:
|
||||
sources:
|
||||
- url: ..
|
||||
start_path: doc
|
||||
edit_url: 'https://github.com/boostorg/dynamic_bitset/edit/{refname}/{path}'
|
||||
|
||||
ui:
|
||||
bundle:
|
||||
url: https://github.com/boostorg/website-v2-docs/releases/download/ui-master/ui-bundle.zip
|
||||
snapshot: true
|
||||
|
||||
antora:
|
||||
extensions:
|
||||
- require: '@antora/lunr-extension' # https://gitlab.com/antora/antora-lunr-extension
|
||||
index_latest_only: true
|
||||
- require: '@cppalliance/antora-cpp-tagfiles-extension'
|
||||
cpp-tagfiles:
|
||||
using-namespaces:
|
||||
- 'boost::'
|
||||
- require: '@cppalliance/antora-cpp-reference-extension'
|
||||
version: 'develop'
|
||||
dependencies:
|
||||
- name: 'boost'
|
||||
repo: 'https://github.com/boostorg/boost.git'
|
||||
tag: 'develop'
|
||||
variable: 'BOOST_SRC_DIR'
|
||||
system-env: 'BOOST_SRC_DIR'
|
||||
|
||||
asciidoc:
|
||||
attributes:
|
||||
# Enable pagination
|
||||
page-pagination: ''
|
||||
extensions:
|
||||
- '@cppalliance/asciidoctor-boost-links'
|
||||
- '@asciidoctor/tabs'
|
||||
10
doc/modules/ROOT/nav.adoc
Normal file
10
doc/modules/ROOT/nav.adoc
Normal file
@@ -0,0 +1,10 @@
|
||||
// ===========================================================================
|
||||
// Copyright 2025 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)
|
||||
// ===========================================================================
|
||||
|
||||
* xref:index.adoc[]
|
||||
* xref:reference:boost/dynamic_bitset.adoc[Reference]
|
||||
79
doc/modules/ROOT/pages/index.adoc
Normal file
79
doc/modules/ROOT/pages/index.adoc
Normal file
@@ -0,0 +1,79 @@
|
||||
// ===========================================================================
|
||||
// Copyright 2025 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)
|
||||
// ===========================================================================
|
||||
|
||||
= Boost.DynamicBitset
|
||||
|
||||
Boost.DynamicBitset is a portable library that provides a set of bits.
|
||||
|
||||
The set
|
||||
(xref:reference:boost/dynamic_bitset.adoc#boost-dynamic_bitset[dynamic_bitset])
|
||||
provides access to the value of individual bits via
|
||||
xref:reference:boost/dynamic_bitset/operator_subs-08.adoc[operator[\]] and
|
||||
provides all of the bitwise operators that one can apply to builtin integers,
|
||||
such as xref:reference:boost/operator_bitand.adoc[operator&] and
|
||||
xref:reference:boost/dynamic_bitset/operator_lshift.adoc[operator<<]. The number
|
||||
of bits can change at runtime.
|
||||
|
||||
`dynamic_bitset` is nearly identical to `std::bitset`. The difference is that
|
||||
the size of a `dynamic_bitset` (the number of bits) can change at runtime,
|
||||
whereas the size of a `std::bitset` is specified at compile-time through an
|
||||
integer template parameter.
|
||||
|
||||
The main problem that `dynamic_bitset` is designed to solve is that of
|
||||
representing a subset of a finite set. Each bit represents whether an element of
|
||||
the finite set is in the subset or not. As such the bitwise operations of
|
||||
`dynamic_bitset`, such as `operator&` and `operator|`, correspond to set
|
||||
operations, such as intersection and union.
|
||||
|
||||
== Definitions
|
||||
Each bit represents either the Boolean value `true` or `false` (1 or 0). To set
|
||||
a bit is to assign it 1. To clear or reset a bit is to assign it 0. To flip a
|
||||
bit is to change the value to 1 if it was 0 and to 0 if it was 1. Each bit has a
|
||||
non-negative position. A bitset `x` contains `x.size()` bits, with each bit
|
||||
assigned a unique position in the range `[0, x.size())`. The bit at position 0
|
||||
is called the least significant bit and the bit at position `size() - 1` is the
|
||||
most significant bit. When converting an instance of `dynamic_bitset` to or from
|
||||
an unsigned long `n`, the bit at position `i` of the bitset has the same value
|
||||
as `(n >> i) & 1`.
|
||||
|
||||
== Rationale
|
||||
`dynamic_bitset` is not a <a
|
||||
href="https://en.cppreference.com/w/cpp/named_req/Container.html">Container</a>
|
||||
and does not provide iterators for the following reason:
|
||||
|
||||
A container with a proxy reference type can not fulfill the container
|
||||
requirements as specified in the C++ standard (unless one resorts to strange
|
||||
iterator semantics). `std::vector<bool>` has a proxy reference type and does not
|
||||
fulfill the container requirements and as a result has caused many problems. One
|
||||
common problem is when people try to use iterators from `std::vector<bool>` with
|
||||
a standard algorithm such as `std::search()`. The `std::search()` requirements
|
||||
say that the iterator must be a LegacyForwardIterator, but
|
||||
`std::vector<bool>::iterator` does not meet this requirement because of the
|
||||
proxy reference. Depending on the implementation, they may or not be a compile
|
||||
error or even a run-time error due to this misuse. For further discussion of the
|
||||
problem see "Effective STL" by Scott Meyers. So `dynamic_bitset` tries to avoid
|
||||
these problems by not pretending to be a container.
|
||||
|
||||
Some people prefer the name "toggle" to "flip". The name "flip" was chosen
|
||||
because that is the name used in `std::bitset`. In fact, most of the function
|
||||
names for `dynamic_bitset` were chosen for this reason.
|
||||
|
||||
`dynamic_bitset` does not throw exceptions when a precondition is violated (as
|
||||
is done in `std::bitset`). Instead `BOOST_ASSERT()` is used. See the guidelines
|
||||
for Error and Exception Handling for the explanation. Note that, consistently
|
||||
with this, the documentation of the member functions doesn't use the term
|
||||
"precondition" for conditions that cause an exception to be emitted (the C++
|
||||
standard uses the term "requires" in such cases).
|
||||
|
||||
== Acknowledgments
|
||||
|
||||
We would like to thank the Boost community for putting in the time to review and
|
||||
accept this library. This library is much better than it ever would have been
|
||||
due to all the suggestions from Boost members. We especially thank Matt Marcus
|
||||
for taking on the task of review manager. Also, a special thanks goes to James
|
||||
Kanze for his invaluable help with the internationalization issues.
|
||||
26
doc/mrdocs.yml
Normal file
26
doc/mrdocs.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
# ============================================================================
|
||||
# Copyright 2025 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)
|
||||
# ============================================================================
|
||||
|
||||
verbose: true
|
||||
source-root: ..
|
||||
cmake: '-DDYNAMIC_BITSET_MRDOCS_BUILD=ON'
|
||||
input:
|
||||
- ../include
|
||||
exclude-symbols:
|
||||
- 'boost::detail'
|
||||
- 'boost::detail::**'
|
||||
- 'boost::to_string_helper'
|
||||
- 'boost::dynamic_bitset::bit_appender'
|
||||
- 'std'
|
||||
- 'std::**'
|
||||
# Why does MrDocs pick up ::size_t?
|
||||
- 'size_t'
|
||||
file-patterns:
|
||||
- '*.hpp'
|
||||
multipage: false
|
||||
generator: adoc
|
||||
2366
doc/package-lock.json
generated
Normal file
2366
doc/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
doc/package.json
Normal file
21
doc/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "doc",
|
||||
"version": "1.0.0",
|
||||
"description": "The documentation for the dynamic_bitset library is the top-level index.html file.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@alandefreitas/antora-cpp-reference-extension": "^0.0.3",
|
||||
"@antora/lunr-extension": "^1.0.0-alpha.10",
|
||||
"@asciidoctor/tabs": "^1.0.0-beta.6",
|
||||
"@cppalliance/antora-cpp-reference-extension": "^0.0.6",
|
||||
"@cppalliance/antora-cpp-tagfiles-extension": "^0.0.4",
|
||||
"@cppalliance/asciidoctor-boost-links": "^0.0.2",
|
||||
"antora": "^3.1.10"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
The documentation for the dynamic_bitset library is the top-level index.html file.
|
||||
To build the documentation, run build_docs.sh.
|
||||
|
||||
1799
dynamic_bitset.html
1799
dynamic_bitset.html
File diff suppressed because it is too large
Load Diff
@@ -7,10 +7,7 @@
|
||||
#
|
||||
# -----------------------------------------------------------
|
||||
|
||||
exe timing_tests
|
||||
: timing_tests.cpp
|
||||
../../timer/build//boost_timer
|
||||
;
|
||||
project : requirements <library>/boost/dynamic_bitset//boost_dynamic_bitset ;
|
||||
|
||||
exe example1
|
||||
: example1.cpp
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
|
||||
// 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
|
||||
@@ -17,17 +15,18 @@
|
||||
// 10011
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include <iostream>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
int main()
|
||||
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];
|
||||
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";
|
||||
|
||||
|
||||
@@ -10,23 +10,23 @@
|
||||
// bits(2) = 10
|
||||
// bits(3) = 11
|
||||
|
||||
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include <iostream>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
int main()
|
||||
int
|
||||
main()
|
||||
{
|
||||
const boost::dynamic_bitset<> b0(2, 0ul);
|
||||
std::cout << "bits(0) = " << b0 << std::endl;
|
||||
const boost::dynamic_bitset<> b0( 2, 0ul );
|
||||
std::cout << "bits(0) = " << b0 << std::endl;
|
||||
|
||||
const boost::dynamic_bitset<> b1(2, 1ul);
|
||||
std::cout << "bits(1) = " << b1 << std::endl;
|
||||
const boost::dynamic_bitset<> b1( 2, 1ul );
|
||||
std::cout << "bits(1) = " << b1 << std::endl;
|
||||
|
||||
const boost::dynamic_bitset<> b2(2, 2ul);
|
||||
std::cout << "bits(2) = " << b2 << std::endl;
|
||||
const boost::dynamic_bitset<> b2( 2, 2ul );
|
||||
std::cout << "bits(2) = " << b2 << std::endl;
|
||||
|
||||
const boost::dynamic_bitset<> b3(2, 3ul);
|
||||
std::cout << "bits(3) = " << b3 << std::endl;
|
||||
const boost::dynamic_bitset<> b3( 2, 3ul );
|
||||
std::cout << "bits(3) = " << b3 << std::endl;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -19,38 +19,36 @@
|
||||
// Shifted left by 1: 001000100
|
||||
// Shifted right by 1: 010010001
|
||||
|
||||
|
||||
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
int main()
|
||||
int
|
||||
main()
|
||||
{
|
||||
boost::dynamic_bitset<> mask(12, 2730ul);
|
||||
boost::dynamic_bitset<> mask( 12, 2730ul );
|
||||
std::cout << "mask = " << mask << std::endl;
|
||||
|
||||
boost::dynamic_bitset<> x;
|
||||
std::cout << "x.size() = " << x.size() << std::endl;
|
||||
|
||||
std::cout << "Enter a bitset in binary: x = " << std::flush;
|
||||
if (std::cin >> x) {
|
||||
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;
|
||||
bool fits_in_ulong = true;
|
||||
unsigned long ul = 0;
|
||||
try {
|
||||
ul = x.to_ulong();
|
||||
} catch(std::overflow_error &) {
|
||||
} catch ( std::overflow_error & ) {
|
||||
fits_in_ulong = false;
|
||||
}
|
||||
|
||||
std::cout << "As unsigned long: ";
|
||||
if(fits_in_ulong) {
|
||||
if ( fits_in_ulong ) {
|
||||
std::cout << ul;
|
||||
} else {
|
||||
std::cout << "(overflow exception)";
|
||||
@@ -58,14 +56,14 @@ int main()
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
mask.resize(sz);
|
||||
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;
|
||||
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,142 +0,0 @@
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// 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
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
// boost::dynamic_bitset timing tests
|
||||
//
|
||||
// NOTE:
|
||||
// ~~~~~
|
||||
// This is a preliminary, incomplete version.
|
||||
//
|
||||
// If you are interested in having more benchmarks please make a
|
||||
// request on the boost list, which could encourage me to continue
|
||||
// this work.
|
||||
|
||||
// Also, if you use boost::dynamic_bitset on a platform where
|
||||
// CHAR_BIT >= 9 I suggest experimenting with the size of the count
|
||||
// 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)
|
||||
// for pre 3.0 versions of libstdc++
|
||||
# define BOOST_OLD_IOSTREAMS
|
||||
#endif
|
||||
// ------------------------------------------------- //
|
||||
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
#if !defined(BOOST_OLD_IOSTREAMS)
|
||||
# include <ostream>
|
||||
#endif
|
||||
|
||||
|
||||
#include "boost/cstdlib.hpp"
|
||||
#include "boost/version.hpp"
|
||||
#include "boost/timer/timer.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// the m_ prefixes, below, are mainly to avoid problems with g++:
|
||||
// see http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00884.html
|
||||
//
|
||||
class boost_version {
|
||||
int m_major;
|
||||
int m_minor;
|
||||
int m_subminor;
|
||||
|
||||
public:
|
||||
boost_version(unsigned long v = BOOST_VERSION):
|
||||
m_major(v / 100000), m_minor(v / 100 % 1000), m_subminor(v % 100) {}
|
||||
|
||||
friend std::ostream & operator<<(std::ostream &, const boost_version &);
|
||||
};
|
||||
|
||||
|
||||
// give up using basic_ostream, to avoid headaches with old libraries
|
||||
std::ostream& operator<<(std::ostream& os, const boost_version & v) {
|
||||
return os << v.m_major << '.' << v.m_minor << '.' << v.m_subminor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void prologue()
|
||||
{
|
||||
std::cout << '\n';
|
||||
std::cout << "Compiler: " << BOOST_COMPILER << '\n';
|
||||
std::cout << "Std lib : " << BOOST_STDLIB << '\n';
|
||||
std::cout << "Boost v.: " << boost_version() << '\n';
|
||||
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
void timing_test(T* = 0) // dummy parameter to workaround VC6
|
||||
{
|
||||
#ifndef BOOST_NO_STRESS_TEST
|
||||
const unsigned long num = 30 * 100000;
|
||||
#else
|
||||
const unsigned long num = 30 * 1000;
|
||||
#endif
|
||||
|
||||
|
||||
// This variable is printed at the end of the test,
|
||||
// to prevent the optimizer from removing the call to
|
||||
// count() in the loop below.
|
||||
typename boost::dynamic_bitset<T>::size_type dummy = 0;
|
||||
|
||||
std::cout << "\nTimings for dynamic_bitset<" << typeid(T).name()
|
||||
<< "> [" << num << " iterations]\n";
|
||||
std::cout << "--------------------------------------------------\n";
|
||||
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "(total count: " << dummy << ")\n\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
prologue();
|
||||
|
||||
timing_test<unsigned char>();
|
||||
timing_test<unsigned short>();
|
||||
timing_test<unsigned int>();
|
||||
timing_test<unsigned long>();
|
||||
# ifdef BOOST_HAS_LONG_LONG
|
||||
timing_test< ::boost::ulong_long_type>();
|
||||
# endif
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
@@ -13,38 +13,25 @@
|
||||
#define BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
|
||||
// support for pre 3.0 libstdc++ - thanks Phil Edwards!
|
||||
#if defined (__STL_CONFIG_H) && !defined (__STL_USE_NEW_IOSTREAMS)
|
||||
# define BOOST_OLD_IOSTREAMS
|
||||
#endif
|
||||
|
||||
// no-op function to workaround gcc bug c++/8419
|
||||
//
|
||||
namespace boost { namespace detail {
|
||||
template <typename T> T make_non_const(T t) { return t; }
|
||||
}}
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
template< typename T >
|
||||
T
|
||||
make_non_const( T t )
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(expr) \
|
||||
(boost::detail::make_non_const(expr))
|
||||
#if defined( __GNUC__ )
|
||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( expr ) \
|
||||
( boost::detail::make_non_const( expr ) )
|
||||
#else
|
||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(expr) (expr)
|
||||
#endif
|
||||
|
||||
//
|
||||
#if (defined __BORLANDC__ && BOOST_WORKAROUND(__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 we simply expose private members
|
||||
//
|
||||
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
|
||||
#define BOOST_DYNAMIC_BITSET_PRIVATE public
|
||||
#else
|
||||
#define BOOST_DYNAMIC_BITSET_PRIVATE private
|
||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( expr ) ( expr )
|
||||
#endif
|
||||
|
||||
// A couple of macros to cope with libraries without locale
|
||||
@@ -54,18 +41,18 @@ namespace boost { namespace detail {
|
||||
// the first macro is a no-op and the second one just expands
|
||||
// to its parameter c.
|
||||
//
|
||||
#if defined (BOOST_USE_FACET)
|
||||
#if defined BOOST_USE_FACET
|
||||
|
||||
#define BOOST_DYNAMIC_BITSET_CTYPE_FACET(ch, name, loc) \
|
||||
const std::ctype<ch> & name = \
|
||||
BOOST_USE_FACET(std::ctype<ch>, loc) /**/
|
||||
# define BOOST_DYNAMIC_BITSET_CTYPE_FACET( ch, name, loc ) \
|
||||
const std::ctype< ch > & name = \
|
||||
BOOST_USE_FACET( std::ctype< ch >, loc ) /**/
|
||||
|
||||
#define BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, c) \
|
||||
(fac.widen(c))
|
||||
# define BOOST_DYNAMIC_BITSET_WIDEN_CHAR( fac, c ) \
|
||||
( fac.widen( c ) )
|
||||
#else
|
||||
|
||||
#define BOOST_DYNAMIC_BITSET_CTYPE_FACET(ch, name, loc) /**/
|
||||
#define BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, c) c
|
||||
# define BOOST_DYNAMIC_BITSET_CTYPE_FACET( ch, name, loc ) /**/
|
||||
# define BOOST_DYNAMIC_BITSET_WIDEN_CHAR( fac, c ) c
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,289 +16,126 @@
|
||||
#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"
|
||||
|
||||
#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
|
||||
#include "boost/core/allocator_access.hpp"
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
namespace dynamic_bitset_impl {
|
||||
namespace detail {
|
||||
namespace dynamic_bitset_impl {
|
||||
|
||||
// Gives (read-)access to the object representation
|
||||
// of an object of type T (3.9p4). CANNOT be used
|
||||
// on a base sub-object
|
||||
//
|
||||
template <typename T>
|
||||
inline const unsigned char * object_representation (T* p)
|
||||
template< typename T, int amount, int width /* = default */ >
|
||||
struct shifter
|
||||
{
|
||||
static void
|
||||
left_shift( T & v )
|
||||
{
|
||||
return static_cast<const unsigned char *>(static_cast<const void *>(p));
|
||||
amount >= width ? ( v = 0 )
|
||||
: ( v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( amount ) );
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, int amount, int width /* = default */>
|
||||
struct shifter
|
||||
template< bool value >
|
||||
struct value_to_type
|
||||
{
|
||||
};
|
||||
|
||||
// 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
|
||||
{
|
||||
static void left_shift(T & v) {
|
||||
amount >= width ? (v = 0)
|
||||
: (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount));
|
||||
}
|
||||
value = T( -1 ) > 0 // ensure T has no sign
|
||||
};
|
||||
};
|
||||
|
||||
// ------- 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
|
||||
template<>
|
||||
struct allowed_block_type< bool >
|
||||
{
|
||||
enum
|
||||
{
|
||||
value_to_type() {}
|
||||
value = false
|
||||
};
|
||||
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[] =
|
||||
template< typename T >
|
||||
struct is_numeric
|
||||
{
|
||||
enum
|
||||
{
|
||||
// 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
|
||||
value = false
|
||||
};
|
||||
};
|
||||
|
||||
#define BOOST_dynamic_bitset_is_numeric( x ) \
|
||||
template<> \
|
||||
struct is_numeric< x > \
|
||||
{ \
|
||||
enum \
|
||||
{ \
|
||||
value = true \
|
||||
}; \
|
||||
} /**/
|
||||
|
||||
// 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));
|
||||
}
|
||||
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
|
||||
|
||||
// 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;
|
||||
}
|
||||
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 );
|
||||
|
||||
if (length > 0u)
|
||||
num1 += popcount<ValueType>(*first);
|
||||
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 );
|
||||
|
||||
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();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef std::allocator_traits<allocator_type> allocator_traits;
|
||||
|
||||
const typename allocator_traits::size_type alloc_max =
|
||||
allocator_traits::max_size(alloc);
|
||||
#else
|
||||
const typename allocator_type::size_type alloc_max = alloc.max_size();
|
||||
#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
|
||||
|
||||
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);
|
||||
// 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
|
||||
} // dynamic_bitset_impl
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// -----------------------------------------------------------
|
||||
// lowest_bit.hpp
|
||||
// lowest_bit()
|
||||
//
|
||||
// Position of the lowest bit 'on'
|
||||
// Position of the lowest bit that is set.
|
||||
//
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
//
|
||||
@@ -14,26 +14,25 @@
|
||||
#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||
#define BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||
|
||||
#include "boost/integer/integer_log2.hpp"
|
||||
#include "boost/assert.hpp"
|
||||
#include "boost/integer/integer_log2.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
int lowest_bit(T x) {
|
||||
template< typename T >
|
||||
int
|
||||
lowest_bit( T x )
|
||||
{
|
||||
BOOST_ASSERT( x >= 1 );
|
||||
|
||||
BOOST_ASSERT(x >= 1); // PRE
|
||||
|
||||
// clear all bits on except the rightmost one,
|
||||
// then calculate the logarithm base 2
|
||||
//
|
||||
return boost::integer_log2<T>( x - ( x & (x-1) ) );
|
||||
|
||||
}
|
||||
// Clear all the bits that are set except the rightmost one,
|
||||
// then calculate the logarithm to base 2.
|
||||
//
|
||||
return boost::integer_log2< T >( x - ( x & ( x - 1 ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1723
include/boost/dynamic_bitset/impl/dynamic_bitset.tpp
Normal file
1723
include/boost/dynamic_bitset/impl/dynamic_bitset.tpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,36 +11,39 @@
|
||||
#ifndef BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||
#define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||
|
||||
#include "boost/core/nvp.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include <boost/serialization/vector.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 & serialization::make_nvp("m_num_bits", bs.m_num_bits)
|
||||
& serialization::make_nvp("m_bits", bs.m_bits);
|
||||
}
|
||||
};
|
||||
// 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 {
|
||||
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);
|
||||
}
|
||||
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 serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename Block = unsigned long,
|
||||
typename Allocator = std::allocator<Block> >
|
||||
template< typename Block = unsigned long, typename Allocator = std::allocator< Block > >
|
||||
class dynamic_bitset;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
Automatic redirection failed, please go to
|
||||
<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
|
||||
<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>
|
||||
@@ -5,12 +5,13 @@
|
||||
"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.",
|
||||
"description": "The dynamic_bitset template represents a set of bits. It provides access to the value of individual bits via 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 can change at runtime.",
|
||||
"documentation": "dynamic_bitset.html",
|
||||
"category": [
|
||||
"Containers"
|
||||
"Data structures"
|
||||
],
|
||||
"maintainers": [
|
||||
"Jeremy Siek <jeremy.siek -at- gmail.com>"
|
||||
]
|
||||
"Gennaro Prota <firstName.lastName -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
||||
@@ -7,22 +7,29 @@
|
||||
#
|
||||
|
||||
import os ;
|
||||
import testing ;
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
|
||||
project : requirements <library>/boost/dynamic_bitset//boost_dynamic_bitset ;
|
||||
|
||||
test-suite dynamic_bitset :
|
||||
|
||||
[ run dyn_bitset_unit_tests1.cpp : : : <library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests2.cpp : : : <library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests3.cpp : : : <library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests1.cpp : : : <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests2.cpp : : : <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests3.cpp : : : <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/system//boost_system ]
|
||||
[ run dyn_bitset_unit_tests4.cpp : : : <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/system//boost_system ]
|
||||
[ run test_ambiguous_set.cpp ]
|
||||
[ run test_lowest_bit.cpp ]
|
||||
|
||||
[ run test_boost_hash.cpp ]
|
||||
[ run test_std_hash.cpp : : : [ requires cxx11_hdr_unordered_set ] ]
|
||||
[ run test_std_hash.cpp : : : [ requires cxx11_hdr_unordered_set ] ]
|
||||
|
||||
[ compile-fail test_std_hash.cpp : [ requires cxx11_hdr_unordered_set ]
|
||||
<define>BOOST_DYNAMIC_BITSET_NO_STD_HASH
|
||||
@@ -36,6 +43,7 @@ if ! [ os.environ UBSAN_OPTIONS ]
|
||||
|
||||
[ run dyn_bitset_unit_tests5.cpp
|
||||
: : : <define>_SCL_SECURE_NO_WARNINGS=1
|
||||
<library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/serialization//boost_serialization
|
||||
<library>/boost/system//boost_system ]
|
||||
;
|
||||
|
||||
2741
test/bitset_test.hpp
2741
test/bitset_test.hpp
File diff suppressed because it is too large
Load Diff
22
test/cmake_test/CMakeLists.txt
Normal file
22
test/cmake_test/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2021-2024 Alexander Grund
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
# Those 2 should work the same
|
||||
# while using find_package for the installed Boost avoids the need to manually specify dependencies
|
||||
if(BOOST_CI_INSTALL_TEST)
|
||||
find_package(boost_dynamic_bitset REQUIRED)
|
||||
else()
|
||||
set(BOOST_INCLUDE_LIBRARIES dynamic_bitset)
|
||||
add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::dynamic_bitset)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME main COMMAND main)
|
||||
8
test/cmake_test/main.cpp
Normal file
8
test/cmake_test/main.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
const boost::dynamic_bitset<> db{3, 4};
|
||||
|
||||
return db[2] ? 0 : 1;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,373 +11,368 @@
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
|
||||
|
||||
template <typename Block>
|
||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
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;
|
||||
const int bits_per_block = bitset_type::bits_per_block;
|
||||
typedef boost::dynamic_bitset< Block > bitset_type;
|
||||
typedef bitset_test< bitset_type > Tests;
|
||||
const int bits_per_block = bitset_type::bits_per_block;
|
||||
|
||||
std::string long_string = get_long_string();
|
||||
std::string long_string = get_long_string();
|
||||
|
||||
//=====================================================================
|
||||
// Test operator&=
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs, rhs;
|
||||
Tests::and_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
||||
Tests::and_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
||||
Tests::and_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
||||
Tests::and_assignment(lhs, rhs);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator |=
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs, rhs;
|
||||
Tests::or_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
||||
Tests::or_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
||||
Tests::or_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
||||
Tests::or_assignment(lhs, rhs);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator^=
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs, rhs;
|
||||
Tests::xor_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
||||
Tests::xor_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
|
||||
Tests::xor_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
|
||||
Tests::xor_assignment(lhs, rhs);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator-=
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs, rhs;
|
||||
Tests::sub_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
||||
Tests::sub_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
|
||||
Tests::sub_assignment(lhs, rhs);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
|
||||
Tests::sub_assignment(lhs, rhs);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator<<=
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
//=====================================================================
|
||||
// Test operator&=
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::shift_left_assignment(b, pos);
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
Tests::and_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("1010"));
|
||||
Tests::shift_left_assignment(b, pos);
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
Tests::and_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::shift_left_assignment(b, pos);
|
||||
boost::dynamic_bitset< Block > lhs( long_string.size(), 0 ), rhs( long_string );
|
||||
Tests::and_assignment( lhs, rhs );
|
||||
}
|
||||
}
|
||||
{
|
||||
// test with both multiple and
|
||||
// non multiple of bits_per_block
|
||||
const int how_many = 10;
|
||||
for (int i = 1; i <= how_many; ++i) {
|
||||
std::size_t multiple = i * bits_per_block;
|
||||
std::size_t non_multiple = multiple - 1;
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::and_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator |=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
Tests::or_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
Tests::or_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string.size(), 0 ), rhs( long_string );
|
||||
Tests::or_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::or_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator^=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string ), rhs( long_string );
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator-=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string ), rhs( long_string );
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator<<=
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
}
|
||||
{
|
||||
// test with both multiple and
|
||||
// non multiple of bits_per_block
|
||||
const int how_many = 10;
|
||||
for ( int i = 1; i <= how_many; ++i ) {
|
||||
std::size_t multiple = i * bits_per_block;
|
||||
std::size_t non_multiple = multiple - 1;
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
|
||||
Tests::shift_left_assignment(b, multiple);
|
||||
Tests::shift_left_assignment(b, non_multiple);
|
||||
Tests::shift_left_assignment( b, multiple );
|
||||
Tests::shift_left_assignment( b, non_multiple );
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // case pos == size()/2
|
||||
std::size_t pos = long_string.size() / 2;
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::shift_left_assignment(b, pos);
|
||||
}
|
||||
{ // case pos >= n
|
||||
std::size_t pos = long_string.size();
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::shift_left_assignment(b, pos);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator>>=
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::shift_right_assignment(b, pos);
|
||||
{ // case pos == size()/2
|
||||
std::size_t pos = long_string.size() / 2;
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
{ // case pos >= n
|
||||
std::size_t pos = long_string.size();
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator>>=
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("1010"));
|
||||
Tests::shift_right_assignment(b, pos);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::shift_right_assignment(b, pos);
|
||||
}
|
||||
}
|
||||
{
|
||||
// test with both multiple and
|
||||
// non multiple of bits_per_block
|
||||
const int how_many = 10;
|
||||
for (int i = 1; i <= how_many; ++i) {
|
||||
std::size_t multiple = i * bits_per_block;
|
||||
std::size_t non_multiple = multiple - 1;
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
// test with both multiple and
|
||||
// non multiple of bits_per_block
|
||||
const int how_many = 10;
|
||||
for ( int i = 1; i <= how_many; ++i ) {
|
||||
std::size_t multiple = i * bits_per_block;
|
||||
std::size_t non_multiple = multiple - 1;
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
|
||||
Tests::shift_right_assignment(b, multiple);
|
||||
Tests::shift_right_assignment(b, non_multiple);
|
||||
Tests::shift_right_assignment( b, multiple );
|
||||
Tests::shift_right_assignment( b, non_multiple );
|
||||
}
|
||||
}
|
||||
{ // case pos == size()/2
|
||||
std::size_t pos = long_string.size() / 2;
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
{ // case pos >= n
|
||||
std::size_t pos = long_string.size();
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
//=====================================================================
|
||||
// test b.set()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::set_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
Tests::set_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::set_all( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.set(pos)
|
||||
{ // 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()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::reset_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
Tests::reset_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::reset_all( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reset(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::reset_one( b, 0 );
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
Tests::reset_one( b, 0 );
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
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;
|
||||
Tests::operator_flip( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
Tests::operator_flip( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::operator_flip( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::flip_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
Tests::flip_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
Tests::flip_all( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::flip_one( b, 0 );
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
Tests::flip_one( b, 0 );
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
{ // case pos == size()/2
|
||||
std::size_t pos = long_string.size() / 2;
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::shift_right_assignment(b, pos);
|
||||
}
|
||||
{ // case pos >= n
|
||||
std::size_t pos = long_string.size();
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::shift_right_assignment(b, pos);
|
||||
}
|
||||
//=====================================================================
|
||||
// test b.set()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::set_all(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::set_all(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::set_all(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.set(pos)
|
||||
{ // 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()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::reset_all(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::reset_all(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::reset_all(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reset(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::reset_one(b, 0);
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::reset_one(b, 0);
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
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;
|
||||
Tests::operator_flip(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
||||
Tests::operator_flip(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::operator_flip(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip()
|
||||
{
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::flip_all(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
||||
Tests::flip_all(b);
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset<Block> b(long_string);
|
||||
Tests::flip_all(b);
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset<Block> b;
|
||||
Tests::flip_one(b, 0);
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
||||
Tests::flip_one(b, 0);
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
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
|
||||
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
|
||||
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();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,331 +8,304 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <stdexcept> // for std::logic_error
|
||||
#include <assert.h>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined (BOOST_NO_STRINGSTREAM)
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/config/workaround.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include <assert.h>
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
// 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
|
||||
#if ! defined( BOOST_NO_STRINGSTREAM )
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
|
||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
#endif
|
||||
|
||||
#if !defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
std::wstring widen_string( const std::string & str,
|
||||
const std::locale & loc = std::locale() )
|
||||
#if ! defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
std::wstring
|
||||
widen_string( const std::string & str, const std::locale & loc = std::locale() )
|
||||
{
|
||||
std::wstring result;
|
||||
const std::string::size_type len = str.length();
|
||||
if(len != 0) {
|
||||
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 );
|
||||
|
||||
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);
|
||||
for (std::size_t i = 0; i < len; ++i)
|
||||
tr_type::assign(result[i], ct.widen(str[i]));
|
||||
|
||||
}
|
||||
return result;
|
||||
result.resize( len );
|
||||
for ( std::size_t i = 0; i < len; ++i )
|
||||
tr_type::assign( result[ i ], ct.widen( str[ i ] ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Block>
|
||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
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 boost::dynamic_bitset<Block> bitset_type;
|
||||
typedef bitset_test<bitset_type> Tests;
|
||||
//=====================================================================
|
||||
// Test stream operator<<
|
||||
{
|
||||
// The test "variables" are: the stream type and its state, the
|
||||
// exception mask, the width, the fill char and the padding side (left/right)
|
||||
|
||||
//=====================================================================
|
||||
// Test stream operator<<
|
||||
{
|
||||
std::ios::iostate masks[] = {
|
||||
std::ios::goodbit,
|
||||
std::ios::eofbit,
|
||||
std::ios::failbit,
|
||||
std::ios::eofbit | std::ios::failbit
|
||||
};
|
||||
|
||||
// The test "variables" are: the stream type and its state, the
|
||||
// exception mask, the width, the fill char and the padding side (left/right)
|
||||
static std::string strings[] = {
|
||||
std::string( "" ),
|
||||
std::string( "0" ),
|
||||
std::string( "1" ),
|
||||
std::string( "11100" ),
|
||||
get_long_string()
|
||||
};
|
||||
|
||||
std::ios::iostate masks[] = {
|
||||
std::ios::goodbit,
|
||||
std::ios::eofbit,
|
||||
std::ios::failbit,
|
||||
std::ios::eofbit | std::ios::failbit
|
||||
};
|
||||
char fill_chars[] = { '*', 'x', ' ' };
|
||||
|
||||
static std::string strings[] = {
|
||||
std::string(""),
|
||||
std::string("0"),
|
||||
std::string("1"),
|
||||
std::string("11100"),
|
||||
get_long_string()
|
||||
};
|
||||
std::size_t num_masks = sizeof( masks ) / sizeof( masks[ 0 ] );
|
||||
std::size_t num_strings = sizeof( strings ) / sizeof( strings[ 0 ] );
|
||||
std::size_t num_chars = sizeof( fill_chars ) / sizeof( fill_chars[ 0 ] );
|
||||
|
||||
char fill_chars[] = { '*', 'x', ' ' };
|
||||
std::fstream not_good_stream( "dynamic_bitset_tests - this file shouldn't exist", std::ios::in );
|
||||
|
||||
std::size_t num_masks = sizeof(masks) / sizeof(masks[0]);
|
||||
std::size_t num_strings = sizeof(strings) / sizeof(strings[0]);
|
||||
std::size_t num_chars = sizeof(fill_chars) / sizeof(fill_chars[0]);
|
||||
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
|
||||
for ( std::size_t si = 0; si < num_strings; ++si ) {
|
||||
std::streamsize slen = (std::streamsize)( strings[ si ].length() );
|
||||
|
||||
std::fstream not_good_stream("dynamic_bitset_tests - this file shouldn't exist",
|
||||
std::ios::in);
|
||||
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
|
||||
|
||||
for ( std::size_t ci = 0; ci < num_chars; ++ci ) {
|
||||
// note how "negative widths" are tested too
|
||||
const std::streamsize widths[] = { -1 - slen / 2, 0, slen / 2, 1 + slen * 2 };
|
||||
std::size_t num_widths = sizeof( widths ) / sizeof( widths[ 0 ] );
|
||||
|
||||
for (std::size_t mi = 0; mi < num_masks; ++mi) {
|
||||
for (std::size_t si = 0; si < num_strings; ++si) {
|
||||
for ( std::size_t wi = 0; wi < num_widths; ++wi ) {
|
||||
std::streamsize w = widths[ wi ];
|
||||
{
|
||||
// test 0 - stream !good()
|
||||
if ( not_good_stream.good() )
|
||||
throw std::logic_error( "Error in operator << tests"
|
||||
" - please, double check" );
|
||||
bitset_type b( strings[ si ] );
|
||||
not_good_stream.width( w );
|
||||
not_good_stream.fill( fill_chars[ ci ] );
|
||||
try {
|
||||
not_good_stream.exceptions( masks[ mi ] );
|
||||
} catch ( ... ) {
|
||||
}
|
||||
|
||||
std::streamsize slen = (std::streamsize)(strings[si].length());
|
||||
|
||||
assert( (std::numeric_limits<std::streamsize>::max)()
|
||||
>=(std::streamsize)(1+slen*2) );
|
||||
|
||||
for (std::size_t ci = 0; ci < num_chars; ++ci) {
|
||||
|
||||
// note how "negative widths" are tested too
|
||||
const std::streamsize widths[] = { -1 - slen/2, 0, slen/2, 1 + slen*2 };
|
||||
std::size_t num_widths = sizeof(widths) / sizeof(widths[0]);
|
||||
|
||||
for (std::size_t wi = 0; wi < num_widths; ++wi) {
|
||||
std::streamsize w = widths[wi];
|
||||
{
|
||||
// test 0 - stream !good()
|
||||
if(not_good_stream.good())
|
||||
throw std::logic_error("Error in operator << tests"
|
||||
" - please, double check");
|
||||
bitset_type b(strings[si]);
|
||||
not_good_stream.width(w);
|
||||
not_good_stream.fill(fill_chars[ci]);
|
||||
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
|
||||
|
||||
Tests::stream_inserter(b, not_good_stream, "<unused_string>");
|
||||
}
|
||||
{
|
||||
// test 1a - file stream
|
||||
scoped_temp_file stf;
|
||||
bitset_type b(strings[si]);
|
||||
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, stf.path().string().c_str());
|
||||
}
|
||||
{
|
||||
//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(stf.path().string().c_str());
|
||||
file.width(w);
|
||||
file.fill(fill_chars[ci]);
|
||||
file.exceptions(masks[mi]);
|
||||
Tests::stream_inserter(b, file, stf.path().string().c_str());
|
||||
}
|
||||
Tests::stream_inserter( b, not_good_stream, "<unused_string>" );
|
||||
}
|
||||
{
|
||||
// test 1a - file stream
|
||||
scoped_temp_file stf;
|
||||
bitset_type b( strings[ si ] );
|
||||
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, stf.path().string().c_str() );
|
||||
}
|
||||
{
|
||||
// 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( stf.path().string().c_str() );
|
||||
file.width( w );
|
||||
file.fill( fill_chars[ ci ] );
|
||||
file.exceptions( masks[ mi ] );
|
||||
Tests::stream_inserter( b, file, stf.path().string().c_str() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for (; mi..)
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for (; mi..)
|
||||
}
|
||||
|
||||
}
|
||||
//=====================================================================
|
||||
// Test stream operator>>
|
||||
{
|
||||
// The test "variables" are: the stream type, the exception mask,
|
||||
// the actual contents (and/or state) of the stream, and width.
|
||||
//
|
||||
// With few exceptions, each test case consists of writing a different
|
||||
// assortment of digits and "whitespaces" to a text stream and then checking
|
||||
// that what was written gets read back unchanged. That's NOT guaranteed by
|
||||
// the standard, unless the assortment always ends with a '\n' and satisfies
|
||||
// other conditions (see C99, 7.19.2/2), however it works in practice and is
|
||||
// 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)
|
||||
//
|
||||
// Note how the bitset object is not initially empty. That helps checking
|
||||
// that it isn't erroneously clear()ed by operator>>.
|
||||
|
||||
//=====================================================================
|
||||
// Test stream operator>>
|
||||
{
|
||||
std::ios::iostate masks[] = {
|
||||
std::ios::goodbit,
|
||||
std::ios::eofbit,
|
||||
std::ios::failbit,
|
||||
std::ios::eofbit | std::ios::failbit
|
||||
};
|
||||
|
||||
// The test "variables" are: the stream type, the exception mask,
|
||||
// the actual contents (and/or state) of the stream, and width.
|
||||
//
|
||||
// With few exceptions, each test case consists of writing a different
|
||||
// assortment of digits and "whitespaces" to a text stream and then checking
|
||||
// that what was written gets read back unchanged. That's NOT guaranteed by
|
||||
// the standard, unless the assortment always ends with a '\n' and satisfies
|
||||
// other conditions (see C99, 7.19.2/2), however it works in practice and is
|
||||
// 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)
|
||||
//
|
||||
// Note how the bitset object is not initially empty. That helps checking
|
||||
// that it isn't erroneously clear()ed by operator>>.
|
||||
const std::string spaces = "\t\n "; //"\t\n\v\f ";
|
||||
|
||||
const std::string long_string = get_long_string();
|
||||
const static std::string strings[] = {
|
||||
|
||||
std::ios::iostate masks[] = {
|
||||
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*/ static std::string strings[] = {
|
||||
// NOTE: "const" gives the usual problems with Borland
|
||||
// (in Tests::stream_extractor instantiation)
|
||||
|
||||
|
||||
#if !(defined __BORLANDC__ \
|
||||
&& BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)))
|
||||
// Borland 5.5.1 with RW library crashes
|
||||
// empty string
|
||||
std::string(""),
|
||||
std::string( "" ),
|
||||
// no bitset
|
||||
spaces,
|
||||
#endif
|
||||
|
||||
// no bitset
|
||||
std::string("x"),
|
||||
std::string("\t xyz"),
|
||||
std::string( "x" ),
|
||||
std::string( "\t xyz" ),
|
||||
|
||||
// bitset of size 1
|
||||
std::string("0"),
|
||||
std::string("1"),
|
||||
std::string( "0" ),
|
||||
std::string( "1" ),
|
||||
|
||||
std::string(" 0 "),
|
||||
std::string(" 1 "),
|
||||
std::string( " 0 " ),
|
||||
std::string( " 1 " ),
|
||||
spaces + "1",
|
||||
"1" + spaces,
|
||||
spaces + "1" + spaces,
|
||||
std::string(" x1x "),
|
||||
std::string(" 1x "),
|
||||
std::string( " x1x " ),
|
||||
std::string( " 1x " ),
|
||||
|
||||
// long bitset
|
||||
long_string,
|
||||
" " + long_string + " xyz",
|
||||
spaces + long_string,
|
||||
spaces + long_string + spaces
|
||||
};
|
||||
};
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------
|
||||
std::stringstream not_good_stream;
|
||||
not_good_stream << "test";
|
||||
std::string sink;
|
||||
not_good_stream >> sink; // now the stream should be in eof state
|
||||
|
||||
std::stringstream not_good_stream;
|
||||
not_good_stream << "test";
|
||||
std::string sink;
|
||||
not_good_stream >> sink; // now the stream should be in eof state
|
||||
const std::size_t num_masks = sizeof( masks ) / sizeof( masks[ 0 ] );
|
||||
const std::size_t num_strings = sizeof( strings ) / sizeof( strings[ 0 ] );
|
||||
|
||||
const std::size_t num_masks = sizeof(masks) / sizeof(masks[0]);
|
||||
const std::size_t num_strings = sizeof(strings) / sizeof(strings[0]);
|
||||
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
|
||||
for ( std::size_t si = 0; si < num_strings; ++si ) {
|
||||
const std::streamsize slen = (std::streamsize)( strings[ si ].length() );
|
||||
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
|
||||
|
||||
for (std::size_t mi = 0; mi < num_masks; ++mi) {
|
||||
for (std::size_t si = 0; si < num_strings; ++si) {
|
||||
std::streamsize widths[] = { -1, 0, slen / 2, slen, 1 + slen * 2 };
|
||||
std::size_t num_widths = sizeof( widths ) / sizeof( widths[ 0 ] );
|
||||
|
||||
const std::streamsize slen = (std::streamsize)(strings[si].length());
|
||||
assert((std::numeric_limits<std::streamsize>::max)() >= (std::streamsize)(1+slen*2));
|
||||
for ( std::size_t wi = 0; wi < num_widths; ++wi ) {
|
||||
const std::streamsize w = widths[ wi ];
|
||||
|
||||
std::streamsize widths[] = { -1, 0, slen/2, slen, 1 + slen*2 };
|
||||
std::size_t num_widths = sizeof(widths) / sizeof(widths[0]);
|
||||
// test 0 - !good() stream
|
||||
{
|
||||
if ( not_good_stream.good() )
|
||||
throw std::logic_error( "Error in operator >> tests"
|
||||
" - please, double check" );
|
||||
bitset_type b( 1, 15ul ); // note: b is not empty
|
||||
not_good_stream.width( w );
|
||||
try {
|
||||
not_good_stream.exceptions( masks[ mi ] );
|
||||
} catch ( ... ) {
|
||||
}
|
||||
std::string irrelevant;
|
||||
Tests::stream_extractor( b, not_good_stream, irrelevant );
|
||||
}
|
||||
// test 1a - (narrow) file stream
|
||||
{
|
||||
scoped_temp_file stf;
|
||||
bitset_type b( 1, 255ul );
|
||||
{
|
||||
std::ofstream f( stf.path().string().c_str() );
|
||||
f << strings[ si ];
|
||||
}
|
||||
|
||||
for(std::size_t wi = 0; wi < num_widths; ++wi) {
|
||||
const std::streamsize w = widths[wi];
|
||||
|
||||
// test 0 - !good() stream
|
||||
{
|
||||
if(not_good_stream.good())
|
||||
throw std::logic_error("Error in operator >> tests"
|
||||
" - please, double check");
|
||||
bitset_type b(1, 15ul); // note: b is not empty
|
||||
not_good_stream.width(w);
|
||||
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
|
||||
std::string irrelevant;
|
||||
Tests::stream_extractor(b, not_good_stream, irrelevant);
|
||||
}
|
||||
// test 1a - (narrow) file stream
|
||||
{
|
||||
scoped_temp_file stf;
|
||||
bitset_type b(1, 255ul);
|
||||
{
|
||||
std::ofstream f(stf.path().string().c_str());
|
||||
f << strings[si];
|
||||
}
|
||||
|
||||
std::ifstream f(stf.path().string().c_str());
|
||||
f.width(w);
|
||||
f.exceptions(masks[mi]);
|
||||
Tests::stream_extractor(b, f, strings[si]);
|
||||
}
|
||||
#if !defined(BOOST_NO_STRINGSTREAM)
|
||||
// test 2a - stringstream
|
||||
{
|
||||
bitset_type b(1, 255ul);
|
||||
std::istringstream stream(strings[si]);
|
||||
stream.width(w);
|
||||
stream.exceptions(masks[mi]);
|
||||
Tests::stream_extractor(b, stream, strings[si]);
|
||||
}
|
||||
std::ifstream f( stf.path().string().c_str() );
|
||||
f.width( w );
|
||||
f.exceptions( masks[ mi ] );
|
||||
Tests::stream_extractor( b, f, strings[ si ] );
|
||||
}
|
||||
#if ! defined( BOOST_NO_STRINGSTREAM )
|
||||
// test 2a - stringstream
|
||||
{
|
||||
bitset_type b( 1, 255ul );
|
||||
std::istringstream stream( strings[ si ] );
|
||||
stream.width( w );
|
||||
stream.exceptions( masks[ mi ] );
|
||||
Tests::stream_extractor( b, stream, strings[ si ] );
|
||||
}
|
||||
#endif
|
||||
|
||||
#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(stf.path().string().c_str());
|
||||
of << wstr;
|
||||
}
|
||||
#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( stf.path().string().c_str() );
|
||||
of << wstr;
|
||||
}
|
||||
|
||||
std::basic_ifstream<wchar_t> f(stf.path().string().c_str());
|
||||
f.width(w);
|
||||
f.exceptions(masks[mi]);
|
||||
Tests::stream_extractor(b, f, wstr);
|
||||
}
|
||||
// test 2b - wstringstream
|
||||
{
|
||||
bitset_type b(1, 255ul);
|
||||
std::wstring wstr = widen_string(strings[si]);
|
||||
std::basic_ifstream< wchar_t > f( stf.path().string().c_str() );
|
||||
f.width( w );
|
||||
f.exceptions( masks[ mi ] );
|
||||
Tests::stream_extractor( b, f, wstr );
|
||||
}
|
||||
// test 2b - wstringstream
|
||||
{
|
||||
bitset_type b( 1, 255ul );
|
||||
std::wstring wstr = widen_string( strings[ si ] );
|
||||
|
||||
std::wistringstream wstream(wstr);
|
||||
wstream.width(w);
|
||||
wstream.exceptions(masks[mi]);
|
||||
Tests::stream_extractor(b, wstream, wstr);
|
||||
}
|
||||
std::wistringstream wstream( wstr );
|
||||
wstream.width( w );
|
||||
wstream.exceptions( masks[ mi ] );
|
||||
Tests::stream_extractor( b, wstream, wstr );
|
||||
}
|
||||
#endif // BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // for ( mi = 0; ...)
|
||||
}
|
||||
|
||||
} // for ( mi = 0; ...)
|
||||
|
||||
|
||||
}
|
||||
//=====================================================================
|
||||
// << Any other tests go here >>
|
||||
// .....
|
||||
|
||||
//=====================================================================
|
||||
// << Any other tests go here >>
|
||||
// .....
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
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();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -10,102 +10,104 @@
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#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>
|
||||
#include "boost/archive/binary_iarchive.hpp"
|
||||
#include "boost/archive/binary_oarchive.hpp"
|
||||
#include "boost/archive/xml_iarchive.hpp"
|
||||
#include "boost/archive/xml_oarchive.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/config/workaround.hpp"
|
||||
#include "boost/dynamic_bitset/serialization.hpp"
|
||||
#include "boost/serialization/vector.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
|
||||
#if ! defined( BOOST_NO_STRINGSTREAM )
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
|
||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
#endif
|
||||
|
||||
#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;
|
||||
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);
|
||||
}
|
||||
};
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template< class Archive >
|
||||
void
|
||||
serialize( Archive & ar, 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;
|
||||
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);
|
||||
for ( int i = 0; i < 128; ++i )
|
||||
a.x.resize( 11 * i, i % 2 );
|
||||
|
||||
#if !defined (BOOST_NO_STRINGSTREAM)
|
||||
std::stringstream ss;
|
||||
#if ! defined( BOOST_NO_STRINGSTREAM )
|
||||
std::stringstream ss;
|
||||
|
||||
// test serialization
|
||||
{
|
||||
OArchive oa(ss);
|
||||
oa << BOOST_SERIALIZATION_NVP(a);
|
||||
}
|
||||
// test serialization
|
||||
{
|
||||
OArchive oa( ss );
|
||||
oa << BOOST_SERIALIZATION_NVP( a );
|
||||
}
|
||||
|
||||
// test de-serialization
|
||||
{
|
||||
IArchive ia(ss);
|
||||
SerializableType<Block> b;
|
||||
ia >> BOOST_SERIALIZATION_NVP(b);
|
||||
// test de-serialization
|
||||
{
|
||||
IArchive ia( ss );
|
||||
SerializableType< Block > b;
|
||||
ia >> BOOST_SERIALIZATION_NVP( b );
|
||||
|
||||
assert(a.x == b.x);
|
||||
}
|
||||
BOOST_TEST( a.x == b.x );
|
||||
}
|
||||
#else
|
||||
# error "TODO implement file-based test path?"
|
||||
# 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) )
|
||||
template< typename Block >
|
||||
void
|
||||
test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
{
|
||||
test_binary_archive<Block>();
|
||||
test_xml_archive<Block>();
|
||||
test_serialization< Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive >();
|
||||
}
|
||||
|
||||
int main()
|
||||
template< typename Block >
|
||||
void
|
||||
test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
{
|
||||
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
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
//
|
||||
// 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>
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
|
||||
int main(int, char*[])
|
||||
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));
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1,47 +1,43 @@
|
||||
//
|
||||
// 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 "boost/config.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include <set>
|
||||
|
||||
int main(int, char*[])
|
||||
int
|
||||
main( int, char *[] )
|
||||
{
|
||||
typedef boost::dynamic_bitset<unsigned long> bitset_type;
|
||||
const std::string long_string =
|
||||
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);
|
||||
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));
|
||||
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);
|
||||
BOOST_TEST_EQ( results.size(), 5 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
//
|
||||
// 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>
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/cstdint.hpp"
|
||||
#include "boost/dynamic_bitset/detail/lowest_bit.hpp"
|
||||
|
||||
int main(int, char*[])
|
||||
int
|
||||
main( int, char *[] )
|
||||
{
|
||||
for (boost::int32_t i = 1; i < 32; ++i) {
|
||||
BOOST_TEST_EQ(i, boost::detail::lowest_bit(1u << i));
|
||||
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)));
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1,39 +1,33 @@
|
||||
//
|
||||
// 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 "boost/config.hpp"
|
||||
#include "boost/detail/lightweight_test.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include <unordered_set>
|
||||
|
||||
int main(int, char*[])
|
||||
int
|
||||
main( int, char *[] )
|
||||
{
|
||||
typedef boost::dynamic_bitset<unsigned long> bitset_type;
|
||||
const std::string long_string =
|
||||
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);
|
||||
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);
|
||||
std::unordered_set< bitset_type > bitsets;
|
||||
bitsets.insert( zeroes );
|
||||
bitsets.insert( stuff );
|
||||
bitsets.insert( ones );
|
||||
|
||||
BOOST_TEST_EQ(bitsets.size(), 3);
|
||||
BOOST_TEST_EQ( bitsets.size(), 3 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user