Compare commits

..

246 Commits

Author SHA1 Message Date
Peter Dimov
11d85403b9 Regenerate CMakeLists.txt 2021-05-30 07:28:07 +03:00
Sam Darwin
296f902453 Add GitHub Actions config [ci skip] (#60) 2021-03-03 18:26:18 -08:00
Sam Darwin
a16a1c3afa add drone config [ci skip] (#57) 2021-03-03 18:25:37 -08:00
Edward Diener
66a956b114 Add "cxxstd" json field 2021-01-19 17:48:52 -05:00
Glen Fernandes
b59fc97a67 Use core/allocator_access for allocator use 2020-05-25 22:57:13 -04:00
Andrey Semashev
4a38853898 Avoid using deprecated headers to silence compiler warnings. (#56)
The warnings are generated by boost/detail/iterator.hpp and
boost/detail/no_exceptions_support.hpp. Also, updated location of
addressof.hpp.
2020-05-13 06:44:47 -07:00
joprodrigues
54b15ad171 Improvement to m_do_find_from (#55)
Use find_if to inside find next bit
2020-04-26 10:11:36 -04:00
Edward Diener
ffff25ac00 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. (#54) 2020-04-16 07:47:58 -07:00
Glen Fernandes
3e0107909b Replace Block(~0) with a max_limit<Block>::value 2020-01-22 07:41:06 -05:00
Glen Fernandes
8359a80feb Make DynamicBitset no longer depend on Serialization (#50) 2019-09-30 15:29:43 -04:00
James E. King III
db5da12bcd Update CI
This fixes #41
2019-06-23 20:19:38 -04:00
Miutsuru kariya
ab192ca5f1 Make default constructor non-explicit (#48)
It is better to support copy-initialization with default constructor. cf. LWG Issue 2193. Default constructors for standard library containers are explicit.
2019-06-12 19:45:11 -04:00
James E. King III
26918f80d5 Add support for std::hash and unit tests for hashing 2019-06-07 13:55:57 -04:00
Alexey Stukalov
229bced733 hash_value() for dynamic_bitset (support boost::hash) 2019-06-07 13:55:57 -04:00
Glen Fernandes
ccb380a1bc Switch from deprecated Test to LightweightTest 2019-06-07 07:02:31 -04:00
Sam Day
4de44e9112 Add basic CMake support. 2019-06-06 11:37:47 -04:00
James E. King III
3f650f50c3 Since coverity with gcc hangs, trying clang 2019-04-26 12:56:07 -04:00
James E. King III
b64e20079c Fix coverity scan job 2019-04-26 09:48:03 -04:00
Andrey Semashev
83bdf5a335 Reenabled popcnt for MSVC, improved perf by leveraging ILP.
On MSVC and compatible compilers popcnt is now enabled if it is known at
compile time that the target CPU supports popcnt instruction. Unfortunately,
MSVC does not have a predefined macro specifically for popcnt, so we have
to test for AVX instead. __POPCNT__ is still tested in case clang or user
defines it.

For MSVC, the 64-bit popcount is now also implemented on 32-bit targets by
issuing two 32-bit popcnt instructions. For gcc and compatible compilers,
16-bit popcount implementation is provided, which is better than the generic
popcount implementation, but still slower than byte-wise do_count.

The do_count algorithm implementations have been improved by leveraging
instruction level parallelism better, which gives 0 to 27% improvement and
no regressions.

Also made code formatting more consistent and reduced code duplication between
do_count implementations.
2019-04-26 08:55:53 -04:00
Tinko Bartels
c747bec057 Change sgi/stl links to boost.org. 2019-04-23 13:32:20 -04:00
James E. King III
f506b99f70 Update CI and change boost/timer deprecated use 2019-04-23 10:40:34 -04:00
Tinko Bartels
1b8b128f29 Replaced links to sgi.com with links to a mirror. 2019-04-22 12:20:38 -04:00
James E. King III
91625cece1 Disable hardware supported popcount on MSVC.
- the new implementation failed to check for hardware support
- the behavior was undefined on platforms without SSE4
2019-02-22 08:36:12 -05:00
James E. King III
a580c496fa fix set() ambiguity with range based call and default value 2018-11-03 16:45:29 -04:00
James E. King III
1ca15c5fcd Enhance CI with libc++ and VC2017 strict jobs 2018-11-03 15:54:53 -04:00
James E. King III
512ac37529 Enhance Travis CI build coverage 2018-10-28 10:42:35 -04:00
James E. King III
8e265c49f8 cleanup pending and detail headers 2018-10-21 12:44:12 -04:00
Evgeny Shulgin
a449a11a80 Add set/reset/flip functions to change sequences (#27)
* Add set(pos, len) function to change sequences
* Add reset(pos, len) function to clear sequences
* Add flip(pos, len) function to flip sequences
* Add custom range operations
2018-10-12 08:07:01 -04:00
James E. King III
a0735943f2 Merge branch 'master' into develop 2018-10-12 11:47:12 +00:00
Glen Fernandes
8fe1db1b08 Correct e-mail address 2018-09-23 08:55:34 -04:00
Glen Fernandes
d7d6555f85 Correct e-mail address 2018-09-05 08:11:50 -04:00
Evgeny Shulgin
a90fe08934 Add hardware supported popcount 2018-09-01 21:56:57 -04:00
James E. King III
b944aa3008 fix broken ci jobs in travis 2018-07-14 20:51:19 +00:00
James E. King III
759af5e853 Fix coverity badges in readme 2018-07-04 08:05:54 -04:00
James E. King III
7b6379a356 Add CI framework used in a number of other repositories:
- travis with valgrind, cppcheck, ubsan, codecov, covscan (future)
  - appveyor with MSVC 2010 through 2017, cygwin 32/64, mingw 32/64
  - README, LICENSE, etc.
2018-07-04 07:49:11 -04:00
Edward Diener
4f54d83981 Merge pull request #21 from NAThompson/remove_deprecated_header
Replace deprecated header with non-deprecated
2018-02-11 16:50:56 -05:00
Nick Thompson
4cac68e762 Remove deprecated header. 2018-02-11 15:08:19 -06:00
Marshall Clow
d3eb4faf0c Fix some warnings from gcc - https://github.com/boostorg/dynamic_bitset/issues/19 2018-01-31 11:11:12 -08:00
Marshall Clow
3f3662d39d Fix comment block in Jamfile; addresses https://github.com/boostorg/dynamic_bitset/issues/20 2018-01-31 09:27:51 -08:00
Edward Diener
184d1ba7ad Merge pull request #17 from DanielaE/feature/squash-narrowing-warnings
squash compiler warnings due to wrong order of type-cast and integral…
2017-06-27 09:36:10 -04:00
Daniela Engert
5b39db5ba0 squash compiler warnings due to wrong order of type-cast and integral type promotion
Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-05-25 10:29:34 +02:00
Edward Diener
f4e49ff56f Revert masks change 2017-05-18 11:52:03 -04:00
Edward Diener
0c8640efb8 Merge branch 'develop' into LessThanFix 2017-05-17 20:59:44 -04:00
Edward Diener
0ead484c37 Implemented lexigraphic compare when bitsets have different lengths. 2017-05-17 20:59:08 -04:00
Edward Diener
6cafa21c6d Fix for gcc and clang using libstdc++. 2017-05-15 16:29:38 -04:00
Edward Diener
dbfce8e174 Allow different sized bitsets to be compared for <, >, <=, >= 2017-05-15 13:03:15 -04:00
Marshall Clow
684b6117dd Merge pull request #16 from DanielaE/fix/wrong-parameter-type
fix wrong parameter type in constructor of dynamic_bitset::reference
2017-04-16 07:03:51 -07:00
Daniela Engert
572e9d78ff fix wrong parameter type in constructor of dynamic_bitset::reference
Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-03-18 13:49:16 +01:00
Edward Diener
e49b08a289 Added expected doc subdirectory 2017-01-09 03:09:28 -05:00
Edward Diener
d644c83b13 Merge pull request #14 from sehe/develop
Add support for Boost Serialization of dynamic_bitset<>
2017-01-08 23:35:27 -05:00
Seth Heeren
a50768c085 Add tests for serialization support 2017-01-09 03:26:14 +01:00
Seth Heeren
91895380c6 Add optional serialization support
This implemenents non-intrusive serialization support to dynamic_bitset<> based on Boost Serialization

 - it supports archives that require named elements
 - it gets private member access using a nested friend class (to decouple the interface entirely)
 - relies on boost/serialization/vector.hpp for actual implementation
2017-01-09 03:19:57 +01:00
Marshall Clow
7259281f5b Merge pull request #15 from danieljames/move-tests
This looks fine to me.  I'll watch the test bots, and merge to master in a week or so.
2016-07-01 08:24:46 -07:00
Daniel
92af4f52e9 Dummy jamfile for the super project's build script. 2016-07-01 09:10:18 +01:00
Daniel
d86f4ebddb Move tests into test subdirectory 2016-07-01 09:08:51 +01:00
ricky65
340822f979 Add capacity(), reserve(), and shrink_to_fit(). 2015-06-03 22:45:16 -07:00
Ahmed Charles
1c5e30fe49 Merge branch 'master' into develop 2015-06-03 22:44:34 -07:00
Ahmed Charles
0f48010783 Merge branch 'develop' 2015-06-03 22:43:44 -07:00
Ahmed Charles
1d59cc4788 Add converting constructor to minimal_allocator. 2015-05-19 00:36:26 -07:00
Marshall Clow
9879dd05b5 Merge changes from develop for the 1.58.0 release 2015-04-01 10:29:10 -07:00
Marshall Clow
29ba0c22b1 Merge pull request #13 from ahmedcharles/doc
Update 'more' links.
2015-03-18 16:10:57 -07:00
Daniel James
8b7374b1db Update 'more' links.
[SVN r44996]
2015-03-18 22:51:14 +00:00
Steven Watanabe
2091a4fd18 Merge branch 'develop' 2015-03-07 11:53:03 -07:00
Marshall Clow
225064d355 Patch by Riccardo Marcangelo: Added a pop_back() member function which decreases the size of the bitset by one 2014-09-15 08:29:05 -07:00
Noel Belcourt
b151c97fd2 Merge pull request #10 from danieljames/metadata
Create metadata file.
2014-08-23 14:08:58 -06:00
Daniel James
a93174ddf9 Add metadata file. 2014-08-18 14:58:36 +01:00
Noel Belcourt
1611aeb16a Merge pull request #9 from boostorg/develop
Merge develop to master

Tested on Darwin, thanks.
2014-06-25 13:27:29 -06:00
Ahmed Charles
3229e26108 Merge pull request #8 from glenfe/develop
Support C++11 minimal allocators and add noexcept specifications
2014-05-28 10:12:07 -07:00
Glen Fernandes
083c5e6214 Use non-deprecated macro for r-value reference support detection 2014-05-19 17:41:50 -07:00
Glen Fernandes
18eb52ecee Add noexcept specifications 2014-05-19 17:39:39 -07:00
Glen Fernandes
a3ea40d932 Support C++11 minimal allocators 2014-05-19 17:38:23 -07:00
Ahmed Charles
dd7cdc794e Merge branch 'master' into develop 2014-05-17 16:32:16 -06:00
Ahmed Charles
10195375ed Fix lacking include in previous pull request. 2014-05-17 16:30:18 -06:00
Noel Belcourt
9ed6f608a1 Merge pull request #6 from 0-wiz-0/master
Fix implicit conversion changes signedness problems.

Looks good, thanks!
2014-05-16 11:46:05 -06:00
Boleslaw Ciesielski
ba0ba59f24 Add support to dynamic_bitset for compiling with exceptions disabled by using BOOST_TRY/BOOST_CATCH.
This applies the patch from bug https://svn.boost.org/trac/boost/ticket/9939
2014-05-16 12:05:43 -04:00
Thomas Klausner
bcc384b604 Fix implicit conversion changes signedness problems.
clang-3.5 trunk 201163 and OS X's clang (not sure which version)
report -Wsign-conversion warnings with this header. This patch fixes
them.

https://svn.boost.org/trac/boost/ticket/9725

Signed-off-by: Thomas Klausner <tk@giga.or.at>
2014-05-16 16:38:38 +02:00
Ahmed Charles
7b14895ec6 Merge branch 'develop' 2014-03-05 21:22:39 -08:00
Ahmed Charles
eb6004d98d Merge branch 'master' into develop 2014-03-05 21:17:47 -08:00
Ahmed Charles
f34a8a4b23 Fix broken build due to addressof() not being included on some platforms. 2014-03-04 12:21:31 -08:00
Ahmed Charles
d19aeced56 Add test_set() (#6164). 2014-03-01 18:19:54 -08:00
Ahmed Charles
5f4c0dc4d9 Improve testing for set(pos, val). 2014-03-01 18:13:58 -08:00
Ahmed Charles
1b880102fe Add all() (#8445).
Includes test cases.
2014-03-01 18:11:59 -08:00
Ahmed Charles
e8b37ccf10 Improve tests for any() and none(). 2014-03-01 18:09:52 -08:00
Ahmed Charles
e7aa32f5db Reenable check within test for dynamic_bitset::any(). 2014-03-01 18:09:51 -08:00
Ahmed Charles
86b177d3ee Add support for move constructors in C++11 (#6947). 2014-03-01 18:06:19 -08:00
Ahmed Charles
4c6825716f Fix MSVC warnings (#9621). There should be no behavior change. 2014-03-01 17:56:52 -08:00
Ahmed Charles
ac0baa94ee Whitespace changes. 2014-03-01 17:43:44 -08:00
Ahmed Charles
ae64496e98 Merge develop into master.
Tests on develop are passing.
2014-03-01 17:38:08 -08:00
Alexey Stukalov
0a1621f0e7 simplify dynamic_bitset::find_next()
Instead of masking all bits in the current block that were already
visited and then finding the lowest remaining bit, it shifts the current
block directly to the first unvisited bit and identifies the lowest
set bit.
It requires fewer operations that the original implementation and should
be faster.

See https://svn.boost.org/trac/boost/ticket/5159.
2014-03-01 17:26:39 -08:00
Marshall Clow
4d8b9b5c33 Merge pull request #4 from ahmedcharles/patch-2
Merge master into develop.
2014-02-24 07:51:35 -08:00
Ahmed Charles
9fe813dd93 Merge branch 'master' into develop. 2014-02-19 01:27:09 -08:00
Ahmed Charles
dd69fe8756 Create merge point from develop to master after git migration.
Both branches are the same, so this merge is uninteresting.
2014-02-18 23:34:43 -08:00
Marshall Clow
20df4eadc8 Merge pull request #2 from ahmedcharles/patch-1
Fix MSVC warning about mismatched sizes.
2014-02-18 22:44:15 -08:00
Ahmed Charles
cccd1f74dc Fix MSVC warning about mismatched sizes. 2014-02-18 22:04:43 -08:00
Ahmed Charles
71a5cc6eeb Rename variable to make slightly more sense. 2014-02-18 21:49:59 -08:00
Ahmed Charles
c9fa6dbdd1 Fix spelling mistake. 2014-02-18 21:46:27 -08:00
Gennaro Prota
7186546f7d Removed unused local typedef in dyn_bitset_unit_tests1.cpp.
[SVN r86557]
2013-11-03 21:41:30 +00:00
Gennaro Prota
b82bfe4832 Merged the latest tweaks to dynamic_bitset/example/timing_tests.cpp (trunk revision 86553).
[SVN r86556]
2013-11-03 21:33:30 +00:00
Gennaro Prota
a257dead26 Minor adjustments to dynamic_bitset's timing_test.cpp.
[SVN r86553]
2013-11-03 20:46:56 +00:00
Marshall Clow
f44fbae9ba Merge fixes to release; Fixes #5439
[SVN r72331]
2011-06-01 15:59:04 +00:00
Marshall Clow
d6f1835fbb Applied patch; Refs #5439
[SVN r71505]
2011-04-26 14:41:50 +00:00
Steven Watanabe
e6fc8e8ec9 Merge dynamic_bitset from the trunk
[SVN r67617]
2011-01-03 16:38:46 +00:00
Steven Watanabe
734861bdac Fix test for C++0x
[SVN r67581]
2011-01-02 19:24:47 +00:00
Steven Watanabe
594140a081 Document intersects. Fixes #2837.
[SVN r63221]
2010-06-22 04:38:42 +00:00
Steven Watanabe
59e99b9b45 Use the correct variable type to save the result of count_extra_bits(). Fixes #4022.
[SVN r62898]
2010-06-13 04:36:50 +00:00
Steven Watanabe
f199a7f006 Cast an anonymous enum to bool. Fixes #4025.
[SVN r62897]
2010-06-13 04:23:35 +00:00
Troy D. Straszheim
60f871da0c rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
Troy D. Straszheim
d77a2c4afa rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release.
[SVN r56941]
2009-10-17 01:10:45 +00:00
Troy D. Straszheim
76d2f9d4d1 Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
Troy D. Straszheim
e3a2ca7276 Add basic copyright/license to keep cmake out of the inspection report
[SVN r55095]
2009-07-22 21:51:01 +00:00
Daniel James
38819630fd Merge dynamic bitset fixes for gcc 4.3.3.
Merged revisions 52879-52881,53050 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r52879 | hkaiser | 2009-05-10 17:52:14 +0100 (Sun, 10 May 2009) | 1 line
  
  Applying patch fixing problem on certain patch levels for gcc.4.3.3/Ubuntu
........
  r52880 | hkaiser | 2009-05-10 17:55:07 +0100 (Sun, 10 May 2009) | 1 line
  
  Fixing the fix by taking into account __GNUC_PATCHLEVEL__ as well
........
  r52881 | hkaiser | 2009-05-10 17:59:27 +0100 (Sun, 10 May 2009) | 1 line
  
  Minor comment edit
........
  r53050 | danieljames | 2009-05-16 15:58:33 +0100 (Sat, 16 May 2009) | 13 lines
  
  Merge dynamic bitset from release.
  
  I think the recent changes in trunk and release were for the same problem. But
  I'm not sure so I've merged them together. Hopefully, the release branch might
  fix the Intel C++ errors as well.
  
  ------------------------------------------------------------------------
  r52960 | dgregor | 2009-05-13 07:11:03 +0100 (Wed, 13 May 2009) | 1 line
  
  Use enum constants rather than local variables for integral constants. Should fix dynamic_bitset failures on GCC 4.3.x
  ------------------------------------------------------------------------
........


[SVN r53259]
2009-05-25 20:26:02 +00:00
Daniel James
5c79c20827 Merge dynamic bitset from release.
I think the recent changes in trunk and release were for the same problem. But
I'm not sure so I've merged them together. Hopefully, the release branch might
fix the Intel C++ errors as well.

------------------------------------------------------------------------
r52960 | dgregor | 2009-05-13 07:11:03 +0100 (Wed, 13 May 2009) | 1 line

Use enum constants rather than local variables for integral constants. Should fix dynamic_bitset failures on GCC 4.3.x
------------------------------------------------------------------------



[SVN r53050]
2009-05-16 14:58:33 +00:00
Douglas Gregor
6d0f9801f5 Use enum constants rather than local variables for integral constants. Should fix dynamic_bitset failures on GCC 4.3.x
[SVN r52960]
2009-05-13 06:11:03 +00:00
Hartmut Kaiser
ed32df5ad2 Minor comment edit
[SVN r52881]
2009-05-10 16:59:27 +00:00
Hartmut Kaiser
da0b582703 Fixing the fix by taking into account __GNUC_PATCHLEVEL__ as well
[SVN r52880]
2009-05-10 16:55:07 +00:00
Hartmut Kaiser
622c8d8fd5 Applying patch fixing problem on certain patch levels for gcc.4.3.3/Ubuntu
[SVN r52879]
2009-05-10 16:52:14 +00:00
Troy D. Straszheim
b7eedd0f46 merge of cmake build files from trunk per beman
[SVN r50756]
2009-01-24 18:57:20 +00:00
Gennaro Prota
16ca9cbb3c dynamic_bitset: ported revisions 49433, 49586 from trunk
[SVN r50470]
2009-01-04 23:03:28 +00:00
Michael A. Jackson
97d2bff3b6 Updating dependency information for modularized libraries.
[SVN r49628]
2008-11-07 17:05:27 +00:00
Michael A. Jackson
a143af6e2f Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
Gennaro Prota
59825bc8db dynamic_bitset:
* removed use of BOOST_WORKAROUND in #if for gcc bug c++/8419, as recent
      changes to the implementation of BOOST_WORKAROUND broke its usage with
      arguments such as ( (__GNUC__) * 100 * 100 + (__GNUC_MINOR__) * 100 )


[SVN r49586]
2008-11-04 16:52:00 +00:00
Michael A. Jackson
7d1144a461 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
Gennaro Prota
c298ba0c5f dynamic_bitset:
always provide a definition for static data members of const integral type

[SVN r49433]
2008-10-22 15:47:27 +00:00
Gennaro Prota
4efeaee302 dynamic_bitset: full (recursive) sync with trunk for libs/dynamic_bitset/
[SVN r49423]
2008-10-21 17:57:39 +00:00
Gennaro Prota
066e7dcf71 dynamic_bitset:
ported revisions 49345-49346 (roughly: workaround for VC++ <= 7.0 removal, comment and documentation improvements) from trunk

[SVN r49378]
2008-10-18 11:04:39 +00:00
Gennaro Prota
574f1dfe62 dynamic_bitset: documentation:
* improved documentation of constructor from block range, with notes about library issue 438
    * fixed/improved wording and markup in several places
    * partially adjusted word wrap, for consistency


[SVN r49346]
2008-10-15 14:38:19 +00:00
Gennaro Prota
e953b16cee dynamic_bitset:
* removed one of the workarounds for VC++ <= 7.0 (we don't run tests on
      those compilers, anymore, so we don't really know if the library still
      works with them); other such workarounds exist, though: removing them
      involves heavy refactoring and is probably not worth the corresponding
      risk of destabilization; comments have been added about this latter point

    * comment fixes in detail/dynamic_bitset.hpp


[SVN r49345]
2008-10-15 12:33:37 +00:00
Gennaro Prota
6b0d9627a8 Ported *all* my trunk changes not yet merged so far, i.e. revisions 48251-48252,48280,48290,48350,48478,48496,48663-48664,48695,48729-48730; besides dynamic_bitset, these include fixes to setup_boostbook.sh and setup_boostbook.py, and changes to config/suffix.hpp [So: the affected "elements" are: a) the two setup_boostbook scripts, config/suffix.hpp and dynamic_bitset --note: yes, the list is exhaustive: all and only]
[SVN r48773]
2008-09-14 10:46:28 +00:00
Gennaro Prota
180aa15c44 dynamic_bitset: in reference constructor, assert() before it is (eventually) too late!
[SVN r48730]
2008-09-11 09:46:54 +00:00
Gennaro Prota
7ed46a6667 dynamic_bitset: in dyn_bitset_unit_tests1.cpp, replaced very ill-thought assert() with more sensible code to check for "negative sizes"
[SVN r48729]
2008-09-11 09:35:49 +00:00
Gennaro Prota
24d2081a73 added specific tests for constructor dispatch and clarified the corresponding comments a bit; minor formatting consistency fixes; updated documentation and added license reference text to it
[SVN r48695]
2008-09-10 10:07:46 +00:00
Gennaro Prota
f6ce97de67 dynamic_bitset: added spaces in the definition of BOOST_dynamic_bitset_is_numeric (detail/dynamic_bitset.hpp), to avoid getting an unintended alternative token "<:" when invoking the macro with argument "::boost::[u]long_long_type"
[SVN r48664]
2008-09-08 10:20:49 +00:00
Gennaro Prota
7530a40476 dynamic_bitset: changed a using directive to a set of using declarations, in the hope that this will fix regressions of Intel and others; (very minor) changed comment text
[SVN r48663]
2008-09-08 10:10:02 +00:00
Gennaro Prota
c05a47b50d dynamic_bitset:
* added user-declared default constructor to value_to_type<bool> (yeah, the
      usual "initializing a const instance of an empty class" problem, which
      also affected S. Meyers' null)
    * explicitly qualified occurrence of "bits_per_block" in count() member
      function, to let gcc 3.4.x understand that it *is* a constant expression
    * fixed namespace qualification for vector_max_size_workaround (should've
      been done in the previous commit, sorry)


[SVN r48496]
2008-08-31 11:53:45 +00:00
Gennaro Prota
d09c7d2180 dynamic_bitset:
* fixed form of some remaining copyright lines
    * using namespace detail::dynamic_bitset_impl for *all* implementation
      details (dynamic_bitset_*count*_impl removed) and consequently shortened
      some entity names
    * switched from enum to bools for "enum mode", to help several compilers
      which show problems with recognizing access_by_bytes and access_by_blocks
      as constant expressions
    * minor comment changes
    * implemented the do-the-right-thing dispatch for constructor from
      iterator-range, a la standard sequence containers (feature request #2172)
    * dropped now useless comparison with zero in reference constructor

NOTE:
    updated tests and documentation not committed yet; let's wait for the trunk
    results first


[SVN r48478]
2008-08-30 18:00:30 +00:00
Gennaro Prota
bddf77e5a4 boost/pending/: ported revision 48251 ("integer_log2.hpp and lowest_bit.hpp, in boost/pending/: little comment cleanup (svn anchors, etc.); added a static_cast<> to silence (harmless) MSVC++ warnings") from trunk
[SVN r48353]
2008-08-24 18:16:24 +00:00
Gennaro Prota
d80a9dbdf8 dynamic_bitset: tentative code reworking in count() member function, to help gcc 3.4.6 on Sandia-sun, which seems to have troubles with a simple constant expression of enumeration type (see <http://www.boost.org/development/tests/trunk/developer/dynamic_bitset_.html>)
[SVN r48280]
2008-08-21 11:49:12 +00:00
Gennaro Prota
15b61f694a dynamic_bitset:
* clean up and fix of copyright notices for the include files that are directly under boost/
    * parenthesized a couple of macro names in boost/dynamic_bitset/config.hpp
      (yeah, a bit paranoid, I know :-))
    * removed some superfluous comments and enclosed an url in angle brackets
    * changed block_width_type, to avoid a few level 4 warnings with MSVC++
    * added the usual private-and-non-implemented copy members to bit_appender
    * removed useless #pragma warning(disable:4996) for MSVC++ (it should have
      been eventually applied to much more places than it was; and, anyhow, the
      only sensible way to get rid of the warning is to disable it globally)
    * slight tweak in to_ulong (assert moved a bit earlier)


[SVN r48252]
2008-08-20 11:16:16 +00:00
Gennaro Prota
eef25927d7 integer_log2.hpp and lowest_bit.hpp, in boost/pending/: little comment cleanup (svn anchors, etc.); added a static_cast<> to silence (harmless) MSVC++ warnings
[SVN r48251]
2008-08-20 11:06:23 +00:00
Gennaro Prota
357e434387 dynamic_bitset.hpp: (minor) removed tab characters introduced with revision 35066 on trunk
[SVN r47666]
2008-07-21 23:46:39 +00:00
Gennaro Prota
a8998ae8a0 dynamic_bitset: in example3.cpp, changed #include of boost/dynamic_bitset.hpp to quoted form and moved the directive itself at the top (there has been discussion in the past about using the quoted form for boost includes, but it's almost two years now that the resolution of core issue 370 has been voted into WP...)
[SVN r47456]
2008-07-15 20:49:32 +00:00
Gennaro Prota
aa6053121c dynamic_bitset: cleaner implementation of to_ulong (which should also avoid some warnings on 64-bit implementations)
[SVN r47401]
2008-07-13 19:38:48 +00:00
Gennaro Prota
5d66eda2ac dynamic_bitset: removed svn keywords and anchors; removed useless "see ... for documentation" pointers; fixed copyright notices and made all "comment headers" consistent; cleaned up trailing whitespaces
[SVN r47392]
2008-07-13 19:08:31 +00:00
Gennaro Prota
771e3d8779 dynamic_bitset documentation and examples:
Documentation:
    --------------

    * converted from HTML 4.01 Transitional to XHTML 1.1 (reason: the website
      uses already XHTML 1.0 Strict, and our page didn't validate as such, even
      though on the website a link to the W3C markup validation service is
      affixed)
    * removed some misleading sentences
    * referenced the source files of examples, so that they do not go out of
      sync again
    * clarified rationale section

    Example files:
    --------------

    * example 3 shows that stream extraction may expand the bitset
    * minor improvements to all examples


[SVN r47389]
2008-07-13 17:55:45 +00:00
Gennaro Prota
d8b2330d42 dynamic_bitset.html: Documentation: dropped all sentences of the kind "note that the expression... is equivalent to creating a temporary copy and then...". They seem to be just a sort of performance warning and carry no useful information. This fixes issue #1591.
[SVN r47328]
2008-07-11 21:21:14 +00:00
Daniel James
61702fef06 Merged revisions 43206,43208-43213 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r43206 | danieljames | 2008-02-10 09:55:03 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix some broken links.
........
  r43209 | danieljames | 2008-02-10 14:56:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Link to people pages on the website, as they've been removed from the download.
........
  r43210 | danieljames | 2008-02-10 15:02:17 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Point links to the pages that used to be in 'more' to the site.
........
  r43212 | danieljames | 2008-02-10 16:10:16 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix links on the home page as well.
........
  r43213 | danieljames | 2008-02-10 16:21:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Generated documentation which is no longer generated.
........


[SVN r43214]
2008-02-10 16:39:38 +00:00
Daniel James
1b7c462afe Point links to the pages that used to be in 'more' to the site.
[SVN r43210]
2008-02-10 15:02:17 +00:00
Daniel James
8a1da9667b Link to people pages on the website, as they've been removed from the download.
[SVN r43209]
2008-02-10 14:56:22 +00:00
Boris Gubenko
6bf10f4ef0 merge change in trunk (changeset/41778) to release branch
[SVN r41959]
2007-12-10 18:51:19 +00:00
Boris Gubenko
717fb80e40 compute 'result' in to_ulong() as it is done in Boost 1.34
[SVN r41778]
2007-12-06 10:47:52 +00:00
Beman Dawes
0999a9b907 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
2007-11-25 18:38:02 +00:00
Beman Dawes
4ae778ba4a Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2007-11-25 18:07:19 +00:00
Beman Dawes
c9dcc1de64 config, detail, filesystem, system, tools, at 41278.
[SVN r41316]
2007-11-23 17:03:14 +00:00
Beman Dawes
adc36a2b7f Add missing copyright and license
[SVN r40835]
2007-11-06 13:41:19 +00:00
Beman Dawes
cc9b262cb9 Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +00:00
Vladimir Prus
a8c3c80888 Update to V2
[SVN r38525]
2007-08-08 19:31:55 +00:00
Vladimir Prus
3a04624801 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
nobody
ba7ccc50ae This commit was manufactured by cvs2svn to create tag
'Version_1_34_1'.

[SVN r38286]
2007-07-24 19:28:14 +00:00
Beman Dawes
08357c3972 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
Rene Rivera
3e03a8d947 Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
Frederick Akalin
41e1f468d3 added pragma to shut up warning for std::fill_n
[SVN r35066]
2006-09-11 02:23:00 +00:00
Gennaro Prota
ae44c787e2 identification
[SVN r34907]
2006-08-19 11:14:34 +00:00
Gennaro Prota
60375651d9 identification
[SVN r34905]
2006-08-19 11:04:25 +00:00
Gennaro Prota
50ffc7be59 (minor) oops in previous edit
[SVN r34904]
2006-08-19 10:55:07 +00:00
Gennaro Prota
02f4b61f14 identification
[SVN r34903]
2006-08-19 10:52:24 +00:00
Gennaro Prota
07b5b85dfe some cleanup (beware: not compiled)
[SVN r34883]
2006-08-13 15:08:24 +00:00
Gennaro Prota
1170f90afb boost guidelines (mainly from inspect tool: tabs, license reference text, etc.)
[SVN r34752]
2006-07-27 10:27:37 +00:00
Gennaro Prota
a0d66fd920 prevented spurious Digital Mars warning
[SVN r34645]
2006-07-20 22:55:07 +00:00
Gennaro Prota
3e3d36c571 added extra parentheses to workaround Digital Mars
[SVN r34644]
2006-07-20 22:52:21 +00:00
Gennaro Prota
3be249a20e workarounded absurd Digital Mars behavior
[SVN r34643]
2006-07-20 22:50:11 +00:00
Gennaro Prota
98917625dd improved swap tests
[SVN r34642]
2006-07-20 22:13:26 +00:00
Gennaro Prota
5f1c39cb6c added copyright/license notes
[SVN r34570]
2006-07-17 02:14:22 +00:00
Gennaro Prota
7c48bf04c2 added copyright/license notes; validated (XHTML 1.0 Strict)
[SVN r34569]
2006-07-17 02:09:49 +00:00
Gennaro Prota
109a0aef13 updated copyright notice (years); used <assert.h>
[SVN r34401]
2006-06-25 19:32:44 +00:00
Gennaro Prota
5995354ceb updated copyright notice (years); used <assert.h>; included subdir main header; more count() and operator< tests; minor fixes
[SVN r34400]
2006-06-25 19:31:06 +00:00
Gennaro Prota
7f268666ad updated copyright notice (years); included subdir main header
[SVN r34399]
2006-06-25 19:28:33 +00:00
Gennaro Prota
ecbc0c4262 updated copyright notice (years); included "dynamic_bitset/dynamic_bitset.hpp"; added BOOST_BITSET_TEST_COUNT_OF (in the meantime); used -Wundef immune idiom everywhere; improved and simplified test code for construction from unsigned long; fixed some comments; added "all_1s" helper variable
[SVN r34398]
2006-06-25 19:26:21 +00:00
Gennaro Prota
184337e1cc updated copyright notice (years); used <assert.h> instead of <cassert>; include "dynamic_bitset/dynamic_bitset.hpp"; added a comment related to a Borland numeric_limits<> issue; some cleanup; strengthened many tests
[SVN r34397]
2006-06-25 19:16:48 +00:00
Gennaro Prota
2726ad0c3c updated copyright notice (years); added slash to doc url; introduced shifter<> template, for the implementation of the constructor from ulong
[SVN r34396]
2006-06-25 19:05:46 +00:00
Gennaro Prota
30bd2e5bab updated copyright notice (years); added slash to doc url; reworded some comments
[SVN r34395]
2006-06-25 18:58:27 +00:00
Gennaro Prota
38f7aa5d40 updated copyright notice (years); added slash to doc url; used <assert.h> instead of <cassert>; added assert in reference constructor; clarified some comments; removed superfluos Allocator parameter from init_from_string(); improved constructor from unsigned long, push_back(bool), to_ulong(), is_proper_subset_of(), operator <(); cleanup
[SVN r34394]
2006-06-25 18:54:35 +00:00
Gennaro Prota
48aaaabed2 init_from_string() doesn't need the alloc parameter; usual style for BOOST_WORKAROUNDs
[SVN r34303]
2006-06-14 17:33:31 +00:00
Gennaro Prota
755fa101f8 included *sub-directory* main source file (dynamic_bitset/dynamic_bitset.hpp); immunized BOOST_WORKAROUND invocations against gcc's -Wundef (for now); used single parameter version of std::ctype<> ::widen (which is valid regardless of the resolution of lib issue 530)
[SVN r34302]
2006-06-14 14:59:25 +00:00
Gennaro Prota
9c0620b7f9 use our usual -Wundef compatible form for IBM's AIX workaround; added a comment pointing out that the compiler is actually right
[SVN r34115]
2006-05-29 17:43:42 +00:00
Gennaro Prota
30b986e549 to_ulong function cleanup (including removal of a superfluous if test)
[SVN r34114]
2006-05-29 17:12:25 +00:00
Gennaro Prota
eb7f05d0c4 made valid HTML 4.01 transitional (but this redirect tecnique is considered poor practice by the W3C, anyway; among other things, it breaks the browser's back button)
[SVN r34113]
2006-05-29 16:58:42 +00:00
Gennaro Prota
fff12b2c59 added new test for to_ulong function
[SVN r34112]
2006-05-29 16:43:42 +00:00
Gennaro Prota
fb5e1d024d in to_string(): removed initial comment (besides having several typos, it was incosistent: other test functions don't explain what the tested function does); avoided all-uppercase identifiers and shortened test expression; minor cleanup
[SVN r34111]
2006-05-29 16:40:15 +00:00
nobody
5e260f4364 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
Markus Schöpflin
896a792bec Workaround for IBM's compiler on AIX.
[SVN r32101]
2005-12-19 10:00:51 +00:00
Douglas Gregor
39f11e7cc0 Workaround for CodeWarrior 9.4/9.5, I think
[SVN r28956]
2005-05-16 14:22:35 +00:00
Aleksey Gurtovoy
b18fc5cd99 merge RC_1_32_0 fixes
[SVN r26328]
2004-11-28 03:35:12 +00:00
Aleksey Gurtovoy
c5ea9df026 c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
John Maddock
6f1a3ed336 Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.
[SVN r24899]
2004-09-04 10:34:49 +00:00
Rene Rivera
e85ab3cb63 Add workaround for CW8 when it compiles reset(), as it generates invalid code otherwise.
[SVN r24319]
2004-08-06 06:56:13 +00:00
Rene Rivera
c23e3f28dc Prevent "possibly unwanted ;" warning.
[SVN r24318]
2004-08-06 06:54:07 +00:00
Douglas Gregor
f4eefb6abb dynamic_bitset.hpp: Split the string constructor, which causes problems on the
msvc-stlport toolset, into two separate constructors to avoid the npos issue.


[SVN r24179]
2004-07-30 04:41:57 +00:00
Douglas Gregor
f28eec4a37 Converted to Boost Software License, Version 1.0
[SVN r24055]
2004-07-26 00:32:12 +00:00
Gennaro Prota
e2529a0423 settled macros to cope with the absence of std::locale on some platforms/configurations
[SVN r23886]
2004-07-21 09:23:17 +00:00
Vladimir Prus
0ff409e7d6 More V2 Jamfile tweaks.
[SVN r23764]
2004-07-19 07:12:45 +00:00
Gennaro Prota
912ab0576e use BOOST_WORKAROUND for Codewarrior workarounds
[SVN r23207]
2004-06-27 08:54:02 +00:00
Gennaro Prota
abd8bc3795 Fix for Codewarrior 8.3 for Windows. Suggested by Howard Hinnant.
[SVN r23198]
2004-06-26 08:48:53 +00:00
Gennaro Prota
42922140ed typo
[SVN r23127]
2004-06-20 09:33:03 +00:00
Gennaro Prota
fe0c5c0563 new Codewarrior workaround
[SVN r23124]
2004-06-19 08:32:31 +00:00
Gennaro Prota
f46a423bbe restored version 1.6 (MW attempts failed)
[SVN r23123]
2004-06-19 08:27:45 +00:00
Gennaro Prota
6d8300e094 attempt to fix another CW 8.3 error :(
[SVN r23094]
2004-06-13 07:48:46 +00:00
Gennaro Prota
8c5ab9dcca CW 8.3 fix suggested by Howard
[SVN r23092]
2004-06-12 08:18:26 +00:00
Gennaro Prota
7d3869d208 use boost::detail::distance instead of std::distance
[SVN r23025]
2004-06-05 08:45:02 +00:00
Gennaro Prota
4fe6bbdbed local array numbers[] made static - this is an attempt to fix a CW 8.3 error
[SVN r22996]
2004-06-02 08:30:53 +00:00
Gennaro Prota
31f06cc395 exclude wchar_t tests when BOOST_NO_STD_LOCALE is defined
[SVN r22973]
2004-05-30 09:42:44 +00:00
Gennaro Prota
f4073fc6aa - added a missing #include (climits)
- extended usage of BOOST_BITSET_CHAR to accomodate libraries with no locale support (MWCW with _MSL_NO_LOCALE)
- untabified


[SVN r22972]
2004-05-30 09:40:25 +00:00
Gennaro Prota
f61de66d04 removed some superfluous spaces and added workaround for VC6's Dinkum
[SVN r22833]
2004-05-16 08:43:38 +00:00
Gennaro Prota
c688bf1763 changed workaround for gcc bug nr. 8419
[SVN r22771]
2004-05-09 09:21:33 +00:00
Gennaro Prota
0c613d24c4 - workaround for Borland bug
- untabified


[SVN r22769]
2004-05-09 08:03:21 +00:00
Gennaro Prota
e6ca3c67c4 use division by 2 instead of >>=1, because Borland C++ yields sometimes an access violation when shifting with Block = unsigned long long
[SVN r22768]
2004-05-09 07:48:12 +00:00
Gennaro Prota
c1d95c8d3e Added URI of the DTD in the <!DOCTYPE> tag
[SVN r22764]
2004-05-08 08:27:59 +00:00
Gennaro Prota
5cdfb675be removed superfluous spaces
[SVN r22704]
2004-04-25 09:04:36 +00:00
Gennaro Prota
3af18952b3 just aligned a backslash
[SVN r22703]
2004-04-25 09:03:10 +00:00
Gennaro Prota
a1cc5de6eb removed #undef for BOOST_OLD_IOSTREAMS
[SVN r22702]
2004-04-25 08:54:14 +00:00
Gennaro Prota
48f9b61f3d no message
[SVN r22700]
2004-04-25 08:30:00 +00:00
Gennaro Prota
9015fe1e59 removed the 3 examples and the "timing_tests" file (this way we can use bjam's subinclude feature from boost-root/status/Jamfile without also running examples etc. with the regression tests)
[SVN r22699]
2004-04-25 08:29:17 +00:00
Gennaro Prota
ebcb04e23b Jamfile for examples and 'timing_tests' - doesn't run with the regression tests, of course
[SVN r22698]
2004-04-25 08:24:50 +00:00
Gennaro Prota
ddc4d80d4b moved here from the parent directory
[SVN r22697]
2004-04-25 08:21:42 +00:00
Gennaro Prota
c5f0c1610f new license reference
[SVN r22696]
2004-04-25 08:15:26 +00:00
Gennaro Prota
3942289151 the examples - moved here so that they can have an independent Jamfile that doesn't trigger together with the regression tests
[SVN r22695]
2004-04-25 08:09:46 +00:00
Gennaro Prota
29f03d2456 removed (will go into the example/ subdirectory)
[SVN r22694]
2004-04-25 08:05:11 +00:00
Gennaro Prota
7e9eaaa25f removed definition of BOOST_OLD_IOSTREAMS (it's now in the dynamic_bitset config file)
[SVN r22693]
2004-04-25 07:45:09 +00:00
Gennaro Prota
c516fe3cb8 test functions call to_string, to_block_range, etc., so let's include "boost/dynamic_bitset.hpp" (see regression logs for gcc 3.4 on Linux)
[SVN r22692]
2004-04-24 09:04:01 +00:00
Gennaro Prota
37fd8373e8 removed const qualification on test_file_name()'s return type
[SVN r22691]
2004-04-24 08:55:08 +00:00
Gennaro Prota
0d8327315c moved more config stuff to here
[SVN r22690]
2004-04-24 08:48:36 +00:00
Gennaro Prota
99035b25ac removed config stuff
[SVN r22689]
2004-04-24 08:48:03 +00:00
Gennaro Prota
7068fe4b24 removed make_non_const() workaround, now useless
[SVN r22688]
2004-04-24 08:38:55 +00:00
Gennaro Prota
9ce38213e4 config stuff
[SVN r22687]
2004-04-24 08:36:46 +00:00
Gennaro Prota
e03aea94d9 moved config stuff to its own file and changed workaround for gcc bug 8419, as the former workaround gave problems with some compilers (e.g. VACPP for AIX)
[SVN r22686]
2004-04-24 08:35:42 +00:00
Gennaro Prota
8397bc3326 - removed dependency on test_exec_monitor
- added dyn_bitset_unit_tests4


[SVN r22652]
2004-04-18 09:24:05 +00:00
Gennaro Prota
760839ff10 new file (needed by dynamic_bitset)
[SVN r22651]
2004-04-18 09:15:08 +00:00
Gennaro Prota
16a25f7f10 moved from the sandbox
[SVN r22650]
2004-04-18 09:14:20 +00:00
Gennaro Prota
d35b2d1117 new tests (from the sandbox)
[SVN r22649]
2004-04-18 09:13:06 +00:00
Gennaro Prota
6e9450562e new version (from the sandbox)
[SVN r22648]
2004-04-18 09:11:17 +00:00
Gennaro Prota
e445e12e06 new version (the actual code, from the sandbox, is in dynamic_bitset/dynamic_bitset.hpp)
[SVN r22647]
2004-04-18 09:07:24 +00:00
Eric Niebler
f66792a57d remove minmax hack from win32.hpp and fix all places that could be affected by the minmax macros
[SVN r22394]
2004-02-26 18:27:02 +00:00
Jens Maurer
702e7dd26b remove unused variable
[SVN r18997]
2003-07-09 19:41:40 +00:00
Gennaro Prota
d878395ca6 small comment fixes again
[SVN r18279]
2003-04-19 14:11:14 +00:00
Gennaro Prota
c4a81fc3e8 shortened comments
[SVN r18278]
2003-04-19 11:47:17 +00:00
Gennaro Prota
588891f0a1 minor comment fixes
[SVN r18036]
2003-03-20 18:22:31 +00:00
Gennaro Prota
fd8ccde0b4 overall cleanup
[SVN r18035]
2003-03-20 18:08:42 +00:00
44 changed files with 8803 additions and 4048 deletions

41
.drone.star Normal file
View File

@@ -0,0 +1,41 @@
# Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE.txt)
#
# Copyright Rene Rivera 2020.
# For Drone CI we use the Starlark scripting language to reduce duplication.
# As the yaml syntax for Drone CI is rather limited.
#
#
globalenv={'B2_VARIANT': 'variant=release'}
linuxglobalimage="cppalliance/droneubuntu1604:1"
windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):
return [
linux_cxx("B2_TOOLSET=gcc-4.8 B2_CXXSTD=03,11 Job 0", "g++-4.8", packages="g++-4.8", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'B2_TOOLSET': 'gcc-4.8', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=gcc-4.9 B2_CXXSTD=03,11 Job 1", "g++-4.9", packages="g++-4.9", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'B2_TOOLSET': 'gcc-4.9', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=gcc-5 B2_CXXSTD=03,11 Job 2", "g++-5", packages="g++-5", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-5', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=gcc-6 B2_CXXSTD=11,14 Job 3", "g++-6", packages="g++-6", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-6', 'B2_CXXSTD': '11,14', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=gcc-7 B2_CXXSTD=14,17 Job 4", "g++-7", packages="g++-7", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-7', 'B2_CXXSTD': '14,17', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=gcc-8 B2_CXXSTD=17,2a Job 5", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=gcc-9 B2_CXXSTD=17,2a Job 6", "g++-9", packages="g++-9", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-9', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-3.8 B2_CXXSTD=03,11 Job 7", "clang++-3.8", packages="clang-3.8 libstdc++-6-dev", llvm_os="xenial", llvm_ver="3.8", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'B2_TOOLSET': 'clang-3.8', 'B2_CXXSTD': '03,11', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-4.0 B2_CXXSTD=11,14 Job 8", "clang++-4.0", packages="clang-4.0 libstdc++-6-dev", llvm_os="xenial", llvm_ver="4.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-4.0', 'B2_CXXSTD': '11,14', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-5.0 B2_CXXSTD=11,14 Job 9", "clang++-5.0", packages="clang-5.0 libstdc++-7-dev", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-5.0', 'B2_CXXSTD': '11,14', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-6.0 B2_CXXSTD=14,17 Job 10", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXSTD': '14,17', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-7 B2_CXXSTD=17,2a Job 11", "clang++-7", packages="clang-7 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="7", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-7', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-8 B2_CXXSTD=17,2a Job 12", "clang++-8", packages="clang-8 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-8', 'B2_CXXSTD': '17,2a', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
linux_cxx("B2_TOOLSET=clang-6.0 B2_CXXSTD=03,11,14 Job 13", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': '-stdlib=libc++', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
osx_cxx("B2_TOOLSET=clang B2_CXXSTD=03,11,17 Job 14", "g++", packages="", buildtype="boost", buildscript="drone", environment={'B2_TOOLSET': 'clang', 'B2_CXXSTD': '03,11,17', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
linux_cxx("COMMENT=codecov.io B2_CXXSTD=03,11 B2_TOOLSET Job 15", "g++-8", packages="g++-8", buildtype="b5847f804b-0fcaf592f9", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'codecov.io', 'B2_CXXSTD': '03,11', 'B2_TOOLSET': 'gcc-8', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
linux_cxx("COMMENT=asan B2_VARIANT=variant=debug B2_TOOL Job 16", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'asan', 'B2_VARIANT': 'variant=debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': 'address-sanitizer=norecover', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'DRONE_EXTRA_PRIVILEGED': 'True', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv, privileged=True),
linux_cxx("COMMENT=tsan B2_VARIANT=variant=debug B2_TOOL Job 17", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'tsan', 'B2_VARIANT': 'variant=debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': 'thread-sanitizer=norecover', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'DRONE_JOB_UUID': '0716d9708d'}, globalenv=globalenv),
linux_cxx("COMMENT=ubsan B2_VARIANT=variant=debug B2_TOO Job 18", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'variant=debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '03,11,14', 'B2_CXXFLAGS': 'undefined-sanitizer=norecover', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': 'linkflags=-fuse-ld=gold', 'UBSAN_OPTIONS': 'print_stacktrace=1', 'DRONE_JOB_UUID': '9e6a55b6b4'}, globalenv=globalenv),
linux_cxx("COMMENT=valgrind B2_TOOLSET=clang-6.0 B2_CXXS Job 19", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="xenial", llvm_ver="6.0", buildtype="b5847f804b-db180b7bd2", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'valgrind', 'B2_TOOLSET': 'clang-6.0', 'B2_CXXSTD': '03,11,14', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'B2_VARIANT': 'variant=debug', 'B2_TESTFLAGS': 'testing.launcher=valgrind', 'VALGRIND_OPTS': '--error-exitcode=1', 'DRONE_JOB_UUID': 'b3f0c7f6bb'}, globalenv=globalenv),
linux_cxx("COMMENT=Coverity Scan B2_TOOLSET=clang Job 20", "g++", packages="binutils-gold gdb libc6-dbg", buildtype="b5847f804b-cce9827eb5", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'Coverity Scan', 'B2_TOOLSET': 'clang', 'DRONE_JOB_UUID': '91032ad7bb'}, globalenv=globalenv),
]
# from https://github.com/boostorg/boost-ci
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")

106
.drone/drone.sh Executable file
View File

@@ -0,0 +1,106 @@
#!/bin/bash
# Copyright 2020 Rene Rivera, Sam Darwin
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export DRONE_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=$DRONE_BRANCH
export VCS_COMMIT_ID=$DRONE_COMMIT
export GIT_COMMIT=$DRONE_COMMIT
export REPO_NAME=$DRONE_REPO
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$DRONE_JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/build.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "b5847f804b-0fcaf592f9" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/codecov.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "b5847f804b-db180b7bd2" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/valgrind.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "b5847f804b-cce9827eb5" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$DRONE_BRANCH" = "develop" -o "$DRONE_BRANCH" = "master" \) -a "$DRONE_BUILD_EVENT" = "push" ] ; then
cd $BOOST_ROOT/libs/$SELF
ci/travis/coverity.sh
fi
fi

525
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,525 @@
name: GitHub Actions CI
on:
pull_request:
push:
branches:
- master
- develop
- githubactions*
- feature/**
- fix/**
- pr/**
env:
B2_VARIANT: variant=release
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- name: "B2_TOOLSET=gcc-4.8 B2_CXXSTD=03,11 Job 0"
buildtype: "boost"
packages: "g++-4.8"
packages_to_remove: ""
os: "ubuntu-16.04"
container: "ubuntu:14.04"
cxx: "g++-4.8"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-4.8"
b2_cxxstd: "03,11"
- name: "B2_TOOLSET=gcc-4.9 B2_CXXSTD=03,11 Job 1"
buildtype: "boost"
packages: "g++-4.9"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-4.9"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-4.9"
b2_cxxstd: "03,11"
- name: "B2_TOOLSET=gcc-5 B2_CXXSTD=03,11 Job 2"
buildtype: "boost"
packages: "g++-5"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-5"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-5"
b2_cxxstd: "03,11"
- name: "B2_TOOLSET=gcc-6 B2_CXXSTD=11,14 Job 3"
buildtype: "boost"
packages: "g++-6"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-6"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-6"
b2_cxxstd: "11,14"
- name: "B2_TOOLSET=gcc-7 B2_CXXSTD=14,17 Job 4"
buildtype: "boost"
packages: "g++-7"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-7"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-7"
b2_cxxstd: "14,17"
- name: "B2_TOOLSET=gcc-8 B2_CXXSTD=17,2a Job 5"
buildtype: "boost"
packages: "g++-8"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-8"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-8"
b2_cxxstd: "17,2a"
- name: "B2_TOOLSET=gcc-9 B2_CXXSTD=17,2a Job 6"
buildtype: "boost"
packages: "g++-9"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-9"
sources: ""
llvm_os: ""
llvm_ver: ""
b2_toolset: "gcc-9"
b2_cxxstd: "17,2a"
- name: "B2_TOOLSET=clang-3.8 B2_CXXSTD=03,11 Job 7"
buildtype: "boost"
packages: "clang-3.8 libstdc++-6-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
container: "ubuntu:14.04"
cxx: "clang++-3.8"
sources: ""
llvm_os: "xenial"
llvm_ver: "3.8"
b2_toolset: "clang-3.8"
b2_cxxstd: "03,11"
- name: "B2_TOOLSET=clang-4.0 B2_CXXSTD=11,14 Job 8"
buildtype: "boost"
packages: "clang-4.0 libstdc++-6-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-4.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "4.0"
b2_toolset: "clang-4.0"
b2_cxxstd: "11,14"
- name: "B2_TOOLSET=clang-5.0 B2_CXXSTD=11,14 Job 9"
buildtype: "boost"
packages: "clang-5.0 libstdc++-7-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-5.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "5.0"
b2_toolset: "clang-5.0"
b2_cxxstd: "11,14"
- name: "B2_TOOLSET=clang-6.0 B2_CXXSTD=14,17 Job 10"
buildtype: "boost"
packages: "clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-6.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "6.0"
b2_toolset: "clang-6.0"
b2_cxxstd: "14,17"
- name: "B2_TOOLSET=clang-7 B2_CXXSTD=17,2a Job 11"
buildtype: "boost"
packages: "clang-7 libc6-dbg libc++-dev libstdc++-8-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-7"
sources: ""
llvm_os: "xenial"
llvm_ver: "7"
b2_toolset: "clang-7"
b2_cxxstd: "17,2a"
- name: "B2_TOOLSET=clang-8 B2_CXXSTD=17,2a Job 12"
buildtype: "boost"
packages: "clang-8 libc6-dbg libc++-dev libstdc++-8-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-8"
sources: ""
llvm_os: "xenial"
llvm_ver: "8"
b2_toolset: "clang-8"
b2_cxxstd: "17,2a"
- name: "B2_TOOLSET=clang-6.0 B2_CXXSTD=03,11,14 Job 13"
buildtype: "boost"
packages: "clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-6.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "6.0"
b2_toolset: "clang-6.0"
b2_cxxstd: "03,11,14"
b2_cxxflags: "-stdlib=libc++"
- name: "COMMENT=codecov.io B2_CXXSTD=03,11 B2_TOOLSET Job 15"
buildtype: "b5847f804b-0fcaf592f9"
packages: "g++-8"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-8"
sources: ""
llvm_os: ""
llvm_ver: ""
comment: "codecov.io"
b2_cxxstd: "03,11"
b2_toolset: "gcc-8"
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
- name: "COMMENT=asan B2_VARIANT=variant=debug B2_TOOL Job 16"
buildtype: "boost"
packages: "g++-8"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-8"
sources: ""
llvm_os: ""
llvm_ver: ""
comment: "asan"
b2_variant: "variant=debug"
b2_toolset: "gcc-8"
b2_cxxstd: "03,11,14"
b2_cxxflags: "address-sanitizer=norecover"
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
- name: "COMMENT=tsan B2_VARIANT=variant=debug B2_TOOL Job 17"
buildtype: "boost"
packages: "g++-8"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-8"
sources: ""
llvm_os: ""
llvm_ver: ""
comment: "tsan"
b2_variant: "variant=debug"
b2_toolset: "gcc-8"
b2_cxxstd: "03,11,14"
b2_cxxflags: "thread-sanitizer=norecover"
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
- name: "COMMENT=ubsan B2_VARIANT=variant=debug B2_TOO Job 18"
buildtype: "boost"
packages: "g++-8"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-8"
sources: ""
llvm_os: ""
llvm_ver: ""
comment: "ubsan"
b2_variant: "variant=debug"
b2_toolset: "gcc-8"
b2_cxxstd: "03,11,14"
b2_cxxflags: "undefined-sanitizer=norecover"
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
b2_linkflags: "linkflags=-fuse-ld=gold"
ubsan_options: "print_stacktrace=1"
- name: "COMMENT=valgrind B2_TOOLSET=clang-6.0 B2_CXXS Job 19"
buildtype: "b5847f804b-db180b7bd2"
packages: "clang-6.0 libc6-dbg libc++-dev libstdc++-8-dev"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-6.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "6.0"
comment: "valgrind"
b2_toolset: "clang-6.0"
b2_cxxstd: "03,11,14"
b2_defines: "define=BOOST_NO_STRESS_TEST=1"
b2_variant: "variant=debug"
b2_testflags: "testing.launcher=valgrind"
valgrind_opts: "--error-exitcode=1"
- name: "COMMENT=Coverity Scan B2_TOOLSET=clang Job 20"
buildtype: "b5847f804b-cce9827eb5"
packages: "binutils-gold gdb libc6-dbg"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
comment: "Coverity Scan"
b2_toolset: "clang"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Check if running in container
if: matrix.container != ''
run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV
- name: If running in container, upgrade packages
if: matrix.container != ''
run: |
sudo apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python python-pip ruby cpio gcc-multilib g++-multilib pkgconf python3 python3-pip ccache libpython-dev
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git
sudo python -m pip install --upgrade pip==20.3.4
sudo /usr/local/bin/pip install cmake
- uses: actions/checkout@v2
- name: linux
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
B2_TOOLSET: ${{ matrix.b2_toolset }}
B2_CXXSTD: ${{ matrix.b2_cxxstd }}
B2_CXXFLAGS: ${{ matrix.b2_cxxflags }}
COMMENT: ${{ matrix.comment }}
B2_DEFINES: ${{ matrix.b2_defines }}
B2_VARIANT: ${{ matrix.b2_variant }}
B2_LINKFLAGS: ${{ matrix.b2_linkflags }}
UBSAN_OPTIONS: ${{ matrix.ubsan_options }}
B2_TESTFLAGS: ${{ matrix.b2_testflags }}
VALGRIND_OPTS: ${{ matrix.valgrind_opts }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "linux"
run: |
echo '==================================> SETUP'
echo '==================================> PACKAGES'
set -e
if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi
echo ">>>>> APT: REPO.."
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
if test -n "${LLVM_OS}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
if test -n "${LLVM_VER}" ; then
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main"
else
# Snapshot (i.e. trunk) build of clang
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main"
fi
fi
echo ">>>>> APT: UPDATE.."
sudo -E apt-get -o Acquire::Retries=3 update
if test -n "${SOURCES}" ; then
echo ">>>>> APT: INSTALL SOURCES.."
for SOURCE in $SOURCES; do
sudo -E apt-add-repository ppa:$SOURCE
done
fi
echo ">>>>> APT: INSTALL ${PACKAGES}.."
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES}
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/build.sh
elif [ "$JOB_BUILDTYPE" == "b5847f804b-0fcaf592f9" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/codecov.sh
elif [ "$JOB_BUILDTYPE" == "b5847f804b-db180b7bd2" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/valgrind.sh
elif [ "$JOB_BUILDTYPE" == "b5847f804b-cce9827eb5" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$TRAVIS_BRANCH" = "develop" -o "$TRAVIS_BRANCH" = "master" \) -a \("$GITHUB_EVENT_NAME" = "push" -o "$GITHUB_EVENT_NAME" = "cron" \) ] ; then
cd $BOOST_ROOT/libs/$SELF
ci/travis/coverity.sh
fi
fi
osx:
strategy:
fail-fast: false
matrix:
include:
- name: "B2_TOOLSET=clang B2_CXXSTD=03,11,17 Job 14"
buildtype: "boost"
packages: ""
os: "macos-10.15"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
xcode_version: 11.7
b2_toolset: "clang"
b2_cxxstd: "03,11,17"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set DEVELOPER_DIR
if: matrix.xcode_version != ''
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
- name: Test DEVELOPER_DIR
run: echo $DEVELOPER_DIR
- name: "osx"
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
B2_TOOLSET: ${{ matrix.b2_toolset }}
B2_CXXSTD: ${{ matrix.b2_cxxstd }}
B2_CXXFLAGS: ${{ matrix.b2_cxxflags }}
COMMENT: ${{ matrix.comment }}
B2_DEFINES: ${{ matrix.b2_defines }}
B2_VARIANT: ${{ matrix.b2_variant }}
B2_LINKFLAGS: ${{ matrix.b2_linkflags }}
UBSAN_OPTIONS: ${{ matrix.ubsan_options }}
B2_TESTFLAGS: ${{ matrix.b2_testflags }}
VALGRIND_OPTS: ${{ matrix.valgrind_opts }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "osx"
run: |
echo '==================================> SETUP'
set -e
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck
echo '==================================> PACKAGES'
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=`basename $REPO_NAME`
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/build.sh
fi

216
.travis.yml Normal file
View File

@@ -0,0 +1,216 @@
# Copyright 2016 Peter Dimov
# Copyright 2017 - 2019 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Travis CI build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want in the 'jobs'.
# 2. If you have more than include/, src/, test/, example/, examples/, or
# tools/ directories, modify your Travis CI project and add the environment
# variable DEPINST. For example if your build uses code in "bench/" and
# "fog/" directories, then set DEPINST to the following:
# --include bench --include fog
# 3. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 4. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the scripts will do everything else for you.
dist: xenial
language: cpp
env:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release
install:
- git clone https://github.com/boostorg/boost-ci.git boost-ci
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
- source ci/travis/install.sh
addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/build.sh
#
# Default toolsets in Ubuntu
#
# trusty xenial bionic
# 14.04 16.04 18.04
# ------ ------ ------
# clang 3.4 3.8 6.0
# gcc 4.8.2 5.3.1 7.3.0
#
anchors:
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
"ubuntu-toolchain-r-test" ] } }
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
"ubuntu-toolchain-r-test" ] } }
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
"ubuntu-toolchain-r-test" ] } }
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
"ubuntu-toolchain-r-test" ] } }
clang-7: &clang-7 { apt: { packages: [ "clang-7",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
"ubuntu-toolchain-r-test" ] } }
clang-8: &clang-8 { apt: { packages: [ "clang-8",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
"ubuntu-toolchain-r-test" ] } }
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
jobs:
allow_failures:
- env:
- COPY="all the environment settings from your job"
include:
# libstdc++
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=03,11" ], addons: *gcc-48 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=03,11" ], addons: *gcc-49 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=03,11" ], addons: *gcc-5 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17,2a" ], addons: *gcc-8 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17,2a" ], addons: *gcc-9 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=03,11" ], addons: *clang-38 }
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17,2a" ], addons: *clang-7 }
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17,2a" ], addons: *clang-8 }
# libc++
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=03,11,14",
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=03,11,17" ] }
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following:
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
- os: linux
env:
- COMMENT=codecov.io
- B2_CXXSTD=03,11
- B2_TOOLSET=gcc-8
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/codecov.sh
- os: linux
env:
- COMMENT=asan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=03,11,14
- B2_CXXFLAGS="address-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=tsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=03,11,14
- B2_CXXFLAGS="thread-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=ubsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=03,11,14
- B2_CXXFLAGS="undefined-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
# https://github.com/boostorg/build/issues/451 using the gold linker to work around an issue
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
addons: *gcc-8
- os: linux
env:
- COMMENT=valgrind
- B2_TOOLSET=clang-6.0
- B2_CXXSTD=03,11,14
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_VARIANT=variant=debug
- B2_TESTFLAGS=testing.launcher=valgrind
- VALGRIND_OPTS=--error-exitcode=1
addons: *clang-6
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/valgrind.sh
# - os: linux
# env:
# - COMMENT=cppcheck
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/cppcheck.sh
#################### Jobs to run on pushes to master, develop ###################
# Coverity Scan
- os: linux
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
env:
- COMMENT="Coverity Scan"
- B2_TOOLSET=clang
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/coverity.sh
notifications:
email:
false

32
CMakeLists.txt Normal file
View File

@@ -0,0 +1,32 @@
# Generated by `boostdep --cmake dynamic_bitset`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_dynamic_bitset VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_dynamic_bitset INTERFACE)
add_library(Boost::dynamic_bitset ALIAS boost_dynamic_bitset)
target_include_directories(boost_dynamic_bitset INTERFACE include)
target_link_libraries(boost_dynamic_bitset
INTERFACE
Boost::assert
Boost::config
Boost::container_hash
Boost::core
Boost::integer
Boost::move
Boost::static_assert
Boost::throw_exception
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

49
Jamfile
View File

@@ -1,40 +1,11 @@
subproject libs/dynamic_bitset ;
unit-test dyn_bitset_unit_tests1
: dyn_bitset_unit_tests1.cpp
<lib>../test/build/test_exec_monitor
: <include>$(BOOST_ROOT)
;
unit-test dyn_bitset_unit_tests2
: dyn_bitset_unit_tests2.cpp
<lib>../test/build/test_exec_monitor
: <include>$(BOOST_ROOT)
;
unit-test dyn_bitset_unit_tests3
: dyn_bitset_unit_tests3.cpp
<lib>../test/build/test_exec_monitor
: <include>$(BOOST_ROOT)
;
exe timing_tests
: timing_tests.cpp
: <include>$(BOOST_ROOT)
;
exe example1
: example1.cpp
: <include>$(BOOST_ROOT)
;
exe example2
: example2.cpp
: <include>$(BOOST_ROOT)
;
exe example3
: example3.cpp
: <include>$(BOOST_ROOT)
;
# Boost.DynamicBitset Library Jamfile
#
# Copyright (c) 2018 James E. King III
#
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# please order by name to ease maintenance
build-project example ;
build-project test ;

23
LICENSE Normal file
View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

34
README.md Normal file
View File

@@ -0,0 +1,34 @@
DynamicBitset, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is similar to std::bitset however the size is specified at run-time instead of at compile-time.
### License
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
### Properties
* C++03
* Header-only
### Build Status
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [![Build Status](https://travis-ci.org/boostorg/dynamic_bitset.svg?branch=master)](https://travis-ci.org/boostorg/dynamic_bitset) | [![Build status](https://ci.appveyor.com/api/projects/status/keyn57y5d3sl1gw5/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/dynamic_bitset.html)
[`develop`](https://github.com/boostorg/dynamic_bitset/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/dynamic_bitset.svg?branch=develop)](https://travis-ci.org/boostorg/dynamic_bitset) | [![Build status](https://ci.appveyor.com/api/projects/status/keyn57y5d3sl1gw5/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)
### Directories
| Name | Purpose |
| ----------- | ------------------------------ |
| `example` | examples |
| `doc` | documentation |
| `include` | headers |
| `test` | unit tests |
### More information
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-dynamic_bitset)
* [Report bugs](https://github.com/boostorg/dynamic_bitset/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[dynamic_bitset]` tag at the beginning of the subject line.

147
appveyor.yml Normal file
View File

@@ -0,0 +1,147 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright (C) 2017 - 2019 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Appveyor build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have more than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
#
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
matrix:
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
allow_failures:
- MAYFAIL: true
environment:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however:
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
# libraries that care about this exercise it in their Jamfiles...
# B2_ADDRESS_MODEL: address-model=64,32
# B2_LINK: link=shared,static
# B2_THREADING: threading=multi,single
B2_VARIANT: variant=release
matrix:
- FLAVOR: Visual Studio 2019
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
B2_ADDRESS_MODEL: address-model=64
B2_CXXFLAGS: cxxflags=-permissive-
B2_CXXSTD: latest # 2a
B2_TOOLSET: msvc-14.2
- FLAVOR: Visual Studio 2017 C++2a Strict
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXFLAGS: cxxflags=-permissive-
B2_CXXSTD: latest # 2a
B2_TOOLSET: msvc-14.1
- FLAVOR: Visual Studio 2017 C++17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 17
B2_TOOLSET: msvc-14.1
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2017 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64,32
B2_TOOLSET: msvc-14.1
- FLAVOR: clang-cl
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 11
B2_TOOLSET: clang-win
- FLAVOR: Visual Studio 2015 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_ADDRESS_MODEL: address-model=64,32
B2_TOOLSET: msvc-14.0
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2010, 2012, 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
- FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: address-model=32
B2_CXXSTD: 03,11
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc
B2_VARIANT: variant=debug
- FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 11,17
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc
- FLAVOR: mingw32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: i686
B2_ADDRESS_MODEL: address-model=32
B2_CXXSTD: 03,11
SCRIPT: ci\appveyor\mingw.bat
B2_VARIANT: variant=debug
- FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: x86_64
B2_ADDRESS_MODEL: address-model=64
B2_CXXSTD: 11,17
B2_DEFINES: define=__USE_ISOC99
SCRIPT: ci\appveyor\mingw.bat
install:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- git clone https://github.com/boostorg/boost-ci.git C:\boost-ci
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
- ci\appveyor\install.bat
build: off
test_script:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- PATH=%ADDPATH%%PATH%
# The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
# Echo the complete build command to the build log
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
# Now go build...
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)

View File

@@ -1,727 +0,0 @@
// (C) Copyright Jeremy Siek 2001.
// 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.
#include <vector>
#include <algorithm> // for std::min
#include <fstream>
#include <boost/test/test_tools.hpp>
// Extract the bit at position n from num.
template <typename Block>
inline bool nth_bit(Block num, std::size_t n)
{
// Move the nth bit to position 0 and then clear all other bits.
return (num >> n) & 1;
}
inline unsigned long max_num(std::size_t num_bits)
{
using namespace std; // for std::pow, VC++ workaround -JGS
return (unsigned long)(pow((double)2, (double)num_bits));
}
// constructors
// default (can't do this generically)
// from unsigned long
template <typename Bitset>
struct bitset_test {
static void from_unsigned_long(Bitset b, unsigned long num)
{
// initializes the first M bit position to the cooresponding bit
// values in val. M is the smaller of N and the value CHAR_BIT *
// sizeof(unsigned long)
// missing from the std?
// if M < N then the remaining bit positions are initialized to zero
std::size_t N = b.size();
std::size_t M = std::min(N, CHAR_BIT * sizeof(unsigned long));
std::size_t I;
for (I = 0; I < M; ++I)
BOOST_CHECK(b[I] == nth_bit(num, I));
for (; I < N; ++I)
BOOST_CHECK(b[I] == 0);
}
// from string
static void from_string(const std::string& str, std::size_t pos,
std::size_t n)
{
if (pos > str.size()) {
// Not in range, doesn't satisfy precondition.
} else {
std::size_t rlen = std::min(n, str.size() - pos);
// Throws invalid_argument if any of the rlen characters in str
// beginning at position pos is other than 0 or 1.
bool any_non_zero_or_one = false;
for (std::size_t i = pos; i < pos + rlen; ++i)
if (! (str[i] == '0' || str[i] == '1'))
any_non_zero_or_one = true;
if (any_non_zero_or_one) {
// Input does not satisfy precondition.
} else {
// Construct an object, initializing the first M bit position to
// values determined from the corresponding characters in the
// str. M is the smaller of N and rlen. Character position pos
// + M - 1 corresponds to bit position zero. Subsequent
// decreasing character position correspond to increasing bit
// positions.
Bitset b(str, pos, n);
std::size_t N = b.size();
std::size_t M = std::min(N, rlen);
std::size_t j;
for (j = 0; j < M; ++j)
BOOST_CHECK(b[j] == (str[pos + M - 1 - j] == '1'));
// If M < N, remaining bit positions are initialize to zero
for (; j < N; ++j)
BOOST_CHECK(b[j] == 0);
}
}
}
typedef typename Bitset::block_type Block;
// PRE: std::equal(first1, last1, first2) == true
static void from_block_range(std::vector<Block> blocks)
{
{
Bitset bset(blocks.begin(), blocks.end());
std::size_t n = blocks.size();
for (std::size_t b = 0; b < n; ++b) {
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
}
}
}
{
Bitset bset(blocks.size() * sizeof(Block) * CHAR_BIT);
boost::from_block_range(blocks.begin(), blocks.end(), bset);
std::size_t n = blocks.size();
for (std::size_t b = 0; b < n; ++b) {
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
}
}
}
}
// copy constructor (absent from std::bitset)
static void copy_constructor(const Bitset& b)
{
Bitset copy(b);
BOOST_CHECK(b == copy);
// Changes to the copy do not affect the original
if (b.size() > 0) {
std::size_t pos = copy.size() / 2;
copy.flip(pos);
BOOST_CHECK(copy[pos] != b[pos]);
}
}
// assignment operator (absent from std::bitset)
static void assignment_operator(const Bitset& lhs, const Bitset& rhs)
{
Bitset b(lhs);
b = rhs;
BOOST_CHECK(b == rhs);
// Changes to the copy do not affect the original
if (b.size() > 0) {
std::size_t pos = b.size() / 2;
b.flip(pos);
BOOST_CHECK(b[pos] != rhs[pos]);
}
}
static void resize(const Bitset& lhs)
{
Bitset b(lhs);
// Test no change in size
b.resize(lhs.size());
BOOST_CHECK(b == lhs);
// Test increase in size
b.resize(lhs.size() * 2, true);
std::size_t i;
for (i = 0; i < lhs.size(); ++i)
BOOST_CHECK(b[i] == lhs[i]);
for (; i < b.size(); ++i)
BOOST_CHECK(b[i] == true);
// Test decrease in size
b.resize(lhs.size());
for (i = 0; i < lhs.size(); ++i)
BOOST_CHECK(b[i] == lhs[i]);
}
static void clear(const Bitset& lhs)
{
Bitset b(lhs);
b.clear();
BOOST_CHECK(b.size() == 0);
}
static void append_bit(const Bitset& lhs)
{
Bitset b(lhs);
b.push_back(true);
BOOST_CHECK(b.size() == lhs.size() + 1);
BOOST_CHECK(b[b.size() - 1] == true);
for (std::size_t i = 0; i < lhs.size(); ++i)
BOOST_CHECK(b[i] == lhs[i]);
b.push_back(false);
BOOST_CHECK(b.size() == lhs.size() + 2);
BOOST_CHECK(b[b.size() - 1] == false);
BOOST_CHECK(b[b.size() - 2] == true);
for (std::size_t j = 0; j < lhs.size(); ++j)
BOOST_CHECK(b[j] == lhs[j]);
}
static void append_block(const Bitset& lhs)
{
Bitset b(lhs);
Block value(128);
b.append(value);
BOOST_CHECK(b.size() == lhs.size() + Bitset::bits_per_block);
for (std::size_t i = 0; i < Bitset::bits_per_block; ++i)
BOOST_CHECK(b[lhs.size() + i] == bool((value >> i) & 1));
}
static void append_block_range(const Bitset& lhs, std::vector<Block> blocks)
{
Bitset b(lhs), c(lhs);
b.append(blocks.begin(), blocks.end());
for (typename std::vector<Block>::iterator i = blocks.begin();
i != blocks.end(); ++i)
c.append(*i);
BOOST_CHECK(b == c);
}
// operator[] and reference members
// PRE: b[i] == bit_vec[i]
static void operator_bracket(const Bitset& lhs, const std::vector<bool>& bit_vec)
{
Bitset b(lhs);
std::size_t i, j, k;
// x = b[i]
// x = ~b[i]
for (i = 0; i < b.size(); ++i) {
bool x = b[i];
BOOST_CHECK(x == bit_vec[i]);
x = ~b[i];
BOOST_CHECK(x == !bit_vec[i]);
}
Bitset prev(b);
// b[i] = x
for (j = 0; j < b.size(); ++j) {
bool x = !prev[j];
b[j] = x;
for (k = 0; k < b.size(); ++k)
if (j == k)
BOOST_CHECK(b[k] == x);
else
BOOST_CHECK(b[k] == prev[k]);
b[j] = prev[j];
}
b.flip();
// b[i] = b[j]
for (i = 0; i < b.size(); ++i) {
b[i] = prev[i];
for (j = 0; j < b.size(); ++j) {
if (i == j)
BOOST_CHECK(b[j] == prev[j]);
else
BOOST_CHECK(b[j] == !prev[j]);
}
b[i] = !prev[i];
}
// b[i].flip()
for (i = 0; i < b.size(); ++i) {
b[i].flip();
for (j = 0; j < b.size(); ++j) {
if (i == j)
BOOST_CHECK(b[j] == prev[j]);
else
BOOST_CHECK(b[j] == !prev[j]);
}
b[i].flip();
}
}
//===========================================================================
// bitwise operators
// bitwise and assignment
// PRE: b.size() == rhs.size()
static void and_assignment(const Bitset& b, const Bitset& rhs)
{
Bitset lhs(b);
Bitset prev(lhs);
lhs &= rhs;
// Clears each bit in lhs for which the corresponding bit in rhs is
// clear, and leaves all other bits unchanged.
for (std::size_t I = 0; I < lhs.size(); ++I)
if (rhs[I] == 0)
BOOST_CHECK(lhs[I] == 0);
else
BOOST_CHECK(lhs[I] == prev[I]);
}
// PRE: b.size() == rhs.size()
static void or_assignment(const Bitset& b, const Bitset& rhs)
{
Bitset lhs(b);
Bitset prev(lhs);
lhs |= rhs;
// Sets each bit in lhs for which the corresponding bit in rhs is set, and
// leaves all other bits unchanged.
for (std::size_t I = 0; I < lhs.size(); ++I)
if (rhs[I] == 1)
BOOST_CHECK(lhs[I] == 1);
else
BOOST_CHECK(lhs[I] == prev[I]);
}
// PRE: b.size() == rhs.size()
static void xor_assignment(const Bitset& b, const Bitset& rhs)
{
Bitset lhs(b);
Bitset prev(lhs);
lhs ^= rhs;
// Flips each bit in lhs for which the corresponding bit in rhs is set,
// and leaves all other bits unchanged.
for (std::size_t I = 0; I < lhs.size(); ++I)
if (rhs[I] == 1)
BOOST_CHECK(lhs[I] == !prev[I]);
else
BOOST_CHECK(lhs[I] == prev[I]);
}
// PRE: b.size() == rhs.size()
static void sub_assignment(const Bitset& b, const Bitset& rhs)
{
Bitset lhs(b);
Bitset prev(lhs);
lhs -= rhs;
// Resets each bit in lhs for which the corresponding bit in rhs is set,
// and leaves all other bits unchanged.
for (std::size_t I = 0; I < lhs.size(); ++I)
if (rhs[I] == 1)
BOOST_CHECK(lhs[I] == 0);
else
BOOST_CHECK(lhs[I] == prev[I]);
}
static void shift_left_assignment(const Bitset& b, std::size_t pos)
{
Bitset lhs(b);
Bitset prev(lhs);
lhs <<= pos;
// Replaces each bit at position I in lhs with the following value:
// - If I < pos, the new value is zero
// - If I >= pos, the new value is the previous value of the bit at
// position I - pos
for (std::size_t I = 0; I < lhs.size(); ++I)
if (I < pos)
BOOST_CHECK(lhs[I] == 0);
else
BOOST_CHECK(lhs[I] == prev[I - pos]);
}
static void shift_right_assignment(const Bitset& b, std::size_t pos)
{
Bitset lhs(b);
Bitset prev(lhs);
lhs >>= pos;
// Replaces each bit at position I in lhs with the following value:
// - If pos >= N - I, the new value is zero
// - If pos < N - I, the new value is the previous value of the bit at
// position I + pos
std::size_t N = lhs.size();
for (std::size_t I = 0; I < N; ++I)
if (pos >= N - I)
BOOST_CHECK(lhs[I] == 0);
else
BOOST_CHECK(lhs[I] == prev[I + pos]);
}
static void set_all(const Bitset& b)
{
Bitset lhs(b);
lhs.set();
for (std::size_t I = 0; I < lhs.size(); ++I)
BOOST_CHECK(lhs[I] == 1);
}
static void set_one(const Bitset& b, std::size_t pos, bool value)
{
Bitset lhs(b);
std::size_t N = lhs.size();
if (pos < N) {
Bitset prev(lhs);
// Stores a new value in the bit at position pos in lhs.
lhs.set(pos, value);
BOOST_CHECK(lhs[pos] == value);
// All other values of lhs remain unchanged
for (std::size_t I = 0; I < N; ++I)
if (I != pos)
BOOST_CHECK(lhs[I] == prev[I]);
} else {
// Not in range, doesn't satisfy precondition.
}
}
static void reset_all(const Bitset& b)
{
Bitset lhs(b);
// Resets all bits in lhs
lhs.reset();
for (std::size_t I = 0; I < lhs.size(); ++I)
BOOST_CHECK(lhs[I] == 0);
}
static void reset_one(const Bitset& b, std::size_t pos)
{
Bitset lhs(b);
std::size_t N = lhs.size();
if (pos < N) {
Bitset prev(lhs);
lhs.reset(pos);
// Resets the bit at position pos in lhs
BOOST_CHECK(lhs[pos] == 0);
// All other values of lhs remain unchanged
for (std::size_t I = 0; I < N; ++I)
if (I != pos)
BOOST_CHECK(lhs[I] == prev[I]);
} else {
// Not in range, doesn't satisfy precondition.
}
}
static void operator_flip(const Bitset& b)
{
Bitset lhs(b);
Bitset x(lhs);
BOOST_CHECK(~lhs == x.flip());
}
static void flip_all(const Bitset& b)
{
Bitset lhs(b);
std::size_t N = lhs.size();
Bitset prev(lhs);
lhs.flip();
// Toggles all the bits in lhs
for (std::size_t I = 0; I < N; ++I)
BOOST_CHECK(lhs[I] == !prev[I]);
}
static void flip_one(const Bitset& b, std::size_t pos)
{
Bitset lhs(b);
std::size_t N = lhs.size();
if (pos < N) {
Bitset prev(lhs);
lhs.flip(pos);
// Toggles the bit at position pos in lhs
BOOST_CHECK(lhs[pos] == !prev[pos]);
// All other values of lhs remain unchanged
for (std::size_t I = 0; I < N; ++I)
if (I != pos)
BOOST_CHECK(lhs[I] == prev[I]);
} else {
// Not in range, doesn't satisfy precondition.
}
}
// to_ulong()
static void to_ulong(const Bitset& lhs)
{
std::size_t N = lhs.size();
std::size_t n = CHAR_BIT * sizeof(unsigned long);
bool will_overflow = false;
for (std::size_t I = n; I < N; ++I)
if (lhs[I] != 0)
will_overflow = true;
if (will_overflow) {
try {
(void)lhs.to_ulong();
BOOST_CHECK(false); // It should have thrown and exception
} catch (std::overflow_error) {
// Good!
} catch (...) {
BOOST_CHECK(false); // threw the wrong exception
}
} else {
unsigned long num = lhs.to_ulong();
// Make sure the number is right
for (std::size_t I = 0; I < N; ++I)
BOOST_CHECK(lhs[I] == nth_bit(num, I));
}
}
// to_string()
static void to_string(const Bitset& b)
{
// Construct a string object of the appropriate type and initializes
// it to a string of length N characters. Each character is determined
// by the value of its corresponding bit position in b. Character
// position N - 1 corresponds to bit position zero. Sebsequent
// decreasing character positions correspond to increasing bit
// positions. Bit value zero becomes the charactet 0, bit value one
// becomes the character 1.
std::string str;
boost::to_string(b, str);
std::size_t N = b.size();
BOOST_CHECK(str.size() == b.size());
for (std::size_t I = 0; I < b.size(); ++I)
BOOST_CHECK(b[I] == 0 ? (str[N - 1 - I] == '0') : (str[N - 1 - I] == '1'));
}
static void count(const Bitset& b)
{
std::size_t c = b.count();
std::size_t c_real = 0;
for (std::size_t I = 0; I < b.size(); ++I)
if (b[I])
++c_real;
BOOST_CHECK(c == c_real);
}
static void size(const Bitset& b)
{
BOOST_CHECK(Bitset(b).set().count() == b.size());
}
static void any(const Bitset& b)
{
BOOST_CHECK(b.any() == (b.count() > 0));
}
static void none(const Bitset& b)
{
BOOST_CHECK(b.none() == (b.count() == 0));
}
static void subset(const Bitset& a, const Bitset& b)
{
if (a.is_subset_of(b)) {
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I])
BOOST_CHECK(b[I]);
} else {
bool is_subset = true;
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I] && !b[I]) {
is_subset = false;
break;
}
BOOST_CHECK(is_subset == false);
}
}
static void proper_subset(const Bitset& a, const Bitset& b)
{
if (a.is_proper_subset_of(b)) {
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I])
BOOST_CHECK(b[I]);
BOOST_CHECK(a.count() < b.count());
} else {
bool is_subset = true;
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I] && !b[I]) {
is_subset = false;
break;
}
BOOST_CHECK(is_subset == false || a.count() >= b.count());
}
}
static void operator_equal(const Bitset& a, const Bitset& b)
{
if (a == b) {
for (std::size_t I = 0; I < a.size(); ++I)
BOOST_CHECK(a[I] == b[I]);
} else {
if (a.size() == b.size()) {
bool diff = false;
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I] != b[I]) {
diff = true;
break;
}
BOOST_CHECK(diff);
}
}
}
static void operator_not_equal(const Bitset& a, const Bitset& b)
{
if (a != b) {
if (a.size() == b.size()) {
bool diff = false;
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I] != b[I]) {
diff = true;
break;
}
BOOST_CHECK(diff);
}
} else {
for (std::size_t I = 0; I < a.size(); ++I)
BOOST_CHECK(a[I] == b[I]);
}
}
static bool less_than(const Bitset& a, const Bitset& b)
{
// Compare from most significant to least.
// Careful, don't send unsigned int into negative territory!
if (a.size() == 0)
return false;
std::size_t I;
for (I = a.size() - 1; I > 0; --I)
if (a[I] < b[I])
return true;
else if (a[I] > b[I])
return false;
// if (a[I] = b[I]) skip to next
if (a[0] < b[0])
return true;
else
return false;
}
static void operator_less_than(const Bitset& a, const Bitset& b)
{
if (less_than(a, b))
BOOST_CHECK(a < b);
else
BOOST_CHECK(!(a < b));
}
static void operator_greater_than(const Bitset& a, const Bitset& b)
{
if (less_than(a, b) || a == b)
BOOST_CHECK(!(a > b));
else
BOOST_CHECK(a > b);
}
static void operator_less_than_eq(const Bitset& a, const Bitset& b)
{
if (less_than(a, b) || a == b)
BOOST_CHECK(a <= b);
else
BOOST_CHECK(!(a <= b));
}
static void operator_greater_than_eq(const Bitset& a, const Bitset& b)
{
if (less_than(a, b))
BOOST_CHECK(!(a >= b));
else
BOOST_CHECK(a >= b);
}
static void test_bit(const Bitset& b, std::size_t pos)
{
Bitset lhs(b);
std::size_t N = lhs.size();
if (pos < N) {
BOOST_CHECK(lhs.test(pos) == lhs[pos]);
} else {
// Not in range, doesn't satisfy precondition.
}
}
static void operator_shift_left(const Bitset& lhs, std::size_t pos)
{
Bitset x(lhs);
BOOST_CHECK((lhs << pos) == (x <<= pos));
}
static void operator_shift_right(const Bitset& lhs, std::size_t pos)
{
Bitset x(lhs);
BOOST_CHECK((lhs >> pos) == (x >>= pos));
}
// operator|
static
void operator_or(const Bitset& lhs, const Bitset& rhs)
{
Bitset x(lhs);
BOOST_CHECK((lhs | rhs) == (x |= rhs));
}
// operator&
static
void operator_and(const Bitset& lhs, const Bitset& rhs)
{
Bitset x(lhs);
BOOST_CHECK((lhs & rhs) == (x &= rhs));
}
// operator^
static
void operator_xor(const Bitset& lhs, const Bitset& rhs)
{
Bitset x(lhs);
BOOST_CHECK((lhs ^ rhs) == (x ^= rhs));
}
// operator-
static
void operator_sub(const Bitset& lhs, const Bitset& rhs)
{
Bitset x(lhs);
BOOST_CHECK((lhs - rhs) == (x -= rhs));
}
// operator<<(ostream,
// operator>>(istream,
static
void stream_read_write(const Bitset& out, const Bitset& in)
{
Bitset x(in);
{
std::ofstream f("tmp");
f << out;
}
{
std::ifstream f("tmp");
f >> x;
BOOST_CHECK(out == x);
}
}
};

1
doc/readme Normal file
View File

@@ -0,0 +1 @@
The documentation for the dynamic_bitset library is the top-level index.html file.

View File

@@ -1,258 +0,0 @@
// (C) Copyright Jeremy Siek 2001.
// 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.
#include <iostream>
#include <fstream>
#include <cmath> // for pow
#include <boost/limits.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/test/test_tools.hpp>
#include "bitset_test.hpp"
template <typename Block>
void test_from_ulong(std::size_t n, unsigned long number)
{
boost::dynamic_bitset<Block> b(n, number);
bitset_test< boost::dynamic_bitset<Block> >::from_unsigned_long(b, number);
}
template <typename Block>
void run_test_cases()
{
typedef bitset_test< boost::dynamic_bitset<Block> > Tests;
std::string long_string(101, '0');
for (std::size_t j = 0; j < long_string.size(); ++j)
long_string[j] = '0' + (j % 2);
std::size_t N, ul_size = CHAR_BIT * sizeof(unsigned long),
block_size = CHAR_BIT * sizeof(Block);
unsigned long numbers[] = { 0, 40247,
std::numeric_limits<unsigned long>::max() };
//=====================================================================
// Test construction from unsigned long
for (std::size_t i = 0; i < 3; ++i) {
unsigned long number = numbers[i];
N = 0;
test_from_ulong<Block>(N, number);
N = std::size_t(0.7 * double(ul_size));
test_from_ulong<Block>(N, number);
N = 1 * ul_size;
test_from_ulong<Block>(N, number);
N = std::size_t(1.3 * double(ul_size));
test_from_ulong<Block>(N, number);
N = std::size_t(0.7 * double(block_size));
test_from_ulong<Block>(N, number);
N = block_size;
test_from_ulong<Block>(N, number);
N = std::size_t(1.3 * double(block_size));
test_from_ulong<Block>(N, number);
N = 3 * block_size;
test_from_ulong<Block>(N, number);
}
//=====================================================================
// Test construction from a string
{
// case pos > str.size()
Tests::from_string(std::string(""), 1, 1);
// invalid arguments
Tests::from_string(std::string("x11"), 0, 3);
Tests::from_string(std::string("0y1"), 0, 3);
Tests::from_string(std::string("10z"), 0, 3);
// valid arguments
Tests::from_string(std::string(""), 0, 0);
Tests::from_string(std::string("0"), 0, 1);
Tests::from_string(std::string("1"), 0, 1);
Tests::from_string(long_string, 0, long_string.size());
}
//=====================================================================
// Test construction from a block range
{
std::vector<Block> blocks;
Tests::from_block_range(blocks);
}
{
std::vector<Block> blocks(3);
blocks[0] = static_cast<Block>(0);
blocks[1] = static_cast<Block>(1);
blocks[2] = ~Block(0);
Tests::from_block_range(blocks);
}
{
std::vector<Block> blocks(101);
for (typename std::vector<Block>::size_type i = 0;
i < blocks.size(); ++i)
blocks[i] = i;
Tests::from_block_range(blocks);
}
//=====================================================================
// Test copy constructor
{
boost::dynamic_bitset<Block> b;
Tests::copy_constructor(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::copy_constructor(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::copy_constructor(b);
}
//=====================================================================
// Test assignment operator
{
boost::dynamic_bitset<Block> a, b;
Tests::assignment_operator(a, b);
}
{
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("0"));
Tests::assignment_operator(a, b);
}
{
boost::dynamic_bitset<Block> a(long_string), b(long_string);
Tests::assignment_operator(a, b);
}
//=====================================================================
// Test resize
{
boost::dynamic_bitset<Block> a;
Tests::resize(a);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
Tests::resize(a);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
Tests::resize(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::resize(a);
}
//=====================================================================
// Test clear
{
boost::dynamic_bitset<Block> a;
Tests::clear(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::clear(a);
}
//=====================================================================
// Test append bit
{
boost::dynamic_bitset<Block> a;
Tests::append_bit(a);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
Tests::append_bit(a);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
Tests::append_bit(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::append_bit(a);
}
//=====================================================================
// Test append block
{
boost::dynamic_bitset<Block> a;
Tests::append_block(a);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
Tests::append_block(a);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
Tests::append_block(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::append_block(a);
}
//=====================================================================
// Test append block range
{
boost::dynamic_bitset<Block> a;
std::vector<Block> blocks;
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
std::vector<Block> blocks(3);
blocks[0] = static_cast<Block>(0);
blocks[1] = static_cast<Block>(1);
blocks[2] = ~Block(0);
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
std::vector<Block> blocks(101);
for (typename std::vector<Block>::size_type i = 0;
i < blocks.size(); ++i)
blocks[i] = i;
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a(long_string);
std::vector<Block> blocks(3);
blocks[0] = static_cast<Block>(0);
blocks[1] = static_cast<Block>(1);
blocks[2] = ~Block(0);
Tests::append_block_range(a, blocks);
}
//=====================================================================
// Test bracket operator
{
boost::dynamic_bitset<Block> b1;
std::vector<bool> bitvec1;
Tests::operator_bracket(b1, bitvec1);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
std::vector<bool> bit_vec(1, true);
Tests::operator_bracket(b, bit_vec);
}
{
boost::dynamic_bitset<Block> b(long_string);
std::size_t n = long_string.size();
std::vector<bool> bit_vec(n);
for (std::size_t i = 0; i < n; ++i)
bit_vec[i] = long_string[n - 1 - i] == '0' ? 0 : 1;
Tests::operator_bracket(b, bit_vec);
}
}
int
test_main(int, char*[])
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned long>();
return EXIT_SUCCESS;
}

View File

@@ -1,240 +0,0 @@
// (C) Copyright Jeremy Siek 2001.
// 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.
#include <iostream>
#include <fstream>
#include <cmath> // for pow
#include <boost/dynamic_bitset.hpp>
#include <boost/test/test_tools.hpp>
#include "bitset_test.hpp"
template <typename Block>
void run_test_cases()
{
typedef bitset_test< boost::dynamic_bitset<Block> > Tests;
std::string long_string(101, '0');
for (std::size_t i = 0; i < long_string.size(); ++i)
long_string[i] = '0' + (i % 2);
//=====================================================================
// Test operator&=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::and_assignment(lhs, rhs);
}
//=====================================================================
// Test operator |=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::or_assignment(lhs, rhs);
}
//=====================================================================
// Test operator^=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
Tests::xor_assignment(lhs, rhs);
}
//=====================================================================
// Test operator-=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
Tests::sub_assignment(lhs, rhs);
}
//=====================================================================
// Test operator<<=
{ // case pos == 0
std::size_t pos = 0;
boost::dynamic_bitset<Block> b(std::string("1010"));
Tests::shift_left_assignment(b, pos);
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
//=====================================================================
// Test operator>>=
{ // case pos == 0
std::size_t pos = 0;
boost::dynamic_bitset<Block> b(std::string("1010"));
Tests::shift_right_assignment(b, pos);
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
//=====================================================================
// test b.set()
{
boost::dynamic_bitset<Block> b;
Tests::set_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::set_all(b);
}
//=====================================================================
// Test b.set(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::set_one(b, 0, true);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_one(b, 0, true);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_one(b, long_string.size()/2, true);
}
//=====================================================================
// Test b.reset()
{
boost::dynamic_bitset<Block> b;
Tests::reset_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_all(b);
}
//=====================================================================
// Test b.reset(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::reset_one(b, 0);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_one(b, 0);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_one(b, long_string.size()/2);
}
//=====================================================================
// Test ~b
{
boost::dynamic_bitset<Block> b;
Tests::operator_flip(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::operator_flip(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::operator_flip(b);
}
//=====================================================================
// Test b.flip()
{
boost::dynamic_bitset<Block> b;
Tests::flip_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::flip_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_all(b);
}
//=====================================================================
// Test b.flip(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::flip_one(b, 0);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::flip_one(b, 0);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_one(b, long_string.size()/2);
}
}
int
test_main(int argc, char*[])
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned long>();
return EXIT_SUCCESS;
}

File diff suppressed because it is too large Load Diff

26
example/Jamfile Normal file
View File

@@ -0,0 +1,26 @@
# -----------------------------------------------------------
# Copyright (c) 2002 Gennaro Prota
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# -----------------------------------------------------------
exe timing_tests
: timing_tests.cpp
../../timer/build//boost_timer
;
exe example1
: example1.cpp
;
exe example2
: example2.cpp
;
exe example3
: example3.cpp
;

35
example/example1.cpp Normal file
View File

@@ -0,0 +1,35 @@
// (C) Copyright Jeremy Siek 2001.
// 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 example of setting and reading some bits. Note that operator[]
// goes from the least-significant bit at 0 to the most significant
// bit at size()-1. The operator<< for dynamic_bitset prints the
// bitset from most-significant to least-significant, since that is
// the format most people are used to reading.
//
// The output is:
//
// 11001
// 10011
// ---------------------------------------------------------------------
#include <iostream>
#include <boost/dynamic_bitset.hpp>
int main()
{
boost::dynamic_bitset<> x(5); // all 0's by default
x[0] = 1;
x[1] = 1;
x[4] = 1;
for (boost::dynamic_bitset<>::size_type i = 0; i < x.size(); ++i)
std::cout << x[i];
std::cout << "\n";
std::cout << x << "\n";
return 0;
}

32
example/example2.cpp Normal file
View File

@@ -0,0 +1,32 @@
// (C) Copyright Jeremy Siek 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Sample output:
//
// bits(0) = 00
// bits(1) = 01
// bits(2) = 10
// bits(3) = 11
#include <iostream>
#include <boost/dynamic_bitset.hpp>
int main()
{
const boost::dynamic_bitset<> b0(2, 0ul);
std::cout << "bits(0) = " << b0 << std::endl;
const boost::dynamic_bitset<> b1(2, 1ul);
std::cout << "bits(1) = " << b1 << std::endl;
const boost::dynamic_bitset<> b2(2, 2ul);
std::cout << "bits(2) = " << b2 << std::endl;
const boost::dynamic_bitset<> b3(2, 3ul);
std::cout << "bits(3) = " << b3 << std::endl;
return 0;
}

71
example/example3.cpp Normal file
View File

@@ -0,0 +1,71 @@
// Copyright (c) 2001 Jeremy Siek
// Copyright (c) 2008 Gennaro Prota
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Sample run:
//
// mask = 101010101010
// x.size() = 0
// Enter a bitset in binary: x = 100100010
//
// Input number: 100100010
// x.size() is now: 9
// As unsigned long: 290
// Mask (possibly resized): 010101010
// And with mask: 000100010
// Or with mask: 110101010
// Shifted left by 1: 001000100
// Shifted right by 1: 010010001
#include "boost/dynamic_bitset.hpp"
#include <ostream>
#include <iostream>
int main()
{
boost::dynamic_bitset<> mask(12, 2730ul);
std::cout << "mask = " << mask << std::endl;
boost::dynamic_bitset<> x;
std::cout << "x.size() = " << x.size() << std::endl;
std::cout << "Enter a bitset in binary: x = " << std::flush;
if (std::cin >> x) {
const std::size_t sz = x.size();
std::cout << std::endl;
std::cout << "Input number: " << x << std::endl;
std::cout << "x.size() is now: " << sz << std::endl;
bool fits_in_ulong = true;
unsigned long ul = 0;
try {
ul = x.to_ulong();
} catch(std::overflow_error &) {
fits_in_ulong = false;
}
std::cout << "As unsigned long: ";
if(fits_in_ulong) {
std::cout << ul;
} else {
std::cout << "(overflow exception)";
}
std::cout << std::endl;
mask.resize(sz);
std::cout << "Mask (possibly resized): " << mask << std::endl;
std::cout << "And with mask: " << (x & mask) << std::endl;
std::cout << "Or with mask: " << (x | mask) << std::endl;
std::cout << "Shifted left by 1: " << (x << 1) << std::endl;
std::cout << "Shifted right by 1: " << (x >> 1) << std::endl;
}
return 0;
}

142
example/timing_tests.cpp Normal file
View File

@@ -0,0 +1,142 @@
// -----------------------------------------------------------
//
// Copyright (c) 2003-2004 Gennaro Prota
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
// boost::dynamic_bitset timing tests
//
// NOTE:
// ~~~~~
// This is a preliminary, incomplete version.
//
// If you are interested in having more benchmarks please make a
// request on the boost list, which could encourage me to continue
// this work.
// Also, if you use boost::dynamic_bitset on a platform where
// CHAR_BIT >= 9 I suggest experimenting with the size of the count
// table in detail/dynamic_bitset.hpp and report any interesting
// discovery on the list as well.
// You might also want to try both counting methods (by_bytes vs.
// by_blocks) to see if the one that is selected automatically is
// actually the fastest on your system.
//
//
// -----------------------------------------------------------------------//
#include "boost/config.hpp"
#if defined (__STL_CONFIG_H) && !defined (__STL_USE_NEW_IOSTREAMS)
// for pre 3.0 versions of libstdc++
# define BOOST_OLD_IOSTREAMS
#endif
// ------------------------------------------------- //
#include <typeinfo>
#include <iostream>
#if !defined(BOOST_OLD_IOSTREAMS)
# include <ostream>
#endif
#include "boost/cstdlib.hpp"
#include "boost/version.hpp"
#include "boost/timer/timer.hpp"
#include "boost/dynamic_bitset.hpp"
namespace {
// the m_ prefixes, below, are mainly to avoid problems with g++:
// see http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00884.html
//
class boost_version {
int m_major;
int m_minor;
int m_subminor;
public:
boost_version(unsigned long v = BOOST_VERSION):
m_major(v / 100000), m_minor(v / 100 % 1000), m_subminor(v % 100) {}
friend std::ostream & operator<<(std::ostream &, const boost_version &);
};
// give up using basic_ostream, to avoid headaches with old libraries
std::ostream& operator<<(std::ostream& os, const boost_version & v) {
return os << v.m_major << '.' << v.m_minor << '.' << v.m_subminor;
}
}
void prologue()
{
std::cout << '\n';
std::cout << "Compiler: " << BOOST_COMPILER << '\n';
std::cout << "Std lib : " << BOOST_STDLIB << '\n';
std::cout << "Boost v.: " << boost_version() << '\n';
std::cout << '\n';
}
template <typename T>
void timing_test(T* = 0) // dummy parameter to workaround VC6
{
#ifndef BOOST_NO_STRESS_TEST
const unsigned long num = 30 * 100000;
#else
const unsigned long num = 30 * 1000;
#endif
// This variable is printed at the end of the test,
// to prevent the optimizer from removing the call to
// count() in the loop below.
typename boost::dynamic_bitset<T>::size_type dummy = 0;
std::cout << "\nTimings for dynamic_bitset<" << typeid(T).name()
<< "> [" << num << " iterations]\n";
std::cout << "--------------------------------------------------\n";
{
boost::timer::auto_cpu_timer time;
const typename boost::dynamic_bitset<T>::size_type sz = 5000;
for (unsigned long i = 0; i < num; ++i) {
boost::dynamic_bitset<T> bs(sz, i);
dummy += bs.count();
}
}
std::cout << "(total count: " << dummy << ")\n\n";
}
int main()
{
prologue();
timing_test<unsigned char>();
timing_test<unsigned short>();
timing_test<unsigned int>();
timing_test<unsigned long>();
# ifdef BOOST_HAS_LONG_LONG
timing_test< ::boost::ulong_long_type>();
# endif
return boost::exit_success;
}

View File

@@ -1,26 +0,0 @@
// (C) Copyright Jeremy Siek 2001. 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.
// Sample output:
// 1
// 1
// 0
// 0
// 1
#include <iostream>
#include <boost/dynamic_bitset.hpp>
int main() {
boost::dynamic_bitset<> x(5); // all 0's by default
x[0] = 1;
x[1] = 1;
x[4] = 1;
for (boost::dynamic_bitset<>::size_type i = 0; i < x.size(); ++i)
std::cout << x[i];
std::cout << "\n";
std::cout << x << "\n";
return EXIT_SUCCESS;
}

View File

@@ -1,30 +0,0 @@
// (C) Copyright Jeremy Siek 2001. 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.
//
// Sample output:
// bits(0) = 00
// bits(1) = 01
// bits(2) = 10
// bits(3) = 11
#include <iostream>
#include <boost/dynamic_bitset.hpp>
int main()
{
const boost::dynamic_bitset<> b0(2, 0ul);
std::cout << "bits(0) = " << b0 << std::endl;
const boost::dynamic_bitset<> b1(2, 1ul);
std::cout << "bits(1) = " << b1 << std::endl;
const boost::dynamic_bitset<> b2(2, 2ul);
std::cout << "bits(2) = " << b2 << std::endl;
const boost::dynamic_bitset<> b3(2, 3ul);
std::cout << "bits(3) = " << b3 << std::endl;
return EXIT_SUCCESS;
}

View File

@@ -1,36 +0,0 @@
// (C) Copyright Jeremy Siek 2001. 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.
//
// Sample output:
// mask = 101010101010
// Enter a 12-bit bitset in binary: 100110101101
// x = 100110101101
// As ulong: 2477
// And with mask: 100010101000
// Or with mask: 101110101111
#include <iostream>
#include <boost/dynamic_bitset.hpp>
int main(int, char*[]) {
const boost::dynamic_bitset<> mask(12, 2730ul);
std::cout << "mask = " << mask << std::endl;
boost::dynamic_bitset<> x(12);
std::cout << "x.size()=" << x.size() << std::endl;
std::cout << "Enter a 12-bit bitset in binary: " << std::flush;
if (std::cin >> x) {
std::cout << "input number: " << x << std::endl;
std::cout << "As unsigned long: " << x.to_ulong() << std::endl;
std::cout << "And with mask: " << (x & mask) << std::endl;
std::cout << "Or with mask: " << (x | mask) << std::endl;
std::cout << "Shifted left: " << (x << 1) << std::endl;
std::cout << "Shifted right: " << (x >> 1) << std::endl;
}
return EXIT_SUCCESS;
}

View File

@@ -1,176 +0,0 @@
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
//
// 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.
// With optimizations by Gennaro Prota.
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
#include "boost/config.hpp"
#include "boost/detail/iterator.hpp"
#if !(defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) || defined(__BORLANDC__))
#define BOOST_DYN_BITSET_USE_FRIENDS
#endif
namespace boost {
namespace detail {
// Forward references
template <typename BlockInputIterator>
std::size_t initial_num_blocks(BlockInputIterator first,
BlockInputIterator last,
std::input_iterator_tag);
template <typename BlockForwardIterator>
std::size_t initial_num_blocks(BlockForwardIterator first,
BlockForwardIterator last,
std::forward_iterator_tag);
// The following 2 classes make sure that the bitset
// gets allocated in an exception safe manner
template <typename Allocator>
class dynamic_bitset_alloc_base {
public:
dynamic_bitset_alloc_base(const Allocator& alloc)
: m_alloc(alloc) { }
protected:
Allocator m_alloc;
};
template <typename Block, typename Allocator>
class dynamic_bitset_base :
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
protected
#else
public
#endif
dynamic_bitset_alloc_base<Allocator>
{
typedef std::size_t size_type;
#ifndef BOOST_DYN_BITSET_USE_FRIENDS
public:
#endif
enum { bits_per_block = CHAR_BIT * sizeof(Block) };
public:
dynamic_bitset_base()
: m_bits(0), m_num_bits(0), m_num_blocks(0) { }
dynamic_bitset_base(size_type num_bits, const Allocator& alloc)
: dynamic_bitset_alloc_base<Allocator>(alloc),
m_bits(dynamic_bitset_alloc_base<Allocator>::
m_alloc.allocate(calc_num_blocks(num_bits), static_cast<void const *>(0))),
m_num_bits(num_bits),
m_num_blocks(calc_num_blocks(num_bits))
{
using namespace std;
memset(m_bits, 0, m_num_blocks * sizeof(Block)); // G.P.S. ask to Jeremy
}
~dynamic_bitset_base() {
if (m_bits)
this->m_alloc.deallocate(m_bits, m_num_blocks);
}
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
protected:
#endif
Block* m_bits;
size_type m_num_bits;
size_type m_num_blocks;
static size_type word(size_type bit) { return bit / bits_per_block; } // [gps]
static size_type offset(size_type bit){ return bit % bits_per_block; } // [gps]
static Block mask1(size_type bit) { return Block(1) << offset(bit); }
static Block mask0(size_type bit) { return ~(Block(1) << offset(bit)); }
static size_type calc_num_blocks(size_type num_bits)
{ return (num_bits + bits_per_block - 1) / bits_per_block; }
};
// ------- count table implementation --------------
typedef unsigned char byte_t;
// only count<true> has a definition
#if 0
// This was giving Intel C++ and Borland C++ trouble -JGS
template <bool = true> struct count;
template <> struct count <true> {
#else
template <bool bogus = true>
struct count {
#endif
typedef byte_t element_type;
static const byte_t table[];
BOOST_STATIC_CONSTANT (unsigned int, max_bit = 8); // must be a power of two
};
//typedef count<true> table_t;
// the table: wrapped in a class template, so
// that it is only instantiated if/when needed
//
#if 0
// Intel C++ and Borland C++ trouble -JGS
template <>
const byte_t count <true>::table[] =
#else
template <bool bogus>
const byte_t count<bogus>::table[] =
#endif
{
// 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
};
// -------------------------------------------------------
template <typename BlockInputIterator>
std::size_t initial_num_blocks(BlockInputIterator first,
BlockInputIterator last,
std::input_iterator_tag)
{
return 0;
}
template <typename BlockForwardIterator>
std::size_t initial_num_blocks(BlockForwardIterator first,
BlockForwardIterator last,
std::forward_iterator_tag)
{
std::size_t n = 0;
while (first != last)
++first, ++n;
return n;
}
template <typename BlockInputIterator>
std::size_t initial_num_blocks(BlockInputIterator first,
BlockInputIterator last)
{
typename detail::iterator_traits<BlockInputIterator>::iterator_category cat;
return initial_num_blocks(first, last, cat);
}
} // namespace detail
} // namespace boost
#endif // BOOST_DETAIL_DYNAMIC_BITSET_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
// -----------------------------------------------------------
//
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
// Copyright (c) 2003-2006, 2008 Gennaro Prota
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
#define BOOST_DYNAMIC_BITSET_CONFIG_HPP_GP_20040424
#include "boost/config.hpp"
#include "boost/detail/workaround.hpp"
// support for pre 3.0 libstdc++ - thanks Phil Edwards!
#if defined (__STL_CONFIG_H) && !defined (__STL_USE_NEW_IOSTREAMS)
# define BOOST_OLD_IOSTREAMS
#endif
// no-op function to workaround gcc bug c++/8419
//
namespace boost { namespace detail {
template <typename T> T make_non_const(T t) { return t; }
}}
#if defined(__GNUC__)
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(expr) \
(boost::detail::make_non_const(expr))
#else
# define BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(expr) (expr)
#endif
//
#if (defined BOOST_BORLANDC && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))) \
|| (defined BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
#endif
// if we can't use friends then we simply expose private members
//
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_PRIVATE public
#else
#define BOOST_DYNAMIC_BITSET_PRIVATE private
#endif
// A couple of macros to cope with libraries without locale
// support. The first macro must be used to declare a reference
// 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
#define BOOST_DYNAMIC_BITSET_CTYPE_FACET(ch, name, loc) /**/
#define BOOST_DYNAMIC_BITSET_WIDEN_CHAR(fac, c) c
#endif
#endif // include guard

View File

@@ -0,0 +1,307 @@
// -----------------------------------------------------------
//
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
// Copyright (c) 2003-2006, 2008 Gennaro Prota
// Copyright (c) 2014 Glen Joseph Fernandes
// (glenjofe@gmail.com)
// Copyright (c) 2018 Evgeny Shulgin
// Copyright (c) 2019 Andrey Semashev
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
#include <memory>
#include <cstddef>
#include "boost/config.hpp"
#include "boost/detail/workaround.hpp"
#include <boost/core/allocator_access.hpp>
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
#include <intrin.h>
#endif
namespace boost {
namespace detail {
namespace dynamic_bitset_impl {
template<class T>
struct max_limit {
BOOST_STATIC_CONSTEXPR T value = static_cast<T>(-1);
};
template<class T>
BOOST_CONSTEXPR_OR_CONST T max_limit<T>::value;
// Gives (read-)access to the object representation
// of an object of type T (3.9p4). CANNOT be used
// on a base sub-object
//
template <typename T>
inline const unsigned char * object_representation (T* p)
{
return static_cast<const unsigned char *>(static_cast<const void *>(p));
}
template<typename T, int amount, int width /* = default */>
struct shifter
{
static void left_shift(T & v) {
amount >= width ? (v = 0)
: (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount));
}
};
// ------- count function implementation --------------
typedef unsigned char byte_type;
// These two entities
//
// enum mode { access_by_bytes, access_by_blocks };
// template <mode> struct mode_to_type {};
//
// were removed, since the regression logs (as of 24 Aug 2008)
// showed that several compilers had troubles with recognizing
//
// const mode m = access_by_bytes
//
// as a constant expression
//
// * So, we'll use bool, instead of enum *.
//
template <bool value>
struct value_to_type
{
value_to_type() {}
};
const bool access_by_bytes = true;
const bool access_by_blocks = false;
// the table: wrapped in a class template, so
// that it is only instantiated if/when needed
//
template <bool dummy_name = true>
struct count_table { static const byte_type table[]; };
template <>
struct count_table<false> { /* no table */ };
const unsigned int table_width = 8;
template <bool b>
const byte_type count_table<b>::table[] =
{
// Automatically generated by GPTableGen.exe v.1.0
//
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
// Some platforms have fast popcount operation, that allow us to implement
// counting bits much more efficiently
//
template <typename ValueType>
BOOST_FORCEINLINE std::size_t popcount(ValueType value) BOOST_NOEXCEPT
{
std::size_t num = 0u;
while (value) {
num += count_table<>::table[value & ((1u<<table_width) - 1)];
value >>= table_width;
}
return num;
}
#if (((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))) \
&& (defined(__POPCNT__) || defined(__AVX__))
template <>
BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
{
return static_cast<std::size_t>(__popcnt16(value));
}
template <>
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
{
return static_cast<std::size_t>(__popcnt(value));
}
template <>
BOOST_FORCEINLINE std::size_t popcount<unsigned __int64>(unsigned __int64 value) BOOST_NOEXCEPT
{
#if defined(_M_X64)
return static_cast<std::size_t>(__popcnt64(value));
#else
return static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value))) + static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value >> 32)));
#endif
}
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
// Note: gcc builtins are implemented by compiler runtime when the target CPU may not support the necessary instructions
template <>
BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
{
return static_cast<unsigned int>(__builtin_popcount(static_cast<unsigned int>(value)));
}
template <>
BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
{
return static_cast<unsigned int>(__builtin_popcount(value));
}
template <>
BOOST_FORCEINLINE std::size_t popcount<unsigned long>(unsigned long value) BOOST_NOEXCEPT
{
return static_cast<unsigned int>(__builtin_popcountl(value));
}
template <>
BOOST_FORCEINLINE std::size_t popcount<boost::ulong_long_type>(boost::ulong_long_type value) BOOST_NOEXCEPT
{
return static_cast<unsigned int>(__builtin_popcountll(value));
}
#endif
// overload for access by blocks
//
template <typename Iterator, typename ValueType>
inline std::size_t do_count(Iterator first, std::size_t length, ValueType,
value_to_type<access_by_blocks>*)
{
std::size_t num1 = 0u, num2 = 0u;
while (length >= 2u) {
num1 += popcount<ValueType>(*first);
++first;
num2 += popcount<ValueType>(*first);
++first;
length -= 2u;
}
if (length > 0u)
num1 += popcount<ValueType>(*first);
return num1 + num2;
}
// overload for access by bytes
//
template <typename Iterator>
inline std::size_t do_count(Iterator first, std::size_t length,
int /*dummy param*/,
value_to_type<access_by_bytes>*)
{
if (length > 0u) {
const byte_type* p = object_representation(&*first);
length *= sizeof(*first);
return do_count(p, length, static_cast<byte_type>(0u),
static_cast< value_to_type<access_by_blocks>* >(0));
}
return 0u;
}
// -------------------------------------------------------
// Some library implementations simply return a dummy
// value such as
//
// size_type(-1) / sizeof(T)
//
// from vector<>::max_size. This tries to get more
// meaningful info.
//
template <typename T>
inline typename T::size_type vector_max_size_workaround(const T & v)
BOOST_NOEXCEPT
{
typedef typename T::allocator_type allocator_type;
const allocator_type& alloc = v.get_allocator();
typename boost::allocator_size_type<allocator_type>::type alloc_max =
boost::allocator_max_size(alloc);
const typename T::size_type container_max = v.max_size();
return alloc_max < container_max ? alloc_max : container_max;
}
// for static_asserts
template <typename T>
struct allowed_block_type {
enum { value = T(-1) > 0 }; // ensure T has no sign
};
template <>
struct allowed_block_type<bool> {
enum { value = false };
};
template <typename T>
struct is_numeric {
enum { value = false };
};
# define BOOST_dynamic_bitset_is_numeric(x) \
template<> \
struct is_numeric< x > { \
enum { value = true }; \
} /**/
BOOST_dynamic_bitset_is_numeric(bool);
BOOST_dynamic_bitset_is_numeric(char);
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
BOOST_dynamic_bitset_is_numeric(wchar_t);
#endif
BOOST_dynamic_bitset_is_numeric(signed char);
BOOST_dynamic_bitset_is_numeric(short int);
BOOST_dynamic_bitset_is_numeric(int);
BOOST_dynamic_bitset_is_numeric(long int);
BOOST_dynamic_bitset_is_numeric(unsigned char);
BOOST_dynamic_bitset_is_numeric(unsigned short);
BOOST_dynamic_bitset_is_numeric(unsigned int);
BOOST_dynamic_bitset_is_numeric(unsigned long);
#if defined(BOOST_HAS_LONG_LONG)
BOOST_dynamic_bitset_is_numeric(::boost::long_long_type);
BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type);
#endif
// intentionally omitted
//BOOST_dynamic_bitset_is_numeric(float);
//BOOST_dynamic_bitset_is_numeric(double);
//BOOST_dynamic_bitset_is_numeric(long double);
#undef BOOST_dynamic_bitset_is_numeric
} // dynamic_bitset_impl
} // namespace detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,39 @@
// -----------------------------------------------------------
// lowest_bit.hpp
//
// Position of the lowest bit 'on'
//
// Copyright (c) 2003-2004, 2008 Gennaro Prota
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
#define BOOST_LOWEST_BIT_HPP_GP_20030301
#include "boost/integer/integer_log2.hpp"
#include "boost/assert.hpp"
namespace boost {
namespace detail {
template <typename T>
int lowest_bit(T x) {
BOOST_ASSERT(x >= 1); // PRE
// clear all bits on except the rightmost one,
// then calculate the logarithm base 2
//
return boost::integer_log2<T>( x - ( x & (x-1) ) );
}
}
}
#endif // include guard

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
// -----------------------------------------------------------
//
// Copyright (c) 2015 Seth Heeren
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
#define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
#include <boost/core/nvp.hpp>
namespace boost {
// implementation for optional zero-copy serialization support
template <typename Block, typename Allocator>
class dynamic_bitset<Block, Allocator>::serialize_impl
{
public:
template <typename Ar>
static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
ar & boost::make_nvp("m_num_bits", bs.m_num_bits)
& boost::make_nvp("m_bits", bs.m_bits);
}
};
}
// ADL hook to Boost Serialization library
namespace boost {
namespace serialization {
template <typename Ar, typename Block, typename Allocator>
void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned version) {
dynamic_bitset<Block, Allocator>::serialize_impl::serialize(ar, bs, version);
}
} // namespace serialization
} // namespace boost
#endif // include guard

View File

@@ -1,12 +1,13 @@
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
// -----------------------------------------------------------
//
// 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.
// See http://www.boost.org/libs/dynamic_bitset for documentation.
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
// Copyright (c) 2003-2004 Gennaro Prota
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#ifndef BOOST_DYNAMIC_BITSET_FWD_HPP
#define BOOST_DYNAMIC_BITSET_FWD_HPP
@@ -19,6 +20,6 @@ template <typename Block = unsigned long,
typename Allocator = std::allocator<Block> >
class dynamic_bitset;
} // namespace boost
}
#endif // BOOST_DYNAMIC_BITSET_FWD_HPP
#endif // include guard

View File

@@ -1,9 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="refresh" content="0; URL=dynamic_bitset.html">
<meta http-equiv=refresh content="0; URL=dynamic_bitset.html">
<title>Automatic redirection</title>
</head>
<body>
Automatic redirection failed, please go to
<a href="dynamic_bitset.html">dynamic_bitset.html</a>.
<a href="dynamic_bitset.html">dynamic_bitset.html</a>.&nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
</body>
</html>

17
meta/libraries.json Normal file
View File

@@ -0,0 +1,17 @@
{
"key": "dynamic_bitset",
"name": "Dynamic Bitset",
"authors": [
"Jeremy Siek",
"Chuck Allison"
],
"description": "The dynamic_bitset class represents a set of bits. It provides accesses to the value of individual bits via an operator[] and provides all of the bitwise operators that one can apply to builtin integers, such as operator& and operator<<. The number of bits in the set is specified at runtime via a parameter to the constructor of the dynamic_bitset.",
"documentation": "dynamic_bitset.html",
"category": [
"Containers"
],
"maintainers": [
"Jeremy Siek <jeremy.siek -at- gmail.com>"
],
"cxxstd": "03"
}

42
test/Jamfile.v2 Normal file
View File

@@ -0,0 +1,42 @@
#
# Copyright Vladimir Prus 2004
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
import os ;
# import rules for testing conditional on config file variables
import ../../config/checks/config : requires ;
test-suite dynamic_bitset :
[ run dyn_bitset_unit_tests1.cpp : : : <library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests2.cpp : : : <library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests3.cpp : : : <library>/boost/system//boost_system ]
[ run dyn_bitset_unit_tests4.cpp : : : <library>/boost/filesystem//boost_filesystem
<library>/boost/system//boost_system ]
[ run test_ambiguous_set.cpp ]
[ run test_lowest_bit.cpp ]
[ run test_boost_hash.cpp ]
[ run test_std_hash.cpp : : : [ requires cxx11_hdr_unordered_set ] ]
[ compile-fail test_std_hash.cpp : [ requires cxx11_hdr_unordered_set ]
<define>BOOST_DYNAMIC_BITSET_NO_STD_HASH
: test_std_hash_disabled ]
;
# due to https://github.com/boostorg/serialization/issues/108
if ! [ os.environ UBSAN_OPTIONS ]
{
test-suite dynamic_bitset_serialization :
[ run dyn_bitset_unit_tests5.cpp
: : : <define>_SCL_SECURE_NO_WARNINGS=1
<library>/boost/serialization//boost_serialization
<library>/boost/system//boost_system ]
;
}

1454
test/bitset_test.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,539 @@
// -----------------------------------------------------------
// Copyright (c) 2001 Jeremy Siek
// Copyright (c) 2003-2006 Gennaro Prota
// Copyright (c) 2014 Ahmed Charles
// Copyright (c) 2014 Riccardo Marcangelo
//
// Copyright (c) 2014 Glen Joseph Fernandes
// (glenjofe@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#include "bitset_test.hpp"
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
#include <boost/limits.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <cstdlib>
template<class T>
class minimal_allocator {
public:
typedef T value_type;
minimal_allocator() {}
template <typename U>
minimal_allocator(const minimal_allocator<U>&) {}
T* allocate(std::size_t n) {
void* p = std::malloc(sizeof(T) * n);
if (!p) {
throw std::bad_alloc();
}
return static_cast<T*>(p);
}
void deallocate(T* p, std::size_t) {
std::free(p);
}
};
#endif
#define BOOST_BITSET_TEST_COUNT(x) (sizeof(x)/sizeof(x[0]))
// 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>
void run_string_tests(const String& s
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tests)
)
{
const std::size_t len = s.length();
const std::size_t step = len/4 ? len/4 : 1;
// bitset length determined by the string-related arguments
std::size_t i;
for (i = 0; i <= len/2 ; i += step) {
Tests::from_string(s, i, len/2); // len/2 - i bits
Tests::from_string(s, i, len); // len - i bits
Tests::from_string(s, i, 1 + len*2); // len - i bits
}
// bitset length explicitly specified
for (i = 0; i <= len/2; i += step) {
for (std::size_t sz = 0; sz <= len*4; sz+= step*2) {
Tests::from_string(s, i, len/2, sz);
Tests::from_string(s, i, len, sz);
Tests::from_string(s, i, 1 + len*2, sz);
}
}
}
// tests the do-the-right-thing constructor dispatch
template <typename Tests, typename T>
void run_numeric_ctor_tests( BOOST_EXPLICIT_TEMPLATE_TYPE(Tests)
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) )
{
const int bits_per_block = Tests::bits_per_block;
const int width = std::numeric_limits<T>::digits;
const T ma = (std::numeric_limits<T>::max)();
const T mi = (std::numeric_limits<T>::min)();
int sizes[] = {
0, 7*width/10, width, 13*width/10, 3*width,
7*bits_per_block/10, bits_per_block, 13*bits_per_block/10, 3*bits_per_block
};
const T numbers[] = {
T(-1), T(-3), T(-8), T(-15), T(mi/2), T(mi),
T(0), T(1), T(3), T(8), T(15), T(ma/2), T(ma)
};
for (std::size_t s = 0; s < BOOST_BITSET_TEST_COUNT(sizes); ++s) {
for (std::size_t n = 0; n < BOOST_BITSET_TEST_COUNT(numbers); ++n ) {
// can match ctor from ulong or templated one
Tests::from_unsigned_long(sizes[s], numbers[n]);
typedef std::size_t compare_type;
const compare_type sz = sizes[s];
// this condition is to be sure that size is representable in T, so
// that for signed T's we avoid implementation-defined behavior [if ma
// is larger than what std::size_t can hold then this is ok for our
// purposes: our sizes are anyhow < max(size_t)], which in turn could
// make the first argument of from_unsigned_long() a small negative,
// later converted to a very large unsigned. Example: signed 8-bit
// char (CHAR_MAX=127), bits_per_block=64, sz = 192 > 127.
const bool fits =
sz <= static_cast<compare_type>(ma);
if (fits) {
// can match templated ctor only (so we test dispatching)
Tests::from_unsigned_long(static_cast<T>(sizes[s]), numbers[n]);
}
}
}
}
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
typedef boost::dynamic_bitset<Block> bitset_type;
typedef bitset_test<bitset_type> Tests;
const int bits_per_block = bitset_type::bits_per_block;
const std::string long_string = get_long_string();
const Block all_1s = static_cast<Block>(-1);
//=====================================================================
// Test construction from unsigned long
{
// NOTE:
//
// 1. keep this in sync with the numeric types supported
// for constructor dispatch (of course)
// 2. bool is tested separately; ugly and inelegant, but
// we don't have much time to think of a better solution
// which is likely to work on broken compilers
//
const int sizes[] = {
0, 1, 3,
7*bits_per_block/10, bits_per_block, 13*bits_per_block/10, 3*bits_per_block
};
const bool values[] = { false, true };
for (std::size_t s = 0; s < BOOST_BITSET_TEST_COUNT(sizes); ++s) {
for (std::size_t v = 0; v < BOOST_BITSET_TEST_COUNT(values); ++v) {
Tests::from_unsigned_long(sizes[s], values[v]);
Tests::from_unsigned_long(sizes[s] != 0, values[v]);
}
}
run_numeric_ctor_tests<Tests, char>();
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
run_numeric_ctor_tests<Tests, wchar_t>();
#endif
run_numeric_ctor_tests<Tests, signed char>();
run_numeric_ctor_tests<Tests, short int>();
run_numeric_ctor_tests<Tests, int>();
run_numeric_ctor_tests<Tests, long int>();
run_numeric_ctor_tests<Tests, unsigned char>();
run_numeric_ctor_tests<Tests, unsigned short>();
run_numeric_ctor_tests<Tests, unsigned int>();
run_numeric_ctor_tests<Tests, unsigned long>();
#if defined(BOOST_HAS_LONG_LONG)
run_numeric_ctor_tests<Tests, ::boost::long_long_type>();
run_numeric_ctor_tests<Tests, ::boost::ulong_long_type>();
#endif
}
//=====================================================================
// Test construction from a string
{
run_string_tests<Tests>(std::string("")); // empty string
run_string_tests<Tests>(std::string("1"));
run_string_tests<Tests>(long_string);
# if !defined BOOST_NO_STD_WSTRING
// I need to decide what to do for non "C" locales here. On
// one hand I should have better tests. On the other one
// I don't want tests for dynamic_bitset to cope with locales,
// ctype::widen, etc. (but that's what you deserve when you
// don't separate concerns at the library level)
//
run_string_tests<Tests>(
std::wstring(L"11111000000111111111010101010101010101010111111"));
# endif
// Note that these are _valid_ arguments
Tests::from_string(std::string("x11y"), 1, 2);
Tests::from_string(std::string("x11"), 1, 10);
Tests::from_string(std::string("x11"), 1, 10, 10);
}
//=====================================================================
// test from_block_range
{
std::vector<Block> blocks;
Tests::from_block_range(blocks);
}
{
std::vector<Block> blocks(3);
blocks[0] = static_cast<Block>(0);
blocks[1] = static_cast<Block>(1);
blocks[2] = all_1s;
Tests::from_block_range(blocks);
}
{
const unsigned int n = (std::numeric_limits<unsigned char>::max)();
std::vector<Block> blocks(n);
for (typename std::vector<Block>::size_type i = 0; i < n; ++i)
blocks[i] = static_cast<Block>(i);
Tests::from_block_range(blocks);
}
//=====================================================================
// test to_block_range
{
bitset_type b;
Tests::to_block_range(b);
}
{
bitset_type b(1, 1ul);
Tests::to_block_range(b);
}
{
bitset_type b(long_string);
Tests::to_block_range(b);
}
//=====================================================================
// Test copy constructor
{
boost::dynamic_bitset<Block> b;
Tests::copy_constructor(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::copy_constructor(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::copy_constructor(b);
}
//=====================================================================
// Test copy assignment operator
{
bitset_type a, b;
Tests::copy_assignment_operator(a, b);
}
{
bitset_type a(std::string("1")), b(std::string("0"));
Tests::copy_assignment_operator(a, b);
}
{
bitset_type a(long_string), b(long_string);
Tests::copy_assignment_operator(a, b);
}
{
bitset_type a;
bitset_type b(long_string); // b greater than a, a empty
Tests::copy_assignment_operator(a, b);
}
{
bitset_type a(std::string("0"));
bitset_type b(long_string); // b greater than a
Tests::copy_assignment_operator(a, b);
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
//=====================================================================
// Test move constructor
{
boost::dynamic_bitset<Block> b;
Tests::move_constructor(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::move_constructor(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::move_constructor(b);
}
//=====================================================================
// Test move assignment operator
{
bitset_type a, b;
Tests::move_assignment_operator(a, b);
}
{
bitset_type a(std::string("1")), b(std::string("0"));
Tests::move_assignment_operator(a, b);
}
{
bitset_type a(long_string), b(long_string);
Tests::move_assignment_operator(a, b);
}
{
bitset_type a;
bitset_type b(long_string); // b greater than a, a empty
Tests::move_assignment_operator(a, b);
}
{
bitset_type a(std::string("0"));
bitset_type b(long_string); // b greater than a
Tests::move_assignment_operator(a, b);
}
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
//=====================================================================
// Test swap
{
bitset_type a;
bitset_type b(std::string("1"));
Tests::swap(a, b);
Tests::swap(b, a);
Tests::swap(a, a);
}
{
bitset_type a;
bitset_type b(long_string);
Tests::swap(a, b);
Tests::swap(b, a);
}
{
bitset_type a(std::string("0"));
bitset_type b(long_string);
Tests::swap(a, b);
Tests::swap(b, a);
Tests::swap(a, a);
Tests::swap(b, b);
}
//=====================================================================
// Test resize
{
boost::dynamic_bitset<Block> a;
Tests::resize(a);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
Tests::resize(a);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
Tests::resize(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::resize(a);
}
//=====================================================================
// Test clear
{
boost::dynamic_bitset<Block> a;
Tests::clear(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::clear(a);
}
//=====================================================================
// Test pop back
{
boost::dynamic_bitset<Block> a(std::string("01"));
Tests::pop_back(a);
}
{
boost::dynamic_bitset<Block> a(std::string("10"));
Tests::pop_back(a);
}
{
const int size_to_fill_all_blocks = 4 * bits_per_block;
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 255ul);
Tests::pop_back(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::pop_back(a);
}
//=====================================================================
// Test append bit
{
boost::dynamic_bitset<Block> a;
Tests::append_bit(a);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
Tests::append_bit(a);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
Tests::append_bit(a);
}
{
const int size_to_fill_all_blocks = 4 * bits_per_block;
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 255ul);
Tests::append_bit(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::append_bit(a);
}
//=====================================================================
// Test append block
{
boost::dynamic_bitset<Block> a;
Tests::append_block(a);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
Tests::append_block(a);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
Tests::append_block(a);
}
{
const int size_to_fill_all_blocks = 4 * bits_per_block;
boost::dynamic_bitset<Block> a(size_to_fill_all_blocks, 15ul);
Tests::append_block(a);
}
{
boost::dynamic_bitset<Block> a(long_string);
Tests::append_block(a);
}
//=====================================================================
// Test append block range
{
boost::dynamic_bitset<Block> a;
std::vector<Block> blocks;
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a(std::string("0"));
std::vector<Block> blocks(3);
blocks[0] = static_cast<Block>(0);
blocks[1] = static_cast<Block>(1);
blocks[2] = all_1s;
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a(std::string("1"));
const unsigned int n = (std::numeric_limits<unsigned char>::max)();
std::vector<Block> blocks(n);
for (typename std::vector<Block>::size_type i = 0; i < n; ++i)
blocks[i] = static_cast<Block>(i);
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a;
a.append(Block(1));
a.append(Block(2));
Block x[] = {3, 4, 5};
std::size_t sz = sizeof(x) / sizeof(x[0]);
std::vector<Block> blocks(x, x + sz);
Tests::append_block_range(a, blocks);
}
{
boost::dynamic_bitset<Block> a(long_string);
std::vector<Block> blocks(3);
blocks[0] = static_cast<Block>(0);
blocks[1] = static_cast<Block>(1);
blocks[2] = all_1s;
Tests::append_block_range(a, blocks);
}
//=====================================================================
// Test bracket operator
{
boost::dynamic_bitset<Block> b1;
std::vector<bool> bitvec1;
Tests::operator_bracket(b1, bitvec1);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
std::vector<bool> bit_vec(1, true);
Tests::operator_bracket(b, bit_vec);
}
{
boost::dynamic_bitset<Block> b(long_string);
std::size_t n = long_string.size();
std::vector<bool> bit_vec(n);
for (std::size_t i = 0; i < n; ++i)
bit_vec[i] = long_string[n - 1 - i] == '0' ? 0 : 1;
Tests::operator_bracket(b, bit_vec);
}
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
{
typedef boost::dynamic_bitset<Block,
minimal_allocator<Block> > Bitset;
Bitset b;
bitset_test<Bitset>::max_size(b);
}
#endif
// Test copy-initialize with default constructor
{
boost::dynamic_bitset<Block> b[1] = {};
(void)b;
}
}
int
main()
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned int>();
run_test_cases<unsigned long>();
# ifdef BOOST_HAS_LONG_LONG
run_test_cases< ::boost::ulong_long_type>();
# endif
return boost::report_errors();
}

View File

@@ -0,0 +1,383 @@
// -----------------------------------------------------------
// Copyright (c) 2001 Jeremy Siek
// Copyright (c) 2003-2006 Gennaro Prota
// Copyright (c) 2014 Ahmed Charles
// Copyright (c) 2018 Evgeny Shulgin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#include "bitset_test.hpp"
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
#include <boost/config.hpp>
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
typedef boost::dynamic_bitset<Block> bitset_type;
typedef bitset_test< bitset_type > Tests;
const int bits_per_block = bitset_type::bits_per_block;
std::string long_string = get_long_string();
//=====================================================================
// Test operator&=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::and_assignment(lhs, rhs);
}
//=====================================================================
// Test operator |=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::or_assignment(lhs, rhs);
}
//=====================================================================
// Test operator^=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
Tests::xor_assignment(lhs, rhs);
}
//=====================================================================
// Test operator-=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
Tests::sub_assignment(lhs, rhs);
}
//=====================================================================
// Test operator<<=
{ // case pos == 0
std::size_t pos = 0;
{
boost::dynamic_bitset<Block> b;
Tests::shift_left_assignment(b, pos);
}
{
boost::dynamic_bitset<Block> b(std::string("1010"));
Tests::shift_left_assignment(b, pos);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
}
{
// test with both multiple and
// non multiple of bits_per_block
const int how_many = 10;
for (int i = 1; i <= how_many; ++i) {
std::size_t multiple = i * bits_per_block;
std::size_t non_multiple = multiple - 1;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, multiple);
Tests::shift_left_assignment(b, non_multiple);
}
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
//=====================================================================
// Test operator>>=
{ // case pos == 0
std::size_t pos = 0;
{
boost::dynamic_bitset<Block> b;
Tests::shift_right_assignment(b, pos);
}
{
boost::dynamic_bitset<Block> b(std::string("1010"));
Tests::shift_right_assignment(b, pos);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
}
{
// test with both multiple and
// non multiple of bits_per_block
const int how_many = 10;
for (int i = 1; i <= how_many; ++i) {
std::size_t multiple = i * bits_per_block;
std::size_t non_multiple = multiple - 1;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, multiple);
Tests::shift_right_assignment(b, non_multiple);
}
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
//=====================================================================
// test b.set()
{
boost::dynamic_bitset<Block> b;
Tests::set_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::set_all(b);
}
//=====================================================================
// Test b.set(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::set_one(b, 0, true);
Tests::set_one(b, 0, false);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_one(b, 0, true);
Tests::set_one(b, 0, false);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_one(b, long_string.size()/2, true);
Tests::set_one(b, long_string.size()/2, false);
}
//=====================================================================
// Test b.set(pos, len)
{ // case size is 1
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_segment(b, 0, 1, true);
Tests::set_segment(b, 0, 1, false);
}
{ // case fill the whole set
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, 0, b.size(), true);
Tests::set_segment(b, 0, b.size(), false);
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, b.size() / 4, b.size() / 2, true);
Tests::set_segment(b, b.size() / 4, b.size() / 2, false);
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block, true);
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block, false);
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, 1, b.size() - 2, true);
Tests::set_segment(b, 1, b.size() - 2, false);
}
{ // case pos = 3, len = 7
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, 3, 7, true);
Tests::set_segment(b, 3, 7, false);
}
//=====================================================================
// Test b.reset()
{
boost::dynamic_bitset<Block> b;
Tests::reset_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_all(b);
}
//=====================================================================
// Test b.reset(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::reset_one(b, 0);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_one(b, 0);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_one(b, long_string.size()/2);
}
//=====================================================================
// Test b.reset(pos, len)
{ // case size is 1
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_segment(b, 0, 1);
}
{ // case fill the whole set
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, 0, b.size());
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, b.size() / 4, b.size() / 2);
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, 1, b.size() - 2);
}
{ // case pos = 3, len = 7
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, 3, 7);
}
//=====================================================================
// Test ~b
{
boost::dynamic_bitset<Block> b;
Tests::operator_flip(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::operator_flip(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::operator_flip(b);
}
//=====================================================================
// Test b.flip()
{
boost::dynamic_bitset<Block> b;
Tests::flip_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::flip_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_all(b);
}
//=====================================================================
// Test b.flip(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::flip_one(b, 0);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::flip_one(b, 0);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_one(b, long_string.size()/2);
}
//=====================================================================
// Test b.flip(pos, len)
{ // case size is 1
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::flip_segment(b, 0, 1);
}
{ // case fill the whole set
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, 0, b.size());
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, b.size() / 4, b.size() / 2);
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, 1, b.size() - 2);
}
{ // case pos = 3, len = 7
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, 3, 7);
}
}
int
main()
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned int>();
run_test_cases<unsigned long>();
# ifdef BOOST_HAS_LONG_LONG
run_test_cases< ::boost::ulong_long_type>();
# endif
return boost::report_errors();
}

View File

@@ -1,30 +1,47 @@
// (C) Copyright Jeremy Siek 2001.
// 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.
#include <iostream>
#include <fstream>
#include <cmath> // for pow
#include <boost/dynamic_bitset.hpp>
#include <boost/test/test_tools.hpp>
// -----------------------------------------------------------
// Copyright (c) 2001 Jeremy Siek
// Copyright (c) 2003-2006 Gennaro Prota
// Copyright (c) 2014 Ahmed Charles
// Copyright (c) 2014 Riccardo Marcangelo
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#include <assert.h>
#include "bitset_test.hpp"
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
#include <boost/limits.hpp>
#include <boost/config.hpp>
template <typename Block>
void run_test_cases()
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
typedef bitset_test< boost::dynamic_bitset<Block> > Tests;
// a bunch of typedefs which will be handy later on
typedef boost::dynamic_bitset<Block> bitset_type;
typedef bitset_test<bitset_type> Tests;
// typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
std::string long_string(101, '0');
for (std::size_t i = 0; i < long_string.size(); ++i)
long_string[i] = '0' + (i % 2);
std::size_t ul_size = CHAR_BIT * sizeof(unsigned long);
std::string long_string = get_long_string();
std::size_t ul_width = std::numeric_limits<unsigned long>::digits;
//=====================================================================
// Test b.empty()
{
bitset_type b;
Tests::empty(b);
}
{
bitset_type b(1, 1ul);
Tests::empty(b);
}
{
bitset_type b(bitset_type::bits_per_block
+ bitset_type::bits_per_block/2, 15ul);
Tests::empty(b);
}
//=====================================================================
// Test b.to_long()
{
@@ -32,7 +49,21 @@ void run_test_cases()
Tests::to_ulong(b);
}
{
std::string ul_str(ul_size, '1');
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::to_ulong(b);
}
{
boost::dynamic_bitset<Block> b(bitset_type::bits_per_block,
static_cast<unsigned long>(-1));
Tests::to_ulong(b);
}
{
std::string str(ul_width - 1, '1');
boost::dynamic_bitset<Block> b(str);
Tests::to_ulong(b);
}
{
std::string ul_str(ul_width, '1');
boost::dynamic_bitset<Block> b(ul_str);
Tests::to_ulong(b);
}
@@ -64,6 +95,14 @@ void run_test_cases()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::count(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::count(b);
}
{
boost::dynamic_bitset<Block> b(8, 255ul);
Tests::count(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::count(b);
@@ -83,32 +122,103 @@ void run_test_cases()
Tests::size(b);
}
//=====================================================================
// Test b.capacity()
{
boost::dynamic_bitset<Block> b;
Tests::capacity_test_one(b);
}
{
boost::dynamic_bitset<Block> b(100);
Tests::capacity_test_two(b);
}
//=====================================================================
// Test b.reserve()
{
boost::dynamic_bitset<Block> b;
Tests::reserve_test_one(b);
}
{
boost::dynamic_bitset<Block> b(100);
Tests::reserve_test_two(b);
}
//=====================================================================
// Test b.shrink_to_fit()
{
boost::dynamic_bitset<Block> b;
Tests::shrink_to_fit_test_one(b);
}
{
boost::dynamic_bitset<Block> b(100);
Tests::shrink_to_fit_test_two(b);
}
//=====================================================================
// Test b.all()
{
boost::dynamic_bitset<Block> b;
Tests::all(b);
Tests::all(~b);
Tests::all(b.set());
Tests::all(b.reset());
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::all(b);
Tests::all(~b);
Tests::all(b.set());
Tests::all(b.reset());
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::all(b);
Tests::all(~b);
Tests::all(b.set());
Tests::all(b.reset());
}
//=====================================================================
// Test b.any()
{
boost::dynamic_bitset<Block> b;
Tests::any(b);
Tests::any(~b);
Tests::any(b.set());
Tests::any(b.reset());
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::any(b);
Tests::any(~b);
Tests::any(b.set());
Tests::any(b.reset());
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::any(b);
Tests::any(~b);
Tests::any(b.set());
Tests::any(b.reset());
}
//=====================================================================
// Test b.none()
{
boost::dynamic_bitset<Block> b;
Tests::none(b);
Tests::none(~b);
Tests::none(b.set());
Tests::none(b.reset());
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::none(b);
Tests::none(~b);
Tests::none(b.set());
Tests::none(b.reset());
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::none(b);
Tests::none(~b);
Tests::none(b.set());
Tests::none(b.reset());
}
//=====================================================================
// Test a.is_subset_of(b)
@@ -167,6 +277,132 @@ void run_test_cases()
Tests::proper_subset(a, b);
}
//=====================================================================
// Test intersects
{
bitset_type a; // empty
bitset_type b;
Tests::intersects(a, b);
}
{
bitset_type a;
bitset_type b(5, 8ul);
Tests::intersects(a, b);
}
{
bitset_type a(8, 0ul);
bitset_type b(15, 0ul);
b[9] = 1;
Tests::intersects(a, b);
}
{
bitset_type a(15, 0ul);
bitset_type b(22, 0ul);
a[14] = b[14] = 1;
Tests::intersects(a, b);
}
//=====================================================================
// Test find_first
{
// empty bitset
bitset_type b;
Tests::find_first(b);
}
{
// bitset of size 1
bitset_type b(1, 1ul);
Tests::find_first(b);
}
{
// all-0s bitset
bitset_type b(4 * bitset_type::bits_per_block, 0ul);
Tests::find_first(b);
}
{
// first bit on
bitset_type b(1, 1ul);
Tests::find_first(b);
}
{
// last bit on
bitset_type b(4 * bitset_type::bits_per_block - 1, 0ul);
b.set(b.size() - 1);
Tests::find_first(b);
}
//=====================================================================
// Test find_next
{
// empty bitset
bitset_type b;
// check
Tests::find_next(b, 0);
Tests::find_next(b, 1);
Tests::find_next(b, 200);
Tests::find_next(b, b.npos);
}
{
// bitset of size 1 (find_next can never find)
bitset_type b(1, 1ul);
// check
Tests::find_next(b, 0);
Tests::find_next(b, 1);
Tests::find_next(b, 200);
Tests::find_next(b, b.npos);
}
{
// all-1s bitset
bitset_type b(16 * bitset_type::bits_per_block);
b.set();
// check
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) {
Tests::find_next(b, i);
}
Tests::find_next(b, b.npos);
}
{
// a bitset with 1s at block boundary only
const int num_blocks = 32;
const int block_width = bitset_type::bits_per_block;
bitset_type b(num_blocks * block_width);
typename bitset_type::size_type i = block_width - 1;
for ( ; i < b.size(); i += block_width) {
b.set(i);
typename bitset_type::size_type first_in_block = i - (block_width - 1);
b.set(first_in_block);
}
// check
const typename bitset_type::size_type larger_than_size = 5 + b.size();
for (i = 0; i <= larger_than_size; ++i) {
Tests::find_next(b, i);
}
Tests::find_next(b, b.npos);
}
{
// bitset with alternate 1s and 0s
const typename bitset_type::size_type sz = 1000;
bitset_type b(sz);
typename bitset_type::size_type i = 0;
for ( ; i < sz; ++i) {
b[i] = (i%2 == 0);
}
// check
const typename bitset_type::size_type larger_than_size = 5 + b.size();
for (i = 0; i <= larger_than_size; ++i) {
Tests::find_next(b, i);
}
Tests::find_next(b, b.npos);
}
//=====================================================================
// Test operator==
{
boost::dynamic_bitset<Block> a, b;
@@ -236,6 +472,18 @@ void run_test_cases()
boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
Tests::operator_less_than(a, b);
}
{
boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("11"));
Tests::operator_less_than(a, b);
}
{
boost::dynamic_bitset<Block> a(std::string("101")), b(std::string("11"));
Tests::operator_less_than(a, b);
}
{
boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("111"));
Tests::operator_less_than(a, b);
}
{
boost::dynamic_bitset<Block> a(long_string), b(long_string);
Tests::operator_less_than(a, b);
@@ -250,7 +498,7 @@ void run_test_cases()
b[long_string.size()/2].flip();
Tests::operator_less_than(a, b);
}
// check for consistency with ulong behaviour
// check for consistency with ulong behaviour when the sizes are equal
{
boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
assert(a < b);
@@ -263,6 +511,31 @@ void run_test_cases()
boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
assert(!(a < b));
}
// when the sizes are not equal lexicographic compare does not necessarily correspond to ulong behavior
{
boost::dynamic_bitset<Block> a(4, 4ul), b(3, 5ul);
assert(a < b);
}
{
boost::dynamic_bitset<Block> a(3, 4ul), b(4, 5ul);
assert(!(a < b));
}
{
boost::dynamic_bitset<Block> a(4, 4ul), b(3, 4ul);
assert(a < b);
}
{
boost::dynamic_bitset<Block> a(3, 4ul), b(4, 4ul);
assert(!(a < b));
}
{
boost::dynamic_bitset<Block> a(4, 5ul), b(3, 4ul);
assert(a < b);
}
{
boost::dynamic_bitset<Block> a(3, 5ul), b(4, 4ul);
assert(!(a < b));
}
//=====================================================================
// Test operator<=
{
@@ -387,7 +660,7 @@ void run_test_cases()
assert(a >= b);
}
//=====================================================================
// Test b.test(pos)
// Test b.test(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::test_bit(b, 0);
@@ -401,7 +674,24 @@ void run_test_cases()
Tests::test_bit(b, long_string.size()/2);
}
//=====================================================================
// Test b << pos
// Test b.test_set(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::test_set_bit(b, 0, true);
Tests::test_set_bit(b, 0, false);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::test_set_bit(b, 0, true);
Tests::test_set_bit(b, 0, false);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::test_set_bit(b, long_string.size() / 2, true);
Tests::test_set_bit(b, long_string.size() / 2, false);
}
//=====================================================================
// Test b << pos
{ // case pos == 0
std::size_t pos = 0;
boost::dynamic_bitset<Block> b(std::string("1010"));
@@ -418,7 +708,7 @@ void run_test_cases()
Tests::operator_shift_left(b, pos);
}
//=====================================================================
// Test b >> pos
// Test b >> pos
{ // case pos == 0
std::size_t pos = 0;
boost::dynamic_bitset<Block> b(std::string("1010"));
@@ -506,30 +796,19 @@ void run_test_cases()
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::operator_sub(lhs, rhs);
}
//=====================================================================
// Test stream operator<< and operator>>
{
boost::dynamic_bitset<Block> b;
boost::dynamic_bitset<Block> x(b.size());
Tests::stream_read_write(b, x);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
boost::dynamic_bitset<Block> x(b.size());
Tests::stream_read_write(b, x);
}
{
boost::dynamic_bitset<Block> b(long_string);
boost::dynamic_bitset<Block> x(b.size());
Tests::stream_read_write(b, x);
}
}
int
test_main(int, char*[])
{
main()
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned int>();
run_test_cases<unsigned long>();
return EXIT_SUCCESS;
# ifdef BOOST_HAS_LONG_LONG
run_test_cases< ::boost::ulong_long_type>();
# endif
return boost::report_errors();
}

View File

@@ -0,0 +1,338 @@
// -----------------------------------------------------------
// Copyright (c) 2001 Jeremy Siek
// Copyright (c) 2003-2006 Gennaro Prota
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#include <fstream>
#include <string>
#include <cstddef> // for std::size_t
#include <stdexcept> // for std::logic_error
#include <assert.h>
#include <boost/config.hpp>
#if !defined (BOOST_NO_STRINGSTREAM)
# include <sstream>
#endif
#include "bitset_test.hpp"
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
#include <boost/config/workaround.hpp>
// Codewarrior 8.3 for Win fails without this.
// Thanks Howard Hinnant ;)
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
# pragma parse_func_templ off
#endif
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
#endif
#if !defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
std::wstring widen_string( const std::string & str,
const std::locale & loc = std::locale() )
{
std::wstring result;
const std::string::size_type len = str.length();
if(len != 0) {
typedef std::ctype<wchar_t> ct_type;
typedef std::wstring::traits_type tr_type;
const ct_type & ct = BOOST_USE_FACET(ct_type, loc);
result.resize(len);
for (std::size_t i = 0; i < len; ++i)
tr_type::assign(result[i], ct.widen(str[i]));
}
return result;
}
#endif
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
typedef boost::dynamic_bitset<Block> bitset_type;
typedef bitset_test<bitset_type> Tests;
//=====================================================================
// Test stream operator<<
{
// The test "variables" are: the stream type and its state, the
// exception mask, the width, the fill char and the padding side (left/right)
std::ios::iostate masks[] = {
std::ios::goodbit,
std::ios::eofbit,
std::ios::failbit,
std::ios::eofbit | std::ios::failbit
};
static std::string strings[] = {
std::string(""),
std::string("0"),
std::string("1"),
std::string("11100"),
get_long_string()
};
char fill_chars[] = { '*', 'x', ' ' };
std::size_t num_masks = sizeof(masks) / sizeof(masks[0]);
std::size_t num_strings = sizeof(strings) / sizeof(strings[0]);
std::size_t num_chars = sizeof(fill_chars) / sizeof(fill_chars[0]);
std::fstream not_good_stream("dynamic_bitset_tests - this file shouldn't exist",
std::ios::in);
for (std::size_t mi = 0; mi < num_masks; ++mi) {
for (std::size_t si = 0; si < num_strings; ++si) {
std::streamsize slen = (std::streamsize)(strings[si].length());
assert( (std::numeric_limits<std::streamsize>::max)()
>=(std::streamsize)(1+slen*2) );
for (std::size_t ci = 0; ci < num_chars; ++ci) {
// note how "negative widths" are tested too
const std::streamsize widths[] = { -1 - slen/2, 0, slen/2, 1 + slen*2 };
std::size_t num_widths = sizeof(widths) / sizeof(widths[0]);
for (std::size_t wi = 0; wi < num_widths; ++wi) {
std::streamsize w = widths[wi];
{
// test 0 - stream !good()
if(not_good_stream.good())
throw std::logic_error("Error in operator << tests"
" - please, double check");
bitset_type b(strings[si]);
not_good_stream.width(w);
not_good_stream.fill(fill_chars[ci]);
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
Tests::stream_inserter(b, not_good_stream, "<unused_string>");
}
{
// test 1a - file stream
scoped_temp_file stf;
bitset_type b(strings[si]);
std::ofstream file(stf.path().string().c_str(), std::ios::trunc);
file.width(w);
file.fill(fill_chars[ci]);
file.exceptions(masks[mi]);
Tests::stream_inserter(b, file, stf.path().string().c_str());
}
{
//NOTE: there are NO string stream tests
}
#if !defined (BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS)
{
// test 1b - wide file stream
scoped_temp_file stf;
bitset_type b(strings[si]);
std::wofstream file(stf.path().string().c_str());
file.width(w);
file.fill(fill_chars[ci]);
file.exceptions(masks[mi]);
Tests::stream_inserter(b, file, stf.path().string().c_str());
}
#endif
}
}
}
} // for (; mi..)
}
//=====================================================================
// Test stream operator>>
{
// The test "variables" are: the stream type, the exception mask,
// the actual contents (and/or state) of the stream, and width.
//
// With few exceptions, each test case consists of writing a different
// assortment of digits and "whitespaces" to a text stream and then checking
// that what was written gets read back unchanged. That's NOT guaranteed by
// the standard, unless the assortment always ends with a '\n' and satisfies
// other conditions (see C99, 7.19.2/2), however it works in practice and is
// a good "real life" test. Some characters, such as '\v' and '\f', are not
// used exactly because they are the ones which will most likely give problems
// on some systems (for instance '\f' could actually be written as a sequence
// of new-lines, and we could never be able to read it back)
//
// Note how the bitset object is not initially empty. That helps checking
// that it isn't erroneously clear()ed by operator>>.
std::ios::iostate masks[] = {
std::ios::goodbit,
std::ios::eofbit,
std::ios::failbit,
std::ios::eofbit | std::ios::failbit
};
const std::string spaces = "\t\n "; //"\t\n\v\f ";
const std::string long_string = get_long_string();
/*const*/ static std::string strings[] = {
// NOTE: "const" gives the usual problems with Borland
// (in Tests::stream_extractor instantiation)
#if !(defined BOOST_BORLANDC \
&& BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)))
// Borland 5.5.1 with RW library crashes
// empty string
std::string(""),
// no bitset
spaces,
#endif
// no bitset
std::string("x"),
std::string("\t xyz"),
// bitset of size 1
std::string("0"),
std::string("1"),
std::string(" 0 "),
std::string(" 1 "),
spaces + "1",
"1" + spaces,
spaces + "1" + spaces,
std::string(" x1x "),
std::string(" 1x "),
// long bitset
long_string,
" " + long_string + " xyz",
spaces + long_string,
spaces + long_string + spaces
};
//-----------------------------------------------------
std::stringstream not_good_stream;
not_good_stream << "test";
std::string sink;
not_good_stream >> sink; // now the stream should be in eof state
const std::size_t num_masks = sizeof(masks) / sizeof(masks[0]);
const std::size_t num_strings = sizeof(strings) / sizeof(strings[0]);
for (std::size_t mi = 0; mi < num_masks; ++mi) {
for (std::size_t si = 0; si < num_strings; ++si) {
const std::streamsize slen = (std::streamsize)(strings[si].length());
assert((std::numeric_limits<std::streamsize>::max)() >= (std::streamsize)(1+slen*2));
std::streamsize widths[] = { -1, 0, slen/2, slen, 1 + slen*2 };
std::size_t num_widths = sizeof(widths) / sizeof(widths[0]);
for(std::size_t wi = 0; wi < num_widths; ++wi) {
const std::streamsize w = widths[wi];
// test 0 - !good() stream
{
if(not_good_stream.good())
throw std::logic_error("Error in operator >> tests"
" - please, double check");
bitset_type b(1, 15ul); // note: b is not empty
not_good_stream.width(w);
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
std::string irrelevant;
Tests::stream_extractor(b, not_good_stream, irrelevant);
}
// test 1a - (narrow) file stream
{
scoped_temp_file stf;
bitset_type b(1, 255ul);
{
std::ofstream f(stf.path().string().c_str());
f << strings[si];
}
std::ifstream f(stf.path().string().c_str());
f.width(w);
f.exceptions(masks[mi]);
Tests::stream_extractor(b, f, strings[si]);
}
#if !defined(BOOST_NO_STRINGSTREAM)
// test 2a - stringstream
{
bitset_type b(1, 255ul);
std::istringstream stream(strings[si]);
stream.width(w);
stream.exceptions(masks[mi]);
Tests::stream_extractor(b, stream, strings[si]);
}
#endif
#if !defined(BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS)
// test 1b - wchar_t file stream
{
scoped_temp_file stf;
std::wstring wstr = widen_string(strings[si]);
bitset_type b(1, 255ul);
{
std::basic_ofstream<wchar_t> of(stf.path().string().c_str());
of << wstr;
}
std::basic_ifstream<wchar_t> f(stf.path().string().c_str());
f.width(w);
f.exceptions(masks[mi]);
Tests::stream_extractor(b, f, wstr);
}
// test 2b - wstringstream
{
bitset_type b(1, 255ul);
std::wstring wstr = widen_string(strings[si]);
std::wistringstream wstream(wstr);
wstream.width(w);
wstream.exceptions(masks[mi]);
Tests::stream_extractor(b, wstream, wstr);
}
#endif // BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
}
}
} // for ( mi = 0; ...)
}
//=====================================================================
// << Any other tests go here >>
// .....
}
int
main()
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned int>();
run_test_cases<unsigned long>();
# ifdef BOOST_HAS_LONG_LONG
run_test_cases< ::boost::ulong_long_type>();
# endif
return boost::report_errors();
}

View File

@@ -0,0 +1,112 @@
// -----------------------------------------------------------
// Copyright (c) 2001 Jeremy Siek
// Copyright (c) 2003-2006 Gennaro Prota
//
// Copyright (c) 2015 Seth Heeren
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// -----------------------------------------------------------
#include "boost/config.hpp"
#if !defined (BOOST_NO_STRINGSTREAM)
# include <sstream>
#endif
#include "bitset_test.hpp"
#include <boost/dynamic_bitset/serialization.hpp>
#include <boost/config/workaround.hpp>
// Codewarrior 8.3 for Win fails without this.
// Thanks Howard Hinnant ;)
#if defined __MWERKS__ && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
# pragma parse_func_templ off
#endif
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
#endif
#include <boost/serialization/vector.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <sstream>
namespace {
template <typename Block>
struct SerializableType {
boost::dynamic_bitset<Block> x;
private:
friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int) {
ar & BOOST_SERIALIZATION_NVP(x);
}
};
template <typename Block, typename IArchive, typename OArchive>
void test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
SerializableType<Block> a;
for (int i=0; i<128; ++i)
a.x.resize(11*i, i%2);
#if !defined (BOOST_NO_STRINGSTREAM)
std::stringstream ss;
// test serialization
{
OArchive oa(ss);
oa << BOOST_SERIALIZATION_NVP(a);
}
// test de-serialization
{
IArchive ia(ss);
SerializableType<Block> b;
ia >> BOOST_SERIALIZATION_NVP(b);
assert(a.x == b.x);
}
#else
# error "TODO implement file-based test path?"
#endif
}
template <typename Block>
void test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
test_serialization<Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive>();
}
template <typename Block>
void test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
test_serialization<Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive>();
}
}
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
test_binary_archive<Block>();
test_xml_archive<Block>();
}
int main()
{
run_test_cases<unsigned char>();
run_test_cases<unsigned short>();
run_test_cases<unsigned int>();
run_test_cases<unsigned long>();
# ifdef BOOST_HAS_LONG_LONG
run_test_cases< ::boost::ulong_long_type>();
# endif
return boost::report_errors();
}

View File

@@ -0,0 +1,30 @@
//
// Copyright (C) 2018 James E. King III
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/dynamic_bitset.hpp>
#include <boost/core/lightweight_test.hpp>
int main(int, char*[])
{
boost::dynamic_bitset<> x(5); // all 0's by default
x.set(1, 2);
x.set(3, 1, true);
x.set(2, 1, false);
BOOST_TEST(!x.test(0));
BOOST_TEST( x.test(1));
BOOST_TEST(!x.test(2));
BOOST_TEST( x.test(3));
BOOST_TEST(!x.test(4));
return boost::report_errors();
}

47
test/test_boost_hash.cpp Normal file
View File

@@ -0,0 +1,47 @@
//
// Copyright (C) 2019 James E. King III
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/config.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/core/lightweight_test.hpp>
#include <set>
int main(int, char*[])
{
typedef boost::dynamic_bitset<unsigned long> bitset_type;
const std::string long_string =
"01001110101110110101011010000000000011110101101111111111";
const std::string long_string_prime_begin =
"11001110101110110101011010000000000011110101101111111111";
const std::string long_string_prime_end =
"01001110101110110101011010000000000011110101101111111110";
bitset_type zeroes(long_string.size(), 0);
bitset_type stuff (long_string);
bitset_type stupb (long_string_prime_begin);
bitset_type stupe (long_string_prime_end);
bitset_type ones (long_string.size(), 1);
boost::hash<bitset_type> bitset_hasher;
std::set<std::size_t> results;
results.insert(bitset_hasher(zeroes));
results.insert(bitset_hasher(stuff));
results.insert(bitset_hasher(stupb));
results.insert(bitset_hasher(stupe));
results.insert(bitset_hasher(ones));
// if any hash is identical to another there will be less than 5
BOOST_TEST_EQ(results.size(), 5);
return boost::report_errors();
}

28
test/test_lowest_bit.cpp Normal file
View File

@@ -0,0 +1,28 @@
//
// Copyright (C) 2018 James E. King III
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/cstdint.hpp>
#include <boost/dynamic_bitset/detail/lowest_bit.hpp>
#include <boost/core/lightweight_test.hpp>
int main(int, char*[])
{
for (boost::int32_t i = 1; i < 32; ++i) {
BOOST_TEST_EQ(i, boost::detail::lowest_bit(1u << i));
}
BOOST_TEST_EQ(2, boost::detail::lowest_bit(123456788));
BOOST_TEST_EQ(30, boost::detail::lowest_bit(static_cast<boost::int64_t>(1507208177123328)));
return boost::report_errors();
}

39
test/test_std_hash.cpp Normal file
View File

@@ -0,0 +1,39 @@
//
// Copyright (C) 2019 James E. King III
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/config.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <functional>
#include <unordered_set>
int main(int, char*[])
{
typedef boost::dynamic_bitset<unsigned long> bitset_type;
const std::string long_string =
"01001110101110110101011010000000000011110101101111111111";
bitset_type zeroes(long_string.size(), 0);
bitset_type stuff (long_string);
bitset_type ones (long_string.size(), 1);
std::unordered_set<bitset_type> bitsets;
bitsets.insert(zeroes);
bitsets.insert(stuff);
bitsets.insert(ones);
BOOST_TEST_EQ(bitsets.size(), 3);
return boost::report_errors();
}

View File

@@ -1,101 +0,0 @@
// boost::dynamic_bitset timing test ---------------------------------------//
// (C) Copyright Gennaro Prota 2002.
// 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.
//****************************************************************************//
// WARNING:
// ~~~~~~~
// This is a preliminary version, for internal testing only.
// For now, it stresses the count() function only and has been executed
// on a very few platforms. The previous version, for instance, was never
// executed on MSVC (boost::bitset<> didn't even compile with it) and at
// the first try it crashed at startup, presumably because of a linker bug.
// To cope with it, the definition of
//
// template <typename T> void timing_test()
//
// has been moved before the definition of main()
//
// LAST MODIFIED: 2 Aug 2002
//****************************************************************************//
#include <iostream>
#include <typeinfo>
#include <iomanip>
#include "boost/timer.hpp"
#include "boost/dynamic_bitset.hpp"
#include "boost/cstdlib.hpp"
void prologue()
{
std::cout << "Compiler: " << BOOST_COMPILER << '\n';
std::cout << "STLPort used? ";
# ifdef _STLPORT_VERSION
std::cout << "Yes, v." << std::hex << _STLPORT_VERSION;
# else
std::cout << "No.";
# endif
std::cout << std::dec << "\n";
}
template <typename T>
void timing_test()
{
const unsigned long num = 10000;
std::size_t dummy = 0; // this is printed at the end of the test,
// to prevent the optimizer to eliminate
// the call to count() in the loop below :-)
std::cout << "\n\nTimings for dynamic_bitset<" << typeid(T).name()
<< "> [" << num << " iterations]\n";
std::cout << "--------------------------------------------------\n";
{ // new implementation
boost::timer time;
for (unsigned long i=0; i<num; ++i) {
boost::dynamic_bitset<T> bs(std::size_t(5000), i);
dummy += bs.count();
}
const double elaps = time.elapsed();
std::cout << "Elapsed: " << elaps << '\n';
}
std::cout << "(total count: " << dummy << ")\n";
}
int main()
{
prologue();
timing_test<unsigned short>();
timing_test<unsigned int>();
timing_test<unsigned long>();
# ifdef BOOST_HAS_LONG_LONG
timing_test<unsigned long long>();
# endif
return boost::exit_success;
}