mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-27 19:02:09 +00:00
Compare commits
183 Commits
experiment
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75d3e4d83d | ||
|
|
9b64641093 | ||
|
|
54c841d585 | ||
|
|
7c4dbfa2ac | ||
|
|
e19c647bc7 | ||
|
|
f12c918881 | ||
|
|
354c63cb24 | ||
|
|
0622f6a59f | ||
|
|
3fab9dfdf7 | ||
|
|
393b731466 | ||
|
|
41799d3fe5 | ||
|
|
957ee38823 | ||
|
|
796fcb615b | ||
|
|
982073fbcd | ||
|
|
809b7a3796 | ||
|
|
caee95bddd | ||
|
|
c9964a771b | ||
|
|
6b5e49ea40 | ||
|
|
67115073d2 | ||
|
|
a2d4a0ebbb | ||
|
|
2c7085502a | ||
|
|
bd00ce2e58 | ||
|
|
f3d7d5c960 | ||
|
|
63716d84a3 | ||
|
|
286e721430 | ||
|
|
7aca0a80fd | ||
|
|
7a00f3c051 | ||
|
|
cd68ee4632 | ||
|
|
f637b5bab1 | ||
|
|
57bdff3f12 | ||
|
|
5a25945ed7 | ||
|
|
7755190288 | ||
|
|
b52e7cd97b | ||
|
|
bf2e39ec65 | ||
|
|
fd0c440888 | ||
|
|
410068c17d | ||
|
|
d8131f641c | ||
|
|
fc47959cd4 | ||
|
|
8387c4f494 | ||
|
|
5f62214ad5 | ||
|
|
3ff4a319d9 | ||
|
|
2cff357a91 | ||
|
|
ff1a0fda26 | ||
|
|
134fab263b | ||
|
|
68c5913983 | ||
|
|
882e0e0665 | ||
|
|
843b6c3dd0 | ||
|
|
bbb2fa90df | ||
|
|
15a73050cb | ||
|
|
ac5df5566a | ||
|
|
9bba7af0b5 | ||
|
|
4cf19a2b0a | ||
|
|
a740393527 | ||
|
|
7ae245eabf | ||
|
|
9d604eba5a | ||
|
|
fae55af67d | ||
|
|
81011d8161 | ||
|
|
51db99cf32 | ||
|
|
ac6b01140d | ||
|
|
26dac17a4a | ||
|
|
d3c4e2751a | ||
|
|
c58487c26a | ||
|
|
6f3634aa4b | ||
|
|
d8365ee015 | ||
|
|
4ca26518ec | ||
|
|
8f07dd356a | ||
|
|
efd4d41f60 | ||
|
|
30ee0f68b5 | ||
|
|
eba192e3a3 | ||
|
|
bb489c186a | ||
|
|
0177f4adfa | ||
|
|
079cff781d | ||
|
|
e00d9b30ae | ||
|
|
ae9703b119 | ||
|
|
3ccf097dc1 | ||
|
|
88995c08b0 | ||
|
|
3531f6703b | ||
|
|
0ff8509214 | ||
|
|
08191fc025 | ||
|
|
759c4f4e4a | ||
|
|
12dfcea22f | ||
|
|
526104dbe9 | ||
|
|
b6a875976d | ||
|
|
394854535a | ||
|
|
1bef343d12 | ||
|
|
0ca460971e | ||
|
|
6747f81566 | ||
|
|
b428ca6365 | ||
|
|
35b0094529 | ||
|
|
1b8ef09564 | ||
|
|
e194055264 | ||
|
|
54b32707c4 | ||
|
|
07e110d522 | ||
|
|
17e2192154 | ||
|
|
4a928c8787 | ||
|
|
f429a0a50d | ||
|
|
7f4078b1a9 | ||
|
|
043b5e1c86 | ||
|
|
0052e61ccc | ||
|
|
f262bea730 | ||
|
|
1c82de1c51 | ||
|
|
b0bc76bfc8 | ||
|
|
b429e550e4 | ||
|
|
aa7105f209 | ||
|
|
ac485ff3d2 | ||
|
|
ac2a5a65b4 | ||
|
|
80da0cdd28 | ||
|
|
431df92f41 | ||
|
|
6f1b27797d | ||
|
|
acc7f2a458 | ||
|
|
8547f23e2d | ||
|
|
fa4f504a01 | ||
|
|
e848c84da3 | ||
|
|
a7c9175201 | ||
|
|
74d1e42a3f | ||
|
|
41c20338ef | ||
|
|
882a352a8e | ||
|
|
b2712c0112 | ||
|
|
d63c03ceb2 | ||
|
|
f47536a712 | ||
|
|
abff9a45a1 | ||
|
|
31c0804722 | ||
|
|
1105d6e3c9 | ||
|
|
b9ec4cdfae | ||
|
|
a3288d871b | ||
|
|
5f2c3cc0dd | ||
|
|
b6cc8844ee | ||
|
|
255295adf2 | ||
|
|
a8fcf950af | ||
|
|
23ac016871 | ||
|
|
737e95c053 | ||
|
|
0936305e82 | ||
|
|
e9f99a4446 | ||
|
|
14c1b22a4c | ||
|
|
688fa7c451 | ||
|
|
9403b3bf7e | ||
|
|
802278fec2 | ||
|
|
d96d00ef08 | ||
|
|
7c8b554850 | ||
|
|
0fce729fe1 | ||
|
|
5da2852728 | ||
|
|
2ef8b15211 | ||
|
|
d839f23916 | ||
|
|
963cc09f3c | ||
|
|
c203591add | ||
|
|
aebe027628 | ||
|
|
a65fe4dd9e | ||
|
|
825260e482 | ||
|
|
12acc40123 | ||
|
|
1092cdbfe6 | ||
|
|
482c4b9701 | ||
|
|
5459cdf373 | ||
|
|
fffe155495 | ||
|
|
f61a1bf652 | ||
|
|
28ddbd7afc | ||
|
|
76656c9a0f | ||
|
|
4b7a03234d | ||
|
|
93cd78c251 | ||
|
|
c6709f3c74 | ||
|
|
2e0e407ad5 | ||
|
|
e8d9288620 | ||
|
|
4c26bd9a97 | ||
|
|
2044a0c53c | ||
|
|
59ceb8f16f | ||
|
|
4db39188a4 | ||
|
|
190096e539 | ||
|
|
599cc67e9d | ||
|
|
a9fe026431 | ||
|
|
6a92632638 | ||
|
|
4485bf9bbf | ||
|
|
583cb08f6f | ||
|
|
2579c3d6cd | ||
|
|
4aedddb332 | ||
|
|
dab7861b74 | ||
|
|
e28c5636d6 | ||
|
|
dc945046aa | ||
|
|
8400b5c4c7 | ||
|
|
aea65e101f | ||
|
|
3c2546f0bb | ||
|
|
831ad00039 | ||
|
|
6591f2fd30 | ||
|
|
048a1cd3e5 | ||
|
|
e00b0048f9 |
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:
|
||||||
457
.github/workflows/ci.yml
vendored
457
.github/workflows/ci.yml
vendored
@@ -1,12 +1,21 @@
|
|||||||
|
#
|
||||||
# Copyright 2020-2021 Peter Dimov
|
# Copyright 2020-2021 Peter Dimov
|
||||||
# Copyright 2021 Andrey Semashev
|
# Copyright 2021 Andrey Semashev
|
||||||
# Copyright 2021 Alexander Grund
|
# Copyright 2021-2024 Alexander Grund
|
||||||
# Copyright 2022-2024 James E. King III
|
# Copyright 2022-2025 James E. King III
|
||||||
|
# Copyright 2023 Alan de Freitas
|
||||||
#
|
#
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# (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: CI
|
name: Boost.CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -23,407 +32,79 @@ on:
|
|||||||
- meta/**
|
- meta/**
|
||||||
- README.md
|
- README.md
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{format('{0}:{1}', github.repository, github.ref)}}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
env:
|
|
||||||
GIT_FETCH_JOBS: 8
|
|
||||||
NET_RETRY_COUNT: 5
|
|
||||||
B2_CI_VERSION: 1
|
|
||||||
B2_VARIANT: debug,release
|
|
||||||
B2_LINK: shared,static
|
|
||||||
LCOV_BRANCH_COVERAGE: 0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
posix:
|
call-boost-ci:
|
||||||
defaults:
|
name: Run Boost.CI
|
||||||
run:
|
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
|
||||||
shell: bash
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
# linux, gcc
|
|
||||||
- { compiler: gcc-7, cxxstd: '11,14,17', os: ubuntu-20.04 }
|
|
||||||
- { compiler: gcc-8, cxxstd: '11,14,17,2a', os: ubuntu-20.04 }
|
|
||||||
- { compiler: gcc-9, cxxstd: '11,14,17,2a', os: ubuntu-20.04 }
|
|
||||||
- { compiler: gcc-10, cxxstd: '11,14,17,20', os: ubuntu-20.04 }
|
|
||||||
- { compiler: gcc-11, cxxstd: '11,14,17,20', os: ubuntu-20.04 }
|
|
||||||
- { compiler: gcc-12, cxxstd: '11,14,17,20', os: ubuntu-22.04 }
|
|
||||||
- { compiler: gcc-13, cxxstd: '11,14,17,20,2b', os: ubuntu-22.04 }
|
|
||||||
- { compiler: gcc-14, cxxstd: '11,14,17,20,2b', os: ubuntu-24.04 }
|
|
||||||
- { name: GCC w/ sanitizers, sanitize: yes,
|
|
||||||
compiler: gcc-13, cxxstd: '11,14,17,20', os: ubuntu-22.04 }
|
|
||||||
- { name: Collect coverage, coverage: yes,
|
|
||||||
compiler: gcc-12, cxxstd: '11', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '32,64' }
|
|
||||||
|
|
||||||
# linux, clang
|
|
||||||
- { compiler: clang-9, cxxstd: '11,14,17,2a', os: ubuntu-20.04 }
|
|
||||||
- { compiler: clang-10, cxxstd: '11,14,17,20', os: ubuntu-20.04 }
|
|
||||||
- { compiler: clang-11, cxxstd: '11,14,17,20', os: ubuntu-20.04 }
|
|
||||||
- { compiler: clang-12, cxxstd: '11,14,17,20', os: ubuntu-20.04 }
|
|
||||||
# Clang isn't compatible with libstdc++-13, so use the slightly older one
|
|
||||||
- { compiler: clang-13, cxxstd: '11,14,17,20', os: ubuntu-22.04, install: 'clang-13 g++-12', gcc_toolchain: 12 }
|
|
||||||
- { compiler: clang-14, cxxstd: '11,14,17,20', os: ubuntu-22.04, install: 'clang-14 g++-12', gcc_toolchain: 12 }
|
|
||||||
- { compiler: clang-15, cxxstd: '11,14,17,20', os: ubuntu-22.04, install: 'clang-15 g++-12', gcc_toolchain: 12 }
|
|
||||||
- { compiler: clang-16, cxxstd: '11,14,17,20,2b', os: ubuntu-24.04 }
|
|
||||||
# https://github.com/llvm/llvm-project/issues/59827: disabled 2b/23 for clang-17 with libstdc++13 in 24.04
|
|
||||||
- { compiler: clang-17, cxxstd: '11,14,17,20', os: ubuntu-24.04 }
|
|
||||||
- { compiler: clang-18, cxxstd: '11,17,20,23,2c', os: ubuntu-24.04 }
|
|
||||||
|
|
||||||
# linux, libc++
|
|
||||||
- { name: Clang w/ sanitizers, sanitize: yes,
|
|
||||||
compiler: clang-12, cxxstd: '11,14,17,20', os: ubuntu-20.04, stdlib: 'libc++', install: 'clang-12 libc++-12-dev libc++abi-12-dev' }
|
|
||||||
|
|
||||||
- { name: MacOS w/ clang and sanitizers,
|
|
||||||
compiler: clang, cxxstd: '11,14,17,20,2b', os: macos-13, sanitize: yes }
|
|
||||||
- { compiler: clang, cxxstd: '11,14,17,20,2b', os: macos-14 }
|
|
||||||
- { compiler: clang, cxxstd: '11,14,17,20,2b', os: macos-15 }
|
|
||||||
|
|
||||||
# Coverity Scan
|
|
||||||
# requires two github secrets in repo to activate; see ci/github/coverity.sh
|
|
||||||
# does not run on pull requests, only on pushes into develop and master
|
|
||||||
- { name: Coverity, coverity: yes,
|
|
||||||
compiler: clang-12, cxxstd: '17', os: ubuntu-20.04, ccache: no }
|
|
||||||
|
|
||||||
# multiarch (bigendian testing) - does not support coverage yet
|
|
||||||
- { name: Big-endian, multiarch: yes,
|
|
||||||
compiler: clang, cxxstd: '17', os: ubuntu-22.04, ccache: no, distro: fedora, edition: 34, arch: s390x }
|
|
||||||
|
|
||||||
timeout-minutes: 120
|
|
||||||
runs-on: ${{matrix.os}}
|
|
||||||
env: {B2_USE_CCACHE: 1}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Setup environment
|
|
||||||
run: |
|
|
||||||
if [ -f "/etc/debian_version" ]; then
|
|
||||||
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
fi
|
|
||||||
if [ -n "${{matrix.container}}" ] && [ -f "/etc/debian_version" ]; then
|
|
||||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
|
||||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common curl
|
|
||||||
# Need (newer) git, and the older Ubuntu container may require requesting the key manually using port 80
|
|
||||||
curl -sSL --retry ${NET_RETRY_COUNT:-5} 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xE1DD270288B4E6030699E45FA1715D88E1DF1F24' | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/git-core_ubuntu_ppa.gpg
|
|
||||||
for i in {1..${NET_RETRY_COUNT:-3}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done
|
|
||||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
|
||||||
osver=$(lsb_release -sr | cut -f1 -d.)
|
|
||||||
pkgs="g++ git xz-utils"
|
|
||||||
# Ubuntu 22+ has only Python 3 in the repos
|
|
||||||
if [ -n "$osver" ] && [ "$osver" -ge "22" ]; then
|
|
||||||
pkgs+=" python-is-python3 libpython3-dev"
|
|
||||||
else
|
|
||||||
pkgs+=" python libpython-dev"
|
|
||||||
fi
|
|
||||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
|
|
||||||
fi
|
|
||||||
# For jobs not compatible with ccache, use "ccache: no" in the matrix
|
|
||||||
if [[ "${{ matrix.ccache }}" == "no" ]]; then
|
|
||||||
echo "B2_USE_CCACHE=0" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
git config --global pack.threads 0
|
|
||||||
if [[ "${{matrix.container}}" == "ubuntu:1"* ]]; then
|
|
||||||
# Node 20 doesn't work with Ubuntu 16/18 glibc: https://github.com/actions/checkout/issues/1590
|
|
||||||
curl -sL https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217
|
|
||||||
fi
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
# For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
|
# These compilers fail.
|
||||||
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
|
exclude_compiler: 'clang-3.5,clang-3.6,clang-3.7,clang-3.8,gcc-4.8,gcc-4.9'
|
||||||
|
secrets:
|
||||||
- name: Cache ccache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
if: env.B2_USE_CCACHE
|
|
||||||
with:
|
|
||||||
path: ~/.ccache
|
|
||||||
key: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}}
|
|
||||||
restore-keys: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-
|
|
||||||
|
|
||||||
- name: Fetch Boost.CI
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: boostorg/boost-ci
|
|
||||||
ref: master
|
|
||||||
path: boost-ci-cloned
|
|
||||||
|
|
||||||
- name: Get CI scripts folder
|
|
||||||
run: |
|
|
||||||
# Copy ci folder if not testing Boost.CI
|
|
||||||
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
|
|
||||||
rm -rf boost-ci-cloned
|
|
||||||
|
|
||||||
- name: Install packages
|
|
||||||
if: startsWith(matrix.os, 'ubuntu')
|
|
||||||
run: |
|
|
||||||
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
|
|
||||||
SOURCES=("${{join(matrix.sources, '" "')}}")
|
|
||||||
# Add this by default
|
|
||||||
SOURCE_KEYS+=('http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x1E9377A2BA9EF27F')
|
|
||||||
SOURCES+=(ppa:ubuntu-toolchain-r/test)
|
|
||||||
|
|
||||||
ci/add-apt-keys.sh "${SOURCE_KEYS[@]}"
|
|
||||||
# Initial update before adding sources required to get e.g. keys
|
|
||||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
|
||||||
ci/add-apt-repositories.sh "${SOURCES[@]}"
|
|
||||||
|
|
||||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
|
||||||
if [[ -z "${{matrix.install}}" ]]; then
|
|
||||||
pkgs="${{matrix.compiler}}"
|
|
||||||
pkgs="${pkgs/gcc-/g++-}"
|
|
||||||
else
|
|
||||||
pkgs="${{matrix.install}}"
|
|
||||||
fi
|
|
||||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
|
|
||||||
|
|
||||||
- name: Setup GCC Toolchain
|
|
||||||
if: matrix.gcc_toolchain
|
|
||||||
run: |
|
|
||||||
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
|
|
||||||
echo "GCC_TOOLCHAIN_ROOT=$GCC_TOOLCHAIN_ROOT" >> $GITHUB_ENV
|
|
||||||
if ! command -v dpkg-architecture; then
|
|
||||||
apt-get install -y dpkg-dev
|
|
||||||
fi
|
|
||||||
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
|
|
||||||
mkdir -p "$GCC_TOOLCHAIN_ROOT"
|
|
||||||
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
|
|
||||||
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
|
|
||||||
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
|
|
||||||
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
|
|
||||||
|
|
||||||
- name: Setup multiarch
|
|
||||||
if: matrix.multiarch
|
|
||||||
env:
|
|
||||||
BDDE_DISTRO: ${{matrix.distro}}
|
|
||||||
BDDE_EDITION: ${{matrix.edition}}
|
|
||||||
BDDE_ARCH: ${{matrix.arch}}
|
|
||||||
run: ci/github/setup_bdde.sh
|
|
||||||
|
|
||||||
- name: Setup Boost
|
|
||||||
env:
|
|
||||||
B2_ADDRESS_MODEL: ${{matrix.address-model}}
|
|
||||||
B2_COMPILER: ${{matrix.compiler}}
|
|
||||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
|
||||||
B2_SANITIZE: ${{matrix.sanitize}}
|
|
||||||
B2_STDLIB: ${{matrix.stdlib}}
|
|
||||||
# More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys.
|
|
||||||
# B2_DEFINES: ${{matrix.defines}}
|
|
||||||
# Variables set here (to non-empty) will override the top-level environment variables, e.g.
|
|
||||||
# B2_VARIANT: ${{matrix.variant}}
|
|
||||||
# Set the (B2) target(s) to build, defaults to the test folder of the current library
|
|
||||||
# Can alternatively be done like this in the build step or in the build command of the build step, e.g. `run: B2_TARGETS=libs/$SELF/doc ci/build.sh`
|
|
||||||
# B2_TARGETS: libs/foo/test//bar
|
|
||||||
run: source ci/github/install.sh
|
|
||||||
|
|
||||||
- name: Setup coverage collection
|
|
||||||
if: matrix.coverage
|
|
||||||
run: ci/github/codecov.sh "setup"
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
if: '!matrix.coverity'
|
|
||||||
run: ci/build.sh
|
|
||||||
|
|
||||||
- name: Upload coverage
|
|
||||||
if: matrix.coverage
|
|
||||||
run: ci/codecov.sh "upload"
|
|
||||||
env:
|
|
||||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
- name: Run coverity
|
|
||||||
if: matrix.coverity && github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'master')
|
|
||||||
run: ci/github/coverity.sh
|
|
||||||
env:
|
|
||||||
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
|
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
|
||||||
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||||
|
|
||||||
windows:
|
antora:
|
||||||
defaults:
|
name: Antora docs
|
||||||
run:
|
|
||||||
shell: cmd
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- { toolset: msvc-14.0, cxxstd: '14,latest', addrmd: '32,64', os: windows-2019 }
|
- { name: Windows, os: windows-latest }
|
||||||
- { toolset: msvc-14.2, cxxstd: '14,17,20', addrmd: '32,64', os: windows-2019 }
|
- { name: Ubuntu, os: ubuntu-latest }
|
||||||
- { toolset: msvc-14.3, cxxstd: '14,17,20,latest',addrmd: '32,64', os: windows-2022 }
|
- { name: macOS, os: macos-15 }
|
||||||
- { name: Collect coverage, coverage: yes,
|
|
||||||
toolset: msvc-14.3, cxxstd: 'latest', addrmd: '64', os: windows-2022 }
|
|
||||||
- { toolset: clang-win, cxxstd: '14,17,latest', addrmd: '32,64', os: windows-2022 }
|
|
||||||
- { toolset: gcc, cxxstd: '11,14,17,2a', addrmd: '64', os: windows-2019 }
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Fetch Boost.CI
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: boostorg/boost-ci
|
|
||||||
ref: master
|
|
||||||
path: boost-ci-cloned
|
|
||||||
- name: Get CI scripts folder
|
|
||||||
run: |
|
|
||||||
REM Copy ci folder if not testing Boost.CI
|
|
||||||
if "%GITHUB_REPOSITORY%" == "%GITHUB_REPOSITORY:boost-ci=%" xcopy /s /e /q /i /y boost-ci-cloned\ci .\ci
|
|
||||||
rmdir /s /q boost-ci-cloned
|
|
||||||
|
|
||||||
- name: Setup Boost
|
|
||||||
run: ci\github\install.bat
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
if: '!matrix.coverage'
|
|
||||||
run: ci\build.bat
|
|
||||||
env:
|
|
||||||
B2_TOOLSET: ${{matrix.toolset}}
|
|
||||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
|
||||||
B2_ADDRESS_MODEL: ${{matrix.addrmd}}
|
|
||||||
|
|
||||||
- name: Collect coverage
|
|
||||||
shell: powershell
|
|
||||||
if: matrix.coverage
|
|
||||||
run: ci\opencppcoverage.ps1
|
|
||||||
env:
|
|
||||||
B2_TOOLSET: ${{matrix.toolset}}
|
|
||||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
|
||||||
B2_ADDRESS_MODEL: ${{matrix.addrmd}}
|
|
||||||
|
|
||||||
- name: Upload coverage
|
|
||||||
if: matrix.coverage
|
|
||||||
uses: codecov/codecov-action@v5
|
|
||||||
with:
|
|
||||||
disable_search: true
|
|
||||||
fail_ci_if_error: true
|
|
||||||
files: __out/cobertura.xml
|
|
||||||
name: github-actions
|
|
||||||
token: ${{secrets.CODECOV_TOKEN}}
|
|
||||||
verbose: true
|
|
||||||
|
|
||||||
MSYS2:
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: msys2 {0}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- { sys: MINGW32, compiler: gcc, cxxstd: '11,17,20' }
|
|
||||||
- { sys: MINGW64, compiler: gcc, cxxstd: '11,17,20' }
|
|
||||||
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup MSYS2 environment
|
|
||||||
uses: msys2/setup-msys2@v2
|
|
||||||
with:
|
|
||||||
msystem: ${{matrix.sys}}
|
|
||||||
update: true
|
|
||||||
install: git python
|
|
||||||
pacboy: gcc:p cmake:p ninja:p
|
|
||||||
|
|
||||||
- name: Fetch Boost.CI
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: boostorg/boost-ci
|
|
||||||
ref: master
|
|
||||||
path: boost-ci-cloned
|
|
||||||
- name: Get CI scripts folder
|
|
||||||
run: |
|
|
||||||
# Copy ci folder if not testing Boost.CI
|
|
||||||
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
|
|
||||||
rm -rf boost-ci-cloned
|
|
||||||
|
|
||||||
- name: Setup Boost
|
|
||||||
env:
|
|
||||||
B2_COMPILER: ${{matrix.compiler}}
|
|
||||||
B2_CXXSTD: ${{matrix.cxxstd}}
|
|
||||||
B2_SANITIZE: ${{matrix.sanitize}}
|
|
||||||
B2_STDLIB: ${{matrix.stdlib}}
|
|
||||||
run: ci/github/install.sh
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: ci/build.sh
|
|
||||||
|
|
||||||
# Run also the CMake tests to avoid having to setup another matrix for CMake on MSYS
|
|
||||||
- name: Run CMake tests
|
|
||||||
run: |
|
|
||||||
cd "$BOOST_ROOT"
|
|
||||||
mkdir __build_cmake_test__ && cd __build_cmake_test__
|
|
||||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
|
|
||||||
cmake --build . --target tests --config Debug -j$B2_JOBS
|
|
||||||
ctest --output-on-failure --build-config Debug
|
|
||||||
|
|
||||||
CMake:
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- { os: ubuntu-20.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' }
|
|
||||||
- { os: ubuntu-20.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' }
|
|
||||||
- { os: windows-2019, build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' }
|
|
||||||
- { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' }
|
|
||||||
|
|
||||||
timeout-minutes: 120
|
|
||||||
runs-on: ${{matrix.os}}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Install packages
|
||||||
- name: Fetch Boost.CI
|
uses: alandefreitas/cpp-actions/package-install@v1.8.8
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
repository: boostorg/boost-ci
|
apt-get: git cmake
|
||||||
ref: master
|
|
||||||
path: boost-ci-cloned
|
|
||||||
- name: Get CI scripts folder
|
|
||||||
run: |
|
|
||||||
# Copy ci folder if not testing Boost.CI
|
|
||||||
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
|
|
||||||
rm -rf boost-ci-cloned
|
|
||||||
- name: Setup Boost
|
|
||||||
env: {B2_DONT_BOOTSTRAP: 1}
|
|
||||||
run: source ci/github/install.sh
|
|
||||||
|
|
||||||
- name: Run CMake tests
|
- name: Clone Boost.DynamicBitset
|
||||||
run: |
|
uses: actions/checkout@v4
|
||||||
cd "$BOOST_ROOT"
|
|
||||||
mkdir __build_cmake_test__ && cd __build_cmake_test__
|
|
||||||
cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
|
|
||||||
cmake --build . --target tests --config ${{matrix.build_type}} -j$B2_JOBS
|
|
||||||
ctest --output-on-failure --build-config ${{matrix.build_type}}
|
|
||||||
|
|
||||||
- name: Run CMake subdir tests
|
- name: Clone Boost
|
||||||
run: |
|
uses: alandefreitas/cpp-actions/boost-clone@v1.8.8
|
||||||
cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
|
id: boost-clone
|
||||||
[ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_subdir_test"
|
with:
|
||||||
cd "$cmake_test_folder"
|
branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }}
|
||||||
mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
|
boost-dir: ../boost-source
|
||||||
cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=OFF -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} ..
|
scan-modules-dir: .
|
||||||
cmake --build . --config ${{matrix.build_type}} -j$B2_JOBS
|
scan-modules-ignore: dynamic_bitset
|
||||||
ctest --output-on-failure --build-config ${{matrix.build_type}}
|
|
||||||
|
|
||||||
- name: Install Library
|
- uses: actions/setup-node@v4
|
||||||
run: |
|
with:
|
||||||
cd "$BOOST_ROOT"
|
node-version: 18
|
||||||
mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
|
|
||||||
cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON ..
|
|
||||||
cmake --build . --target install --config ${{matrix.build_type}} -j$B2_JOBS
|
|
||||||
- name: Run CMake install tests
|
|
||||||
run: |
|
|
||||||
cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
|
|
||||||
[ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_install_test"
|
|
||||||
cd "$cmake_test_folder"
|
|
||||||
mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
|
|
||||||
cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_PREFIX_PATH=~/.local ..
|
|
||||||
cmake --build . --config ${{matrix.build_type}} -j$B2_JOBS
|
|
||||||
ctest --output-on-failure --build-config ${{matrix.build_type}}
|
|
||||||
|
|
||||||
|
- 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_antora.sh
|
||||||
|
|
||||||
|
# Antora returns zero even if it fails, so we check if the site directory exists.
|
||||||
|
if [ ! -d "html" ]
|
||||||
|
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/html
|
||||||
|
|||||||
@@ -1,26 +1,67 @@
|
|||||||
# Generated by `boostdep --cmake dynamic_bitset`
|
# Generated by `boostdep --cmake dynamic_bitset`
|
||||||
# Copyright 2020 Peter Dimov
|
# Copyright 2020 Peter Dimov
|
||||||
|
# Copyright 2025 Gennaro Prota
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# https://www.boost.org/LICENSE_1_0.txt
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5...3.16)
|
cmake_minimum_required(VERSION 3.5...3.16)
|
||||||
|
|
||||||
project(boost_dynamic_bitset VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
project(boost_dynamic_bitset VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
|
set(BOOST_DYNAMIC_BITSET_IS_ROOT OFF)
|
||||||
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
set(BOOST_DYNAMIC_BITSET_IS_ROOT ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_library(boost_dynamic_bitset INTERFACE)
|
add_library(boost_dynamic_bitset INTERFACE)
|
||||||
add_library(Boost::dynamic_bitset ALIAS boost_dynamic_bitset)
|
add_library(Boost::dynamic_bitset ALIAS boost_dynamic_bitset)
|
||||||
|
|
||||||
target_include_directories(boost_dynamic_bitset INTERFACE include)
|
target_include_directories(boost_dynamic_bitset INTERFACE include)
|
||||||
|
|
||||||
|
if (BOOST_DYNAMIC_BITSET_IS_ROOT)
|
||||||
|
# This means this script will be executed as the root CMakeLists.txt
|
||||||
|
# so the Boost:: targets are not available unless we explicitly include
|
||||||
|
# them here. MrDocs executes this script as root too.
|
||||||
|
if (NOT DEFINED BOOST_SRC_DIR AND DEFINED ENV{BOOST_SRC_DIR})
|
||||||
|
set(DEFAULT_BOOST_SRC_DIR "$ENV{BOOST_SRC_DIR}")
|
||||||
|
else ()
|
||||||
|
set(DEFAULT_BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||||
|
endif ()
|
||||||
|
set(BOOST_SRC_DIR ${DEFAULT_BOOST_SRC_DIR} CACHE STRING "Boost source dir to use when running CMake from this directory")
|
||||||
|
if (NOT IS_ABSOLUTE ${BOOST_SRC_DIR})
|
||||||
|
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_SRC_DIR}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Validate BOOST_SRC_DIR
|
||||||
|
set(BOOST_SRC_DIR_IS_VALID ON)
|
||||||
|
foreach (F "CMakeLists.txt" "Jamroot" "boost-build.jam" "bootstrap.sh" "libs")
|
||||||
|
if (NOT EXISTS "${BOOST_SRC_DIR}/${F}")
|
||||||
|
message(STATUS "${BOOST_SRC_DIR}/${F} does not exist. Fallback to find_package.")
|
||||||
|
set(BOOST_SRC_DIR_IS_VALID OFF)
|
||||||
|
break()
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
if (NOT BOOST_SRC_DIR_IS_VALID)
|
||||||
|
message(FATAL_ERROR "BOOST_SRC_DIR is not valid. Please set it to the root of a Boost checkout.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# If BOOST_SRC_DIR is valid, fallback to find_package
|
||||||
|
set(CMAKE_FOLDER Dependencies)
|
||||||
|
set(BOOST_INCLUDE_LIBRARIES assert config container_hash core throw_exception)
|
||||||
|
set(BOOST_EXCLUDE_LIBRARIES dynamic_bitset)
|
||||||
|
set(PREV_BUILD_TESTING ${BUILD_TESTING})
|
||||||
|
set(BUILD_TESTING OFF CACHE BOOL "Build the tests." FORCE)
|
||||||
|
add_subdirectory(${BOOST_SRC_DIR} Dependencies/boost EXCLUDE_FROM_ALL)
|
||||||
|
set(BUILD_TESTING ${PREV_BUILD_TESTING} CACHE BOOL "Build the tests." FORCE)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOOST_SRC_DIR}/tools/cmake/include")
|
||||||
|
unset(CMAKE_FOLDER)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(boost_dynamic_bitset
|
target_link_libraries(boost_dynamic_bitset
|
||||||
INTERFACE
|
INTERFACE
|
||||||
Boost::assert
|
Boost::assert
|
||||||
Boost::config
|
Boost::config
|
||||||
Boost::container_hash
|
Boost::container_hash
|
||||||
Boost::core
|
Boost::core
|
||||||
Boost::integer
|
|
||||||
Boost::move
|
|
||||||
Boost::static_assert
|
|
||||||
Boost::throw_exception
|
Boost::throw_exception
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,3 +71,26 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
|||||||
|
|
||||||
endif()
|
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})
|
||||||
|
|
||||||
|
# This is to get the documentation of the constructor from basic_string_view.
|
||||||
|
set_target_properties(dynamic_bitset_mrdocs_target PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES)
|
||||||
|
|
||||||
|
# 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()
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -1,4 +1,4 @@
|
|||||||
DynamicBitset, part of collection of the [Boost C++ Libraries](https://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
|
### License
|
||||||
|
|
||||||
@@ -9,26 +9,17 @@ Distributed under the [Boost Software License, Version 1.0](https://www.boost.or
|
|||||||
* C++11
|
* C++11
|
||||||
* Header-only
|
* Header-only
|
||||||
|
|
||||||
### Build Status
|
### Build status
|
||||||
|
|
||||||
<!-- boost-ci/tools/makebadges.sh --project dynamic_bitset --appveyor n7bki5ka3v918r5r --codecov PVG5jth1ez --coverity 16167 -->
|
<!-- boost-ci/tools/makebadges.sh --project dynamic_bitset --appveyor n7bki5ka3v918r5r --codecov PVG5jth1ez --coverity 16167 -->
|
||||||
| Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
|
| 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)
|
| [`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)
|
| [`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)
|
||||||
|
|
||||||
### Directories
|
|
||||||
|
|
||||||
| Name | Purpose |
|
|
||||||
| ----------- | ------------------------------ |
|
|
||||||
| `example` | examples |
|
|
||||||
| `doc` | documentation |
|
|
||||||
| `include` | headers |
|
|
||||||
| `test` | unit tests |
|
|
||||||
|
|
||||||
### More information
|
### More information
|
||||||
|
|
||||||
* [Ask questions](https://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-dynamic_bitset)
|
* [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 Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
|
* [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 **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).
|
* 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.
|
* 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.
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ constant boost_dependencies :
|
|||||||
/boost/config//boost_config
|
/boost/config//boost_config
|
||||||
/boost/container_hash//boost_container_hash
|
/boost/container_hash//boost_container_hash
|
||||||
/boost/core//boost_core
|
/boost/core//boost_core
|
||||||
/boost/integer//boost_integer
|
|
||||||
/boost/move//boost_move
|
|
||||||
/boost/static_assert//boost_static_assert
|
|
||||||
/boost/throw_exception//boost_throw_exception ;
|
/boost/throw_exception//boost_throw_exception ;
|
||||||
|
|
||||||
project /boost/dynamic_bitset
|
project /boost/dynamic_bitset
|
||||||
|
|||||||
57
doc/Jamfile.v2
Normal file
57
doc/Jamfile.v2
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import generate ;
|
||||||
|
import path ;
|
||||||
|
import property-set ;
|
||||||
|
import virtual-target ;
|
||||||
|
|
||||||
|
path-constant HERE : . ;
|
||||||
|
|
||||||
|
make html/index.html : build_antora.sh : @run-script ;
|
||||||
|
generate files-to-install : html/index.html : <generating-rule>@delayed-glob ;
|
||||||
|
install install
|
||||||
|
: files-to-install
|
||||||
|
: <location>html
|
||||||
|
<install-source-root>html/dynamic_bitset
|
||||||
|
;
|
||||||
|
explicit html/index.html files-to-install ;
|
||||||
|
|
||||||
|
# this runs the antora script
|
||||||
|
actions run-script
|
||||||
|
{
|
||||||
|
bash $(>)
|
||||||
|
}
|
||||||
|
|
||||||
|
# this globs after its sources are created
|
||||||
|
rule delayed-glob ( project name : property-set : sources * )
|
||||||
|
{
|
||||||
|
for local src in $(sources)
|
||||||
|
{
|
||||||
|
# the next line causes the source to be generated immediately
|
||||||
|
# and not later (which it normally would)
|
||||||
|
UPDATE_NOW [ $(src).actualize ] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# we need to construct the path to the globbed directory;
|
||||||
|
# this path would be <current-project>/antora
|
||||||
|
local root = [ path.root html [ $(project).location ] ] ;
|
||||||
|
local files ;
|
||||||
|
|
||||||
|
# actual globbing happens here
|
||||||
|
for local file in [ path.glob-tree $(root) : * ]
|
||||||
|
{
|
||||||
|
# we have to skip directories, because our match expression accepts anything
|
||||||
|
if [ CHECK_IF_FILE $(file) ]
|
||||||
|
{
|
||||||
|
# we construct a list of targets to copy
|
||||||
|
files += [ virtual-target.from-file $(file:D=) : $(file:D) : $(project) ] ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# we prepend empty usage requirements to the result
|
||||||
|
return [ property-set.empty ] $(files) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
alias boostdoc ;
|
||||||
|
explicit boostdoc ;
|
||||||
|
alias boostrelease : install ;
|
||||||
|
explicit boostrelease ;
|
||||||
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
|
||||||
31
doc/build_antora.sh
Executable file
31
doc/build_antora.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#! /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
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( dirname -- "${BASH_SOURCE[0]}" )
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
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"
|
||||||
57
doc/local-playbook.yml
Normal file
57
doc/local-playbook.yml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# ============================================================================
|
||||||
|
# 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
|
||||||
|
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}'
|
||||||
|
|
||||||
|
output:
|
||||||
|
dir: html
|
||||||
|
|
||||||
|
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'
|
||||||
|
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]
|
||||||
72
doc/modules/ROOT/pages/index.adoc
Normal file
72
doc/modules/ROOT/pages/index.adoc
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Copyright 2001 Jeremy Siek
|
||||||
|
// Copyright 2003-2004, 2008, 2025 Gennaro Prota
|
||||||
|
// Copyright 2014 Ahmed Charles
|
||||||
|
// Copyright 2014 Riccardo Marcangelo
|
||||||
|
// Copyright 2018 Evgeny Shulgin
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
Because of the proxy reference type, `dynamic_bitset` is not a
|
||||||
|
https://en.cppreference.com/w/cpp/named_req/Container.html[Container] and its
|
||||||
|
iterators do not satisfy the requirements for a LegacyForwardIterator. This
|
||||||
|
means that its iterators are not usable with many standard algorithms. However,
|
||||||
|
`dynamic_bitset` provides C++20 iterators which can be used with ranges.
|
||||||
|
|
||||||
|
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::bit_iterator_base'
|
||||||
|
- 'boost::bit_iterator'
|
||||||
|
- 'boost::const_bit_iterator'
|
||||||
|
- 'boost::detail'
|
||||||
|
- 'boost::detail::**'
|
||||||
|
- 'boost::to_string_helper'
|
||||||
|
- 'boost::dynamic_bitset::bit_appender'
|
||||||
|
- 'boost::dynamic_bitset::buffer_type'
|
||||||
|
file-patterns:
|
||||||
|
- '*.hpp'
|
||||||
|
multipage: true
|
||||||
|
generator: adoc
|
||||||
2460
doc/package-lock.json
generated
Normal file
2460
doc/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
doc/package.json
Normal file
15
doc/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"devDependencies": {
|
||||||
|
"@antora/cli": "3.1.10",
|
||||||
|
"@antora/site-generator": "3.1.10",
|
||||||
|
"antora": "3.1.10"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@antora/expand-path-helper": "^2.0.0",
|
||||||
|
"@antora/lunr-extension": "^1.0.0-alpha.8",
|
||||||
|
"@asciidoctor/tabs": "^1.0.0-beta.3",
|
||||||
|
"@cppalliance/antora-cpp-reference-extension": "^0.0.8",
|
||||||
|
"@cppalliance/antora-cpp-tagfiles-extension": "^0.0.5",
|
||||||
|
"@cppalliance/asciidoctor-boost-links": "^0.0.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
The documentation for the dynamic_bitset library is the top-level index.html file.
|
To build the documentation, run build_docs.sh.
|
||||||
|
|||||||
1835
dynamic_bitset.html
1835
dynamic_bitset.html
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,6 @@
|
|||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// An example of setting and reading some bits. Note that operator[]
|
// An example of setting and reading some bits. Note that operator[]
|
||||||
// goes from the least-significant bit at 0 to the most significant
|
// goes from the least-significant bit at 0 to the most significant
|
||||||
// bit at size()-1. The operator<< for dynamic_bitset prints the
|
// bit at size()-1. The operator<< for dynamic_bitset prints the
|
||||||
@@ -17,10 +15,11 @@
|
|||||||
// 10011
|
// 10011
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "boost/dynamic_bitset.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/dynamic_bitset.hpp>
|
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<> x( 5 ); // all 0's by default
|
boost::dynamic_bitset<> x( 5 ); // all 0's by default
|
||||||
x[ 0 ] = 1;
|
x[ 0 ] = 1;
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
// bits(2) = 10
|
// bits(2) = 10
|
||||||
// bits(3) = 11
|
// bits(3) = 11
|
||||||
|
|
||||||
|
#include "boost/dynamic_bitset.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/dynamic_bitset.hpp>
|
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
const boost::dynamic_bitset<> b0( 2, 0ul );
|
const boost::dynamic_bitset<> b0( 2, 0ul );
|
||||||
std::cout << "bits(0) = " << b0 << std::endl;
|
std::cout << "bits(0) = " << b0 << std::endl;
|
||||||
|
|||||||
@@ -19,14 +19,12 @@
|
|||||||
// Shifted left by 1: 001000100
|
// Shifted left by 1: 001000100
|
||||||
// Shifted right by 1: 010010001
|
// Shifted right by 1: 010010001
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "boost/dynamic_bitset.hpp"
|
#include "boost/dynamic_bitset.hpp"
|
||||||
|
|
||||||
#include <ostream>
|
|
||||||
#include <iostream>
|
#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;
|
std::cout << "mask = " << mask << std::endl;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
// Copyright (c) 2003-2006, 2008, 2025 Gennaro Prota
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -13,13 +13,19 @@
|
|||||||
#define BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
|
#define BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
|
||||||
|
|
||||||
#include "boost/config.hpp"
|
#include "boost/config.hpp"
|
||||||
#include "boost/detail/workaround.hpp"
|
|
||||||
|
|
||||||
// no-op function to workaround gcc bug c++/8419
|
// no-op function to workaround gcc bug c++/8419
|
||||||
//
|
//
|
||||||
namespace boost { namespace detail {
|
namespace boost {
|
||||||
template <typename T> T make_non_const(T t) { return t; }
|
namespace detail {
|
||||||
}}
|
template< typename T >
|
||||||
|
T
|
||||||
|
make_non_const( T t )
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined( __GNUC__ )
|
#if defined( __GNUC__ )
|
||||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( expr ) \
|
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( expr ) \
|
||||||
@@ -28,40 +34,18 @@ namespace boost { namespace detail {
|
|||||||
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( expr ) ( expr )
|
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( expr ) ( expr )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
#if ! defined( BOOST_NO_CXX11_HDR_FUNCTIONAL ) && ! defined( BOOST_DYNAMIC_BITSET_NO_STD_HASH )
|
||||||
#if (defined BOOST_BORLANDC && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))) \
|
# define BOOST_DYNAMIC_BITSET_SPECIALIZE_STD_HASH
|
||||||
|| (defined BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
|
||||||
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if we can't use friends then we simply expose private members
|
#if ( defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L
|
||||||
//
|
# define BOOST_DYNAMIC_BITSET_USE_CPP17_OR_LATER
|
||||||
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
|
|
||||||
#define BOOST_DYNAMIC_BITSET_PRIVATE public
|
|
||||||
#else
|
|
||||||
#define BOOST_DYNAMIC_BITSET_PRIVATE private
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// A couple of macros to cope with libraries without locale
|
#if ( defined( _MSVC_LANG ) && _MSVC_LANG >= 202002L ) || __cplusplus >= 202002L
|
||||||
// support. The first macro must be used to declare a reference
|
# define BOOST_DYNAMIC_BITSET_CONSTEXPR20 constexpr
|
||||||
// to a ctype facet. The second one to widen a char by using
|
|
||||||
// that ctype object. If facets and locales aren't available
|
|
||||||
// the first macro is a no-op and the second one just expands
|
|
||||||
// to its parameter c.
|
|
||||||
//
|
|
||||||
#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_WIDEN_CHAR(fac, c) \
|
|
||||||
(fac.widen(c))
|
|
||||||
#else
|
#else
|
||||||
|
# define BOOST_DYNAMIC_BITSET_CONSTEXPR20
|
||||||
#define BOOST_DYNAMIC_BITSET_CTYPE_FACET(ch, name, loc) /**/
|
|
||||||
#define BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, c) c
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
// Copyright (c) 2003-2006, 2008, 2025 Gennaro Prota
|
||||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||||
// (glenjofe@gmail.com)
|
// (glenjofe@gmail.com)
|
||||||
// Copyright (c) 2018 Evgeny Shulgin
|
// Copyright (c) 2018 Evgeny Shulgin
|
||||||
@@ -16,257 +16,108 @@
|
|||||||
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||||
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include "boost/config.hpp"
|
#include <memory>
|
||||||
#include "boost/detail/workaround.hpp"
|
#include <type_traits>
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <utility>
|
||||||
|
|
||||||
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
|
|
||||||
#include <intrin.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
namespace dynamic_bitset_impl {
|
namespace dynamic_bitset_impl {
|
||||||
|
|
||||||
template<class T>
|
template< typename AllocatorOrContainer, typename Block >
|
||||||
struct max_limit {
|
class is_container
|
||||||
BOOST_STATIC_CONSTEXPR T value = static_cast<T>(-1);
|
{
|
||||||
|
private:
|
||||||
|
template< typename U >
|
||||||
|
static decltype( std::declval< U >().resize( std::size_t{} ), std::declval< U >()[ 0 ], typename U::value_type(), std::is_same< typename U::value_type, Block >{}, std::true_type{} ) test( int );
|
||||||
|
|
||||||
|
template< typename >
|
||||||
|
static std::false_type test( ... );
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr bool value = decltype( test< AllocatorOrContainer >( 0 ) )::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template< typename AllocatorOrContainer, bool IsContainer >
|
||||||
BOOST_CONSTEXPR_OR_CONST T max_limit<T>::value;
|
class allocator_type_extractor_impl;
|
||||||
|
|
||||||
// Gives (read-)access to the object representation
|
template< typename AllocatorOrContainer >
|
||||||
// of an object of type T (3.9p4). CANNOT be used
|
class allocator_type_extractor_impl< AllocatorOrContainer, false >
|
||||||
// on a base sub-object
|
|
||||||
//
|
|
||||||
template <typename T>
|
|
||||||
inline const unsigned char * object_representation (T* p)
|
|
||||||
{
|
{
|
||||||
return static_cast<const unsigned char *>(static_cast<const void *>(p));
|
public:
|
||||||
}
|
typedef AllocatorOrContainer type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename AllocatorOrContainer >
|
||||||
|
class allocator_type_extractor_impl< AllocatorOrContainer, true >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename AllocatorOrContainer::allocator_type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename AllocatorOrContainer, typename Block >
|
||||||
|
class allocator_type_extractor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename allocator_type_extractor_impl<
|
||||||
|
AllocatorOrContainer,
|
||||||
|
is_container< AllocatorOrContainer, Block >::value >::type type;
|
||||||
|
};
|
||||||
|
|
||||||
template< typename T, int amount, int width /* = default */ >
|
template< typename T, int amount, int width /* = default */ >
|
||||||
struct shifter
|
struct shifter
|
||||||
{
|
{
|
||||||
static void left_shift(T & v) {
|
static BOOST_DYNAMIC_BITSET_CONSTEXPR20 void
|
||||||
|
left_shift( T & v )
|
||||||
|
{
|
||||||
amount >= width ? ( v = 0 )
|
amount >= width ? ( v = 0 )
|
||||||
: ( v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( amount ) );
|
: ( v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT( amount ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------- count function implementation --------------
|
|
||||||
|
|
||||||
typedef unsigned char byte_type;
|
|
||||||
|
|
||||||
// These two entities
|
|
||||||
//
|
|
||||||
// enum mode { access_by_bytes, access_by_blocks };
|
|
||||||
// template <mode> struct mode_to_type {};
|
|
||||||
//
|
|
||||||
// were removed, since the regression logs (as of 24 Aug 2008)
|
|
||||||
// showed that several compilers had troubles with recognizing
|
|
||||||
//
|
|
||||||
// const mode m = access_by_bytes
|
|
||||||
//
|
|
||||||
// as a constant expression
|
|
||||||
//
|
|
||||||
// * So, we'll use bool, instead of enum *.
|
|
||||||
//
|
|
||||||
template< bool value >
|
template< bool value >
|
||||||
struct value_to_type
|
struct value_to_type
|
||||||
{
|
{
|
||||||
value_to_type() {}
|
|
||||||
};
|
};
|
||||||
const bool access_by_bytes = true;
|
|
||||||
const bool access_by_blocks = false;
|
|
||||||
|
|
||||||
|
|
||||||
// the table: wrapped in a class template, so
|
|
||||||
// that it is only instantiated if/when needed
|
|
||||||
//
|
|
||||||
template <bool dummy_name = true>
|
|
||||||
struct count_table { static const byte_type table[]; };
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct count_table<false> { /* no table */ };
|
|
||||||
|
|
||||||
|
|
||||||
const unsigned int table_width = 8;
|
|
||||||
template <bool b>
|
|
||||||
const byte_type count_table<b>::table[] =
|
|
||||||
{
|
|
||||||
// Automatically generated by GPTableGen.exe v.1.0
|
|
||||||
//
|
|
||||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
||||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
||||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
||||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
||||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
||||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
||||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
||||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Some platforms have fast popcount operation, that allow us to implement
|
|
||||||
// counting bits much more efficiently
|
|
||||||
//
|
|
||||||
template <typename ValueType>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount(ValueType value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
std::size_t num = 0u;
|
|
||||||
while (value) {
|
|
||||||
num += count_table<>::table[value & ((1u<<table_width) - 1)];
|
|
||||||
value >>= table_width;
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))) \
|
|
||||||
&& (defined(__POPCNT__) || defined(__AVX__))
|
|
||||||
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(__popcnt16(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(__popcnt(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<unsigned __int64>(unsigned __int64 value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
#if defined(_M_X64)
|
|
||||||
return static_cast<std::size_t>(__popcnt64(value));
|
|
||||||
#else
|
|
||||||
return static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value))) + static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value >> 32)));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
|
|
||||||
|
|
||||||
// Note: gcc builtins are implemented by compiler runtime when the target CPU may not support the necessary instructions
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return static_cast<unsigned int>(__builtin_popcount(static_cast<unsigned int>(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return static_cast<unsigned int>(__builtin_popcount(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<unsigned long>(unsigned long value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return static_cast<unsigned int>(__builtin_popcountl(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
BOOST_FORCEINLINE std::size_t popcount<boost::ulong_long_type>(boost::ulong_long_type value) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return static_cast<unsigned int>(__builtin_popcountll(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// overload for access by blocks
|
|
||||||
//
|
|
||||||
template <typename Iterator, typename ValueType>
|
|
||||||
inline std::size_t do_count(Iterator first, std::size_t length, ValueType,
|
|
||||||
value_to_type<access_by_blocks>*)
|
|
||||||
{
|
|
||||||
std::size_t num1 = 0u, num2 = 0u;
|
|
||||||
while (length >= 2u) {
|
|
||||||
num1 += popcount<ValueType>(*first);
|
|
||||||
++first;
|
|
||||||
num2 += popcount<ValueType>(*first);
|
|
||||||
++first;
|
|
||||||
length -= 2u;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (length > 0u)
|
|
||||||
num1 += popcount<ValueType>(*first);
|
|
||||||
|
|
||||||
return num1 + num2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// overload for access by bytes
|
|
||||||
//
|
|
||||||
template <typename Iterator>
|
|
||||||
inline std::size_t do_count(Iterator first, std::size_t length,
|
|
||||||
int /*dummy param*/,
|
|
||||||
value_to_type<access_by_bytes>*)
|
|
||||||
{
|
|
||||||
if (length > 0u) {
|
|
||||||
const byte_type* p = object_representation(&*first);
|
|
||||||
length *= sizeof(*first);
|
|
||||||
|
|
||||||
return do_count(p, length, static_cast<byte_type>(0u),
|
|
||||||
static_cast< value_to_type<access_by_blocks>* >(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0u;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// Some library implementations simply return a dummy
|
|
||||||
// value such as
|
|
||||||
//
|
|
||||||
// size_type(-1) / sizeof(T)
|
|
||||||
//
|
|
||||||
// from vector<>::max_size. This tries to get more
|
|
||||||
// meaningful info.
|
|
||||||
//
|
|
||||||
template <typename T>
|
|
||||||
inline typename T::size_type vector_max_size_workaround(const T & v)
|
|
||||||
BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
typedef typename T::allocator_type allocator_type;
|
|
||||||
|
|
||||||
const allocator_type& alloc = v.get_allocator();
|
|
||||||
|
|
||||||
typename boost::allocator_size_type<allocator_type>::type alloc_max =
|
|
||||||
boost::allocator_max_size(alloc);
|
|
||||||
|
|
||||||
const typename T::size_type container_max = v.max_size();
|
|
||||||
|
|
||||||
return alloc_max < container_max ? alloc_max : container_max;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for static_asserts
|
// for static_asserts
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct allowed_block_type {
|
struct allowed_block_type
|
||||||
enum { value = T(-1) > 0 }; // ensure T has no sign
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
value = T( -1 ) > 0 // ensure T has no sign
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct allowed_block_type<bool> {
|
struct allowed_block_type< bool >
|
||||||
enum { value = false };
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
value = false
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct is_numeric {
|
struct is_numeric
|
||||||
enum { value = false };
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
value = false
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BOOST_dynamic_bitset_is_numeric( x ) \
|
#define BOOST_dynamic_bitset_is_numeric( x ) \
|
||||||
template<> \
|
template<> \
|
||||||
struct is_numeric< x > { \
|
struct is_numeric< x > \
|
||||||
enum { value = true }; \
|
{ \
|
||||||
|
enum \
|
||||||
|
{ \
|
||||||
|
value = true \
|
||||||
|
}; \
|
||||||
} /**/
|
} /**/
|
||||||
|
|
||||||
BOOST_dynamic_bitset_is_numeric( bool );
|
BOOST_dynamic_bitset_is_numeric( bool );
|
||||||
@@ -277,19 +128,16 @@ namespace boost {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_dynamic_bitset_is_numeric( signed char );
|
BOOST_dynamic_bitset_is_numeric( signed char );
|
||||||
BOOST_dynamic_bitset_is_numeric(short int);
|
BOOST_dynamic_bitset_is_numeric( short );
|
||||||
BOOST_dynamic_bitset_is_numeric( int );
|
BOOST_dynamic_bitset_is_numeric( int );
|
||||||
BOOST_dynamic_bitset_is_numeric(long int);
|
BOOST_dynamic_bitset_is_numeric( long );
|
||||||
|
BOOST_dynamic_bitset_is_numeric( long long );
|
||||||
|
|
||||||
BOOST_dynamic_bitset_is_numeric( unsigned char );
|
BOOST_dynamic_bitset_is_numeric( unsigned char );
|
||||||
BOOST_dynamic_bitset_is_numeric( unsigned short );
|
BOOST_dynamic_bitset_is_numeric( unsigned short );
|
||||||
BOOST_dynamic_bitset_is_numeric( unsigned int );
|
BOOST_dynamic_bitset_is_numeric( unsigned int );
|
||||||
BOOST_dynamic_bitset_is_numeric( unsigned long );
|
BOOST_dynamic_bitset_is_numeric( unsigned long );
|
||||||
|
BOOST_dynamic_bitset_is_numeric( unsigned long 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
|
// intentionally omitted
|
||||||
// BOOST_dynamic_bitset_is_numeric(float);
|
// BOOST_dynamic_bitset_is_numeric(float);
|
||||||
@@ -304,4 +152,3 @@ namespace boost {
|
|||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// 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
|
// Copyright (c) 2003-2004, 2008, 2025 Gennaro Prota
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -14,26 +14,23 @@
|
|||||||
#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
|
#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||||
#define 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/assert.hpp"
|
||||||
|
#include "boost/core/bit.hpp"
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
int lowest_bit(T x) {
|
int
|
||||||
|
lowest_bit( T x )
|
||||||
BOOST_ASSERT(x >= 1); // PRE
|
{
|
||||||
|
BOOST_ASSERT( x >= 1 );
|
||||||
// clear all bits on except the rightmost one,
|
|
||||||
// then calculate the logarithm base 2
|
|
||||||
//
|
|
||||||
return boost::integer_log2<T>( x - ( x & (x-1) ) );
|
|
||||||
|
|
||||||
|
return boost::core::countr_zero( static_cast< typename std::make_unsigned< T >::type >( x ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
2237
include/boost/dynamic_bitset/impl/dynamic_bitset.ipp
Normal file
2237
include/boost/dynamic_bitset/impl/dynamic_bitset.ipp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,8 @@
|
|||||||
#ifndef BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
#ifndef BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||||
#define 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/dynamic_bitset/dynamic_bitset.hpp"
|
||||||
#include <boost/core/nvp.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
@@ -22,7 +22,9 @@ namespace boost {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template< typename Ar >
|
template< typename Ar >
|
||||||
static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
|
static void
|
||||||
|
serialize( Ar & ar, dynamic_bitset< Block, Allocator > & bs, unsigned )
|
||||||
|
{
|
||||||
ar & boost::make_nvp( "m_num_bits", bs.m_num_bits )
|
ar & boost::make_nvp( "m_num_bits", bs.m_num_bits )
|
||||||
& boost::make_nvp( "m_bits", bs.m_bits );
|
& boost::make_nvp( "m_bits", bs.m_bits );
|
||||||
}
|
}
|
||||||
@@ -35,7 +37,9 @@ namespace boost {
|
|||||||
namespace serialization {
|
namespace serialization {
|
||||||
|
|
||||||
template< typename Ar, typename Block, typename Allocator >
|
template< typename Ar, typename Block, typename Allocator >
|
||||||
void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned version) {
|
void
|
||||||
|
serialize( Ar & ar, dynamic_bitset< Block, Allocator > & bs, unsigned version )
|
||||||
|
{
|
||||||
dynamic_bitset< Block, Allocator >::serialize_impl::serialize( ar, bs, version );
|
dynamic_bitset< Block, Allocator >::serialize_impl::serialize( ar, bs, version );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,4 +47,3 @@ namespace boost {
|
|||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
template <typename Block = unsigned long,
|
template< typename Block = unsigned long, typename AllocatorOrContainer = std::allocator< Block > >
|
||||||
typename Allocator = std::allocator<Block> >
|
|
||||||
class dynamic_bitset;
|
class dynamic_bitset;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv=refresh content="0; URL=dynamic_bitset.html">
|
<meta http-equiv=refresh content="0; URL=doc/html/index.html">
|
||||||
<title>Automatic redirection</title>
|
<title>Automatic redirection</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Automatic redirection failed, please go to
|
Automatic redirection failed, please go to
|
||||||
<a href="dynamic_bitset.html">dynamic_bitset.html</a>. <hr>
|
<a href="dynamic_bitset.html">doc/html/index.html</a>. <hr>
|
||||||
<p>© Copyright Beman Dawes, 2001</p>
|
<p>© Copyright Beman Dawes, 2001</p>
|
||||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
<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
|
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||||
|
|||||||
17
meta/explicit-failures-markup.xml
Normal file
17
meta/explicit-failures-markup.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<explicit-failures-markup>
|
||||||
|
<library name="dynamic_bitset">
|
||||||
|
<mark-unusable>
|
||||||
|
<toolset name="*c++98"/>
|
||||||
|
<toolset name="*gnu98"/>
|
||||||
|
<toolset name="*c++0x"/>
|
||||||
|
<toolset name="*gnu0x"/>
|
||||||
|
<toolset name="msvc-7.1"/>
|
||||||
|
<toolset name="msvc-8.*"/>
|
||||||
|
<toolset name="msvc-9.*"/>
|
||||||
|
<toolset name="msvc-10.*"/>
|
||||||
|
<toolset name="msvc-11.*"/>
|
||||||
|
<note author="Gennaro Prota">DynamicBitset requires at least C++11.</note>
|
||||||
|
</mark-unusable>
|
||||||
|
</library>
|
||||||
|
</explicit-failures-markup>
|
||||||
@@ -5,13 +5,12 @@
|
|||||||
"Jeremy Siek",
|
"Jeremy Siek",
|
||||||
"Chuck Allison"
|
"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": [
|
"category": [
|
||||||
"Containers"
|
"Data structures"
|
||||||
],
|
],
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
"Jeremy Siek <jeremy.siek -at- gmail.com>"
|
"Gennaro Prota <firstName.lastName -at- gmail.com>"
|
||||||
],
|
],
|
||||||
"cxxstd": "11"
|
"cxxstd": "11"
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Copyright (c) 2001 Jeremy Siek
|
// Copyright (c) 2001 Jeremy Siek
|
||||||
// Copyright (c) 2003-2006 Gennaro Prota
|
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||||
// Copyright (c) 2014 Ahmed Charles
|
// Copyright (c) 2014 Ahmed Charles
|
||||||
// Copyright (c) 2014 Riccardo Marcangelo
|
// Copyright (c) 2014 Riccardo Marcangelo
|
||||||
//
|
//
|
||||||
@@ -14,26 +14,32 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
#include "bitset_test.hpp"
|
#include "bitset_test.hpp"
|
||||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
#include "boost/config.hpp"
|
||||||
#include <boost/limits.hpp>
|
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||||
#include <boost/config.hpp>
|
#include "boost/limits.hpp"
|
||||||
|
|
||||||
#include <boost/config/workaround.hpp>
|
|
||||||
|
|
||||||
#if ! defined( BOOST_NO_CXX11_ALLOCATOR )
|
#if ! defined( BOOST_NO_CXX11_ALLOCATOR )
|
||||||
# include <cstdlib>
|
# include <cstdlib>
|
||||||
|
# include <new>
|
||||||
|
|
||||||
template<class T>
|
template< typename T >
|
||||||
class minimal_allocator {
|
class minimal_allocator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
minimal_allocator() {}
|
minimal_allocator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template< typename U >
|
template< typename U >
|
||||||
minimal_allocator(const minimal_allocator<U>&) {}
|
minimal_allocator( const minimal_allocator< U > & )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
T* allocate(std::size_t n) {
|
T *
|
||||||
|
allocate( std::size_t n )
|
||||||
|
{
|
||||||
void * p = std::malloc( sizeof( T ) * n );
|
void * p = std::malloc( sizeof( T ) * n );
|
||||||
if ( ! p ) {
|
if ( ! p ) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
@@ -41,7 +47,9 @@ public:
|
|||||||
return static_cast< T * >( p );
|
return static_cast< T * >( p );
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(T* p, std::size_t) {
|
void
|
||||||
|
deallocate( T * p, std::size_t )
|
||||||
|
{
|
||||||
std::free( p );
|
std::free( p );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -49,20 +57,10 @@ public:
|
|||||||
|
|
||||||
#define BOOST_BITSET_TEST_COUNT( x ) ( sizeof( x ) / sizeof( x[ 0 ] ) )
|
#define BOOST_BITSET_TEST_COUNT( x ) ( sizeof( x ) / sizeof( x[ 0 ] ) )
|
||||||
|
|
||||||
|
|
||||||
// Codewarrior 8.3 for Win fails without this.
|
|
||||||
// Thanks Howard Hinnant ;)
|
|
||||||
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
|
||||||
# pragma parse_func_templ off
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template< typename Tests, typename String >
|
template< typename Tests, typename String >
|
||||||
void run_string_tests(const String& s
|
void
|
||||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tests)
|
run_string_tests( const String & s )
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::size_t len = s.length();
|
const std::size_t len = s.length();
|
||||||
const std::size_t step = len / 4 ? len / 4 : 1;
|
const std::size_t step = len / 4 ? len / 4 : 1;
|
||||||
|
|
||||||
@@ -80,36 +78,30 @@ void run_string_tests(const String& s
|
|||||||
Tests::from_string( s, i, len / 2, sz );
|
Tests::from_string( s, i, len / 2, sz );
|
||||||
Tests::from_string( s, i, len, sz );
|
Tests::from_string( s, i, len, sz );
|
||||||
Tests::from_string( s, i, 1 + len * 2, sz );
|
Tests::from_string( s, i, 1 + len * 2, sz );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tests the do-the-right-thing constructor dispatch
|
// tests the do-the-right-thing constructor dispatch
|
||||||
template< typename Tests, typename T >
|
template< typename Tests, typename T >
|
||||||
void run_numeric_ctor_tests( BOOST_EXPLICIT_TEMPLATE_TYPE(Tests)
|
void
|
||||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) )
|
run_numeric_ctor_tests()
|
||||||
{
|
{
|
||||||
|
|
||||||
const int bits_per_block = Tests::bits_per_block;
|
const int bits_per_block = Tests::bits_per_block;
|
||||||
const int width = std::numeric_limits< T >::digits;
|
const int width = std::numeric_limits< T >::digits;
|
||||||
const T ma = ( std::numeric_limits< T >::max )();
|
const T ma = ( std::numeric_limits< T >::max )();
|
||||||
const T mi = ( std::numeric_limits< T >::min )();
|
const T mi = ( std::numeric_limits< T >::min )();
|
||||||
|
|
||||||
int sizes[] = {
|
int sizes[] = {
|
||||||
0, 7*width/10, width, 13*width/10, 3*width,
|
0, 7 * width / 10, width, 13 * width / 10, 3 * width, 7 * bits_per_block / 10, bits_per_block, 13 * bits_per_block / 10, 3 * bits_per_block
|
||||||
7*bits_per_block/10, bits_per_block, 13*bits_per_block/10, 3*bits_per_block
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const T numbers[] = {
|
const T numbers[] = {
|
||||||
T(-1), T(-3), T(-8), T(-15), T(mi/2), T(mi),
|
T( -1 ), T( -3 ), T( -8 ), T( -15 ), T( mi / 2 ), T( mi ), T( 0 ), T( 1 ), T( 3 ), T( 8 ), T( 15 ), T( ma / 2 ), T( ma )
|
||||||
T(0), T(1), T(3), T(8), T(15), T(ma/2), T(ma)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( std::size_t s = 0; s < BOOST_BITSET_TEST_COUNT( sizes ); ++s ) {
|
for ( std::size_t s = 0; s < BOOST_BITSET_TEST_COUNT( sizes ); ++s ) {
|
||||||
for ( std::size_t n = 0; n < BOOST_BITSET_TEST_COUNT( numbers ); ++n ) {
|
for ( std::size_t n = 0; n < BOOST_BITSET_TEST_COUNT( numbers ); ++n ) {
|
||||||
|
|
||||||
// can match ctor from ulong or templated one
|
// can match ctor from ulong or templated one
|
||||||
Tests::from_unsigned_long( sizes[ s ], numbers[ n ] );
|
Tests::from_unsigned_long( sizes[ s ], numbers[ n ] );
|
||||||
|
|
||||||
@@ -129,17 +121,16 @@ void run_numeric_ctor_tests( BOOST_EXPLICIT_TEMPLATE_TYPE(Tests)
|
|||||||
// can match templated ctor only (so we test dispatching)
|
// can match templated ctor only (so we test dispatching)
|
||||||
Tests::from_unsigned_long( static_cast< T >( sizes[ s ] ), numbers[ n ] );
|
Tests::from_unsigned_long( static_cast< T >( sizes[ s ] ), numbers[ n ] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||||
|
void
|
||||||
|
run_test_cases()
|
||||||
template <typename Block>
|
|
||||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|
||||||
{
|
{
|
||||||
typedef boost::dynamic_bitset<Block> bitset_type;
|
typedef boost::dynamic_bitset< Block, AllocatorOrContainer >
|
||||||
|
bitset_type;
|
||||||
typedef bitset_test< bitset_type > Tests;
|
typedef bitset_test< bitset_type > Tests;
|
||||||
const int bits_per_block = bitset_type::bits_per_block;
|
const int bits_per_block = bitset_type::bits_per_block;
|
||||||
|
|
||||||
@@ -158,8 +149,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
// which is likely to work on broken compilers
|
// which is likely to work on broken compilers
|
||||||
//
|
//
|
||||||
const int sizes[] = {
|
const int sizes[] = {
|
||||||
0, 1, 3,
|
0, 1, 3, 7 * bits_per_block / 10, bits_per_block, 13 * bits_per_block / 10, 3 * bits_per_block
|
||||||
7*bits_per_block/10, bits_per_block, 13*bits_per_block/10, 3*bits_per_block
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const bool values[] = { false, true };
|
const bool values[] = { false, true };
|
||||||
@@ -181,22 +171,17 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
run_numeric_ctor_tests< Tests, short int >();
|
run_numeric_ctor_tests< Tests, short int >();
|
||||||
run_numeric_ctor_tests< Tests, int >();
|
run_numeric_ctor_tests< Tests, int >();
|
||||||
run_numeric_ctor_tests< Tests, long int >();
|
run_numeric_ctor_tests< Tests, long int >();
|
||||||
|
run_numeric_ctor_tests< Tests, long long >();
|
||||||
|
|
||||||
run_numeric_ctor_tests< Tests, unsigned char >();
|
run_numeric_ctor_tests< Tests, unsigned char >();
|
||||||
run_numeric_ctor_tests< Tests, unsigned short >();
|
run_numeric_ctor_tests< Tests, unsigned short >();
|
||||||
run_numeric_ctor_tests< Tests, unsigned int >();
|
run_numeric_ctor_tests< Tests, unsigned int >();
|
||||||
run_numeric_ctor_tests< Tests, unsigned long >();
|
run_numeric_ctor_tests< Tests, unsigned long >();
|
||||||
|
run_numeric_ctor_tests< Tests, unsigned long long >();
|
||||||
#if defined(BOOST_HAS_LONG_LONG)
|
|
||||||
run_numeric_ctor_tests<Tests, ::boost::long_long_type>();
|
|
||||||
run_numeric_ctor_tests<Tests, ::boost::ulong_long_type>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test construction from a string
|
// Test construction from a string
|
||||||
{
|
{
|
||||||
|
|
||||||
run_string_tests< Tests >( std::string( "" ) ); // empty string
|
run_string_tests< Tests >( std::string( "" ) ); // empty string
|
||||||
run_string_tests< Tests >( std::string( "1" ) );
|
run_string_tests< Tests >( std::string( "1" ) );
|
||||||
|
|
||||||
@@ -217,7 +202,6 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::from_string( std::string( "x11y" ), 1, 2 );
|
Tests::from_string( std::string( "x11y" ), 1, 2 );
|
||||||
Tests::from_string( std::string( "x11" ), 1, 10 );
|
Tests::from_string( std::string( "x11" ), 1, 10 );
|
||||||
Tests::from_string( std::string( "x11" ), 1, 10, 10 );
|
Tests::from_string( std::string( "x11" ), 1, 10, 10 );
|
||||||
|
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// test from_block_range
|
// test from_block_range
|
||||||
@@ -239,6 +223,34 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
blocks[ i ] = static_cast< Block >( i );
|
blocks[ i ] = static_cast< Block >( i );
|
||||||
Tests::from_block_range( blocks );
|
Tests::from_block_range( blocks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// test iterators
|
||||||
|
{
|
||||||
|
bitset_type b;
|
||||||
|
Tests::iterate_forward( b );
|
||||||
|
Tests::iterate_backward( b );
|
||||||
|
Tests::iterator_operations( b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type b( 1, 1ul );
|
||||||
|
Tests::iterate_forward( b );
|
||||||
|
Tests::iterate_backward( b );
|
||||||
|
Tests::iterator_operations( b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type b( bitset_type::bits_per_block, 100ul );
|
||||||
|
Tests::iterate_forward( b );
|
||||||
|
Tests::iterate_backward( b );
|
||||||
|
Tests::iterator_operations( b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type b( long_string );
|
||||||
|
Tests::iterate_forward( b );
|
||||||
|
Tests::iterate_backward( b );
|
||||||
|
Tests::iterator_operations( b );
|
||||||
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// test to_block_range
|
// test to_block_range
|
||||||
{
|
{
|
||||||
@@ -257,15 +269,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test copy constructor
|
// Test copy constructor
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::copy_constructor( b );
|
Tests::copy_constructor( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( "0" );
|
||||||
Tests::copy_constructor( b );
|
Tests::copy_constructor( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b ( long_string );
|
||||||
Tests::copy_constructor( b );
|
Tests::copy_constructor( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@@ -275,7 +287,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::copy_assignment_operator( a, b );
|
Tests::copy_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bitset_type a(std::string("1")), b(std::string("0"));
|
bitset_type a( "1" ), b( "0" );
|
||||||
Tests::copy_assignment_operator( a, b );
|
Tests::copy_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -288,24 +300,23 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::copy_assignment_operator( a, b );
|
Tests::copy_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bitset_type a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
bitset_type b( long_string ); // b greater than a
|
bitset_type b( long_string ); // b greater than a
|
||||||
Tests::copy_assignment_operator( a, b );
|
Tests::copy_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test move constructor
|
// Test move constructor
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::move_constructor( b );
|
Tests::move_constructor( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( "0" );
|
||||||
Tests::move_constructor( b );
|
Tests::move_constructor( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::move_constructor( b );
|
Tests::move_constructor( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@@ -315,7 +326,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::move_assignment_operator( a, b );
|
Tests::move_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bitset_type a(std::string("1")), b(std::string("0"));
|
bitset_type a( "1" ), b( "0" );
|
||||||
Tests::move_assignment_operator( a, b );
|
Tests::move_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -328,16 +339,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::move_assignment_operator( a, b );
|
Tests::move_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bitset_type a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
bitset_type b( long_string ); // b greater than a
|
bitset_type b( long_string ); // b greater than a
|
||||||
Tests::move_assignment_operator( a, b );
|
Tests::move_assignment_operator( a, b );
|
||||||
}
|
}
|
||||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test swap
|
// Test swap
|
||||||
{
|
{
|
||||||
bitset_type a;
|
bitset_type a;
|
||||||
bitset_type b(std::string("1"));
|
bitset_type b( "1" );
|
||||||
Tests::swap( a, b );
|
Tests::swap( a, b );
|
||||||
Tests::swap( b, a );
|
Tests::swap( b, a );
|
||||||
Tests::swap( a, a );
|
Tests::swap( a, a );
|
||||||
@@ -349,7 +359,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::swap( b, a );
|
Tests::swap( b, a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bitset_type a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
bitset_type b( long_string );
|
bitset_type b( long_string );
|
||||||
Tests::swap( a, b );
|
Tests::swap( a, b );
|
||||||
Tests::swap( b, a );
|
Tests::swap( b, a );
|
||||||
@@ -359,105 +369,147 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test resize
|
// Test resize
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a;
|
bitset_type a;
|
||||||
Tests::resize( a );
|
Tests::resize( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
Tests::resize( a );
|
Tests::resize( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1"));
|
bitset_type a( "1" );
|
||||||
Tests::resize( a );
|
Tests::resize( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string);
|
bitset_type a( long_string );
|
||||||
Tests::resize( a );
|
Tests::resize( a );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test clear
|
// Test clear
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a;
|
bitset_type a;
|
||||||
Tests::clear( a );
|
Tests::clear( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string);
|
bitset_type a( long_string );
|
||||||
Tests::clear( a );
|
Tests::clear( a );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test pop back
|
// Test pop back
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("01"));
|
bitset_type a( "01" );
|
||||||
Tests::pop_back( a );
|
Tests::pop_back( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("10"));
|
bitset_type a( "10" );
|
||||||
Tests::pop_back( a );
|
Tests::pop_back( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||||
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 255ul);
|
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||||
Tests::pop_back( a );
|
Tests::pop_back( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string);
|
bitset_type a( long_string.c_str() );
|
||||||
Tests::pop_back( a );
|
Tests::pop_back( a );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
|
// Test pop_front
|
||||||
|
{
|
||||||
|
bitset_type a( "01" );
|
||||||
|
Tests::pop_front( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( "10" );
|
||||||
|
Tests::pop_front( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||||
|
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||||
|
Tests::pop_front( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( long_string.c_str() );
|
||||||
|
Tests::pop_front( a );
|
||||||
|
}
|
||||||
|
//=====================================================================
|
||||||
// Test append bit
|
// Test append bit
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a;
|
bitset_type a;
|
||||||
Tests::append_bit( a );
|
Tests::append_bit( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
Tests::append_bit( a );
|
Tests::append_bit( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1"));
|
bitset_type a( "1" );
|
||||||
Tests::append_bit( a );
|
Tests::append_bit( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||||
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 255ul);
|
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||||
Tests::append_bit( a );
|
Tests::append_bit( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string);
|
bitset_type a( long_string );
|
||||||
Tests::append_bit( a );
|
Tests::append_bit( a );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
|
// Test push_front
|
||||||
|
{
|
||||||
|
bitset_type a;
|
||||||
|
Tests::prepend_bit( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( "0" );
|
||||||
|
Tests::prepend_bit( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( "1" );
|
||||||
|
Tests::prepend_bit( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||||
|
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||||
|
Tests::prepend_bit( a );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( long_string );
|
||||||
|
Tests::prepend_bit( a );
|
||||||
|
}
|
||||||
|
//=====================================================================
|
||||||
// Test append block
|
// Test append block
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a;
|
bitset_type a;
|
||||||
Tests::append_block( a );
|
Tests::append_block( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
Tests::append_block( a );
|
Tests::append_block( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1"));
|
bitset_type a( "1" );
|
||||||
Tests::append_block( a );
|
Tests::append_block( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||||
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 15ul);
|
bitset_type a( size_to_fill_all_blocks, 15ul );
|
||||||
Tests::append_block( a );
|
Tests::append_block( a );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string);
|
bitset_type a( long_string.c_str() );
|
||||||
Tests::append_block( a );
|
Tests::append_block( a );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test append block range
|
// Test append block range
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a;
|
bitset_type a;
|
||||||
std::vector< Block > blocks;
|
std::vector< Block > blocks;
|
||||||
Tests::append_block_range( a, blocks );
|
Tests::append_block_range( a, blocks );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0"));
|
bitset_type a( "0" );
|
||||||
std::vector< Block > blocks( 3 );
|
std::vector< Block > blocks( 3 );
|
||||||
blocks[ 0 ] = static_cast< Block >( 0 );
|
blocks[ 0 ] = static_cast< Block >( 0 );
|
||||||
blocks[ 1 ] = static_cast< Block >( 1 );
|
blocks[ 1 ] = static_cast< Block >( 1 );
|
||||||
@@ -465,7 +517,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::append_block_range( a, blocks );
|
Tests::append_block_range( a, blocks );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1"));
|
bitset_type a( "1" );
|
||||||
const unsigned int n = ( std::numeric_limits< unsigned char >::max )();
|
const unsigned int n = ( std::numeric_limits< unsigned char >::max )();
|
||||||
std::vector< Block > blocks( n );
|
std::vector< Block > blocks( n );
|
||||||
for ( typename std::vector< Block >::size_type i = 0; i < n; ++i )
|
for ( typename std::vector< Block >::size_type i = 0; i < n; ++i )
|
||||||
@@ -473,7 +525,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::append_block_range( a, blocks );
|
Tests::append_block_range( a, blocks );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a;
|
bitset_type a;
|
||||||
a.append( Block( 1 ) );
|
a.append( Block( 1 ) );
|
||||||
a.append( Block( 2 ) );
|
a.append( Block( 2 ) );
|
||||||
Block x[] = { 3, 4, 5 };
|
Block x[] = { 3, 4, 5 };
|
||||||
@@ -482,27 +534,40 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::append_block_range( a, blocks );
|
Tests::append_block_range( a, blocks );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string);
|
bitset_type a( long_string.c_str() );
|
||||||
std::vector< Block > blocks( 3 );
|
std::vector< Block > blocks( 3 );
|
||||||
blocks[ 0 ] = static_cast< Block >( 0 );
|
blocks[ 0 ] = static_cast< Block >( 0 );
|
||||||
blocks[ 1 ] = static_cast< Block >( 1 );
|
blocks[ 1 ] = static_cast< Block >( 1 );
|
||||||
blocks[ 2 ] = all_1s;
|
blocks[ 2 ] = all_1s;
|
||||||
Tests::append_block_range( a, blocks );
|
Tests::append_block_range( a, blocks );
|
||||||
}
|
}
|
||||||
|
// Test with input iterators
|
||||||
|
{
|
||||||
|
bitset_type b;
|
||||||
|
Tests::append_block_range_input_iter( b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type b( "0" );
|
||||||
|
Tests::append_block_range_input_iter( b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type b( long_string.c_str() );
|
||||||
|
Tests::append_block_range_input_iter( b );
|
||||||
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test bracket operator
|
// Test bracket operator
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b1;
|
bitset_type b1;
|
||||||
std::vector< bool > bitvec1;
|
std::vector< bool > bitvec1;
|
||||||
Tests::operator_bracket( b1, bitvec1 );
|
Tests::operator_bracket( b1, bitvec1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
bitset_type b( "1" );
|
||||||
std::vector< bool > bit_vec( 1, true );
|
std::vector< bool > bit_vec( 1, true );
|
||||||
Tests::operator_bracket( b, bit_vec );
|
Tests::operator_bracket( b, bit_vec );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string.c_str() );
|
||||||
std::size_t n = long_string.size();
|
std::size_t n = long_string.size();
|
||||||
std::vector< bool > bit_vec( n );
|
std::vector< bool > bit_vec( n );
|
||||||
for ( std::size_t i = 0; i < n; ++i )
|
for ( std::size_t i = 0; i < n; ++i )
|
||||||
@@ -512,34 +577,40 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test at
|
// Test at
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b1;
|
bitset_type b1;
|
||||||
std::vector< bool > bitvec1;
|
std::vector< bool > bitvec1;
|
||||||
Tests::at( b1, bitvec1 );
|
Tests::at( b1, bitvec1 );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
bitset_type b( "1" );
|
||||||
std::vector< bool > bit_vec( 1, true );
|
std::vector< bool > bit_vec( 1, true );
|
||||||
Tests::at( b, bit_vec );
|
Tests::at( b, bit_vec );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string.c_str() );
|
||||||
std::size_t n = long_string.size();
|
std::size_t n = long_string.size();
|
||||||
std::vector< bool > bit_vec( n );
|
std::vector< bool > bit_vec( n );
|
||||||
for ( std::size_t i = 0; i < n; ++i )
|
for ( std::size_t i = 0; i < n; ++i )
|
||||||
bit_vec[ i ] = long_string[ n - 1 - i ] == '0' ? 0 : 1;
|
bit_vec[ i ] = long_string[ n - 1 - i ] == '0' ? 0 : 1;
|
||||||
Tests::at( b, bit_vec );
|
Tests::at( b, bit_vec );
|
||||||
}
|
}
|
||||||
|
//=====================================================================
|
||||||
|
// Test max_size
|
||||||
#if ! defined( BOOST_NO_CXX11_ALLOCATOR )
|
#if ! defined( BOOST_NO_CXX11_ALLOCATOR )
|
||||||
{
|
{
|
||||||
typedef boost::dynamic_bitset<Block,
|
typedef boost::dynamic_bitset< Block, minimal_allocator< Block > > Bitset;
|
||||||
minimal_allocator<Block> > Bitset;
|
|
||||||
Bitset b;
|
Bitset b;
|
||||||
bitset_test< Bitset >::max_size( b );
|
bitset_test< Bitset >::max_size( b );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
typedef boost::dynamic_bitset< Block, small_vector< Block > > Bitset;
|
||||||
|
Bitset b;
|
||||||
|
bitset_test< Bitset >::max_size( b );
|
||||||
|
}
|
||||||
// Test copy-initialize with default constructor
|
// Test copy-initialize with default constructor
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b[1] = {};
|
bitset_type b[ 1 ] = {};
|
||||||
(void)b;
|
(void)b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,12 +619,15 @@ int
|
|||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
run_test_cases< unsigned char >();
|
run_test_cases< unsigned char >();
|
||||||
|
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||||
run_test_cases< unsigned short >();
|
run_test_cases< unsigned short >();
|
||||||
|
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||||
run_test_cases< unsigned int >();
|
run_test_cases< unsigned int >();
|
||||||
|
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||||
run_test_cases< unsigned long >();
|
run_test_cases< unsigned long >();
|
||||||
# ifdef BOOST_HAS_LONG_LONG
|
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||||
run_test_cases< ::boost::ulong_long_type>();
|
run_test_cases< unsigned long long >();
|
||||||
# endif
|
run_test_cases< unsigned long long, small_vector< unsigned long long > >();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Copyright (c) 2001 Jeremy Siek
|
// Copyright (c) 2001 Jeremy Siek
|
||||||
// Copyright (c) 2003-2006 Gennaro Prota
|
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||||
// Copyright (c) 2014 Ahmed Charles
|
// Copyright (c) 2014 Ahmed Charles
|
||||||
// Copyright (c) 2018 Evgeny Shulgin
|
// Copyright (c) 2018 Evgeny Shulgin
|
||||||
//
|
//
|
||||||
@@ -11,89 +11,88 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
#include "bitset_test.hpp"
|
#include "bitset_test.hpp"
|
||||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
|
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||||
template <typename Block>
|
void
|
||||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
run_test_cases()
|
||||||
{
|
{
|
||||||
typedef boost::dynamic_bitset<Block> bitset_type;
|
typedef boost::dynamic_bitset< Block, AllocatorOrContainer > bitset_type;
|
||||||
typedef bitset_test< bitset_type > Tests;
|
typedef bitset_test< bitset_type > Tests;
|
||||||
const int bits_per_block = bitset_type::bits_per_block;
|
const int bits_per_block = bitset_type::bits_per_block;
|
||||||
|
|
||||||
std::string long_string = get_long_string();
|
const std::string long_string = get_long_string();
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator&=
|
// Test operator&=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::and_assignment( lhs, rhs );
|
Tests::and_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::and_assignment( lhs, rhs );
|
Tests::and_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
bitset_type lhs( long_string.size(), 0 ), rhs( long_string );
|
||||||
Tests::and_assignment( lhs, rhs );
|
Tests::and_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||||
Tests::and_assignment( lhs, rhs );
|
Tests::and_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator |=
|
// Test operator |=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::or_assignment( lhs, rhs );
|
Tests::or_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::or_assignment( lhs, rhs );
|
Tests::or_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
bitset_type lhs( long_string.size(), 0 ), rhs( long_string );
|
||||||
Tests::or_assignment( lhs, rhs );
|
Tests::or_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||||
Tests::or_assignment( lhs, rhs );
|
Tests::or_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator^=
|
// Test operator^=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::xor_assignment( lhs, rhs );
|
Tests::xor_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::xor_assignment( lhs, rhs );
|
Tests::xor_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
|
bitset_type lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
|
||||||
Tests::xor_assignment( lhs, rhs );
|
Tests::xor_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
|
bitset_type lhs( long_string ), rhs( long_string );
|
||||||
Tests::xor_assignment( lhs, rhs );
|
Tests::xor_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator-=
|
// Test operator-=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::sub_assignment( lhs, rhs );
|
Tests::sub_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::sub_assignment( lhs, rhs );
|
Tests::sub_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
|
bitset_type lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
|
||||||
Tests::sub_assignment( lhs, rhs );
|
Tests::sub_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
|
bitset_type lhs( long_string ), rhs( long_string );
|
||||||
Tests::sub_assignment( lhs, rhs );
|
Tests::sub_assignment( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@@ -101,15 +100,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
{ // case pos == 0
|
{ // case pos == 0
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::shift_left_assignment( b, pos );
|
Tests::shift_left_assignment( b, pos );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1010"));
|
bitset_type b( std::string( "1010" ) );
|
||||||
Tests::shift_left_assignment( b, pos );
|
Tests::shift_left_assignment( b, pos );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::shift_left_assignment( b, pos );
|
Tests::shift_left_assignment( b, pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +119,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
for ( int i = 1; i <= how_many; ++i ) {
|
for ( int i = 1; i <= how_many; ++i ) {
|
||||||
std::size_t multiple = i * bits_per_block;
|
std::size_t multiple = i * bits_per_block;
|
||||||
std::size_t non_multiple = multiple - 1;
|
std::size_t non_multiple = multiple - 1;
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
|
|
||||||
Tests::shift_left_assignment( b, multiple );
|
Tests::shift_left_assignment( b, multiple );
|
||||||
Tests::shift_left_assignment( b, non_multiple );
|
Tests::shift_left_assignment( b, non_multiple );
|
||||||
@@ -128,12 +127,12 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
}
|
}
|
||||||
{ // case pos == size()/2
|
{ // case pos == size()/2
|
||||||
std::size_t pos = long_string.size() / 2;
|
std::size_t pos = long_string.size() / 2;
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::shift_left_assignment( b, pos );
|
Tests::shift_left_assignment( b, pos );
|
||||||
}
|
}
|
||||||
{ // case pos >= n
|
{ // case pos >= n
|
||||||
std::size_t pos = long_string.size();
|
std::size_t pos = long_string.size();
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::shift_left_assignment( b, pos );
|
Tests::shift_left_assignment( b, pos );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@@ -141,15 +140,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
{ // case pos == 0
|
{ // case pos == 0
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::shift_right_assignment( b, pos );
|
Tests::shift_right_assignment( b, pos );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1010"));
|
bitset_type b( std::string( "1010" ) );
|
||||||
Tests::shift_right_assignment( b, pos );
|
Tests::shift_right_assignment( b, pos );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::shift_right_assignment( b, pos );
|
Tests::shift_right_assignment( b, pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,210 +159,212 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
for ( int i = 1; i <= how_many; ++i ) {
|
for ( int i = 1; i <= how_many; ++i ) {
|
||||||
std::size_t multiple = i * bits_per_block;
|
std::size_t multiple = i * bits_per_block;
|
||||||
std::size_t non_multiple = multiple - 1;
|
std::size_t non_multiple = multiple - 1;
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
|
|
||||||
Tests::shift_right_assignment( b, multiple );
|
Tests::shift_right_assignment( b, multiple );
|
||||||
Tests::shift_right_assignment( b, non_multiple );
|
Tests::shift_right_assignment( b, non_multiple );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
{ // case pos == size()/2
|
{ // case pos == size()/2
|
||||||
std::size_t pos = long_string.size() / 2;
|
std::size_t pos = long_string.size() / 2;
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::shift_right_assignment( b, pos );
|
Tests::shift_right_assignment( b, pos );
|
||||||
}
|
}
|
||||||
{ // case pos >= n
|
{ // case pos >= n
|
||||||
std::size_t pos = long_string.size();
|
std::size_t pos = long_string.size();
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::shift_right_assignment( b, pos );
|
Tests::shift_right_assignment( b, pos );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// test b.set()
|
// test b.set()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::set_all( b );
|
Tests::set_all( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::set_all( b );
|
Tests::set_all( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_all( b );
|
Tests::set_all( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.set(pos)
|
// Test b.set(pos)
|
||||||
{ // case pos >= b.size()
|
{ // case pos >= b.size()
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::set_one( b, 0, true );
|
Tests::set_one( b, 0, true );
|
||||||
Tests::set_one( b, 0, false );
|
Tests::set_one( b, 0, false );
|
||||||
}
|
}
|
||||||
{ // case pos < b.size()
|
{ // case pos < b.size()
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::set_one( b, 0, true );
|
Tests::set_one( b, 0, true );
|
||||||
Tests::set_one( b, 0, false );
|
Tests::set_one( b, 0, false );
|
||||||
}
|
}
|
||||||
{ // case pos == b.size() / 2
|
{ // case pos == b.size() / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_one( b, long_string.size() / 2, true );
|
Tests::set_one( b, long_string.size() / 2, true );
|
||||||
Tests::set_one( b, long_string.size() / 2, false );
|
Tests::set_one( b, long_string.size() / 2, false );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.set(pos, len)
|
// Test b.set(pos, len)
|
||||||
|
|
||||||
|
// case size is 0
|
||||||
|
{
|
||||||
|
bitset_type b( std::string( "10" ) ) ;
|
||||||
|
Tests::set_segment( b, 0, 0, true );
|
||||||
|
Tests::set_segment( b, 0, 0, false );
|
||||||
|
}
|
||||||
{ // case size is 1
|
{ // case size is 1
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::set_segment( b, 0, 1, true );
|
Tests::set_segment( b, 0, 1, true );
|
||||||
Tests::set_segment( b, 0, 1, false );
|
Tests::set_segment( b, 0, 1, false );
|
||||||
}
|
}
|
||||||
{ // case fill the whole set
|
{ // case fill the whole set
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_segment( b, 0, b.size(), true );
|
Tests::set_segment( b, 0, b.size(), true );
|
||||||
Tests::set_segment( b, 0, b.size(), false );
|
Tests::set_segment( b, 0, b.size(), false );
|
||||||
}
|
}
|
||||||
{ // case pos = size / 4, len = size / 2
|
{ // case pos = size / 4, len = size / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_segment( b, b.size() / 4, b.size() / 2, true );
|
Tests::set_segment( b, b.size() / 4, b.size() / 2, true );
|
||||||
Tests::set_segment( b, b.size() / 4, b.size() / 2, false );
|
Tests::set_segment( b, b.size() / 4, b.size() / 2, false );
|
||||||
}
|
}
|
||||||
{ // case pos = block_size / 2, len = size - block_size
|
{ // case pos = block_size / 2, len = size - block_size
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
Tests::set_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block, true );
|
||||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block, true);
|
Tests::set_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block, false );
|
||||||
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
|
{ // case pos = 1, len = size - 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_segment( b, 1, b.size() - 2, true );
|
Tests::set_segment( b, 1, b.size() - 2, true );
|
||||||
Tests::set_segment( b, 1, b.size() - 2, false );
|
Tests::set_segment( b, 1, b.size() - 2, false );
|
||||||
}
|
}
|
||||||
{ // case pos = 3, len = 7
|
{ // case pos = 3, len = 7
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::set_segment( b, 3, 7, true );
|
Tests::set_segment( b, 3, 7, true );
|
||||||
Tests::set_segment( b, 3, 7, false );
|
Tests::set_segment( b, 3, 7, false );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.reset()
|
// Test b.reset()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::reset_all( b );
|
Tests::reset_all( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::reset_all( b );
|
Tests::reset_all( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_all( b );
|
Tests::reset_all( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.reset(pos)
|
// Test b.reset(pos)
|
||||||
{ // case pos >= b.size()
|
{ // case pos >= b.size()
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::reset_one( b, 0 );
|
Tests::reset_one( b, 0 );
|
||||||
}
|
}
|
||||||
{ // case pos < b.size()
|
{ // case pos < b.size()
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::reset_one( b, 0 );
|
Tests::reset_one( b, 0 );
|
||||||
}
|
}
|
||||||
{ // case pos == b.size() / 2
|
{ // case pos == b.size() / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_one( b, long_string.size() / 2 );
|
Tests::reset_one( b, long_string.size() / 2 );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.reset(pos, len)
|
// Test b.reset(pos, len)
|
||||||
{ // case size is 1
|
{ // case size is 1
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::reset_segment( b, 0, 1 );
|
Tests::reset_segment( b, 0, 1 );
|
||||||
}
|
}
|
||||||
{ // case fill the whole set
|
{ // case fill the whole set
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_segment( b, 0, b.size() );
|
Tests::reset_segment( b, 0, b.size() );
|
||||||
}
|
}
|
||||||
{ // case pos = size / 4, len = size / 2
|
{ // case pos = size / 4, len = size / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_segment( b, b.size() / 4, b.size() / 2 );
|
Tests::reset_segment( b, b.size() / 4, b.size() / 2 );
|
||||||
}
|
}
|
||||||
{ // case pos = block_size / 2, len = size - block_size
|
{ // case pos = block_size / 2, len = size - block_size
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
Tests::reset_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block );
|
||||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
|
|
||||||
}
|
}
|
||||||
{ // case pos = 1, len = size - 2
|
{ // case pos = 1, len = size - 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_segment( b, 1, b.size() - 2 );
|
Tests::reset_segment( b, 1, b.size() - 2 );
|
||||||
}
|
}
|
||||||
{ // case pos = 3, len = 7
|
{ // case pos = 3, len = 7
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::reset_segment( b, 3, 7 );
|
Tests::reset_segment( b, 3, 7 );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test ~b
|
// Test ~b
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::operator_flip( b );
|
Tests::operator_flip( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
bitset_type b( std::string( "1" ) );
|
||||||
Tests::operator_flip( b );
|
Tests::operator_flip( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::operator_flip( b );
|
Tests::operator_flip( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.flip()
|
// Test b.flip()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::flip_all( b );
|
Tests::flip_all( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
bitset_type b( std::string( "1" ) );
|
||||||
Tests::flip_all( b );
|
Tests::flip_all( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_all( b );
|
Tests::flip_all( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.flip(pos)
|
// Test b.flip(pos)
|
||||||
{ // case pos >= b.size()
|
{ // case pos >= b.size()
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::flip_one( b, 0 );
|
Tests::flip_one( b, 0 );
|
||||||
}
|
}
|
||||||
{ // case pos < b.size()
|
{ // case pos < b.size()
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::flip_one( b, 0 );
|
Tests::flip_one( b, 0 );
|
||||||
}
|
}
|
||||||
{ // case pos == b.size() / 2
|
{ // case pos == b.size() / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_one( b, long_string.size() / 2 );
|
Tests::flip_one( b, long_string.size() / 2 );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.flip(pos, len)
|
// Test b.flip(pos, len)
|
||||||
{ // case size is 1
|
{ // case size is 1
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::flip_segment( b, 0, 1 );
|
Tests::flip_segment( b, 0, 1 );
|
||||||
}
|
}
|
||||||
{ // case fill the whole set
|
{ // case fill the whole set
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_segment( b, 0, b.size() );
|
Tests::flip_segment( b, 0, b.size() );
|
||||||
}
|
}
|
||||||
{ // case pos = size / 4, len = size / 2
|
{ // case pos = size / 4, len = size / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_segment( b, b.size() / 4, b.size() / 2 );
|
Tests::flip_segment( b, b.size() / 4, b.size() / 2 );
|
||||||
}
|
}
|
||||||
{ // case pos = block_size / 2, len = size - block_size
|
{ // case pos = block_size / 2, len = size - block_size
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
|
Tests::flip_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block );
|
||||||
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
|
|
||||||
}
|
}
|
||||||
{ // case pos = 1, len = size - 2
|
{ // case pos = 1, len = size - 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_segment( b, 1, b.size() - 2 );
|
Tests::flip_segment( b, 1, b.size() - 2 );
|
||||||
}
|
}
|
||||||
{ // case pos = 3, len = 7
|
{ // case pos = 3, len = 7
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::flip_segment( b, 3, 7 );
|
Tests::flip_segment( b, 3, 7 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,12 +373,15 @@ int
|
|||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
run_test_cases< unsigned char >();
|
run_test_cases< unsigned char >();
|
||||||
|
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||||
run_test_cases< unsigned short >();
|
run_test_cases< unsigned short >();
|
||||||
|
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||||
run_test_cases< unsigned int >();
|
run_test_cases< unsigned int >();
|
||||||
|
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||||
run_test_cases< unsigned long >();
|
run_test_cases< unsigned long >();
|
||||||
# ifdef BOOST_HAS_LONG_LONG
|
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||||
run_test_cases< ::boost::ulong_long_type>();
|
run_test_cases< unsigned long long >();
|
||||||
# endif
|
run_test_cases< unsigned long long, small_vector< unsigned long long > >();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Copyright (c) 2001 Jeremy Siek
|
// Copyright (c) 2001 Jeremy Siek
|
||||||
// Copyright (c) 2003-2006 Gennaro Prota
|
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||||
// Copyright (c) 2014 Ahmed Charles
|
// Copyright (c) 2014 Ahmed Charles
|
||||||
// Copyright (c) 2014 Riccardo Marcangelo
|
// Copyright (c) 2014 Riccardo Marcangelo
|
||||||
//
|
//
|
||||||
@@ -10,22 +10,22 @@
|
|||||||
//
|
//
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include "bitset_test.hpp"
|
#include "bitset_test.hpp"
|
||||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||||
#include <boost/limits.hpp>
|
#include "boost/limits.hpp"
|
||||||
#include <boost/config.hpp>
|
#include <assert.h>
|
||||||
|
|
||||||
template <typename Block>
|
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
void
|
||||||
|
run_test_cases()
|
||||||
{
|
{
|
||||||
// a bunch of typedefs which will be handy later on
|
// a bunch of typedefs which will be handy later on
|
||||||
typedef boost::dynamic_bitset<Block> bitset_type;
|
typedef boost::dynamic_bitset< Block, AllocatorOrContainer > bitset_type;
|
||||||
typedef bitset_test< bitset_type > Tests;
|
typedef bitset_test< bitset_type > Tests;
|
||||||
// typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
|
// typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
|
||||||
|
|
||||||
std::string long_string = get_long_string();
|
const std::string long_string = get_long_string();
|
||||||
std::size_t ul_width = std::numeric_limits<unsigned long>::digits;
|
const std::size_t ul_width = std::numeric_limits< unsigned long >::digits;
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.empty()
|
// Test b.empty()
|
||||||
@@ -38,137 +38,135 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::empty( b );
|
Tests::empty( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bitset_type b(bitset_type::bits_per_block
|
bitset_type b( bitset_type::bits_per_block + bitset_type::bits_per_block / 2, 15ul );
|
||||||
+ bitset_type::bits_per_block/2, 15ul);
|
|
||||||
Tests::empty( b );
|
Tests::empty( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.to_long()
|
// Test b.to_long()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::to_ulong( b );
|
Tests::to_ulong( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
bitset_type b( std::string( "1" ) );
|
||||||
Tests::to_ulong( b );
|
Tests::to_ulong( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(bitset_type::bits_per_block,
|
bitset_type b( bitset_type::bits_per_block, static_cast< unsigned long >( -1 ) );
|
||||||
static_cast<unsigned long>(-1));
|
|
||||||
Tests::to_ulong( b );
|
Tests::to_ulong( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string str( ul_width - 1, '1' );
|
std::string str( ul_width - 1, '1' );
|
||||||
boost::dynamic_bitset<Block> b(str);
|
bitset_type b( str );
|
||||||
Tests::to_ulong( b );
|
Tests::to_ulong( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string ul_str( ul_width, '1' );
|
std::string ul_str( ul_width, '1' );
|
||||||
boost::dynamic_bitset<Block> b(ul_str);
|
bitset_type b( ul_str );
|
||||||
Tests::to_ulong( b );
|
Tests::to_ulong( b );
|
||||||
}
|
}
|
||||||
{ // case overflow
|
{ // case overflow
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::to_ulong( b );
|
Tests::to_ulong( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test to_string(b, str)
|
// Test to_string(b, str)
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::to_string( b );
|
Tests::to_string( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::to_string( b );
|
Tests::to_string( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::to_string( b );
|
Tests::to_string( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.count()
|
// Test b.count()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::count( b );
|
Tests::count( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::count( b );
|
Tests::count( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("1"));
|
bitset_type b( std::string( "1" ) );
|
||||||
Tests::count( b );
|
Tests::count( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(8, 255ul);
|
bitset_type b( 8, 255ul );
|
||||||
Tests::count( b );
|
Tests::count( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::count( b );
|
Tests::count( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.size()
|
// Test b.size()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::size( b );
|
Tests::size( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::size( b );
|
Tests::size( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::size( b );
|
Tests::size( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.capacity()
|
// Test b.capacity()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::capacity_test_one(b);
|
Tests::capacity( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(100);
|
bitset_type b( 100 );
|
||||||
Tests::capacity_test_two(b);
|
Tests::capacity( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.reserve()
|
// Test b.reserve()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::reserve_test_one( b );
|
Tests::reserve_test_one( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(100);
|
bitset_type b( 100 );
|
||||||
Tests::reserve_test_two( b );
|
Tests::reserve_test_two( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.shrink_to_fit()
|
// Test b.shrink_to_fit()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::shrink_to_fit_test_one( b );
|
Tests::shrink_to_fit_test_one( b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(100);
|
bitset_type b( 100 );
|
||||||
Tests::shrink_to_fit_test_two( b );
|
Tests::shrink_to_fit_test_two( b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.all()
|
// Test b.all()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::all( b );
|
Tests::all( b );
|
||||||
Tests::all( ~b );
|
Tests::all( ~b );
|
||||||
Tests::all( b.set() );
|
Tests::all( b.set() );
|
||||||
Tests::all( b.reset() );
|
Tests::all( b.reset() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::all( b );
|
Tests::all( b );
|
||||||
Tests::all( ~b );
|
Tests::all( ~b );
|
||||||
Tests::all( b.set() );
|
Tests::all( b.set() );
|
||||||
Tests::all( b.reset() );
|
Tests::all( b.reset() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::all( b );
|
Tests::all( b );
|
||||||
Tests::all( ~b );
|
Tests::all( ~b );
|
||||||
Tests::all( b.set() );
|
Tests::all( b.set() );
|
||||||
@@ -177,21 +175,21 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.any()
|
// Test b.any()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::any( b );
|
Tests::any( b );
|
||||||
Tests::any( ~b );
|
Tests::any( ~b );
|
||||||
Tests::any( b.set() );
|
Tests::any( b.set() );
|
||||||
Tests::any( b.reset() );
|
Tests::any( b.reset() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::any( b );
|
Tests::any( b );
|
||||||
Tests::any( ~b );
|
Tests::any( ~b );
|
||||||
Tests::any( b.set() );
|
Tests::any( b.set() );
|
||||||
Tests::any( b.reset() );
|
Tests::any( b.reset() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::any( b );
|
Tests::any( b );
|
||||||
Tests::any( ~b );
|
Tests::any( ~b );
|
||||||
Tests::any( b.set() );
|
Tests::any( b.set() );
|
||||||
@@ -200,21 +198,21 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.none()
|
// Test b.none()
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::none( b );
|
Tests::none( b );
|
||||||
Tests::none( ~b );
|
Tests::none( ~b );
|
||||||
Tests::none( b.set() );
|
Tests::none( b.set() );
|
||||||
Tests::none( b.reset() );
|
Tests::none( b.reset() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::none( b );
|
Tests::none( b );
|
||||||
Tests::none( ~b );
|
Tests::none( ~b );
|
||||||
Tests::none( b.set() );
|
Tests::none( b.set() );
|
||||||
Tests::none( b.reset() );
|
Tests::none( b.reset() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::none( b );
|
Tests::none( b );
|
||||||
Tests::none( ~b );
|
Tests::none( ~b );
|
||||||
Tests::none( b.set() );
|
Tests::none( b.set() );
|
||||||
@@ -223,56 +221,56 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test a.is_subset_of(b)
|
// Test a.is_subset_of(b)
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::subset( a, b );
|
Tests::subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::subset( a, b );
|
Tests::subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::subset( a, b );
|
Tests::subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::subset( a, b );
|
Tests::subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::subset( a, b );
|
Tests::subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::subset( a, b );
|
Tests::subset( a, b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test a.is_proper_subset_of(b)
|
// Test a.is_proper_subset_of(b)
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::proper_subset( a, b );
|
Tests::proper_subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::proper_subset( a, b );
|
Tests::proper_subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::proper_subset( a, b );
|
Tests::proper_subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::proper_subset( a, b );
|
Tests::proper_subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::proper_subset( a, b );
|
Tests::proper_subset( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::proper_subset( a, b );
|
Tests::proper_subset( a, b );
|
||||||
}
|
}
|
||||||
@@ -306,30 +304,37 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
// empty bitset
|
// empty bitset
|
||||||
bitset_type b;
|
bitset_type b;
|
||||||
Tests::find_first( b );
|
Tests::find_first( b );
|
||||||
|
Tests::find_first( b, 0, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// bitset of size 1
|
// bitset of size 1
|
||||||
bitset_type b( 1, 1ul );
|
bitset_type b( 1, 1ul );
|
||||||
Tests::find_first( b );
|
Tests::find_first( b );
|
||||||
|
Tests::find_first( b, 0, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// all-0s bitset
|
// all-0s bitset
|
||||||
bitset_type b( 4 * bitset_type::bits_per_block, 0ul );
|
bitset_type b( 4 * bitset_type::bits_per_block, 0ul );
|
||||||
Tests::find_first( b );
|
Tests::find_first( b );
|
||||||
|
Tests::find_first( b, 0, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// first bit on
|
// first bit on or off
|
||||||
bitset_type b( 1, 1ul );
|
bitset_type b( 1, 1ul );
|
||||||
Tests::find_first( b );
|
Tests::find_first( b );
|
||||||
|
b.set( 0, false );
|
||||||
|
Tests::find_first( b, 0, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// last bit on
|
// last bit on or off
|
||||||
bitset_type b( 4 * bitset_type::bits_per_block - 1, 0ul );
|
bitset_type b( 4 * bitset_type::bits_per_block - 1, 0ul );
|
||||||
b.set( b.size() - 1 );
|
b.set( b.size() - 1 );
|
||||||
Tests::find_first( b );
|
Tests::find_first( b );
|
||||||
|
b.set( b.size() - 1, false );
|
||||||
|
Tests::find_first( b, 0, false );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test find_next and offset find_first
|
// Test find_next, find_next_off, offset find_first and offset find_first_off
|
||||||
{
|
{
|
||||||
// empty bitset
|
// empty bitset
|
||||||
bitset_type b;
|
bitset_type b;
|
||||||
@@ -339,6 +344,10 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::find_pos( b, 1 );
|
Tests::find_pos( b, 1 );
|
||||||
Tests::find_pos( b, 200 );
|
Tests::find_pos( b, 200 );
|
||||||
Tests::find_pos( b, b.npos );
|
Tests::find_pos( b, b.npos );
|
||||||
|
Tests::find_pos( b, 0, false );
|
||||||
|
Tests::find_pos( b, 1, false );
|
||||||
|
Tests::find_pos( b, 200, false );
|
||||||
|
Tests::find_pos( b, b.npos, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// bitset of size 1 (find_next can never find)
|
// bitset of size 1 (find_next can never find)
|
||||||
@@ -349,6 +358,10 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::find_pos( b, 1 );
|
Tests::find_pos( b, 1 );
|
||||||
Tests::find_pos( b, 200 );
|
Tests::find_pos( b, 200 );
|
||||||
Tests::find_pos( b, b.npos );
|
Tests::find_pos( b, b.npos );
|
||||||
|
Tests::find_pos( b, 0, false );
|
||||||
|
Tests::find_pos( b, 1, false );
|
||||||
|
Tests::find_pos( b, 200, false );
|
||||||
|
Tests::find_pos( b, b.npos, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// all-1s bitset
|
// all-1s bitset
|
||||||
@@ -359,8 +372,10 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
||||||
for ( typename bitset_type::size_type i = 0; i <= larger_than_size; ++i ) {
|
for ( typename bitset_type::size_type i = 0; i <= larger_than_size; ++i ) {
|
||||||
Tests::find_pos( b, i );
|
Tests::find_pos( b, i );
|
||||||
|
Tests::find_pos( b, i, false );
|
||||||
}
|
}
|
||||||
Tests::find_pos( b, b.npos );
|
Tests::find_pos( b, b.npos );
|
||||||
|
Tests::find_pos( b, b.npos, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// a bitset with 1s at block boundary only
|
// a bitset with 1s at block boundary only
|
||||||
@@ -370,7 +385,6 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
bitset_type b( num_blocks * block_width );
|
bitset_type b( num_blocks * block_width );
|
||||||
typename bitset_type::size_type i = block_width - 1;
|
typename bitset_type::size_type i = block_width - 1;
|
||||||
for ( ; i < b.size(); i += block_width ) {
|
for ( ; i < b.size(); i += block_width ) {
|
||||||
|
|
||||||
b.set( i );
|
b.set( i );
|
||||||
typename bitset_type::size_type first_in_block = i - ( block_width - 1 );
|
typename bitset_type::size_type first_in_block = i - ( block_width - 1 );
|
||||||
b.set( first_in_block );
|
b.set( first_in_block );
|
||||||
@@ -380,9 +394,10 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
||||||
for ( i = 0; i <= larger_than_size; ++i ) {
|
for ( i = 0; i <= larger_than_size; ++i ) {
|
||||||
Tests::find_pos( b, i );
|
Tests::find_pos( b, i );
|
||||||
|
Tests::find_pos( b, i, false );
|
||||||
}
|
}
|
||||||
Tests::find_pos( b, b.npos );
|
Tests::find_pos( b, b.npos );
|
||||||
|
Tests::find_pos( b, b.npos, false );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// bitset with alternate 1s and 0s
|
// bitset with alternate 1s and 0s
|
||||||
@@ -398,295 +413,305 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
||||||
for ( i = 0; i <= larger_than_size; ++i ) {
|
for ( i = 0; i <= larger_than_size; ++i ) {
|
||||||
Tests::find_pos( b, i );
|
Tests::find_pos( b, i );
|
||||||
|
Tests::find_pos( b, i, false );
|
||||||
}
|
}
|
||||||
Tests::find_pos( b, b.npos );
|
Tests::find_pos( b, b.npos );
|
||||||
|
Tests::find_pos( b, b.npos, false );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator==
|
// Test operator==
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::operator_equal( a, b );
|
Tests::operator_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::operator_equal( a, b );
|
Tests::operator_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::operator_equal( a, b );
|
Tests::operator_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::operator_equal( a, b );
|
Tests::operator_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_equal( a, b );
|
Tests::operator_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_equal( a, b );
|
Tests::operator_equal( a, b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator!=
|
// Test operator!=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::operator_not_equal( a, b );
|
Tests::operator_not_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::operator_not_equal( a, b );
|
Tests::operator_not_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::operator_not_equal( a, b );
|
Tests::operator_not_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::operator_not_equal( a, b );
|
Tests::operator_not_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_not_equal( a, b );
|
Tests::operator_not_equal( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_not_equal( a, b );
|
Tests::operator_not_equal( a, b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator<
|
// Test operator<
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a;
|
||||||
|
bitset_type b( std::string( "1" ) );
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("11"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("101")), b(std::string("11"));
|
bitset_type a( std::string( "10" ) ), b( std::string( "11" ) );
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("111"));
|
bitset_type a( std::string( "101" ) ), b( std::string( "11" ) );
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( std::string( "10" ) ), b( std::string( "111" ) );
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( std::string( "11" ) ), b( std::string( "111" ) );
|
||||||
|
Tests::operator_less_than( a, b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( long_string ), b( long_string );
|
||||||
|
Tests::operator_less_than( a, b );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_less_than( a, b );
|
Tests::operator_less_than( a, b );
|
||||||
}
|
}
|
||||||
// check for consistency with ulong behaviour when the sizes are equal
|
// check for consistency with ulong behaviour when the sizes are equal
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
|
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||||
assert(a < b);
|
BOOST_TEST( a < b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
|
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||||
assert(!(a < b));
|
BOOST_TEST( ! ( a < b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
|
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||||
assert(!(a < b));
|
BOOST_TEST( ! ( a < b ) );
|
||||||
}
|
}
|
||||||
// when the sizes are not equal lexicographic compare does not necessarily correspond to ulong behavior
|
// when the sizes are not equal lexicographic compare does not necessarily correspond to ulong behavior
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(4, 4ul), b(3, 5ul);
|
bitset_type a( 4, 4ul ), b( 3, 5ul );
|
||||||
assert(a < b);
|
BOOST_TEST( a < b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(4, 5ul);
|
bitset_type a( 3, 4ul ), b( 4, 5ul );
|
||||||
assert(!(a < b));
|
BOOST_TEST( ! ( a < b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(4, 4ul), b(3, 4ul);
|
bitset_type a( 4, 4ul ), b( 3, 4ul );
|
||||||
assert(a < b);
|
BOOST_TEST( a < b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(4, 4ul);
|
bitset_type a( 3, 4ul ), b( 4, 4ul );
|
||||||
assert(!(a < b));
|
BOOST_TEST( ! ( a < b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(4, 5ul), b(3, 4ul);
|
bitset_type a( 4, 5ul ), b( 3, 4ul );
|
||||||
assert(a < b);
|
BOOST_TEST( a < b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 5ul), b(4, 4ul);
|
bitset_type a( 3, 5ul ), b( 4, 4ul );
|
||||||
assert(!(a < b));
|
BOOST_TEST( ! ( a < b ) );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator<=
|
// Test operator<=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::operator_less_than_eq( a, b );
|
Tests::operator_less_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::operator_less_than_eq( a, b );
|
Tests::operator_less_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::operator_less_than_eq( a, b );
|
Tests::operator_less_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::operator_less_than_eq( a, b );
|
Tests::operator_less_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_less_than_eq( a, b );
|
Tests::operator_less_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_less_than_eq( a, b );
|
Tests::operator_less_than_eq( a, b );
|
||||||
}
|
}
|
||||||
// check for consistency with ulong behaviour
|
// check for consistency with ulong behaviour
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
|
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||||
assert(a <= b);
|
BOOST_TEST( a <= b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
|
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||||
assert(a <= b);
|
BOOST_TEST( a <= b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
|
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||||
assert(!(a <= b));
|
BOOST_TEST( ! ( a <= b ) );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator>
|
// Test operator>
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::operator_greater_than( a, b );
|
Tests::operator_greater_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::operator_greater_than( a, b );
|
Tests::operator_greater_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::operator_greater_than( a, b );
|
Tests::operator_greater_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::operator_greater_than( a, b );
|
Tests::operator_greater_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_greater_than( a, b );
|
Tests::operator_greater_than( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_greater_than( a, b );
|
Tests::operator_greater_than( a, b );
|
||||||
}
|
}
|
||||||
// check for consistency with ulong behaviour
|
// check for consistency with ulong behaviour
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
|
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||||
assert(!(a > b));
|
BOOST_TEST( ! ( a > b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
|
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||||
assert(!(a > b));
|
BOOST_TEST( ! ( a > b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
|
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||||
assert(a > b);
|
BOOST_TEST( a > b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test operator<=
|
// Test operator<=
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a, b;
|
bitset_type a, b;
|
||||||
Tests::operator_greater_than_eq( a, b );
|
Tests::operator_greater_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
|
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||||
Tests::operator_greater_than_eq( a, b );
|
Tests::operator_greater_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
|
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||||
Tests::operator_greater_than_eq( a, b );
|
Tests::operator_greater_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
Tests::operator_greater_than_eq( a, b );
|
Tests::operator_greater_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
a[ long_string.size() / 2 ].flip();
|
a[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_greater_than_eq( a, b );
|
Tests::operator_greater_than_eq( a, b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(long_string), b(long_string);
|
bitset_type a( long_string ), b( long_string );
|
||||||
b[ long_string.size() / 2 ].flip();
|
b[ long_string.size() / 2 ].flip();
|
||||||
Tests::operator_greater_than_eq( a, b );
|
Tests::operator_greater_than_eq( a, b );
|
||||||
}
|
}
|
||||||
// check for consistency with ulong behaviour
|
// check for consistency with ulong behaviour
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
|
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||||
assert(!(a >= b));
|
BOOST_TEST( ! ( a >= b ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
|
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||||
assert(a >= b);
|
BOOST_TEST( a >= b );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
|
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||||
assert(a >= b);
|
BOOST_TEST( a >= b );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.test(pos)
|
// Test b.test(pos)
|
||||||
{ // case pos >= b.size()
|
{ // case pos >= b.size()
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::test_bit( b, 0 );
|
Tests::test_bit( b, 0 );
|
||||||
}
|
}
|
||||||
{ // case pos < b.size()
|
{ // case pos < b.size()
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::test_bit( b, 0 );
|
Tests::test_bit( b, 0 );
|
||||||
}
|
}
|
||||||
{ // case pos == b.size() / 2
|
{ // case pos == b.size() / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::test_bit( b, long_string.size() / 2 );
|
Tests::test_bit( b, long_string.size() / 2 );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b.test_set(pos)
|
// Test b.test_set(pos)
|
||||||
{ // case pos >= b.size()
|
{ // case pos >= b.size()
|
||||||
boost::dynamic_bitset<Block> b;
|
bitset_type b;
|
||||||
Tests::test_set_bit( b, 0, true );
|
Tests::test_set_bit( b, 0, true );
|
||||||
Tests::test_set_bit( b, 0, false );
|
Tests::test_set_bit( b, 0, false );
|
||||||
}
|
}
|
||||||
{ // case pos < b.size()
|
{ // case pos < b.size()
|
||||||
boost::dynamic_bitset<Block> b(std::string("0"));
|
bitset_type b( std::string( "0" ) );
|
||||||
Tests::test_set_bit( b, 0, true );
|
Tests::test_set_bit( b, 0, true );
|
||||||
Tests::test_set_bit( b, 0, false );
|
Tests::test_set_bit( b, 0, false );
|
||||||
}
|
}
|
||||||
{ // case pos == b.size() / 2
|
{ // case pos == b.size() / 2
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::test_set_bit( b, long_string.size() / 2, true );
|
Tests::test_set_bit( b, long_string.size() / 2, true );
|
||||||
Tests::test_set_bit( b, long_string.size() / 2, false );
|
Tests::test_set_bit( b, long_string.size() / 2, false );
|
||||||
}
|
}
|
||||||
@@ -694,121 +719,123 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
// Test b << pos
|
// Test b << pos
|
||||||
{ // case pos == 0
|
{ // case pos == 0
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
boost::dynamic_bitset<Block> b(std::string("1010"));
|
bitset_type b( std::string( "1010" ) );
|
||||||
Tests::operator_shift_left( b, pos );
|
Tests::operator_shift_left( b, pos );
|
||||||
}
|
}
|
||||||
{ // case pos == size()/2
|
{ // case pos == size()/2
|
||||||
std::size_t pos = long_string.size() / 2;
|
std::size_t pos = long_string.size() / 2;
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::operator_shift_left( b, pos );
|
Tests::operator_shift_left( b, pos );
|
||||||
}
|
}
|
||||||
{ // case pos >= n
|
{ // case pos >= n
|
||||||
std::size_t pos = long_string.size();
|
std::size_t pos = long_string.size();
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::operator_shift_left( b, pos );
|
Tests::operator_shift_left( b, pos );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test b >> pos
|
// Test b >> pos
|
||||||
{ // case pos == 0
|
{ // case pos == 0
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
boost::dynamic_bitset<Block> b(std::string("1010"));
|
bitset_type b( std::string( "1010" ) );
|
||||||
Tests::operator_shift_right( b, pos );
|
Tests::operator_shift_right( b, pos );
|
||||||
}
|
}
|
||||||
{ // case pos == size()/2
|
{ // case pos == size()/2
|
||||||
std::size_t pos = long_string.size() / 2;
|
std::size_t pos = long_string.size() / 2;
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::operator_shift_right( b, pos );
|
Tests::operator_shift_right( b, pos );
|
||||||
}
|
}
|
||||||
{ // case pos >= n
|
{ // case pos >= n
|
||||||
std::size_t pos = long_string.size();
|
std::size_t pos = long_string.size();
|
||||||
boost::dynamic_bitset<Block> b(long_string);
|
bitset_type b( long_string );
|
||||||
Tests::operator_shift_right( b, pos );
|
Tests::operator_shift_right( b, pos );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test a & b
|
// Test a & b
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::operator_and( lhs, rhs );
|
Tests::operator_and( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::operator_and( lhs, rhs );
|
Tests::operator_and( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
bitset_type lhs( long_string.size(), 0 ), rhs( long_string );
|
||||||
Tests::operator_and( lhs, rhs );
|
Tests::operator_and( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||||
Tests::operator_and( lhs, rhs );
|
Tests::operator_and( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test a | b
|
// Test a | b
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::operator_or( lhs, rhs );
|
Tests::operator_or( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::operator_or( lhs, rhs );
|
Tests::operator_or( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
bitset_type lhs( long_string.size(), 0 ), rhs( long_string );
|
||||||
Tests::operator_or( lhs, rhs );
|
Tests::operator_or( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||||
Tests::operator_or( lhs, rhs );
|
Tests::operator_or( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test a^b
|
// Test a^b
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::operator_xor( lhs, rhs );
|
Tests::operator_xor( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::operator_xor( lhs, rhs );
|
Tests::operator_xor( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
bitset_type lhs( long_string.size(), 0 ), rhs( long_string );
|
||||||
Tests::operator_xor( lhs, rhs );
|
Tests::operator_xor( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||||
Tests::operator_xor( lhs, rhs );
|
Tests::operator_xor( lhs, rhs );
|
||||||
}
|
}
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test a-b
|
// Test a-b
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs, rhs;
|
bitset_type lhs, rhs;
|
||||||
Tests::operator_sub( lhs, rhs );
|
Tests::operator_sub( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
|
bitset_type lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||||
Tests::operator_sub( lhs, rhs );
|
Tests::operator_sub( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
|
bitset_type lhs( long_string.size(), 0 ), rhs( long_string );
|
||||||
Tests::operator_sub( lhs, rhs );
|
Tests::operator_sub( lhs, rhs );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
|
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||||
Tests::operator_sub( lhs, rhs );
|
Tests::operator_sub( lhs, rhs );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
run_test_cases< unsigned char >();
|
run_test_cases< unsigned char >();
|
||||||
|
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||||
run_test_cases< unsigned short >();
|
run_test_cases< unsigned short >();
|
||||||
|
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||||
run_test_cases< unsigned int >();
|
run_test_cases< unsigned int >();
|
||||||
|
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||||
run_test_cases< unsigned long >();
|
run_test_cases< unsigned long >();
|
||||||
# ifdef BOOST_HAS_LONG_LONG
|
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||||
run_test_cases< ::boost::ulong_long_type>();
|
run_test_cases< unsigned long long >();
|
||||||
# endif
|
run_test_cases< unsigned long long, small_vector< unsigned long long > >();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Copyright (c) 2001 Jeremy Siek
|
// Copyright (c) 2001 Jeremy Siek
|
||||||
// Copyright (c) 2003-2006 Gennaro Prota
|
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -8,65 +8,52 @@
|
|||||||
//
|
//
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
#include <fstream>
|
#include "bitset_test.hpp"
|
||||||
#include <string>
|
#include "boost/config.hpp"
|
||||||
#include <cstddef> // for std::size_t
|
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||||
#include <stdexcept> // for std::logic_error
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <fstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#if ! defined( BOOST_NO_STRINGSTREAM )
|
#if ! defined( BOOST_NO_STRINGSTREAM )
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "bitset_test.hpp"
|
#if defined BOOST_NO_STD_WSTRING
|
||||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
|
||||||
#include <boost/config/workaround.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
// Codewarrior 8.3 for Win fails without this.
|
|
||||||
// Thanks Howard Hinnant ;)
|
|
||||||
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
|
||||||
# pragma parse_func_templ off
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
|
|
||||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ! defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
#if ! defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||||
std::wstring widen_string( const std::string & str,
|
std::wstring
|
||||||
const std::locale & loc = std::locale() )
|
widen_string( const std::string & str, const std::locale & loc = std::locale() )
|
||||||
{
|
{
|
||||||
std::wstring result;
|
std::wstring result;
|
||||||
const std::string::size_type len = str.length();
|
const std::string::size_type len = str.length();
|
||||||
if ( len != 0 ) {
|
if ( len != 0 ) {
|
||||||
|
|
||||||
typedef std::ctype< wchar_t > ct_type;
|
typedef std::ctype< wchar_t > ct_type;
|
||||||
typedef std::wstring::traits_type tr_type;
|
typedef std::wstring::traits_type tr_type;
|
||||||
const ct_type & ct = BOOST_USE_FACET(ct_type, loc);
|
const ct_type & ct = std::use_facet< ct_type >( loc );
|
||||||
|
|
||||||
result.resize( len );
|
result.resize( len );
|
||||||
for ( std::size_t i = 0; i < len; ++i )
|
for ( std::size_t i = 0; i < len; ++i )
|
||||||
tr_type::assign( result[ i ], ct.widen( str[ i ] ) );
|
tr_type::assign( result[ i ], ct.widen( str[ i ] ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename Block>
|
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
void
|
||||||
|
run_test_cases()
|
||||||
{
|
{
|
||||||
|
typedef boost::dynamic_bitset< Block, AllocatorOrContainer > bitset_type;
|
||||||
typedef boost::dynamic_bitset<Block> bitset_type;
|
|
||||||
typedef bitset_test< bitset_type > Tests;
|
typedef bitset_test< bitset_type > Tests;
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test stream operator<<
|
// Test stream operator<<
|
||||||
{
|
{
|
||||||
|
|
||||||
// The test "variables" are: the stream type and its state, the
|
// The test "variables" are: the stream type and its state, the
|
||||||
// exception mask, the width, the fill char and the padding side (left/right)
|
// exception mask, the width, the fill char and the padding side (left/right)
|
||||||
|
|
||||||
@@ -91,20 +78,15 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
std::size_t num_strings = sizeof( strings ) / sizeof( strings[ 0 ] );
|
std::size_t num_strings = sizeof( strings ) / sizeof( strings[ 0 ] );
|
||||||
std::size_t num_chars = sizeof( fill_chars ) / sizeof( fill_chars[ 0 ] );
|
std::size_t num_chars = sizeof( fill_chars ) / sizeof( fill_chars[ 0 ] );
|
||||||
|
|
||||||
std::fstream not_good_stream("dynamic_bitset_tests - this file shouldn't exist",
|
std::fstream not_good_stream( "dynamic_bitset_tests - this file shouldn't exist", std::ios::in );
|
||||||
std::ios::in);
|
|
||||||
|
|
||||||
|
|
||||||
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
|
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
|
||||||
for ( std::size_t si = 0; si < num_strings; ++si ) {
|
for ( std::size_t si = 0; si < num_strings; ++si ) {
|
||||||
|
|
||||||
std::streamsize slen = (std::streamsize)( strings[ si ].length() );
|
std::streamsize slen = (std::streamsize)( strings[ si ].length() );
|
||||||
|
|
||||||
assert( (std::numeric_limits<std::streamsize>::max)()
|
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
|
||||||
>=(std::streamsize)(1+slen*2) );
|
|
||||||
|
|
||||||
for ( std::size_t ci = 0; ci < num_chars; ++ci ) {
|
for ( std::size_t ci = 0; ci < num_chars; ++ci ) {
|
||||||
|
|
||||||
// note how "negative widths" are tested too
|
// note how "negative widths" are tested too
|
||||||
const std::streamsize widths[] = { -1 - slen / 2, 0, slen / 2, 1 + slen * 2 };
|
const std::streamsize widths[] = { -1 - slen / 2, 0, slen / 2, 1 + slen * 2 };
|
||||||
std::size_t num_widths = sizeof( widths ) / sizeof( widths[ 0 ] );
|
std::size_t num_widths = sizeof( widths ) / sizeof( widths[ 0 ] );
|
||||||
@@ -119,7 +101,10 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
bitset_type b( strings[ si ] );
|
bitset_type b( strings[ si ] );
|
||||||
not_good_stream.width( w );
|
not_good_stream.width( w );
|
||||||
not_good_stream.fill( fill_chars[ ci ] );
|
not_good_stream.fill( fill_chars[ ci ] );
|
||||||
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
|
try {
|
||||||
|
not_good_stream.exceptions( masks[ mi ] );
|
||||||
|
} catch ( ... ) {
|
||||||
|
}
|
||||||
|
|
||||||
Tests::stream_inserter( b, not_good_stream, "<unused_string>" );
|
Tests::stream_inserter( b, not_good_stream, "<unused_string>" );
|
||||||
}
|
}
|
||||||
@@ -152,13 +137,11 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // for (; mi..)
|
} // for (; mi..)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// Test stream operator>>
|
// Test stream operator>>
|
||||||
{
|
{
|
||||||
|
|
||||||
// The test "variables" are: the stream type, the exception mask,
|
// The test "variables" are: the stream type, the exception mask,
|
||||||
// the actual contents (and/or state) of the stream, and width.
|
// the actual contents (and/or state) of the stream, and width.
|
||||||
//
|
//
|
||||||
@@ -175,7 +158,6 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
// Note how the bitset object is not initially empty. That helps checking
|
// Note how the bitset object is not initially empty. That helps checking
|
||||||
// that it isn't erroneously clear()ed by operator>>.
|
// that it isn't erroneously clear()ed by operator>>.
|
||||||
|
|
||||||
|
|
||||||
std::ios::iostate masks[] = {
|
std::ios::iostate masks[] = {
|
||||||
std::ios::goodbit,
|
std::ios::goodbit,
|
||||||
std::ios::eofbit,
|
std::ios::eofbit,
|
||||||
@@ -186,19 +168,13 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
const std::string spaces = "\t\n "; //"\t\n\v\f ";
|
const std::string spaces = "\t\n "; //"\t\n\v\f ";
|
||||||
|
|
||||||
const std::string long_string = get_long_string();
|
const std::string long_string = get_long_string();
|
||||||
/*const*/ static std::string strings[] = {
|
const static std::string strings[] = {
|
||||||
// NOTE: "const" gives the usual problems with Borland
|
|
||||||
// (in Tests::stream_extractor instantiation)
|
|
||||||
|
|
||||||
|
|
||||||
#if !(defined BOOST_BORLANDC \
|
|
||||||
&& BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)))
|
|
||||||
// Borland 5.5.1 with RW library crashes
|
|
||||||
// empty string
|
// empty string
|
||||||
std::string( "" ),
|
std::string( "" ),
|
||||||
// no bitset
|
// no bitset
|
||||||
spaces,
|
spaces,
|
||||||
#endif
|
|
||||||
// no bitset
|
// no bitset
|
||||||
std::string( "x" ),
|
std::string( "x" ),
|
||||||
std::string( "\t xyz" ),
|
std::string( "\t xyz" ),
|
||||||
@@ -222,7 +198,6 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
spaces + long_string + spaces
|
spaces + long_string + spaces
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
std::stringstream not_good_stream;
|
std::stringstream not_good_stream;
|
||||||
@@ -235,7 +210,6 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
|
|
||||||
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
|
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
|
||||||
for ( std::size_t si = 0; si < num_strings; ++si ) {
|
for ( std::size_t si = 0; si < num_strings; ++si ) {
|
||||||
|
|
||||||
const std::streamsize slen = (std::streamsize)( strings[ si ].length() );
|
const std::streamsize slen = (std::streamsize)( strings[ si ].length() );
|
||||||
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
|
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
|
||||||
|
|
||||||
@@ -252,7 +226,10 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
" - please, double check" );
|
" - please, double check" );
|
||||||
bitset_type b( 1, 15ul ); // note: b is not empty
|
bitset_type b( 1, 15ul ); // note: b is not empty
|
||||||
not_good_stream.width( w );
|
not_good_stream.width( w );
|
||||||
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
|
try {
|
||||||
|
not_good_stream.exceptions( masks[ mi ] );
|
||||||
|
} catch ( ... ) {
|
||||||
|
}
|
||||||
std::string irrelevant;
|
std::string irrelevant;
|
||||||
Tests::stream_extractor( b, not_good_stream, irrelevant );
|
Tests::stream_extractor( b, not_good_stream, irrelevant );
|
||||||
}
|
}
|
||||||
@@ -308,31 +285,29 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
|||||||
Tests::stream_extractor( b, wstream, wstr );
|
Tests::stream_extractor( b, wstream, wstr );
|
||||||
}
|
}
|
||||||
#endif // BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
#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
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
run_test_cases< unsigned char >();
|
run_test_cases< unsigned char >();
|
||||||
|
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||||
run_test_cases< unsigned short >();
|
run_test_cases< unsigned short >();
|
||||||
|
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||||
run_test_cases< unsigned int >();
|
run_test_cases< unsigned int >();
|
||||||
|
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||||
run_test_cases< unsigned long >();
|
run_test_cases< unsigned long >();
|
||||||
# ifdef BOOST_HAS_LONG_LONG
|
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||||
run_test_cases< ::boost::ulong_long_type>();
|
run_test_cases< unsigned long long >();
|
||||||
# endif
|
run_test_cases< unsigned long long, small_vector< unsigned long long > >();
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Copyright (c) 2001 Jeremy Siek
|
// Copyright (c) 2001 Jeremy Siek
|
||||||
// Copyright (c) 2003-2006 Gennaro Prota
|
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||||
//
|
//
|
||||||
// Copyright (c) 2015 Seth Heeren
|
// Copyright (c) 2015 Seth Heeren
|
||||||
//
|
//
|
||||||
@@ -10,48 +10,42 @@
|
|||||||
//
|
//
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
|
#include "bitset_test.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.hpp"
|
||||||
|
#include "boost/dynamic_bitset/serialization.hpp"
|
||||||
|
#include "boost/serialization/vector.hpp"
|
||||||
|
|
||||||
#if ! defined( BOOST_NO_STRINGSTREAM )
|
#if ! defined( BOOST_NO_STRINGSTREAM )
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "bitset_test.hpp"
|
#if defined BOOST_NO_STD_WSTRING
|
||||||
#include <boost/dynamic_bitset/serialization.hpp>
|
|
||||||
#include <boost/config/workaround.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
// Codewarrior 8.3 for Win fails without this.
|
|
||||||
// Thanks Howard Hinnant ;)
|
|
||||||
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
|
||||||
# pragma parse_func_templ off
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
|
|
||||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/serialization/vector.hpp>
|
|
||||||
#include <boost/archive/binary_oarchive.hpp>
|
|
||||||
#include <boost/archive/binary_iarchive.hpp>
|
|
||||||
#include <boost/archive/xml_oarchive.hpp>
|
|
||||||
#include <boost/archive/xml_iarchive.hpp>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template< typename Block >
|
template< typename Block >
|
||||||
struct SerializableType {
|
struct SerializableType
|
||||||
|
{
|
||||||
boost::dynamic_bitset< Block > x;
|
boost::dynamic_bitset< Block > x;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
template <class Archive> void serialize(Archive &ar, const unsigned int) {
|
template< class Archive >
|
||||||
|
void
|
||||||
|
serialize( Archive & ar, unsigned int )
|
||||||
|
{
|
||||||
ar & BOOST_SERIALIZATION_NVP( x );
|
ar & BOOST_SERIALIZATION_NVP( x );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Block, typename IArchive, typename OArchive >
|
template< typename Block, typename IArchive, typename OArchive >
|
||||||
void test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
void
|
||||||
|
test_serialization()
|
||||||
{
|
{
|
||||||
SerializableType< Block > a;
|
SerializableType< Block > a;
|
||||||
|
|
||||||
@@ -73,7 +67,7 @@ namespace {
|
|||||||
SerializableType< Block > b;
|
SerializableType< Block > b;
|
||||||
ia >> BOOST_SERIALIZATION_NVP( b );
|
ia >> BOOST_SERIALIZATION_NVP( b );
|
||||||
|
|
||||||
assert(a.x == b.x);
|
BOOST_TEST( a.x == b.x );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# error "TODO implement file-based test path?"
|
# error "TODO implement file-based test path?"
|
||||||
@@ -81,32 +75,36 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< typename Block >
|
template< typename Block >
|
||||||
void test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
|
void
|
||||||
|
test_binary_archive()
|
||||||
|
{
|
||||||
test_serialization< Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive >();
|
test_serialization< Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive >();
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Block >
|
template< typename Block >
|
||||||
void test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
|
void
|
||||||
|
test_xml_archive()
|
||||||
|
{
|
||||||
test_serialization< Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive >();
|
test_serialization< Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive >();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Block >
|
template< typename Block >
|
||||||
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
void
|
||||||
|
run_test_cases()
|
||||||
{
|
{
|
||||||
test_binary_archive< Block >();
|
test_binary_archive< Block >();
|
||||||
test_xml_archive< Block >();
|
test_xml_archive< Block >();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
run_test_cases< unsigned char >();
|
run_test_cases< unsigned char >();
|
||||||
run_test_cases< unsigned short >();
|
run_test_cases< unsigned short >();
|
||||||
run_test_cases< unsigned int >();
|
run_test_cases< unsigned int >();
|
||||||
run_test_cases< unsigned long >();
|
run_test_cases< unsigned long >();
|
||||||
# ifdef BOOST_HAS_LONG_LONG
|
run_test_cases< unsigned long long >();
|
||||||
run_test_cases< ::boost::ulong_long_type>();
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2018 James E. King III
|
// 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
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// 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
|
boost::dynamic_bitset<> x( 5 ); // all 0's by default
|
||||||
x.set( 1, 2 );
|
x.set( 1, 2 );
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2019 James E. King III
|
// 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
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include "boost/config.hpp"
|
||||||
#include <boost/dynamic_bitset.hpp>
|
#include "boost/core/lightweight_test.hpp"
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include "boost/dynamic_bitset.hpp"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
int main(int, char*[])
|
int
|
||||||
|
main( int, char *[] )
|
||||||
{
|
{
|
||||||
typedef boost::dynamic_bitset< unsigned long > bitset_type;
|
typedef boost::dynamic_bitset< unsigned long > bitset_type;
|
||||||
const std::string long_string =
|
const std::string long_string =
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2018 James E. King III
|
// 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
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/cstdint.hpp>
|
#include "boost/core/lightweight_test.hpp"
|
||||||
#include <boost/dynamic_bitset/detail/lowest_bit.hpp>
|
#include "boost/cstdint.hpp"
|
||||||
#include <boost/core/lightweight_test.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 ) {
|
for ( boost::int32_t i = 1; i < 32; ++i ) {
|
||||||
BOOST_TEST_EQ( i, boost::detail::lowest_bit( 1u << i ) );
|
BOOST_TEST_EQ( i, boost::detail::lowest_bit( 1u << i ) );
|
||||||
|
|||||||
@@ -1,39 +1,40 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2019 James E. King III
|
// Copyright (C) 2019 James E. King III
|
||||||
//
|
// Copyright (C) 2025 Gennaro Prota
|
||||||
// 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
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include "boost/core/lightweight_test.hpp"
|
||||||
#include <boost/dynamic_bitset.hpp>
|
#include "boost/dynamic_bitset.hpp"
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
int main(int, char*[])
|
int
|
||||||
|
main( int, char *[] )
|
||||||
{
|
{
|
||||||
typedef boost::dynamic_bitset< unsigned long > bitset_type;
|
typedef boost::dynamic_bitset< unsigned long > bitset_type;
|
||||||
const std::string long_string =
|
const std::string long_string =
|
||||||
"01001110101110110101011010000000000011110101101111111111";
|
"01001110101110110101011010000000000011110101101111111111";
|
||||||
|
|
||||||
bitset_type zeroes(long_string.size(), 0);
|
// Some bitsets with the same size but different underlying vectors.
|
||||||
bitset_type stuff (long_string);
|
const bitset_type zeroes( long_string.size(), 0 );
|
||||||
bitset_type ones (long_string.size(), 1);
|
const bitset_type stuff( long_string );
|
||||||
|
const bitset_type one( long_string.size(), 1 );
|
||||||
|
|
||||||
|
// Some bitsets with different sizes but equal underlying vectors.
|
||||||
|
const bitset_type zeroes2( 2, 0 );
|
||||||
|
const bitset_type zeroes3( 3, 0 );
|
||||||
|
|
||||||
std::unordered_set< bitset_type > bitsets;
|
std::unordered_set< bitset_type > bitsets;
|
||||||
bitsets.insert( zeroes );
|
bitsets.insert( zeroes );
|
||||||
bitsets.insert( stuff );
|
bitsets.insert( stuff );
|
||||||
bitsets.insert(ones);
|
bitsets.insert( one );
|
||||||
|
bitsets.insert( zeroes2 );
|
||||||
|
bitsets.insert( zeroes3 );
|
||||||
|
|
||||||
BOOST_TEST_EQ(bitsets.size(), 3);
|
BOOST_TEST_EQ( bitsets.size(), 5 );
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user