1
0
forked from boostorg/core

Compare commits

...

452 Commits

Author SHA1 Message Date
Andrey Semashev
f4b3d5dba6 Merge pull request #93 from sdarwin/feature/gha_fix
Small GHA fix, create destination dir
2021-07-27 23:53:44 +03:00
sdarwin
9f0b97c80b Small GHA fix, create destination dir 2021-07-27 13:35:51 -05:00
Andrey Semashev
ce53cc1f8f Changed quotes in format() expression. 2021-07-02 20:38:22 +03:00
Andrey Semashev
8fad14b804 Use gcc-7 toolchain for clang-8 CI job. 2021-07-02 20:35:45 +03:00
Andrey Semashev
24b6d89e7f Changed CI concurrency group format.
This should fix CI and also make concurrncy work for PRs.
2021-07-02 20:34:19 +03:00
Andrey Semashev
ffd79a28e1 Added concurrency settings to auto-cancel redundant CI jobs. 2021-07-02 20:03:50 +03:00
Andrey Semashev
aa97e418f2 Increased git fetch jobs on Windows and use CPU count for build jobs. 2021-07-02 19:33:06 +03:00
Andrey Semashev
f563d50d42 Use more git fetch jobs to speed up clones. 2021-07-02 19:19:48 +03:00
Andrey Semashev
c55a20dff2 Reverted gcc package removal and instead setup a dummy gcc toolset tree.
Removing gcc and libstdc++ packages did not fix the clang-8 test failures.

Instead, setup a dummy gcc toolset tree and point clang to it to force
the compiler detect and use an older libstdc++.
2021-07-02 19:14:04 +03:00
Andrey Semashev
bc508f8b4c Remove gcc-10 for clang-8 testing.
This is another attempt to make clang-8 tests not fail in C++20 mode. Remove
gcc-10 and libstdc++-10 to prevent clang using it.

Also, use apt-get instead of apt since the former is recommended to use in
scripts. This should silence apt warnings.
2021-07-02 16:15:59 +03:00
Andrey Semashev
03c5481dd4 Moved clang-8 to Bionic and gcc-10,11 to Focal.
clang-8 jobs fail in C++20 mode since it doesn't support
std::is_constant_evaluated, which is called from libstdc++-10 that is installed
in Focal image. Moving it back to Bionic should work around the issue
as it should use an older libstdc++ version.

gcc-10 and 11 were moved to Focal just to make this configuration tested.

Also, changed 2a to 20 for compilers that support this.
2021-07-02 11:52:44 +03:00
Andrey Semashev
8e7ee90080 Merge pull request #92 from evanmiller/develop
Restore support for ancient Mac OS
2021-07-02 01:59:50 +03:00
Evan Miller
128d9314d6 Restore support for ancient Mac OS
Mac OS 10.4 and earlier lack Availability.h, causing compilation to
fail. Rearrange the macro logic to include Availability.h only if we
already think there may be support for uncaught exceptions.
2021-07-01 16:32:40 -04:00
Peter Dimov
012d96a72b Use non-const references in non-variadic branch as well 2021-06-10 10:09:46 +03:00
Peter Dimov
27d700ec01 Use non-const references in ignore_unused to avoid g++-11 warning 2021-06-10 09:54:51 +03:00
Peter Dimov
507c182f4c Revert "Initialize variables in ignore_unused_test to avoid a g++-11 warning"
This reverts commit 1a011cde56.
2021-06-10 09:40:08 +03:00
Peter Dimov
1a011cde56 Initialize variables in ignore_unused_test to avoid a g++-11 warning 2021-06-10 08:25:28 +03:00
Peter Dimov
71c3d320d5 Update ci.yml 2021-06-10 07:20:24 +03:00
Peter Dimov
b3fa7ca565 Take care of gcc-4.4 in addition to gcc-4.4.7 2021-06-10 04:58:17 +03:00
Peter Dimov
d3aa4a2f12 Update .travis.yml 2021-06-10 04:56:26 +03:00
Peter Dimov
67107dbaf9 Update ci.yml 2021-06-10 04:22:36 +03:00
Peter Dimov
0b74f0d394 Update CMakeLists.txt 2021-06-10 02:03:10 +03:00
Peter Dimov
e53393357f Update .github/workflows 2021-04-19 18:11:37 +03:00
Peter Dimov
7daee1d41b Add -DBUILD_TESTING=ON to .yml files; it's not default anymore 2021-03-19 03:53:31 +02:00
Glen Fernandes
ddbaa242a9 Update copyright comments 2021-02-16 02:14:14 -05:00
Glen Fernandes
86bff4c2d3 Revise allocator access utilities
Now supports MSVC 2013, and no workarounds use allocator_traits.
2021-02-15 22:11:41 -05:00
Peter Dimov
2e5ecbe6f6 Add test for typeid(struct X) across libraries 2021-02-11 04:43:05 +02:00
Peter Dimov
1c43651533 Test (signed char)-1 instead of 1 2021-01-20 02:40:37 +02:00
Peter Dimov
afba04cf7f Output non-printable chars as \xXY 2021-01-20 02:38:57 +02:00
Peter Dimov
0ae16756eb Add run-fail test for BOOST_TEST_NE and character types 2021-01-20 02:04:30 +02:00
Peter Dimov
2729beab83 Print char types as numeric values (C++20 deletes these ostream overloads) 2021-01-20 01:54:37 +02:00
Peter Dimov
71d60a3fb7 Fix typos in macro names 2021-01-20 01:39:09 +02:00
Peter Dimov
2642ad4562 Add test for BOOST_TEST_EQ and character types 2021-01-20 01:10:57 +02:00
Peter Dimov
f7c1f6c6ab Merge pull request #85 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 00:28:10 +02:00
Edward Diener
10eb5cdf7c [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 13:08:18 -05:00
Glen Fernandes
82a51aea40 Merge branch 'develop' into feature/update-travis 2020-12-31 13:54:01 -05:00
Glen Fernandes
5726534f6d Correct unit test for allocator_size_type 2020-12-31 11:41:04 -05:00
Peter Dimov
a13a82f8c1 Fix Travis configurations 2020-12-31 17:48:48 +02:00
Peter Dimov
cb94f76a5e Remove redundant configurations from Travis; add non-redundant ones 2020-12-30 20:58:04 +02:00
Peter Dimov
a6cab03127 Add documentation for bit.hpp 2020-12-30 20:34:34 +02:00
Peter Dimov
fa82b680cf Work around clang++ 3.3 failure 2020-12-30 19:40:52 +02:00
Peter Dimov
16e9536146 Implement boost::core::endian 2020-12-29 02:41:15 +02:00
Peter Dimov
919b98d425 Use __builtin_popcount 2020-12-29 02:06:56 +02:00
Peter Dimov
e8aa0c75b4 Use _BitScanForward 2020-12-29 02:02:33 +02:00
Peter Dimov
8bd2239b0b Use __builtin_ctz 2020-12-29 01:56:34 +02:00
Peter Dimov
c838ebc003 Use _BitScanReverse 2020-12-29 01:53:30 +02:00
Peter Dimov
aca46fae91 Use __builtin_clz 2020-12-29 01:28:59 +02:00
Peter Dimov
409c809cd8 Add popcount 2020-12-29 01:06:22 +02:00
Peter Dimov
dc8aa5eb39 Update test_bit_floor 2020-12-29 00:30:54 +02:00
Peter Dimov
26728848b4 Add bit_ceil 2020-12-29 00:29:44 +02:00
Peter Dimov
3e41929dfb Update bit_floor_test 2020-12-29 00:22:45 +02:00
Peter Dimov
579cb8f7f3 Add bit_floor_test 2020-12-29 00:06:25 +02:00
Peter Dimov
3b14a3677d Add has_single_bit_test 2020-12-28 23:59:58 +02:00
Peter Dimov
26991f0c75 Add bit_width_test 2020-12-28 23:52:39 +02:00
Peter Dimov
cc877e6b5b Add countl_zero, countl_one 2020-12-28 23:40:59 +02:00
Peter Dimov
123b567051 Add missing unsigned short tests to bit_rotate_test 2020-12-28 21:54:42 +02:00
Peter Dimov
a47eebf41a Add countr_zero, countr_one 2020-12-28 21:52:02 +02:00
Peter Dimov
045487ba96 Add boost/core/bit.hpp (bit_cast, rotl, rotr) 2020-12-28 21:12:22 +02:00
Peter Dimov
804c5b250d Add documentation for cmath.hpp 2020-12-24 01:20:32 +02:00
Peter Dimov
bee040b8cc Add fpclassify. 2020-12-24 00:58:56 +02:00
Peter Dimov
c307f86520 Add core/cmath.hpp 2020-12-24 00:19:20 +02:00
Peter Dimov
0364b64927 Compute LIBRARY from GITHUB_REPOSITORY 2020-12-23 06:47:00 +02:00
Peter Dimov
a04803b6cb Fix BOOST_BRANCH 2020-12-23 05:15:04 +02:00
Peter Dimov
88896d0805 Update ci.yml 2020-12-19 17:54:04 +02:00
Peter Dimov
bff4172486 Move windows.yml into ci.yml 2020-12-19 17:45:30 +02:00
Peter Dimov
ea0b1dc8a9 Rename posix.yml to ci.yml 2020-12-19 17:44:32 +02:00
Peter Dimov
3d6683edb5 Update maintainer e-mail 2020-12-12 01:01:07 +02:00
Peter Dimov
72089753f7 Add Doxygen annotation 2020-11-21 18:18:31 +02:00
Peter Dimov
156a016865 Add matrix.addrmd, toolset=gcc to windows.yml 2020-11-20 05:22:06 +02:00
Peter Dimov
0dcd164a12 Add .github/workflows 2020-11-20 04:23:22 +02:00
Peter Dimov
54671134ae Add implicit conversion between compatible reference wrappers (refs #83) 2020-11-19 18:57:56 +02:00
Peter Dimov
7bc2873e38 Update appveyor.yml 2020-11-14 22:02:03 +02:00
Andrey Semashev
ca4893063f Switch to from c++2a to c++20 for gcc-10 and clang-10. 2020-08-20 15:10:47 +03:00
Andrey Semashev
dcc04c5508 Added a workaround for uncaught_exceptions for older Mac OS and iOS.
libc++ disables std::uncaught_exceptions for Mac OS < 10.12 and
iOS < 10.0, even though it defines __cpp_lib_uncaught_exceptions.

Fixes https://github.com/boostorg/core/issues/80.
2020-07-20 23:13:42 +03:00
Glen Fernandes
484487f958 MSVC2017 /std:c++17 warnings in allocator access 2020-07-17 09:30:00 -04:00
Andrey Semashev
503d035b7f Added a workaround for uncaught_exceptions on AIX with xlclang++.
The compiler provides cxxabi.h header but doesn't have __cxa_get_globals,
even in the ABI library. We have to disable __cxa_get_globals-based
implementation and fall back to std::uncaught_exception.

Fixes https://github.com/boostorg/core/issues/78.
2020-07-16 20:53:09 +03:00
Peter Dimov
35a025d59b Untabify lightweight_test_with_fail 2020-06-15 21:32:50 +03:00
Peter Dimov
c6d72da515 Document BOOST_TEST_WITH 2020-06-07 01:32:19 +03:00
Peter Dimov
f96fb31850 Rename lw_predicate_name to lwt_predicate_name 2020-06-06 22:53:20 +03:00
Peter Dimov
b414be98c9 Add lightweight_test_with_fail 2020-06-06 21:54:16 +03:00
Peter Dimov
544fd495e5 Remove unnecessary includes, add const 2020-06-06 21:49:09 +03:00
Peter Dimov
e155e13084 Change lw_name_traits to lw_predicate_name 2020-06-06 21:48:16 +03:00
Bjorn Reese
6e36923915 Added BOOST_TEST_WITH macro to verify test results with custom predicate 2020-06-06 18:52:43 +02:00
Glen Fernandes
b67cce85c8 Correct spelling mistake in documentation 2020-05-28 09:20:01 -04:00
Glen Fernandes
376aa7aa31 Revise allocator_access implementation 2020-05-25 16:14:40 -04:00
Glen Fernandes
65901249d5 Workarounds for MSVC 2013 expression detection 2020-05-24 13:10:24 -04:00
Glen Fernandes
1c16d5ed87 Workaround for MSVC 2017 warning
MSVC provides deprecated members on allocator which we detect.
2020-05-24 10:48:36 -04:00
Glen Fernandes
27715ed01a Simplify alloc_construct using allocator_access 2020-05-24 02:45:11 -04:00
Glen Fernandes
9f2dbba2fc Workaround for MSVC 2015 expression SFINAE 2020-05-24 02:45:00 -04:00
Glen Fernandes
0159b6d8e5 Revise construction in allocator_access 2020-05-24 02:43:33 -04:00
Glen Fernandes
0dbd5aaadd Update empty_value constructors 2020-05-23 19:53:16 -04:00
Glen Fernandes
34373b0127 Avoid defining a macro in default_allocator 2020-05-23 15:28:10 -04:00
Glen Fernandes
6a33e879dd Simplify noinit_adaptor using allocator_access 2020-05-23 12:26:33 -04:00
Andrey Semashev
15db54983b Added a workaround for MSVC macro max. 2020-05-23 02:39:59 +03:00
Andrey Semashev
fa6e38a9aa Upgraded clang UBSan jobs to clang 10 in Travis CI. 2020-05-22 18:35:41 +03:00
Andrey Semashev
38f827e092 Added gcc 10 build jobs to Travis CI. 2020-05-22 18:33:43 +03:00
Andrey Semashev
2b102e7357 Test the standard library rather than the compiler to select the standard header for std::swap. 2020-05-21 02:04:43 +03:00
Andrey Semashev
9c33851420 Change cxxstd to 2a on clang 10 until Boost.Build is merged to master. 2020-05-08 17:17:14 +03:00
Andrey Semashev
fb593cbbc8 Merge pull request #66 from Kojoley/add-deprecation-warnings
Add deprecation warnings for headers in detail dir
2020-05-08 13:56:33 +03:00
Andrey Semashev
032ce991fb Change cxxstd to 20 on clang 10.
Since https://github.com/boostorg/build/pull/592 was merged, we can switch
back to the most recent C++20 version for clang 10.
2020-05-08 11:49:40 +03:00
Edward Diener
6444de7098 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-05-08 11:41:04 +03:00
Peter Dimov
d3a64554f4 Fix Travis 2020-05-06 15:28:12 +03:00
Andrey Semashev
a57c1e0a80 Added clang-10 jobs to Travis CI. 2020-05-05 23:17:39 +03:00
Glen Fernandes
e9ff763d79 Evaluate expression when BOOST_NO_EXCEPTIONS is defined 2020-05-02 09:34:29 -04:00
Glen Fernandes
6069fea76d Add documentation for BOOST_TEST_NO_THROW 2020-05-01 15:20:25 -04:00
Glen Fernandes
3ca745f400 Add BOOST_TEST_NO_THROW and print expression in BOOST_TEST_THROWS 2020-05-01 14:34:02 -04:00
Peter Dimov
94def8a3a6 Merge branch 'feature/lwt-pedantic' into develop 2020-04-28 04:21:59 +03:00
Peter Dimov
295b72cbc0 Disable -Waddress in lightweight_test_test.cpp 2020-04-28 02:04:29 +03:00
Glen Fernandes
eb86df4a04 Remove duplicate test run 2020-04-27 15:56:35 -04:00
Peter Dimov
0a6b8e667b Add warnings=pedantic to the rest of the lwt tests 2020-04-27 22:29:28 +03:00
Glen Fernandes
4d08e709fe Pedantic tests for default_allocator 2020-04-27 14:27:20 -04:00
Glen Fernandes
12ff209bf7 Revise max_size implementation in default_allocator 2020-04-27 14:27:12 -04:00
Peter Dimov
bb0ef6d41e Disable variadic macros warning in lightweight_test_trait.hpp 2020-04-27 19:17:48 +03:00
Peter Dimov
2dd51f248b Use warnings=pedantic for some lwt tests 2020-04-27 18:47:45 +03:00
Glen Fernandes
8fe9805792 Avoid C99 stdint macros in default_allocator 2020-04-26 19:49:01 -04:00
Glen Fernandes
6624532550 Correct spelling in documentation 2020-04-14 19:40:41 -04:00
Glen Fernandes
c31e23b362 Implement allocator access utilities 2020-04-14 14:52:30 -04:00
Glen Fernandes
690514e87c Use BOOST_INLINE_CONSTEXPR in empty_value 2020-04-05 19:55:24 -04:00
Peter Dimov
5a5d2adda0 Go back to ::quick_exit, but include the correct <stdlib.h>; on Linux and Cygwin, quick_exit is not brought into std in C++03 mode 2020-03-23 15:54:23 +02:00
Peter Dimov
10c01d0d56 Use std::quick_exit instead of ::quick_exit 2020-03-23 05:21:08 +02:00
Peter Dimov
27d8ef1286 Change BOOST_TEST to match BOOST_TEST_EQ et al, in order to avoid 'expression result unused' warning from Clang 2020-02-21 19:46:42 +02:00
Glen Fernandes
b5c2726d1b Include cstddef in pointer_traits 2020-02-17 22:13:10 -05:00
Peter Dimov
0eecbda0b1 Remove unnecessary struct 2020-02-17 05:21:20 +02:00
Peter Dimov
2a471c3417 Add test for BOOST_TEST_* macros return values 2020-02-16 20:52:59 +02:00
Peter Dimov
5ca752323f Return a bool result from the BOOST_TEST_* macros, f.ex. to allow chaining with && 2020-02-16 20:52:12 +02:00
Peter Dimov
13e9d3d4d9 Fix typo in test/Jamfile 2020-02-16 20:17:52 +02:00
Peter Dimov
f3cd812ccb Disable 'should return report_errors()' test on CMake, because CTest doesn't like abort() 2020-01-02 21:05:07 +02:00
Peter Dimov
8f2841de83 Restrict clang-3.5 to 03/11 to avoid ::gets error 2020-01-02 21:04:06 +02:00
Peter Dimov
bf5778403e Update tools/cmake 2020-01-02 20:30:03 +02:00
Peter Dimov
fc285464aa Update Travis to Xenial 2020-01-02 20:23:07 +02:00
Peter Dimov
750625272f Add CMake tests 2020-01-02 20:00:11 +02:00
Peter Dimov
bda2b9b4b1 Disable _CrtDbgReport message boxes, displayed on debug iterator violations 2020-01-01 17:17:43 +02:00
Glen Fernandes
ac4c781cac Include lightweight_test from core and workaround from config 2020-01-01 09:02:46 -05:00
Peter Dimov
72ca0d8664 Add CMake install support 2019-12-28 18:47:11 +02:00
Glen Fernandes
253b07f630 Add empty_init constant to documentation 2019-12-15 12:46:55 -05:00
Peter Dimov
e59271fdc2 Check BOOST_MSVC in addition to __cplusplus, because msvc doesn't define __cplusplus correctly 2019-12-02 02:15:55 +02:00
Nikita Kniazev
bc82adcd0b Remove implementation specific handling 2019-12-02 01:11:04 +03:00
Nikita Kniazev
868cb07578 Try to include std::swap from the most lightweight header
Based on Boost.Move idea
2019-12-01 17:28:07 +03:00
Andrey Semashev
38f71361fb Add a convenience instance of empty_init_t (#65)
* Added a convenience instance of empty_init_t.

Closes https://github.com/boostorg/core/issues/63.
2019-11-23 21:00:59 -05:00
Peter Dimov
6d62fb5f5e Remove clang-win 32 bit, because it fails to link with 'unable to load mspdbcore.dll (error code: 126)' 2019-11-23 21:52:53 +02:00
Peter Dimov
0d71f42365 Separate Appveyor Clang configurations 2019-11-23 21:11:26 +02:00
Nikita Kniazev
080e8581d5 Add deprecation warnings for headers in detail dir 2019-11-23 16:53:32 +03:00
Peter Dimov
259587da7f Add clang-9 to Travis 2019-10-11 21:34:55 +03:00
Peter Dimov
882a792856 Add 2019 to Appveyor 2019-10-11 18:50:35 +03:00
Peter Dimov
130c8f2439 Disable Wsign-compare on gcc 4.4.7 2019-10-11 17:19:01 +03:00
Peter Dimov
e38997be4d Reorder conditions to support clang-cl 2019-10-11 16:43:48 +03:00
Peter Dimov
d112d23e9d Test that BOOST_TEST_EQ doesn't emit sign-compare warnings 2019-10-11 16:02:45 +03:00
Glen Fernandes
e94af0d41a Also define make_nvp in boost::serialization 2019-10-01 08:14:07 -04:00
Glen Fernandes
ac427ad64a Define nvp inside boost::serialization and bring it into boost 2019-10-01 07:28:25 -04:00
Glen Fernandes
f2644886f5 Update section title in documentation 2019-10-01 07:28:06 -04:00
Glen Fernandes
0591b1d855 Add BOOST_NVP convenience macro 2019-09-16 02:15:53 -04:00
Glen Fernandes
7cc1047ab7 Update NVP implementation, tests, docs 2019-09-15 21:12:16 -04:00
Glen Fernandes
f52dec58c2 Add a definition for nvp_bool 2019-09-10 08:04:40 -04:00
Glen Fernandes
26497003f2 Remove save and load helpers and update documentation for NVP 2019-09-04 21:47:39 -04:00
Glen Fernandes
5fb5a3e292 Update nvp tests and documentation 2019-09-04 12:28:00 -04:00
Glen Fernandes
7b8385afc3 Implement NVP in Core for Serialization and other libraries 2019-09-04 09:58:04 -04:00
Glen Fernandes
106a7c0939 Mark throw_exception BOOST_NORETURN 2019-08-27 07:28:28 -04:00
Peter Dimov
f2ee17fa24 Update .travis.yml 2019-07-25 12:27:19 +03:00
Peter Dimov
eba08e936a Only return an 8 bit result from report_errors 2019-06-26 19:53:58 +03:00
Andrey Semashev
7e1d028958 Updated comment about QNX workaround in uncaught_exceptions.hpp. 2019-06-18 12:48:18 +03:00
Andrey Semashev
420dff80b5 Added a workaround for QNX in uncaught_exceptions.hpp.
QNX provides cxxabi.h from LLVM libc++abi, which does not declare
__cxa_get_globals but provides its implementation in the library.
To make things more fun, QNX developers commented _LIBCPPABI_VERSION
definition, which breaks detection of libc++abi in uncaught_exceptions.hpp.

There is also cxxabi.h from glibcxx that does provide __cxa_get_globals
declaration. We want to use that declaration, if possible, to avoid possible
mismatch in attributes.

This commit adds non-glibcxx cxxabi.h on QNX to the list of platforms that
need our declaration of __cxa_get_globals.

Fixes https://github.com/boostorg/core/issues/59.
2019-06-13 15:38:43 +03:00
Glen Fernandes
4f141646b5 Add overloads for non-const lvalue reference 2019-05-19 23:48:11 -04:00
Glen Fernandes
29f281fe7a Add alloc_construct overload for non-const lvalue reference 2019-05-19 21:14:23 -04:00
Glen Fernandes
c96dfcec4a Update test and documentation 2019-05-13 23:43:57 -04:00
Glen Fernandes
ca832d9384 Implement first_scalar 2019-05-13 15:04:26 -04:00
Glen Fernandes
6b65cde816 Add alloc_construct_n overload for input iterators 2019-05-11 12:50:39 -04:00
Glen Fernandes
b0df75ad1c Rename identifiers in alloc_construct documentation 2019-05-10 08:35:35 -04:00
Glen Fernandes
5ffce48fa1 Correct example in documentation 2019-05-06 22:26:46 -04:00
Glen Fernandes
cb154c3ac2 Minor documentation fixes 2019-05-04 01:41:00 -04:00
Glen Fernandes
14fb9e4433 More documentation updates 2019-05-03 21:31:00 -04:00
Glen Fernandes
a90dc39e06 Minor documentation update for noinit_adaptor 2019-05-03 19:53:56 -04:00
Glen Fernandes
8f5f7f9c42 Minor documentation update for alloc_construct 2019-05-03 18:59:04 -04:00
Glen Fernandes
612069c7e4 Move construct and destroy from Smart_Ptr to Core 2019-05-03 08:54:09 -04:00
Glen Fernandes
f3a382c017 Update order of includes in noinit_adaptor_test.cpp 2019-05-02 10:20:58 -04:00
Glen Fernandes
ce05d650dc Update documentation and conditionally include headers in noinit_adaptor.hpp 2019-05-02 07:43:55 -04:00
Glen Fernandes
836ae6917d Update vector value type in unit test 2019-04-29 02:29:00 -04:00
Glen Fernandes
a0e1100421 Add noinit_adapt() free function utility 2019-04-29 02:04:54 -04:00
Glen Fernandes
50491408b1 Implement noinit_allocator_adaptor 2019-04-28 02:10:37 -04:00
Glen Fernandes
62fff4d829 Update documentation for default_allocator 2019-04-27 19:11:45 -04:00
Glen Fernandes
151f2cf645 Support C++03 implementations that require reference and const_pointer 2019-04-27 06:15:24 -04:00
Glen Fernandes
5a549b8b22 Update max_size() implementation and tests 2019-04-25 13:05:06 -04:00
Glen Fernandes
e859d01186 Correct max_size() when PTRDIFF_MAX is less than SIZE_MAX 2019-04-25 12:11:34 -04:00
Glen Fernandes
08382d184d Suppress warnings in Quickbook variablelists 2019-04-25 11:55:03 -04:00
Glen Fernandes
69f7b0c76b Update computation of max_size 2019-04-25 11:49:36 -04:00
Glen Fernandes
b5c178ef0b Increase the size of test type 2019-04-25 09:36:08 -04:00
Glen Fernandes
ba79489ea1 Remove null check in allocate 2019-04-25 02:32:31 -04:00
Glen Fernandes
2eaed5b9e9 Merge pull request #56 from boostorg/feature/default_allocator
Implement default_allocator
2019-04-25 16:25:51 +10:00
Glen Fernandes
9c88e5cbb1 Implement default_allocator 2019-04-25 02:22:45 -04:00
Peter Dimov
006c159dbb Fix typo 2019-04-23 03:06:35 +03:00
Piotr Jawniak
c7f0fa8900 Document an emulation limitation of scoped enum (#28) 2019-04-22 17:00:26 -07:00
Peter Dimov
fb417474ae Mark detail/sp_typeinfo.hpp as deprecated 2019-04-22 17:28:31 +03:00
Peter Dimov
fc83a2e3af Fix expected failures when no rvalue references 2019-04-20 13:09:18 +03:00
Peter Dimov
e023e28369 Merge branch 'develop' of https://github.com/glenfe/boost.core into feature/lwt-print-cvref 2019-04-20 12:58:36 +03:00
Peter Dimov
b1e0735d8f Check number of failures in lightweight_test_all_with_eq, lightweight_test_all_with_fail 2019-04-20 10:11:16 +03:00
Glen Fernandes
a78c25e4ab Print type with cvref qualifiers 2019-04-20 03:04:06 -04:00
Hans Dembinski
02041f6c9f report_errors with expected failures (#51)
* Return number of failures from report_errors
2019-04-19 23:55:50 -07:00
Peter Dimov
f14a464b29 Only disable C4127 on msvc-pre-14.0 2019-04-19 23:41:26 +03:00
Peter Dimov
af7e01b8c4 Merge branch 'no_exceptions_support-conditional-expression-is-constant' of https://github.com/Kojoley/core into feature/no-exceptions-support 2019-04-19 23:33:33 +03:00
Peter Dimov
40424bf0b6 Merge branch 'develop' into feature/no-exceptions-support 2019-04-19 23:28:02 +03:00
Peter Dimov
8d4c039f34 Remove unnecessary include 2019-04-19 23:27:37 +03:00
Peter Dimov
e6aa65a002 Add clang-win to Appveyor 2019-04-19 20:14:03 +03:00
Peter Dimov
bb2e7e4c69 Add __clang__ to BOOST_NO_TYPEID comparison conditions 2019-04-19 20:13:41 +03:00
Peter Dimov
026e0aa732 Add libs/throw_exception to .yml files 2019-04-19 20:05:34 +03:00
Peter Dimov
0600b49827 Add no_exceptions_support_test 2019-04-19 17:32:05 +03:00
Andrey Semashev
d9b524d2e5 Envelop URL in quotes to avoid Boost.Build warning about unescaped special char. 2019-04-19 13:24:36 +03:00
Peter Dimov
8702664188 Switch Appveyor to 2015 image 2019-04-14 18:04:46 +03:00
Andrey Semashev
0c5cff67b6 Corrected a typo in the comment. 2019-04-13 19:19:40 +03:00
Nikita Kniazev
8ac5b5b00e no_exceptions_support: Suppress conditional expression is constant warning 2019-03-26 17:01:41 +03:00
Glen Fernandes
4ea704e80a Add use_default to Core 2019-02-22 16:51:33 -05:00
Glen Fernandes
266076f83b Update empty_value test cases 2019-02-19 02:09:54 -05:00
Peter Dimov
8ea2ac50fe Document BOOST_TEST_TRAIT_SAME 2019-02-06 18:12:25 +02:00
Peter Dimov
7f96d56eff Simplify implementation of BOOST_TEST_TRAIT_SAME 2019-02-06 04:38:27 +02:00
Peter Dimov
dcbe62c6bf Add BOOST_TEST_TRAIT_SAME 2019-02-06 02:02:40 +02:00
Peter Dimov
a8ef600c30 Remove duplicate Travis job 2019-01-28 23:16:52 +02:00
Peter Dimov
d8895bab46 Mark checked_delete as noexcept 2019-01-28 19:15:24 +02:00
Andrey Semashev
a8c870e2e7 Merge branch 'develop' 2019-01-15 13:34:33 +03:00
Peter Dimov
9db11ce554 Add more xcode configurations to Travis 2019-01-13 04:26:10 +02:00
Peter Dimov
3f3bba7869 Add test/cmake_subdir_test 2019-01-12 21:25:10 +02:00
Andrey Semashev
61b4e1a45d Use multiple jobs to checkout submodules in CI. 2019-01-12 21:24:45 +02:00
Andrey Semashev
b1949c0509 Added tools/boost_install and libs/headers manual init to CI jobs. 2019-01-12 21:24:28 +02:00
Andrey Semashev
7d70451b49 Updated the comment about __cxa_uncaught_exceptions. 2019-01-08 04:47:51 +03:00
Andrey Semashev
bf932b4908 Removed the use of __cxa_uncaught_exceptions.
Travis CI shows linking errors on Linux and OS X when __cxa_uncaught_exceptions
is used to implement uncaught_exceptions. There's probably some library missing,
which should be linked in implicitly by the compiler, or the library indeed
does not export the symbol. In any case, __cxa_get_globals-based implementation
should provide the same effect.
2019-01-08 04:17:24 +03:00
Andrey Semashev
e3629dd1c1 Added libc++abi-dev package installation, changed OS X image to xcode10.1.
This is in attempt to debug/work around strange issues in CI with cxxabi.h
provided by libc++abi-dev. The header declares __cxa_uncaught_exceptions
function, but on linking stage the function is missing. The current theory
is that the header and the libc++abi library do not match on CI machines for
some reason, and this commit tries to mitigate or verify that.
2019-01-08 00:29:53 +03:00
Andrey Semashev
dea6b04157 Added workarounds for gcc < 4.7 on Linux and OpenBSD.
Apparently, gcc < 4.7 on Linux also don't have __cxa_get_globals
declaration in cxxabi.h. Declare the function ourselves.

Also, on OpenBSD it seems there is no declaration either, and
on that platform the function implementation has no exception
specification, like on FreeBSD. Add a declaration of that platform.

Lastly, changed __cxa_get_globals and _getptd-based implementations
to avoid violating strict aliasing rules. This is still formally UB
to access structure fields like we do, but this is one less reason to
cause miscompilation or compiler warnings.
2019-01-08 00:23:09 +03:00
Andrey Semashev
9f9da9dc9b Limit __cxa_uncaught_exceptions to only since libc++abi 1002 and later. 2019-01-07 13:34:52 +03:00
Andrey Semashev
cdcc50a455 Added an implementation for uncaught_exceptions for libc++abi.
This should fix compilation errors due to missing declaration of
__cxa_get_globals when compiled against libc++ on Linux.
2019-01-07 02:14:31 +03:00
Andrey Semashev
6f3e6254e7 Only declare __cxa_get_globals on MinGW gcc < 4.7, where it's needed.
This should work around differences between the function signatures on other
platforms, like FreeBSD, for example.
2019-01-06 21:29:15 +03:00
Peter Dimov
245297ab85 Add test/cmake_subdir_test 2019-01-06 04:43:47 +02:00
Andrey Semashev
2574ae8a0c Made git branch selection less obscure and more POSIX shell conforming. 2019-01-03 23:47:43 +03:00
Andrey Semashev
bbcd5b8f5c Use the actual number of logical CPUs for the number of CI build/test jobs. 2019-01-03 23:05:17 +03:00
Andrey Semashev
83ea633d09 Use multiple jobs to checkout submodules in CI. 2018-12-18 22:19:50 +03:00
Andrey Semashev
2b60d044ac Added tools/boost_install and libs/headers manual init to CI jobs. 2018-12-18 21:53:49 +03:00
Andrey Semashev
3cd1885209 Reorganized code and made __cxa_get_globals signature closer to the original.
This should resolve gcc errors caused by mismatch of the return types of
aur declaration of __cxa_get_globals and the original in cxxabi.h.

Fixes https://github.com/boostorg/core/issues/45.
2018-12-18 20:49:24 +03:00
Andrey Semashev
9d123dc9a3 Added missing include guards. 2018-11-11 13:43:04 +03:00
Andrey Semashev
82957de970 Extracted uncaught_exceptions function from Boost.Log.
The uncaught_exceptions function is functionally equivalent to
unhandled_exceptions_count in Boost.Log and implements functionality
similar to the same named C++17 standard function. Tests and docs are
also included.

One notable difference from std::uncaught_exceptions is that the return
type is unsigned rather than signed. This is deliberate as uncaught_exceptions
must never return a negative value and unsigned int better documents that.
Theoretically, as a counter, it may also overflow.
2018-11-10 17:44:13 +03:00
Andrey Semashev
d60775659b Changed http to https in URLs in readme. 2018-11-01 20:40:42 +03:00
Andrey Semashev
bade4d23e8 Added clang 7 CI job. 2018-11-01 20:30:07 +03:00
Peter Dimov
a5c891441c Disable boost::swap for const objects. Fixes #43. 2018-10-24 12:23:56 +03:00
Peter Dimov
e9f986d11e Add compile-fail test for const boost::Wrapper 2018-10-24 12:06:45 +03:00
Peter Dimov
5a55d9572f Add -fsanitize=undefined to Travis 2018-10-21 21:37:14 +03:00
Peter Dimov
e98a546e89 Use string comparison on MinGW/Cygwin when comparing typeinfo across DLLs 2018-10-21 20:29:10 +03:00
Peter Dimov
4dc12c59bd Fix test to compare typeinfo rather than its address 2018-10-21 18:44:34 +03:00
Peter Dimov
3c9c9603ad Add BOOST_SYMBOL_VISIBLE to core_typeid_ 2018-10-21 18:09:31 +03:00
Peter Dimov
026be7659c Add test for BOOST_CORE_TYPEID in a library 2018-10-21 17:47:33 +03:00
Andrey Semashev
ada6b9e447 Merge pull request #42 from igaztanaga/patch-1
_set_abort_behavior not supported in old MSVC
2018-10-12 14:12:33 +03:00
Ion Gaztañaga
79e3bf7175 _set_abort_behavior not supported in old MSVC
Last patch before deprecating old MSVC compilers
2018-10-12 12:17:45 +02:00
Glen Fernandes
1d9d6f579e Qualify empty_init_t and use_empty_value_base 2018-10-01 00:46:43 -04:00
Glen Fernandes
5ed58ee20f Add ADL guard for empty_value and new member typedef 2018-10-01 00:26:08 -04:00
Peter Dimov
9dfa265b49 Add 'unsupported' comment to CMakeLists.txt 2018-09-30 04:24:11 +03:00
Peter Dimov
3aa817e8d0 Reformat copyright banner 2018-09-20 02:58:06 +03:00
Peter Dimov
4ae42efdae Add minimal CMakeLists.txt 2018-09-20 00:04:10 +03:00
Peter Dimov
32ac6c5b36 Add documentation for quick_exit 2018-09-06 22:52:52 +03:00
Peter Dimov
13c09e805b Add .gitignore 2018-09-06 22:39:26 +03:00
Peter Dimov
81df44e80b MinGW-w64 has no quick_exit either 2018-09-06 05:44:56 +03:00
Peter Dimov
944f27853b Declare _exit as extern 'C' 2018-09-06 05:28:23 +03:00
Peter Dimov
0bc795de4a Merge branch 'develop' into feature/quick_exit 2018-09-06 00:30:15 +03:00
Glen Fernandes
d2b20486a0 Call test_results() in BOOST_TEST_THROWS() 2018-09-05 16:40:10 -04:00
Peter Dimov
88acbce1e9 Declare and use _exit under MinGW32 2018-09-05 20:56:03 +03:00
Peter Dimov
0c605bf32f MacOS doesn't have quick_exit; Cygwin doesn't declare it in C++03 mode 2018-09-05 20:45:51 +03:00
Peter Dimov
53772c8c73 Merge branch 'develop' into feature/quick_exit 2018-09-05 20:28:40 +03:00
Peter Dimov
6dd97ee415 Add more Appveyor configurations 2018-09-05 20:25:05 +03:00
Peter Dimov
8d4f1bb4af Revert to always using std::abort instead of the platform-specific _exit/_Exit 2018-09-05 20:23:13 +03:00
Peter Dimov
d56c31d688 Add noreturn/noexcept; use _exit on msvc-12.0 and earlier (and compatible); use ::quick_exit instead of std::quick_exit 2018-09-05 18:16:15 +03:00
Peter Dimov
5e08874182 Add initial implementation of quick_exit 2018-09-05 17:06:42 +03:00
Glen Fernandes
56bd3784bf Update e-mail address in comments and libraries.json 2018-09-05 08:21:35 -04:00
Peter Dimov
cf66842419 MinGW doesn't have _exit either 2018-09-05 08:39:35 +03:00
Peter Dimov
861eb5cf4c Merge branch 'develop' into feature/Exit 2018-09-05 07:24:23 +03:00
Peter Dimov
205b319b57 Use _exit instead of _Exit on MinGW 2018-09-05 07:17:58 +03:00
Glen Fernandes
6f1d88d153 Provide detail::test_errors() as others are using it 2018-09-05 00:16:17 -04:00
Peter Dimov
7f7c4c5b83 Call _set_abort_behavior on all compilers impersonating MSVC 2018-09-05 07:01:29 +03:00
Peter Dimov
dfd5a0b8db Remove dead #else branch 2018-09-05 06:56:59 +03:00
Peter Dimov
d8c0768788 Use _Exit(3) instead of abort() to avoid core dump 2018-09-05 06:26:40 +03:00
Peter Dimov
d0a9206d6a Call _set_abort_behavior on clang-win too 2018-09-05 06:04:53 +03:00
Glen Fernandes
76c3538315 Suppress MSVC error dialogs and add test for report_errors() 2018-09-04 21:16:36 -04:00
Glen Fernandes
f2638b6d64 Merge pull request #40 from glenfe/develop
Abort instead of assert if report_errors() not called
2018-09-04 20:25:11 -04:00
Glen Fernandes
30c006ac82 Call test_results() in BOOST_TEST() 2018-09-04 20:22:56 -04:00
Glen Fernandes
c71eb0e479 Abort instead of assert if report_errors() not called 2018-09-04 17:00:50 -04:00
Glen Fernandes
3f7d36445d Reduce statics in Lightweight_test 2018-09-04 16:53:25 -04:00
Peter Dimov
a08dda22b2 Remove clang-3.7 from Travis, as it's not in trusty-updates and the -precise sources no longer work 2018-08-31 01:52:04 +03:00
Glen Fernandes
2d99acd7ec Name the empty_value template parameters 2018-08-27 22:48:06 -04:00
Glen Fernandes
65b98db868 Update formatting in documentation 2018-08-27 00:57:45 -04:00
Glen Fernandes
edcd9e2cf5 Add documentation for empty_value 2018-08-26 20:16:26 -04:00
Glen Fernandes
2eaba7d6d1 Make empty_value<T> trivial if T is trivial 2018-08-26 02:10:02 -04:00
Peter Dimov
a05906fd44 Add comment describing noncopyable_::base_token 2018-08-25 15:15:53 +03:00
Peter Dimov
f3782a946f Derive noncopyable from a base_token class to allow it to be detected by Type Traits without an #include 2018-08-25 01:47:47 +03:00
Glen Fernandes
f504872d89 Implement empty_value 2018-08-24 16:24:34 -04:00
Glen Fernandes
e1f070b7b4 Remove anti_op and change the error output
The new output is no less useful, and not potentially misleading (for example in the case of BOOST_TEST_LT(1, nan) failing, it was not right to say that 1 >= nan).
2018-08-09 08:04:09 -04:00
Hans Dembinski
740f2142c5 new test backend based on predicates (#39)
* Work in progress, some tests fail

* adding tests

* missing header

* moved close_to to detail, added constness, replaced predicates from <functional> with custom ones, new code does not rely on partial template specialization

* renamed predicates and removed close_to predicate

* removing now superfluous headers

* unpatching the fix to put in a separate PR

* move predicate to first argument

* call op and anti_op as normal methods
2018-08-08 15:37:51 +03:00
Peter Dimov
5c10ee4517 explicit_operator_bool: fix g++ 4.6 workaround 2018-08-08 00:27:59 +03:00
Peter Dimov
b7ad896707 explicit_operator_bool: under g++ 4.6 the operator can't be constexpr 2018-08-07 22:59:25 +03:00
Peter Dimov
70413b0568 Add more Travis configurations 2018-08-07 18:50:14 +03:00
Peter Dimov
b8a9b2c234 Add lightweight_test_test3 2018-08-07 17:58:23 +03:00
Peter Dimov
e11fa9ac03 In lightweight_test_eq_nullptr, test with nullptr as first argument as well 2018-08-07 17:43:38 +03:00
Peter Dimov
e1d50a1de2 Fix typo in lightweight_test.hpp 2018-08-07 17:40:47 +03:00
Glen Fernandes
e128f4e1b8 Add documentation for exchange 2018-07-20 08:25:48 -04:00
Glen Fernandes
cc119253b4 Simplify test case; type does not need to be noncopyable 2018-07-12 21:48:05 -04:00
Glen Fernandes
19ec659a91 Simplify exchange implementation for pre-C++11 2018-07-09 08:48:50 -04:00
Glen Fernandes
75ae238d0c Use #else instead of #elif BOOST_WORKAROUND 2018-07-08 12:04:09 -04:00
Glen Fernandes
630ab2aae4 Workaround MSVC10 and MSVC11 for exchange 2018-07-08 11:18:17 -04:00
Glen Fernandes
2cd4753a02 Implement boost::exchange 2018-07-08 09:25:07 -04:00
Glen Fernandes
9445d08ea7 Rename detail identifiers in addressof 2018-01-27 12:44:50 -05:00
Glen Fernandes
dbb3305050 Only checking BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION is sufficient 2018-01-27 09:42:02 -05:00
Glen Fernandes
23f10ab4bf Update pointer_traits and to_address to reflect the design adopted for C++20 2018-01-27 05:15:05 -05:00
Glen Fernandes
e5281335e0 Simplify pointer_traits detail traits 2018-01-27 01:37:42 -05:00
jzmaddock
b5dcd204e5 address_of.hpp: VC12 namespace ambiguity
I'm seeing compiler errors with vc12, when testing serialization of Boost.Multiprecision types - there is ambiguity between boost::detail and boost::multiprecision::detail.  I assume the error occurs for serialization of any type that has it's own detail namespace.  The fix is trivially to qualify the use of "detail::".
2017-12-25 20:34:11 -05:00
Peter Dimov
081ca76d6c Update Travis and Appveyor 2017-11-06 15:10:55 +02:00
Peter Dimov
2a3387451f Avoid 'unused variable v' warning on msvc-10.0, msvc-11.0 2017-11-01 15:38:54 +02:00
Peter Dimov
69bd3e73bf Fix .travis.yml to support branches 2017-10-27 15:33:19 +03:00
Peter Dimov
0296f44b2b Update .travis.yml 2017-10-25 17:34:21 +03:00
Andrey Semashev
2738af9b52 Removed the deprecated empty_deleter header. 2017-09-18 02:02:38 +03:00
Peter Dimov
6a1c3a82a1 Add quick test target 2017-09-04 15:32:13 +03:00
Peter Dimov
bb800a05e3 Upgrade libstdc++ to 4.9 for clang-3.9 14/1z 2017-07-22 12:03:32 +03:00
Peter Dimov
2d7f98c844 Add a build matrix to Appveyor 2017-07-22 11:35:35 +03:00
Peter Dimov
8914603fcf Add more configurations to Travis 2017-07-22 11:22:12 +03:00
Peter Dimov
3792047e09 Reorder includes per best practices 2017-07-22 11:19:17 +03:00
Peter Dimov
6de3da8360 Upgrade libstdc++ to 4.9 for clang-3.8 14/1z 2017-07-22 11:18:09 +03:00
Glen Fernandes
e55d6279d5 Minor documentation changes 2017-07-21 23:05:00 -04:00
Glen Fernandes
a87fd099e7 Update pointer_traits documentation 2017-07-21 19:27:42 -04:00
Glen Fernandes
09f4823baa Add free function to_address 2017-07-21 07:14:02 -04:00
Glen Fernandes
526e0b2f53 Add tests for user specializations of pointer_traits 2017-07-21 07:13:31 -04:00
Glen Fernandes
ac6044769f Add free function to_address 2017-07-21 06:21:50 -04:00
Glen Fernandes
2876914d02 ptr_traits_address helper should be marked inline 2017-07-18 14:15:03 -04:00
Andrey Semashev
36f60e47ad Minor docs fixes, Trac ticket 10431. 2017-07-08 23:11:46 +03:00
Peter Dimov
a88bbcc8ba Merge branch 'develop' 2017-06-23 00:00:50 +03:00
Peter Dimov
c4f3e1acc0 Merge branch 'master' into develop 2017-06-22 22:54:41 +03:00
Peter Dimov
69696c0cba Merge branch 'master' into develop 2017-06-22 22:53:30 +03:00
Peter Dimov
283460b991 Merge pull request #35 from Flast/test-gt-and-ge
Added BOOST_TEST_GT and BOOST_TEST_GE.
2017-06-21 13:03:35 +03:00
Kohei Takahashi
3a2c94df8c Added BOOST_TEST_GT and BOOST_TEST_GE.
Just LT and LE are insufficient for testing operator overloads.
2017-06-18 01:10:43 +09:00
Glen Fernandes
226ef58027 Merge pull request #34 from glenfe/develop
Use workaround.hpp from boost/config
2017-06-14 01:25:43 -04:00
Glen Fernandes
0f8b499bca Use workaround.hpp from boost/config 2017-06-13 23:24:38 -04:00
Glen Fernandes
a3f6d12b57 Merge branch 'develop' 2017-06-12 07:49:50 -04:00
Glen Fernandes
cccac1d631 Revert "Slightly more succint sfinae expressions" 2017-06-11 10:53:56 -04:00
Glen Fernandes
6153eebc42 Slightly more succint sfinae expressions 2017-06-11 10:17:35 -04:00
Peter Dimov
ab05c190be Merge branch 'develop' 2017-06-01 03:17:44 +03:00
Peter Dimov
637b2ffaff Make BOOST_TEST_EQ/NE work with nullptr 2017-05-29 21:15:49 +03:00
Glen Fernandes
43426067df Merge branch 'develop' 2017-05-28 21:38:06 -04:00
Glen Fernandes
f76116405d Minor formatting changes in pointer_traits documentation 2017-05-28 21:36:52 -04:00
Glen Fernandes
89b1792724 Corrections to pointer_traits documentation 2017-05-28 20:53:58 -04:00
Glen Fernandes
87dd2883b8 Add pointer_traits documentation 2017-05-28 19:30:37 -04:00
Glen Fernandes
cba69f5e4c Merge branch 'develop' 2017-05-25 19:15:47 -04:00
Glen Fernandes
5eaa31e366 Use BOOST_NO_CXX11_POINTER_TRAITS macro 2017-05-20 09:11:11 -04:00
Glen Fernandes
2d56d6f55b Improve ptr_traits_has_rebind trait 2017-05-18 20:09:52 -04:00
Glen Fernandes
6fd649d7fd Qualify pointer_traits in detail namespace 2017-05-18 07:09:26 -04:00
Glen Fernandes
335aa4f396 Merge pull request #33 from glenfe/pointer_traits
Add pointer_traits with to_address
2017-05-17 09:21:21 -04:00
Glen Fernandes
26cab26e52 Add pointer_traits with to_address 2017-05-17 08:09:05 -04:00
Peter Dimov
b805efd4fe Add get_pointer tests for 0 2017-05-10 20:22:19 +03:00
Glen Fernandes
80875a19b6 Reduce detection conditions for constexpr addressof 2017-04-30 21:56:10 -04:00
Glen Fernandes
6ba388125e Merge branch 'develop' 2017-04-30 19:22:27 -04:00
Peter Dimov
889502504d Add BOOST_TEST_LT, BOOST_TEST_LE 2017-04-24 18:52:54 +03:00
Glen Fernandes
16c5503648 Merge pull request #30 from glenfe/develop
Also disable addressof for r-values when possible
2017-04-23 09:16:11 -04:00
Glen Fernandes
dc6003e26f Disable addressof for r-values when possible 2017-04-23 02:04:54 -04:00
Peter Dimov
46545326d8 Add BOOST_TEST_LT, BOOST_TEST_LE 2017-03-16 01:31:43 +02:00
Peter Dimov
a49e7f2f87 Merge branch 'develop' 2017-03-16 00:53:11 +02:00
Peter Dimov
064cfd3d73 Add missing [endsect] 2017-03-16 00:52:00 +02:00
Glen Fernandes
6e7e44e334 Merge branch 'develop' 2017-03-03 21:57:34 -05:00
Glen Fernandes
0942b1a366 Move constexpr notes to a separate section 2017-03-03 21:55:48 -05:00
Glen Fernandes
1343535926 Update addressof documentation 2017-03-03 21:31:29 -05:00
Glen Fernandes
3ef30643a4 Use new BOOST_NO_CXX11_SFINAE_EXPR feature macro 2017-02-24 19:37:02 -05:00
Peter Dimov
4436576c68 Merge branch 'develop' 2017-02-23 21:00:17 +02:00
Peter Dimov
1dff55872b Merge branch 'breese-feature/test-all-with' into develop 2017-02-21 03:19:37 +02:00
Bjorn Reese
a796c200e5 Moved failing test to separate file 2017-02-18 19:52:12 +01:00
Bjorn Reese
a3382dd5a8 Added BOOST_TEST_ALL_WITH macro to compare container contents with a predicate 2017-02-18 13:43:29 +01:00
Andrey Semashev
6ecc56c289 Revert "Use new BOOST_NO_CXX11_SFINAE_EXPR feature macro"
This reverts commit 98ee47effd.

This is a temporary revert until Boost.Config master is updated to
provide BOOST_NO_CXX11_SFINAE_EXPR.
2017-02-17 16:16:53 +03:00
Andrey Semashev
306b792a5e Merge branch 'develop' 2017-02-17 13:32:00 +03:00
Peter Dimov
d753d9a221 Merge branch 'breese-feature/test-all' into develop 2017-02-13 18:14:24 +02:00
Bjorn Reese
1bdb657b71 Renamed test suite for BOOST_TEST_ALL_EQ 2017-02-13 15:58:15 +01:00
Bjorn Reese
54e262ee13 Minor fixes 2017-02-13 15:55:42 +01:00
Bjorn Reese
c8b7acc8aa Changed lightweight_test_fail11 from run-fail to run 2017-02-12 15:11:30 +01:00
Bjorn Reese
baed4103a0 Optimized calculation of container sizes 2017-02-12 15:08:25 +01:00
Bjorn Reese
d828e40f6d Output at most 8 differing container values 2017-02-12 15:06:31 +01:00
Bjorn Reese
db8efb4ce9 Changed ForwardIterator to InputIterator for test_all_eq_impl 2017-02-12 13:19:39 +01:00
Bjorn Reese
fb09632580 Use test_output_impl in test_all_eq_impl 2017-02-12 12:26:58 +01:00
Bjorn Reese
c96ad4ccba Added container sizes to error output of test_all_eq_impl 2017-02-11 18:39:06 +01:00
Bjorn Reese
265583bc78 Fixed error output of test_all_eq_impl 2017-02-11 18:26:57 +01:00
Bjorn Reese
6a5f540f08 Removed std::ostringstream 2017-02-11 16:37:12 +01:00
Bjorn Reese
3bc56800cd Added BOOST_TEST_ALL_EQ macro to compare container contents 2017-02-11 15:03:45 +01:00
Peter Dimov
9dd5285dbb Handle char*, volatile* properly in BOOST_TEST_EQ/NE 2017-02-09 23:14:07 +02:00
Peter Dimov
ef9bb78f19 Merge branch 'bug_fix_support_for_c_string' of https://github.com/HDembinski/core into develop 2017-02-09 19:16:52 +02:00
hans.dembinski@gmail.com
b59a3df4c4 reverting changes to jamfile 2017-02-09 13:52:33 +00:00
hans.dembinski@gmail.com
fe137b97c3 adding documentation for new test macros 2017-02-09 12:48:06 +00:00
hans.dembinski@gmail.com
7038296c15 build fix 2017-02-09 12:47:47 +00:00
hans.dembinski@gmail.com
4570cced27 more compared code following suggestion from Glen Fernandes and testing expected failures 2017-02-07 15:05:08 +00:00
Peter Dimov
a44090aebe Only install necessary packages in .travis.yml to speed it up 2017-02-07 01:52:59 +02:00
hans.dembinski@gmail.com
cc5472623f compare pointers as addresses and use BOOST_TEST_CSTR_xx to compare cstrings 2017-02-06 20:08:43 +00:00
Glen Fernandes
518549f7ff Merge pull request #25 from glenfe/develop
Use new BOOST_NO_CXX11_SFINAE_EXPR feature macro
2017-02-06 10:47:41 -05:00
Glen Fernandes
98ee47effd Use new BOOST_NO_CXX11_SFINAE_EXPR feature macro 2017-02-06 08:14:36 -05:00
hans.dembinski@gmail.com
3942e9c097 following pdimovs suggestion to avoid folding 2017-02-05 20:01:47 +00:00
hans.dembinski@gmail.com
7774d33e45 really make sure addresses are different 2017-02-05 19:24:15 +00:00
hans.dembinski@gmail.com
cdee8e76c5 fix for trac issue #12814, including a new test for the issue 2017-02-05 19:06:21 +00:00
Glen Fernandes
e647763fb0 Exclude g++4.7 from constexpr implementation 2017-02-02 21:44:14 -05:00
Glen Fernandes
9587d6b845 Support g++4.7 with SFINAE workaround 2017-02-02 13:43:08 -05:00
Peter Dimov
b0a58a16e2 Add g++4.7-c++11, g++4.8-c++11, g++5-c++14 to .travis.yml 2017-02-02 20:01:02 +02:00
Peter Dimov
55b2786770 Add ref_cv_test 2017-02-02 18:40:06 +02:00
Glen Fernandes
76110e56a0 Merge pull request #23 from glenfe/develop
Define CORE_NO_CONSTEXPR_ADDRESSOF if NO_CXX11_CONSTEXPR is defined
2017-02-01 11:03:54 -05:00
Glen Fernandes
4016f8e7cc Define CORE_NO_CONSTEXPR_ADDRESSOF if NO_CXX11_CONSTEXPR is defined
The test case could check for BOOST_NO_CXX11_CONSTEXPR but it makes sense for BOOST_CORE_NO_CONSTEXPR_ADDRESSOF to be defined in this case also.
2017-02-01 11:02:01 -05:00
Glen Fernandes
686dbcb8eb No BOOST_WORKAROUND for MSVC as >1900 has builtin 2017-02-01 08:34:03 -05:00
Glen Fernandes
3d98e6aed4 Use __builtin_addressof when available 2017-01-31 20:10:18 -05:00
Peter Dimov
39515e5a78 Remove tools/inspect from .yml files 2017-01-31 16:27:24 +02:00
Peter Dimov
2af0107c1f Merge branch 'develop' 2017-01-31 16:24:12 +02:00
Glen Fernandes
26f290d09f Merge pull request #22 from glenfe/develop
Implement constexpr addressof
2017-01-31 08:47:51 -05:00
Glen Fernandes
09dcc68ecd Implement constexpr addressof 2017-01-31 08:45:47 -05:00
Peter Dimov
fa88cc32cf The build-in clang++ fails in c++11 mode with g++-6 installed for some reason 2017-01-30 17:51:39 +02:00
Peter Dimov
f7183714c1 Expand platform coverage in .travis.yml 2017-01-30 16:03:38 +02:00
Andrey Semashev
b0239ba7be Simplified demangle() a little to make better use of RVO. 2017-01-11 22:25:50 +03:00
Andrey Semashev
1abd68102d Simplified demangle() a little to make better use of RVO. 2017-01-11 22:25:31 +03:00
Andrey Semashev
a1ba85e5f6 Silenced warnings about unused variables. 2016-11-08 16:52:13 +03:00
Andrey Semashev
399ef5207e Disabled warnings about signed/unsigned mismatch when using BOOST_TEST_EQ/BOOST_TEST_NE. 2016-11-08 16:52:04 +03:00
Andrey Semashev
01d5850952 Use auto_ptr only when it is provided by the standard library. Improves compatibility with C++17. 2016-11-08 16:51:54 +03:00
Andrey Semashev
c0f277a7d8 Silenced warnings about unused variables. 2016-11-07 17:56:45 +03:00
Andrey Semashev
5507006fc2 Disabled warnings about signed/unsigned mismatch when using BOOST_TEST_EQ/BOOST_TEST_NE. 2016-11-06 20:57:05 +03:00
Andrey Semashev
b7f49c9c78 Use auto_ptr only when it is provided by the standard library. Improves compatibility with C++17. 2016-11-06 20:00:47 +03:00
Rene Rivera
ee8c2d3e46 Add, and update, documentation build targets. 2016-10-10 11:39:48 -05:00
Rene Rivera
9953994761 Add, and update, documentation build targets. 2016-10-07 23:07:33 -05:00
Peter Dimov
0a50557410 Merge branch 'develop' 2016-09-30 16:08:59 +03:00
Peter Dimov
8156259043 Copy repo instead of doing a checkout, for pull requests. 2016-09-10 13:50:36 +03:00
Peter Dimov
5263c5d47f Enable Travis notifications on success. 2016-09-10 01:50:43 +03:00
Peter Dimov
29810a490a Change Appveyor to use msvc-14.0 because 12.0 doesn't work. 2016-09-10 01:49:51 +03:00
Peter Dimov
aa17d6a5e2 Merge branch 'develop' of https://github.com/eldiener/core into develop 2016-09-10 01:06:07 +03:00
Andrey Semashev
9df5059786 Restored dependency on tools/inspect in master. 2016-07-12 14:09:58 +03:00
Andrey Semashev
df2f358766 Merge branch 'develop' 2016-07-12 13:56:43 +03:00
Andrey Semashev
2128428ca1 Made the workaround for Oracle compiler more strict. 2016-07-12 13:52:05 +03:00
Andrey Semashev
b0b16d6ddb Attempt to re-enable Boost.Core.Swap tests. 2016-07-11 17:08:28 +03:00
Andrey Semashev
d732412924 Added a workaround for Oracle compiler with STLport when the first argument to distance() is an array and the second one is a pointer (presumably, pointing into the array). 2016-07-11 16:34:02 +03:00
Peter Dimov
9823a4135b Do not fetch tools/inspect in .yml files 2016-05-21 23:37:42 +03:00
Peter Dimov
05f6c1d642 Merge branch 'develop' 2016-05-21 22:44:55 +03:00
Peter Dimov
0ad01c60a0 Add .travis.yml 2016-05-21 22:09:15 +03:00
Peter Dimov
a7607030a9 Merge branch 'develop' 2016-05-21 20:55:42 +03:00
Peter Dimov
94d3d3540f Remove test dependency on mpl/not.hpp. 2016-05-21 20:07:35 +03:00
Peter Dimov
45a63809bf Update README.md 2016-05-21 19:37:50 +03:00
Peter Dimov
f55d2a5cf9 Add appveyor.yml. 2016-05-21 19:29:04 +03:00
Edward Diener
fd022e2d86 Added documentation and tests for BOOST_TEST_NOT. 2016-05-20 05:22:20 -04:00
Edward Diener
f1c51cb19c Added BOOST_TEST_NOT to lightweight test. 2016-05-19 09:56:23 -04:00
Andrey Semashev
f81653660b Added a boostdoc target to unify Boost release docs building. 2016-01-06 21:06:49 +03:00
Andrey Semashev
6345b93198 -Added constexpr and noexcept specifiers to make the emulation technically closer to the actual enums. 2016-01-01 19:02:48 +03:00
Andrey Semashev
181965f303 Added support for __has_include on gcc, in addition to clang. 2015-12-31 19:45:37 +03:00
Andrey Semashev
3add966877 Added support for gabi++ ABI implementation used in Android NDK. 2015-08-28 22:31:26 +03:00
Andrey Semashev
3eecdd27fe Added a few notes to the README.md file. 2015-08-28 22:03:30 +03:00
Andrey Semashev
c29b43c80c Merge pull request #18 from jfalcou/fix_enable_if_has_type_test
Fix test for enable_if_has_type
2015-08-18 10:27:28 +03:00
Joel Falcou
482a6f9419 Fix test for enable_if_has_type 2015-08-18 08:59:05 +02:00
Glen Fernandes
2e79e3b63d Update README.md to point to boost.org 2015-08-15 07:48:28 -04:00
Andrey Semashev
a30186cfa4 Merge pull request #16 from jfalcou/enable_if_has_type
Added enable_if_has_type facility.
2015-08-15 14:03:19 +03:00
Joel Falcou
87d43ddffc Rename to enable_if_has_type in concordance with MPL existing traits 2015-08-13 17:42:34 +02:00
Joel Falcou
ad513c1641 Introduces enable_if_type
enable_if_type allow to perform SFINAE check on the existence
of a dependent type.

It has been used here and there in various boost library but it's
useful enough to warrant an autonomous existence.
2015-08-10 16:55:44 +02:00
Andrey Semashev
4268048ab8 Merge branch 'develop' 2015-07-20 12:32:52 +03:00
Andrey Semashev
5d9aeb3161 Slightly more robust check for BOOST_GCC. 2015-07-17 21:50:44 +03:00
Andrey Semashev
5e8b9152be Added a check for C++11 mode to disable auto_ptr deprecation warnings. 2015-07-17 21:41:44 +03:00
Andrey Semashev
c641e8e544 Disabled libstdc++ warnings about auto_ptr deprecation. 2015-07-17 21:37:01 +03:00
Peter Dimov
89630fc2bf Merge branch 'develop' 2015-06-05 15:44:48 +03:00
Peter Dimov
d9b28783e8 Merge pull request #11 from awulkiew/feature/auto_ptr
Disable auto_ptr support in get_pointer when BOOST_NO_AUTO_PTR is def…
2015-06-05 15:31:27 +03:00
Adam Wulkiewicz
de616f6d1b Disable auto_ptr support in get_pointer when BOOST_NO_AUTO_PTR is defined. 2015-06-05 14:09:08 +02:00
Andrey Semashev
6bf1e7a681 Merge pull request #10 from awulkiew/feature/ignore_unused
[core] Add/improve ignore_unused() function specifiers.
2015-04-13 12:20:04 +03:00
Adam Wulkiewicz
7aec0e45bd [core] Add/improve ignore_unused() function specifiers.
Add C++14 constexpr by BOOST_CXX14_CONSTEXPR.
Replace inline with BOOST_FORCEINLINE.
2015-04-12 15:08:55 +02:00
218 changed files with 11558 additions and 441 deletions

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

@@ -0,0 +1,244 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.7
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.8
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
install: g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
- toolset: gcc-10
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: g++-11
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11"
os: ubuntu-16.04
install: clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: clang-8
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
sudo apt-get install ${{matrix.install}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
- name: Run tests
run: |
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
cd ../boost-root
./b2 -j $BUILD_JOBS libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release

210
.travis.yml Normal file
View File

@@ -0,0 +1,210 @@
# Copyright 2016-2019 Peter Dimov
# 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)
language: cpp
dist: xenial
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
addons:
apt:
packages:
- g++-multilib
- os: linux
arch: arm64
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
arch: ppc64le
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
- os: linux
arch: s390x
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-11
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: freebsd
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode7.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode8.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode9.4
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode10.1
- os: osx
osx_image: xcode11.3
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=core ..
- cmake --build . --target tests
- ctest --output-on-failure
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL_TEST=1
script:
- pip install --user cmake
- mkdir __build__ && cd __build__
- cmake -DBOOST_INCLUDE_LIBRARIES=core -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/core/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/headers
- git submodule init libs/assert
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule init tools/cmake
- git submodule update
- cp -r $TRAVIS_BUILD_DIR/* libs/core
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
- ./b2 -j $BUILD_JOBS libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:
on_success: always

24
CMakeLists.txt Normal file
View File

@@ -0,0 +1,24 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_core INTERFACE)
add_library(Boost::core ALIAS boost_core)
target_include_directories(boost_core INTERFACE include)
target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -1,13 +1,20 @@
Boost.Core
==========
Boost.Core, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
Boost.Core, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
The criteria for inclusion is that the utility component be:
* simple,
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core itself, Config, Assert, Static Assert, or Predef.
### CI Status
Branch | Travis | Appveyor
---------|--------|---------
Develop | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=develop)](https://travis-ci.org/boostorg/core) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/core)
Master | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=master)](https://travis-ci.org/boostorg/core) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/core)
### Directories
* **doc** - Documentation of the components
@@ -16,8 +23,10 @@ The criteria for inclusion is that the utility component be:
### More information
* [Documentation](http://boostorg.github.io/core)
* [Documentation](https://boost.org/libs/core)
* [Report bugs](https://svn.boost.org/trac/boost/newticket?component=core;version=Boost%20Release%20Branch). 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](https://www.boost.org/LICENSE_1_0.txt).
### License
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).

93
appveyor.yml Normal file
View File

@@ -0,0 +1,93 @@
# Copyright 2016-2019 Peter Dimov
# 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)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
ADDRMD: 32,64
CXXSTD: 14,17
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
ADDRMD: 64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17,latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/headers
- git submodule init libs/assert
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule update --jobs 4
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core\
- cmd /c bootstrap
- b2 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release

3
doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/html/
/pdf/
ref_reference.xml

View File

@@ -1,5 +1,5 @@
# Copyright (c) 2014 Glen Joseph Fernandes
# glenfe at live dot com
# Copyright 2014 Glen Joseph Fernandes
# (glenjofe@gmail.com)
#
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
@@ -49,5 +49,11 @@ boostbook standalone
<xsl:param>boost.root=../../../..
<xsl:param>generate.section.toc.level=1
<xsl:param>toc.max.depth=1
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/core/doc/html
<format>pdf:<xsl:param>boost.url.prefix="http://www.boost.org/doc/libs/release/libs/core/doc/html"
;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

View File

@@ -14,6 +14,7 @@
* Brad King
* Douglas Gregor
* Peter Dimov
* Glen Fernandes
[endsimplesect]
@@ -59,6 +60,19 @@ void f() {
[endsect]
[section Notes]
In C++11 and above, `boost::addressof` is conditionally
`constexpr` when possible. This is indicated by
`BOOST_CORE_NO_CONSTEXPR_ADDRESSOF` not being defined.
With supported compilers, `boost::addressof` is always
`constexpr` by leveraging compiler intrinsics. This is
indicated by `BOOST_CORE_HAS_BUILTIN_ADDRESSOF` being
defined.
[endsect]
[endsect]
[endsect]

149
doc/alloc_construct.qbk Normal file
View File

@@ -0,0 +1,149 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:alloc_construct alloc_construct, alloc_destroy]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/alloc_construct.hpp> provides function templates
`alloc_construct`, `alloc_construct_n`, `alloc_destroy`, and `alloc_destroy_n`
for allocator aware and exception safe construction and destruction of objects
and arrays.
[endsect]
[section Example]
The following example allocates storage for an array of `n` elements of `T`
using an allocator `a` and constructs `T` elements in that storage. If any
exception was thrown during construction of an element, the constructed
elements are destroyed in reverse order.
```
template<class A>
auto create(A& a, std::size_t n)
{
auto p = a.allocate(n);
try {
boost::alloc_construct_n(a, boost::to_address(p), n);
} catch (...) {
a.deallocate(p, n);
throw;
}
return p;
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class A, class T>
void alloc_destroy(A& a, T* p);
template<class A, class T>
void alloc_destroy_n(A& a, T* p, std::size_t n);
template<class A, class T, class Args>
void alloc_construct(A& a, T* p, Args&&... args);
template<class A, class T>
void alloc_construct_n(A& a, T* p, std::size_t n);
template<class A, class T>
void alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m);
template<class A, class T, class I>
void alloc_construct_n(A& a, T* p, std::size_t n, I begin);
} /* boost */
```
[section Functions]
[variablelist
[[`template<class A, class T> void alloc_destroy(A& a, T* p);`]
[[variablelist
[[Requires][`A` is an /Allocator/]]
[[Effects][`std::allocator_traits<A>::destroy(a, p)`.]]]]]
[[`template<class A, class T> void alloc_destroy_n(A& a, T* p,
std::size_t n);`]
[[variablelist
[[Requires][`A` is an /Allocator/]]
[[Effects]
[Destroys each `i`-th element in reverse order by calling
`std::allocator_traits<A>::destroy(a, &p[i])`.]]]]]
[[`template<class A, class T, class Args> void alloc_construct(A& a, T* p,
Args&&... args);`]
[[variablelist
[[Requires][`A` is an /Allocator/]]
[[Effects]
[`std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...)`.]]]]]
[[`template<class A, class T> void alloc_construct_n(A& a, T* p,
std::size_t n);`]
[[variablelist
[[Requires][`A` is an /Allocator/]]
[[Effects]
[Constructs each `i`-th element in order by calling
`std::allocator_traits<A>::construct(a, &p[i])`.]]
[[Remarks]
[If an exception is thrown destroys each already constructed `j`-th element in
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
[[`template<class A, class T> void alloc_construct_n(A& a, T* p, std::size_t n,
const T* l, std::size_t m);`]
[[variablelist
[[Requires][`A` is an /Allocator/]]
[[Effects]
[Constructs each `i`-th element in order by calling
`std::allocator_traits<A>::construct(a, &p[i], l[i % m])`.]]
[[Remarks]
[If an exception is thrown destroys each already constructed `j`-th element in
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
[[`template<class A, class T, class I> void alloc_construct_n(A& a, T* p,
std::size_t n, I begin);`]
[[variablelist
[[Requires]
[[itemized_list
[`A` is an /Allocator/][`I` is an /InputIterator/]]]]
[[Effects]
[Constructs each `i`-th element in order by calling
`std::allocator_traits<A>::construct(a, &p[i], *begin++])`.]]
[[Remarks]
[If an exception is thrown destroys each already constructed `j`-th element in
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]]
[endsect]
[endsect]
[section Compatibility]
When `BOOST_NO_CXX11_ALLOCATOR` is defined, and the C++11 allocator model is
not supported, these functions invoke constructors and destructors directly
without going through the supplied allocator.
[endsect]
[section Acknowledgments]
Glen Fernandes originally implemented this functionality in Boost.Smart_Ptr and
later moved these functions to Boost.Core for use in other Boost libraries,
such as Boost.Multi_Array and Boost.Histogram.
[endsect]
[endsect]

243
doc/allocator_access.qbk Normal file
View File

@@ -0,0 +1,243 @@
[/
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section Allocator Access]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header `<boost/core/allocator_access.hpp>` provides the class and function
templates to simplify allocator use. It provides the same functionality as the
C++ standard library `std::allocator_traits` but with individual templates for
each allocator feature.
These facilities also simplify existing libraries by avoiding having to check
for `BOOST_NO_CXX11_ALLOCATOR` and conditionally use `std::allocator_traits`.
[endsect]
[section Examples]
The following example shows these utilities used in the definition of
an allocator-aware container class:
```
template<class T, class A = boost::default_allocator<T> >
class container
: boost::empty_value<typename boost::allocator_rebind<A, T>::type> {
public:
typedef T value_type;
typedef A allocator_type;
typedef typename boost::allocator_size_type<A>::type size_type;
typedef typename boost::allocator_difference_type<A>::type difference_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename boost::allocator_pointer<A>::type pointer;
typedef typename boost::allocator_const_pointer<A>::type const_pointer;
// ...
};
```
In C++11 or above, aliases such as `boost::allocator_pointer_t<A>` can be used
instead of `typename boost::allocator_pointer<A>::type`.
[endsect]
[section Reference]
```
namespace boost {
template<class A>
struct allocator_value_type;
template<class A>
using allocator_value_type_t = typename allocator_value_type<A>::type;
template<class A>
struct allocator_pointer;
template<class A>
using allocator_pointer_t = typename allocator_pointer<A>::type;
template<class A>
struct allocator_const_pointer;
template<class A>
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
template<class A>
struct allocator_void_pointer;
template<class A>
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
template<class A>
struct allocator_const_void_pointer;
template<class A>
using allocator_const_void_pointer_t =
typename allocator_const_void_pointer<A>::type;
template<class A>
struct allocator_difference_type;
template<class A>
using allocator_difference_type_t =
typename allocator_difference_type<A>::type;
template<class A>
struct allocator_size_type;
template<class A>
using allocator_size_type_t = typename allocator_size_type<A>::type;
template<class A>
struct allocator_propagate_on_container_copy_assignment;
template<class A>
using allocator_propagate_on_container_copy_assignment_t =
typename allocator_propagate_on_container_copy_assignment<A>::type;
template<class A>
struct allocator_propagate_on_container_move_assignment;
template<class A>
using allocator_propagate_on_container_move_assignment_t =
typename allocator_propagate_on_container_move_assignment<A>::type;
template<class A>
struct allocator_propagate_on_container_swap;
template<class A>
using allocator_propagate_on_container_swap_t =
typename allocator_propagate_on_container_swap<A>::type;
template<class A>
struct allocator_is_always_equal;
template<class A>
using allocator_is_always_equal_t =
typename allocator_is_always_equal<A>::type;
template<class A, class T>
struct allocator_rebind;
template<class A, class T>
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
template<class A>
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);
template<class A>
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n,
allocator_const_void_pointer_t<A> h);
template<class A>
void allocator_deallocate(A& a, allocator_pointer_t<A> p,
allocator_size_type_t<A> n);
template<class A, class T, class... Args>
void allocator_construct(A& a, T* p, Args&&... args);
template<class A, class T>
void allocator_destroy(A& a, T* p);
template<class A>
allocator_size_type_t<A> allocator_max_size(const A& a);
template<class A>
A allocator_select_on_container_copy_construction(const A& a);
} // boost
```
[section Types]
[variablelist
[[`template<class A> struct allocator_value_type;`]
[The member `type` is `A::value_type`.]]
[[`template<class A> struct allocator_pointer;`]
[The member `type` is `A::pointer` if valid, otherwise `A::value_type*`.]]
[[`template<class A> struct allocator_const_pointer;`]
[The member `type` is `A::const_pointer` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::rebind<const
allocator_value_type_t<A> >`.]]
[[`template<class A> struct allocator_void_pointer;`]
[The member `type` is `A::void_pointer` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::rebind<void>`.]]
[[`template<class A> struct allocator_const_void_pointer;`]
[The member `type` is `A::const_void_pointer` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::rebind<const void>`.]]
[[`template<class A> struct allocator_difference_type;`]
[The member `type` is `A::difference_type` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::difference_type`.]]
[[`template<class A> struct allocator_size_type;`]
[The member `type` is `A::size_type` if valid, otherwise
`std::make_unsigned_t<allocator_difference_type_t<A> >`.]]
[[`template<class A> struct allocator_propagate_on_container_copy_assignment;`]
[The member `type` is `A::propagate_on_container_copy_assignment` if valid,
otherwise `std::false_type`.]]
[[`template<class A> struct allocator_propagate_on_container_move_assignment;`]
[The member `type` is `A::propagate_on_container_move_assignment` if valid,
otherwise `std::false_type`.]]
[[`template<class A> struct allocator_propagate_on_container_swap;`]
[The member `type` is `A::propagate_on_container_swap` if valid, otherwise
`std::false_type`.]]
[[`template<class A> struct allocator_is_always_equal;`]
[The member `type` is `A::is_always_equal` if valid, otherwise
`std::is_empty<A>::type`.]]
[[`template<class A, class T> struct allocator_rebind;`]
[The member `type` is `A::rebind<T>::other` if valid, otherwise `A<T, Args>`
if this `A` is `A<U, Args>`.]]]
[endsect]
[section Functions]
[variablelist
[[`template<class A>
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);`]
[Calls `a.allocate(n)`.]]
[[`template<class A> allocator_pointer_t<A> allocator_allocate(A& a,
allocator_size_type_t<A> n, allocator_const_void_pointer_t<A> hint);`]
[Calls `a.allocate(n, hint)` if valid, otherwise calls `a.allocate(n)`.]]
[[`template<class A> void allocator_deallocate(A& a, allocator_pointer_t<A> p,
allocator_size_type_t<A> n);`]
[Calls `a.deallocate(p, n)`.]]
[[`template<class A, class T, class... Args>
void allocator_construct(A& a, T*p, Args&&... args);`]
[Calls `a.construct(p, std::forward<Args>(args)...)` if valid, otherwise calls
`::new(static_cast<void*>(p)) T(std::forward<Args>(args)...)`.]]
[[`template<class A, class T> void allocator_destroy(A& a, T* p);`]
[Calls `a.destroy(p)` if valid, otherwise calls `p->~T()`.]]
[[`template<class A> allocator_size_type_t<A> allocator_max_size(const A& a);`]
[Returns `a.max_size()` if valid, otherwise returns
`std::numeric_limits<allocator_size_type_t<A> >::max() /
sizeof(A::value_type)`.]]
[[`template<class A> A allocator_select_on_container_copy_construction(const
A& a);`]
[Returns `a.select_on_container_copy_construction()` if valid, otherwise
returns `a`.]]]
[endsect]
[endsect]
[section Acknowledgments]
Glen Fernandes implemented the allocator access utilities.
[endsect]
[endsect]

203
doc/bit.qbk Normal file
View File

@@ -0,0 +1,203 @@
[/
Copyright 2020 Peter Dimov
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
]
[section:bit bit]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/bit.hpp>]
The header `<boost/core/bit.hpp>` implements, in a portable way,
the C++20 `<bit>` header.
[section Synopsis]
``
namespace boost
{
namespace core
{
// bit_cast
template<class To, class From>
To bit_cast(From const& from) noexcept;
// Integral powers of 2
template<class T>
constexpr bool has_single_bit(T x) noexcept;
template<class T>
constexpr T bit_ceil(T x) noexcept;
template<class T>
constexpr T bit_floor(T x) noexcept;
template<class T>
constexpr T bit_width(T x) noexcept;
// Rotating
template<class T>
constexpr T rotl(T x, int s) noexcept;
template<class T>
constexpr T rotr(T x, int s) noexcept;
// Counting
template<class T>
constexpr int countl_zero(T x) noexcept;
template<class T>
constexpr int countl_one(T x) noexcept;
template<class T>
constexpr int countr_zero(T x) noexcept;
template<class T>
constexpr int countr_one(T x) noexcept;
template<class T>
constexpr int popcount(T x) noexcept;
// Endian
enum class endian
{
little = see below,
big = see below,
native = see below
};
using endian_type = endian; // portable alias for C++03 code
} // namespace core
} // namespace boost
``
Note: even though the functions are shown as `constexpr` in the synopsis, since they are implemented
via compiler-specific intrinsics, portable code cannot generally rely on their being usable in a
constant expression context.
[endsect]
[section bit_cast]
`template<class To, class From> To bit_cast(From const& from) noexcept;`
* *Requires:* `To` and `From` must be trivially copyable and `sizeof(To)` must be the same as `sizeof(From)`.
* *Returns:* A value of type `To` with the storage bytes copied from `from`.
[endsect]
[section Integral powers of 2]
`template<class T> constexpr bool has_single_bit(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type (i.e. one of `unsigned char`, `unsigned short`, `unsigned int`, `unsigned long`, `unsigned long long`).
* *Returns:* `true` if `x` is an integral power of two, `false` otherwise. (`has_single_bit(0u)` is false.)
`template<class T> constexpr T bit_ceil(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* The smallest integral power of 2 greater than or equal to `x`. If this value is not representable in `T`, behavior is undefined.
`template<class T> constexpr T bit_floor(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* If `x == 0`, 0; otherwise the maximal value `y` such that `has_single_bit(y)` is `true` and `y <= x`.
`template<class T> constexpr T bit_width(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* If `x == 0`, 0; otherwise one plus the base-2 logarithm of `x`, with any fractional part discarded.
[endsect]
[section Rotating]
In the following descriptions, `N` denotes `numeric_limits<T>::digits` and `r` denotes `s % N`.
`template<class T> constexpr T rotl(T x, int s) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* If `s` is negative, `rotr(x, -s)`; if `r` is 0, `x`; if `r` is positive, `(x << r) | (x >> (N - r))`.
`template<class T> constexpr T rotr(T x, int s) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* If `s` is negative, `rotl(x, -s)`; if `r` is 0, `x`; if `r` is positive, `(x >> r) | (x << (N - r))`.
[endsect]
[section Counting]
`template<class T> constexpr int countl_zero(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* The number of consecutive 0 bits in the value of `x`, starting from the most significant ("left") bit.
`template<class T> constexpr int countl_one(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* The number of consecutive 1 bits in the value of `x`, starting from the most significant bit.
`template<class T> constexpr int countr_zero(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* The number of consecutive 0 bits in the value of `x`, starting from the least significant ("right") bit.
`template<class T> constexpr int countr_one(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* The number of consecutive 1 bits in the value of `x`, starting from the least significant bit.
`template<class T> constexpr int popcount(T x) noexcept;`
* *Requires:* `T` must be an unsigned integer type.
* *Returns:* The number of 1 bits in the value of `x`.
[endsect]
[section Endian]
Under C++11, `endian` is defined as `enum class endian` as shown in the synopsis. Under C++03, its definition is
``
namespace endian
{
enum type
{
little = see below,
big = see below,
native = see below
};
}
typedef endian::type endian_type;
``
The values of `endian::big` and `endian::little` are distinct. `endian::native` is equal to `endian::big` on
big endian platforms, equal to `endian::little` on little endian platforms, and a distinct value on platforms
that are neither.
Note that you should not rely on `little` and `big` having any specific values, because the C++20 standard
leaves these unspecified.
[endsect]
[endsect]
[endsect]

122
doc/cmath.qbk Normal file
View File

@@ -0,0 +1,122 @@
[/
Copyright 2018 Peter Dimov
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
]
[section:cmath cmath]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/cmath.hpp>]
The header `<boost/core/cmath.hpp>` defines, in a portable way, the floating
point classification and sign manipulation functions from C++11.
[section Synopsis]
``
namespace boost
{
namespace core
{
// fpclassify return values
int const fp_zero = /*unspecified*/;
int const fp_subnormal = /*unspecified*/;
int const fp_normal = /*unspecified*/;
int const fp_infinite = /*unspecified*/;
int const fp_nan = /*unspecified*/;
// Classification functions
template<class T> bool isfinite( T x );
template<class T> bool isnan( T x );
template<class T> bool isinf( T x );
template<class T> bool isnormal( T x );
template<class T> int fpclassify( T x );
// Sign manipulation functions
template<class T> bool signbit( T x );
template<class T> T copysign( T x, T y );
} // namespace core
} // namespace boost
``
[endsect]
[section Classification Functions]
[section template<class T> bool isfinite( T x );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:* `true` when `x` is finite (not infinity or NaN), `false` otherwise.
[endsect]
[section template<class T> bool isnan( T x );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:* `true` when `x` is NaN, `false` otherwise.
[endsect]
[section template<class T> bool isinf( T x );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:* `true` when `x` is infinity, `false` otherwise.
[endsect]
[section template<class T> bool isnormal( T x );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:* `true` when `x` is a normal number (not zero, subnormal, infinity, or NaN), `false` otherwise.
[endsect]
[section template<class T> int fpclassify( T x );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:*
* `fp_zero` when `x` is zero;
* `fp_subnormal` when `x` is subnormal;
* `fp_infinite` when `x` is infinity;
* `fp_nan` when `x` is NaN;
* `fp_normal` otherwise.
[endsect]
[endsect]
[section Sign Manipulation Functions]
[section template<class T> bool signbit( T x );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:* `true` when `x` is negative, `false` otherwise.
[endsect]
[section template<class T> bool copysign( T x, T y );]
* *Requires:* `T` must be `float`, `double`, or `long double`.
* *Returns:* `x` with the sign copied from `y`.
[endsect]
[endsect]
[endsect]
[endsect]

View File

@@ -1,10 +1,10 @@
[/
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Copyright 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://boost.org/LICENSE_1_0.txt)
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)
]
[library Boost.Core
@@ -39,17 +39,31 @@ criteria for inclusion is that the utility component be:
[endsect]
[include addressof.qbk]
[include allocator_access.qbk]
[include alloc_construct.qbk]
[include bit.qbk]
[include checked_delete.qbk]
[include cmath.qbk]
[include default_allocator.qbk]
[include demangle.qbk]
[include empty_value.qbk]
[include enable_if.qbk]
[include exchange.qbk]
[include explicit_operator_bool.qbk]
[include first_scalar.qbk]
[include ignore_unused.qbk]
[include is_same.qbk]
[include lightweight_test.qbk]
[include no_exceptions_support.qbk]
[include noinit_adaptor.qbk]
[include noncopyable.qbk]
[include null_deleter.qbk]
[include nvp.qbk]
[include pointer_traits.qbk]
[include quick_exit.qbk]
[include ref.qbk]
[include scoped_enum.qbk]
[include swap.qbk]
[include typeinfo.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]

140
doc/default_allocator.qbk Normal file
View File

@@ -0,0 +1,140 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:default_allocator default_allocator]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/default_allocator.hpp> provides the class template
`boost::default_allocator` to serve as a minimal default allocator that:
* Like C++2a's `std::allocator`, does not provide members such as `construct()`
and `destroy()` to be eligible for optimizations by allocator-aware code that
detects the absence of these members to provide more optimal construction.
* Supports `BOOST_NO_EXCEPTIONS` in allocation.
* Does not have `std` as an associated namespace.
[endsect]
[section Examples]
The following snippet shows the use of this allocator as the default allocator
for a container.
```
template<class Key, class Compare = std::less<Key>,
class Allocator = boost::default_allocator<Key> >
class FlatSet;
```
Facilities like `make_shared` can be implemented using `allocate_shared` with
`default_allocator`.
```
template<class T, class... Args>
enable_if_t<!is_array_v<T>, shared_ptr<T> >
make_shared(Args&&... args)
{
return allocate_shared<T>(boost::default_allocator<remove_cv_t<T> >(),
std::forward<Args>(args)...);
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class T>
struct default_allocator {
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef std::add_lvalue_reference_t<T> reference;
typedef std::add_lvalue_reference_t<const T> const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef ``['true_type]`` propagate_on_container_move_assignment;
typedef ``['true_type]`` is_always_equal;
template<class U>
struct rebind {
typedef default_allocator<U> other;
};
constexpr default_allocator() = default;
template<class U>
constexpr default_allocator(const default_allocator<U>&) noexcept { }
constexpr std::size_t max_size() const noexcept;
T* allocate(std::size_t n);
void deallocate(T* p, std::size_t);
};
template<class T, class U>
constexpr bool operator==(const default_allocator<T>&,
const default_allocator<U>&) noexcept;
template<class T, class U>
constexpr bool operator!=(const default_allocator<T>&,
const default_allocator<U>&) noexcept;
} /* boost */
```
[section Members]
[variablelist
[[`constexpr std::size_t max_size() const noexcept;`]
[[variablelist
[[Returns][The largest value `N` for which the call `allocate(N)` might
succeed.]]]]]
[[`T* allocate(std::size_t n);`]
[[variablelist
[[Returns]
[A pointer to the initial element of an array of storage of size
`n * sizeof(T)`, aligned appropriately for objects of type `T`.]]
[[Remarks][The storage is obtained by calling `::operator new`.]]
[[Throws][`std::bad_alloc` if the storage cannot be obtained.]]]]]
[[`void deallocate(T* p, std::size_t n);`]
[[variablelist
[[Requires]
[`p` shall be a pointer value obtained from `allocate()`. `n` shall equal the
value passed as the first argument to the invocation of `allocate` which
returned `p`.]]
[[Effects][Deallocates the storage referenced by `p`.]]
[[Remarks][Uses `::operator delete`.]]]]]]
[endsect]
[section Operators]
[variablelist
[[`template<class T, class U> constexpr bool operator==(const
default_allocator<T>&, const default_allocator<U>&) noexcept;`]
[[variablelist
[[Returns][`true`.]]]]]
[[`template<class T, class U> constexpr bool operator!=(const
default_allocator<T>&, const default_allocator<U>&) noexcept;`]
[[variablelist
[[Returns][`false`.]]]]]]
[endsect]
[endsect]
[endsect]

140
doc/empty_value.qbk Normal file
View File

@@ -0,0 +1,140 @@
[/
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:empty_value empty_value]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/empty_value.hpp> provides the class template
`boost::empty_value` for library authors to conveniently leverage the Empty
Base Optimization to store objects of potentially empty types.
[endsect]
[section Examples]
The following example shows `boost::empty_value` used to create a type that
stores a pointer, comparer, and allocator, where the comparer and allocator
could be empty types.
```
template<class Ptr, class Compare, class Allocator>
class storage
: empty_value<Compare, 0>
, empty_value<Allocator, 1> {
public:
storage()
: empty_value<Compare, 0>(empty_init_t())
, empty_value<Allocator, 1>(empty_init_t())
, ptr_() { }
storage(const Compare& c, const Allocator& a)
: empty_value<Compare, 0>(empty_init_t(), c)
, empty_value<Allocator, 1>(empty_init_t(), a)
, ptr_() { }
const Ptr& pointer() const {
return ptr_;
}
Ptr& pointer() {
return ptr_;
}
const Compare& compare() const {
return empty_value<Compare, 0>::get();
}
Compare& compare() {
return empty_value<Compare, 0>::get();
}
const Allocator& allocator() const {
return empty_value<Allocator, 1>::get();
}
Allocator& allocator() {
return empty_value<Allocator, 1>::get();
}
private:
Ptr ptr_;
};
```
[endsect]
[section Reference]
```
namespace boost {
struct empty_init_t { };
template<class T, unsigned Index = 0, bool Empty = ``/see below/``>
class empty_value {
public:
typedef T type;
empty_value() = default;
template<class... Args>
empty_value(empty_init_t, Args&&... args);
const T& get() const noexcept;
T& get() noexcept;
};
inline constexpr empty_init_t empty_init{ };
} /* boost */
```
[section Template parameters]
[variablelist
[[`T`][The type of value to store]]
[[`Index`][Optional: Specify to create a distinct base type]]
[[`Empty`][Optional: Specify to force inheritance from type]]]
[endsect]
[section Member types]
[variablelist
[[`type`][The template parameter `T`]]]
[endsect]
[section Constructors]
[variablelist
[[`empty_value() = default;`][Default initialize the value]]
[[`template<class... Args> empty_value(empty_init_t, Args&&... args);`]
[Initialize the value with `std::forward<Args>(args)...`]]]
[endsect]
[section Member functions]
[variablelist
[[`const T& get() const noexcept;`][Returns the value]]
[[`T& get() noexcept;`][Returns the value]]]
[endsect]
[endsect]
[endsect]

View File

@@ -304,6 +304,26 @@ depends on the template arguments of the class. Note that
again, the second argument to `enable_if` is not needed; the
default (`void`) is the correct value.
The `enable_if_has_type` template is usable this scenario but instead of
using a type traits to enable or disable a specialization, it use a
SFINAE context to check for the existence of a dependent type inside
its parameter. For example, the following structure extracts a dependent
`value_type` from T if and only if `T::value_type` exists.
``
template <class T, class Enable = void>
class value_type_from
{
typedef T type;
};
template <class T>
class value_type_from<T, typename enable_if_has_type<typename T::value_type>::type>
{
typedef typename T::value_type type;
};
``
[endsect]
[section Overlapping enabler conditions]

63
doc/exchange.qbk Normal file
View File

@@ -0,0 +1,63 @@
[/
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:exchange exchange]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/exchange.hpp> provides the function template
`boost::exchange` which is an implementation of the `std::exchange`
function introduced in C++14. `boost::exchange(o, v)` replaces the
value of `o` with `v` and returns the old value of `o`.
[endsect]
[section Examples]
The following example shows `boost::exchange` used to simplify the
implementation of a move constructor.
```
Node(Node&& other)
: head_(boost::exchange(other.head_, nullptr))
, tail_(boost::exchange(other.tail_, nullptr)) { }
```
[endsect]
[section Reference]
```
namespace boost {
template<class T, class U = T>
constexpr T exchange(T& t, U&& u);
}
```
[section Functions]
[*`template<class T, class U = T> constexpr T exchange(T& t, U&& u);`]
Equivalent to:
```
T v = std::move(t);
t = std::forward<U>(u);
return v;
```
[endsect]
[endsect]
[endsect]

91
doc/first_scalar.qbk Normal file
View File

@@ -0,0 +1,91 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:first_scalar first_scalar]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/first_scalar.hpp> provides the function templates
`boost::first_scalar` that can be used to obtain a pointer to the first scalar
element of an array. Given a pointer of type `T*` they return a pointer of
type `remove_all_extents_t<T>*`. The functions are `constexpr` and can be used
in constant expressions.
[endsect]
[section Examples]
The following function uses an allocator to allocate an array of arrays and
constructs each scalar element in it.
```
#include <boost/alloc_construct.hpp>
#include <boost/first_scalar.hpp>
template<class A>
auto create(const A& allocator)
{
typename std::allocator_traits<A>::template
rebind_alloc<int[2][3]> other(allocator);
auto ptr = other.allocate(4);
try {
boost::alloc_construct_n(other,
boost::first_scalar(boost::to_address(ptr)), 24);
} catch (...) {
other.deallocate(ptr, 4);
throw;
}
return ptr;
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class T>
constexpr T* first_scalar(T* p) noexcept;
template<class T, std::size_t N>
constexpr auto first_scalar(T (*p)[N]) noexcept;
} /* boost */
```
[section Functions]
[variablelist
[[`template<class T> constexpr T* first_scalar(T* p) noexcept;`]
[[variablelist
[[Returns][`p`.]]]]]
[[`template<class T, std::size_t N> constexpr auto first_scalar(T (*p)[N])
noexcept;`]
[[variablelist
[[Returns][`first_scalar(&(*p)[0])`.]]]]]]
[endsect]
[endsect]
[section History]
Glen Fernandes implemented `first_scalar`. Peter Dimov suggested a change for
GCC to support an additional `constexpr` use.
[endsect]
[endsect]

View File

@@ -1,7 +1,8 @@
[/
Copyright 2010, 2011 Beman Dawes
Copyright 2013 Ion Gaztanaga
Copyright 2014 Peter Dimov
Copyright 2014-2019 Peter Dimov
Copyright 2017 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0.
@@ -32,10 +33,21 @@ When using `lightweight_test.hpp`, *do not forget* to
``
#define BOOST_TEST(expression) /*unspecified*/
#define BOOST_TEST_NOT(expression) /*unspecified*/
#define BOOST_ERROR(message) /*unspecified*/
#define BOOST_TEST_EQ(expr1, expr2) /*unspecified*/
#define BOOST_TEST_NE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_LT(expr1, expr2) /*unspecified*/
#define BOOST_TEST_LE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_GT(expr1, expr2) /*unspecified*/
#define BOOST_TEST_GE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/
#define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_WITH(expr1, expr2, pred) /*unspecified*/
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) /* unspecified */
#define BOOST_TEST_THROWS(expr, excep) /*unspecified*/
#define BOOST_TEST_NO_THROW(expr) /*unspecified*/
namespace boost
{
@@ -56,6 +68,17 @@ message containing `expression`.
[endsect]
[section BOOST_TEST_NOT]
``
BOOST_TEST_NOT(expression)
``
If expression is true increases the error count and outputs a
message containing `!(expression)`.
[endsect]
[section BOOST_ERROR]
``
@@ -73,7 +96,7 @@ Increases error count and outputs a message containing
BOOST_TEST_EQ(expr1, expr2)
``
If `expr1 != expr2` increases the error count and outputs a
If `expr1 == expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
@@ -84,11 +107,106 @@ message containing both expressions.
BOOST_TEST_NE(expr1, expr2)
``
If `expr1 == expr2` increases the error count and outputs a
If `expr1 != expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_LT]
``
BOOST_TEST_LT(expr1, expr2)
``
If `expr1 < expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_LE]
``
BOOST_TEST_LE(expr1, expr2)
``
If `expr1 <= expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_GT]
``
BOOST_TEST_GT(expr1, expr2)
``
If `expr1 > expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_GE]
``
BOOST_TEST_GE(expr1, expr2)
``
If `expr1 >= expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_CSTR_EQ]
``
BOOST_TEST_CSTR_EQ(expr1, expr2)
``
Specialization of `BOOST_TEST_EQ` which interprets `expr1` and `expr2` as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) != 0`, increase the error count and output a message containing both expressions.
[endsect]
[section BOOST_TEST_CSTR_NE]
``
BOOST_TEST_CSTR_NE(expr1, expr2)
``
Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) == 0`, increase the error count and output a message containing both expressions.
[endsect]
[section BOOST_TEST_WITH]
``
BOOST_TEST_WITH(expr1, expr2, pred)
``
If `pred(expr1, expr2)` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_ALL_EQ]
``
BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2)
``
Compares the content of two sequences. If they have different sizes, or if any pairwise element differs, increases the error count and outputs a message containing at most 8 differing elements.
[endsect]
[section BOOST_TEST_ALL_WITH]
``
BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate)
``
Compares the content of two sequences. If they have different sizes, or if any pairwise element do not fulfill the binary predicate, increases the error count and outputs a message containing at most 8 differing elements.
[endsect]
[section BOOST_TEST_THROWS]
``
@@ -104,6 +222,20 @@ nothing and `expr` is not evaluated.
[endsect]
[section BOOST_TEST_NO_THROW]
``
BOOST_TEST_NO_THROW(expr)
``
If `BOOST_NO_EXCEPTIONS` is *not* defined and if `expr` throws an exception,
increases the error count and outputs a message containing the expression
and (if possible) the exception message.
If `BOOST_NO_EXCEPTIONS` is defined, `expr` is evaluated.
[endsect]
[section report_errors]
``
@@ -148,6 +280,7 @@ return a boolean value.
``
#define BOOST_TEST_TRAIT_TRUE((Trait)) /*unspecified*/
#define BOOST_TEST_TRAIT_FALSE((Trait)) /*unspecified*/
#define BOOST_TEST_TRAIT_SAME(Type1, Type2) /*unspecified*/
``
[endsect]
@@ -175,6 +308,20 @@ message containing `Trait`. Note the double set of parentheses.
[endsect]
[section BOOST_TEST_TRAIT_SAME]
``
BOOST_TEST_TRAIT_SAME(Type1, Type2)
``
If the two types are not the same, increases the error count and outputs a
message containing them. This macro requires that the compiler supports
variadic macros and `__VA_ARGS__`. (Note that unlike `BOOST_TEST_TRAIT_TRUE`
and `BOOST_TEST_TRAIT_FALSE`, this macro only requires a single set of
parentheses.)
[endsect]
[section Example]
``
@@ -192,6 +339,8 @@ int main()
{
BOOST_TEST_TRAIT_TRUE(( is_same<X<int, long>::type, int> ));
BOOST_TEST_TRAIT_SAME( X<int, long>::type, int );
return boost::report_errors();
}
``

163
doc/noinit_adaptor.qbk Normal file
View File

@@ -0,0 +1,163 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:noinit_adaptor noinit_adaptor]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/noinit_adaptor.hpp> provides the class
template `boost::noinit_adaptor` that converts any allocator into
one whose `construct(ptr)` performs default initialization via placement new,
and whose `destroy(ptr)` invokes `value_type` destructor directly.
[endsect]
[section Examples]
The following example shows use of this allocator adaptor to achieve default
initialization of elements of a trivial type, which are later assigned values.
```
#include <boost/core/noinit_adaptor.hpp>
#include <numeric>
#include <vector>
int main()
{
std::vector<int, boost::noinit_adaptor<std::allocator<int> > > v(5);
std::iota(v.begin(), v.end(), 1);
}
```
The `allocate_shared_noinit` function templates are now implemented simply
using `allocate_shared` with `noinit_adaptor`.
```
template<class T, class A>
enable_if_t<is_unbounded_array_v<T>, shared_ptr<T> >
allocate_shared_noinit(const A& a, size_t n)
{
return allocate_shared<T>(boost::noinit_adapt(a), n);
}
template<class T, class A>
enable_if_t<!is_unbounded_array_v<T>, shared_ptr<T> >
allocate_shared_noinit(const A& a)
{
return allocate_shared<T>(boost::noinit_adapt(a));
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class A>
struct noinit_adaptor
: A {
template<class U>
struct rebind {
typedef noinit_adaptor<allocator_rebind_t<A, U> > other;
};
noinit_adaptor() noexcept;
template<class U>
noinit_adaptor(U&& u) noexcept;
template<class U>
noinit_adaptor(const noinit_adaptor<U>& u) noexcept;
template<class U>
void construct(U* p);
template<class U>
void destroy(U* p);
};
template<class T, class U>
bool operator==(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) noexcept;
template<class T, class U>
bool operator!=(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) noexcept;
template<class A>
noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
} /* boost */
```
[section Constructors]
[variablelist
[[`noinit_adaptor() noexcept;`]
[[variablelist
[[Effects][Value initializes the A base class.]]]]]
[[`template<class U> noinit_adaptor(U&& u) noexcept;`]
[[variablelist
[[Requires][`A` shall be constructible from `U`.]]
[[Effects][Initializes the `A` base class with `std::forward<U>(u)`.]]]]]
[[`template<class U> noinit_adaptor(const noinit_adaptor<U>& u) noexcept;`]
[[variablelist
[[Requires][`A` shall be constructible from `U`.]]
[[Effects][Initializes the `A` base class with
`static_cast<const A&>(u)`.]]]]]]
[endsect]
[section Member functions]
[variablelist
[[`template<class U> void construct(U* p);`]
[[variablelist
[[Effects][`::new((void*)p) U`.]]]]]
[[`template<class U> void destroy(U* p);`]
[[variablelist
[[Effects][`p->~U()`.]]]]]]
[endsect]
[section Operators]
[variablelist
[[`template<class T, class U> constexpr bool
operator==(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) noexcept;`]
[[variablelist
[[Returns][`static_cast<const T&>(lhs) == static_cast<const U&>(rhs)`.]]]]]
[[`template<class T, class U> constexpr bool
operator!=(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) noexcept;`]
[[variablelist
[[Returns][`!(lhs == rhs)`.]]]]]]
[endsect]
[section Free functions]
[variablelist
[[`template<class A> noinit_adaptor<A> noinit_adapt(const A& a) noexcept;`]
[[variablelist
[[Returns][`noinit_adaptor<A>(a)`.]]]]]]
[endsect]
[endsect]
[endsect]

View File

@@ -18,9 +18,9 @@
[section Header <boost/core/noncopyable.hpp>]
The header `<boost/noncopyable.hpp>` defines the class
The header `<boost/core/noncopyable.hpp>` defines the class
`boost::noncopyable`. It is intended to be used as a private
base. `boost::noncopyable` has private (under C++03) or
base class. `boost::noncopyable` has private (under C++03) or
deleted (under C++11) copy constructor and a copy assignment
operator and can't be copied or assigned; a class that derives
from it inherits these properties.

108
doc/nvp.qbk Normal file
View File

@@ -0,0 +1,108 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:nvp nvp]
[section Overview]
The header <boost/core/nvp.hpp> provides the class template `boost::nvp` that
pairs a name (`const char*`) with the address of a value (`T*`). It is the new
implementation of the NVP type previously provided by the Boost Serialization
library. This type now lives in the Core library so that other Boost libraries
can support named value serialization without taking a dependency on the
Serialization library.
[endsect]
[section Examples]
The following snippet shows use in a member serialize function:
```
template<class A>
void serialize(A& archive, unsigned)
{
archive & boost::make_nvp("x", x_) & boost::make_nvp("y", y_);
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class T>
class nvp {
public:
nvp(const char* name, T& value) noexcept;
const char* name() const noexcept;
T& value() const noexcept;
const T& const_value() const noexcept;
};
template<class T>
const nvp<T> make_nvp(const char* name, T& value) noexcept;
} /* boost */
#define BOOST_NVP(object) ``['see below]``
```
[section Constructors]
[variablelist
[[`nvp(const char* name, T& value) noexcept;`]
[Initializes the stored name pointer with `name` and the value pointer with
`addressof(value)`.]]]
[endsect]
[section Members]
[variablelist
[[`const char* name() const noexcept;`]
[Returns a pointer to the name.]]
[[`T& value() const noexcept;`]
[Returns a reference to the value.]]
[[`const T& const_value() const noexcept;`]
[Returns a reference to the value.]]]
[endsect]
[section Functions]
[variablelist
[[`template<class T> const nvp<T> make_nvp(const char* name, T& value)
noexcept;`]
[Returns `nvp<T>(name, value)`.]]]
[endsect]
[section Macros]
[variablelist
[[`#define BOOST_NVP(object) see below`]
[Expands to `boost::make_nvp(BOOST_STRINGIZE(object), object)`.]]]
[endsect]
[endsect]
[section History]
Robert Ramey originally implemented NVP in the Serialization library. Glen
Fernandes implemented this new (but compatible) version in the Core library.
[endsect]
[endsect]

152
doc/pointer_traits.qbk Normal file
View File

@@ -0,0 +1,152 @@
[/
Copyright 2017-2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:pointer_traits pointer_traits]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/pointer_traits.hpp> provides the class template
`boost::pointer_traits` to facilitate use of pointer-like types. The C++11
standard library introduced `std::pointer_traits` along with an allocator
model which supported pointer-like types in addition to plain raw pointers.
This implementation also supports C++98.
It also provides the function template `boost::to_address` to obtain a raw
pointer from an object of any pointer-like type.
[endsect]
[section Examples]
The following example allocates storage and constructs an object in that
storage using an allocator.
```
template<class Allocator>
void function(Allocator& a)
{
auto p = a.allocate(1);
std::allocator_traits<Allocator>::construct(a, boost::to_address(p));
}
```
[endsect]
[section Reference]
```
namespace boost {
template<class T> struct pointer_traits {
typedef T pointer;
typedef ``['see below]`` element_type;
typedef ``['see below]`` difference_type;
template<class U> struct rebind_to { typedef ``['see below]`` type; };
template<class U> using rebind = typename rebind_to<U>::type;
static pointer pointer_to(``['see below]`` v);
};
template<class T> struct pointer_traits<T*> {
typedef T* pointer;
typedef T element_type;
typedef std::ptrdiff_t difference_type;
template<class U> struct rebind_to { typedef U* type; };
template<class U> using rebind = typename rebind_to<U>::type;
static pointer pointer_to(``['see below]`` v) noexcept;
};
template<class T>
constexpr T* to_address(T* v) noexcept;
template<class T>
auto to_address(const T& v) noexcept;
}
```
[section Member types]
[variablelist
[[`typedef` ['see below] `element_type;`]
[`T::element_type` if such a type exists; otherwise `U` if `T` is a class
template instantiation of the form `Pointer<U, Args>`, where `Args` is zero
or more type arguments; otherwise the specialization is ill-formed.]]
[[`typedef` ['see below] `difference_type;`]
[`T::difference_type` if such a type exists; otherwise `std::ptrdiff_t`.]]
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
[`type` is `T::rebind<U>` if such a type exists; otherwise, `Pointer<V, Args>`
if `T` is a class template instantiation of the form `Pointer<T, Args>`,
where `Args` is zero or more type arguments; otherwise, the instantiation of
`rebind_to` is ill-formed.]]]
[endsect]
[section Member functions]
[variablelist
[[`static pointer pointer_traits::pointer_to(`['see below] `v);`]
[[variablelist
[[Remark]
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
it is `element_type&`.]]
[[Returns]
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
[[`static pointer pointer_traits<T*>::pointer_to(`['see below] `v) noexcept;`]
[[variablelist
[[Remark]
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
it is `element_type&`.]]
[[Returns][`addressof(v)`.]]]]]]
[endsect]
[section Optional members]
[variablelist
[[`static element_type* to_address(pointer v) noexcept;`]
[[variablelist
[[Returns]
[A pointer of type `element_type*` that references the same location as the
argument `p`.]]
[[Note]
[This function should be the inverse of `pointer_to`. If defined, it
customizes the behavior of the non-member function `to_address`.]]]]]]
[endsect]
[section Free functions]
[variablelist
[[`template<class T> constexpr T* to_address(T* v) noexcept;`]
[[variablelist
[[Returns][`v`.]]]]]
[[`template<class T> auto to_address(const T& v) noexcept;`]
[[variablelist
[[Returns][`pointer_traits<T>::to_address(v)` if that
expression is well-formed, otherwise `to_address(v.operator->())`.]]]]]]
[endsect]
[endsect]
[section Acknowledgments]
Glen Fernandes implemented `pointer_traits` and `to_address` with reviews and
guidance from Peter Dimov.
[endsect]
[endsect]

40
doc/quick_exit.qbk Normal file
View File

@@ -0,0 +1,40 @@
[/
Copyright 2018 Peter Dimov
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
]
[section:quick_exit quick_exit]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/quick_exit.hpp>]
The header `<boost/core/quick_exit.hpp>` defines the function
`void boost::quick_exit(int code)`. It calls the standard C++11 function
[@https://en.cppreference.com/w/cpp/utility/program/quick_exit
`std::quick_exit(code)`], if that is available, and otherwise exits the
process via [@https://en.cppreference.com/w/cpp/utility/program/_Exit
`std::_Exit(code)`] or equivalent.
[section Synopsis]
``
namespace boost
{
[[noreturn]] void quick_exit(int code) noexcept;
}
``
[endsect]
[endsect]
[endsect]

View File

@@ -67,9 +67,9 @@ The enumeration can be forward declared:
BOOST_SCOPED_ENUM_FORWARD_DECLARE(future_errc);
There are however some limitations. First, the emulated scoped enum is not a C++ enum, so `is_enum< future_errc >` will be `false_type`.
There are however some limitations. The emulated scoped enum is not a C++ enum, so `is_enum< future_errc >` will be `false_type`.
Second, the emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some helpers. Instead of
The emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some helpers. Instead of
switch (ev)
{
@@ -99,10 +99,29 @@ use
{
};
Lastly, explicit conversion to the underlying type should be performed with `boost::underlying_cast` instead of `static_cast`:
Explicit conversion to the underlying type should be performed with `boost::underlying_cast` instead of `static_cast`:
unsigned int val = boost::underlying_cast< unsigned int >(ev);
In C++03, scoped enums behave differently in case of calling an overloaded function when one overload takes a scoped enum as a parameter, and the other takes a parameter of an integral type. Consider the following code:
enum enum_regular { REGULAR_A, REGULAR_B };
BOOST_SCOPED_ENUM_DECLARE_BEGIN(enum_scoped)
{
a, b
}
BOOST_SCOPED_ENUM_DECLARE_END(enum_scoped)
void regular_or_int(enum_regular); // (1)
void regular_or_int(int); // (2)
void scoped_or_int(enum_scoped); // (3)
void scoped_or_int(int); // (4)
regular_or_int(REGULAR_A); // calls (1) in C++03 and C++11
scoped_or_int(enum_scoped::a); // calls (3) in C++11 but (4) in C++03!
scoped_or_int(enum_scoped(enum_scoped::a)); // calls (3) in C++03 and C++11
Here is usage example:
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(algae, char)

View File

@@ -0,0 +1,52 @@
[/
/ Copyright (c) 2018 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)
/]
[section:uncaught_exceptions uncaught_exceptions]
[simplesect Authors]
* Andrey Semashev
[endsimplesect]
[section Header <boost/core/uncaught_exceptions.hpp>]
The header `<boost/core/uncaught_exceptions.hpp>` defines the `boost::core::uncaught_exceptions` function,
which is a more portable implementation of the same named function introduced in C++17. The function
returns the number of the currently pending exceptions. When that function returns a value greater than 0,
throwing an exception from a destructor can terminate the program.
Unfortunately, the function cannot be implemented on every pre-C++17 compiler, although the most commonly
used compilers are supported. When the compiler does not provide the necessary functionality,
`boost::core::uncaught_exceptions` returns a non-zero value if at least one exception is pending (i.e. not
necessarily the number of pending exceptions), and `BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED` macro
is defined.
[section Example]
``
class my_class
{
private:
const unsigned int m_exception_count;
public:
my_class() : m_exception_count(boost::core::uncaught_exceptions())
{
}
~my_class() noexcept(false)
{
if (m_exception_count == boost::core::uncaught_exceptions())
do_something_potentially_throwing();
}
};
``
[endsect]
[endsect]
[endsect]

47
doc/use_default.qbk Normal file
View File

@@ -0,0 +1,47 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:use_default use_default]
[section Overview]
The header <boost/core/use_default.hpp> provides the type `boost::use_default`
which is used by other Boost libraries as a sentinel type in a templates to
indicate defaults.
[endsect]
[section Example]
```
template<class Derived, class Base,
class Value = boost::use_default,
class CategoryOrTraversal = boost::use_default,
class Reference = boost::use_default,
class Difference = boost::use_default>
class iterator_adaptor;
template<class Value>
class node_iterator
: public iterator_adaptor<node_iterator<Value>, Value*,
boost::use_default, boost::forward_traversal_tag>;
```
[endsect]
[section Reference]
```
namespace boost {
struct use_default { };
}
```
[endsect]
[endsect]

View File

@@ -1,162 +1,274 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu)
//
// Copyright (C) 2002, 2008, 2013 Peter Dimov
//
// 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)
/*
Copyright (C) 2002 Brad King (brad.king@kitware.com)
Douglas Gregor (gregod@cs.rpi.edu)
// For more information, see http://www.boost.org
Copyright (C) 2002, 2008, 2013 Peter Dimov
Copyright (C) 2017 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)
*/
#ifndef BOOST_CORE_ADDRESSOF_HPP
#define BOOST_CORE_ADDRESSOF_HPP
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
# include <cstddef>
#include <boost/config.hpp>
namespace boost
#if defined(BOOST_MSVC_FULL_VER) && BOOST_MSVC_FULL_VER >= 190024215
#define BOOST_CORE_HAS_BUILTIN_ADDRESSOF
#elif defined(BOOST_GCC) && BOOST_GCC >= 70000
#define BOOST_CORE_HAS_BUILTIN_ADDRESSOF
#elif defined(__has_builtin)
#if __has_builtin(__builtin_addressof)
#define BOOST_CORE_HAS_BUILTIN_ADDRESSOF
#endif
#endif
#if defined(BOOST_CORE_HAS_BUILTIN_ADDRESSOF)
#if defined(BOOST_NO_CXX11_CONSTEXPR)
#define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF
#endif
namespace boost {
template<class T>
BOOST_CONSTEXPR inline T*
addressof(T& o) BOOST_NOEXCEPT
{
return __builtin_addressof(o);
}
namespace detail
{
template<class T> struct addr_impl_ref
{
T & v_;
BOOST_FORCEINLINE addr_impl_ref( T & v ): v_( v ) {}
BOOST_FORCEINLINE operator T& () const { return v_; }
private:
addr_impl_ref & operator=(const addr_impl_ref &);
};
template<class T> struct addressof_impl
{
static BOOST_FORCEINLINE T * f( T & v, long )
{
return reinterpret_cast<T*>(
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
static BOOST_FORCEINLINE T * f( T * v, int )
{
return v;
}
};
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) )
typedef decltype(nullptr) addr_nullptr_t;
} /* boost */
#else
#include <boost/config/workaround.hpp>
#include <cstddef>
typedef std::nullptr_t addr_nullptr_t;
namespace boost {
namespace detail {
template<class T>
class addrof_ref {
public:
BOOST_FORCEINLINE addrof_ref(T& o) BOOST_NOEXCEPT
: o_(o) { }
BOOST_FORCEINLINE operator T&() const BOOST_NOEXCEPT {
return o_;
}
private:
addrof_ref& operator=(const addrof_ref&);
T& o_;
};
template<class T>
struct addrof {
static BOOST_FORCEINLINE T* get(T& o, long) BOOST_NOEXCEPT {
return reinterpret_cast<T*>(&
const_cast<char&>(reinterpret_cast<const volatile char&>(o)));
}
static BOOST_FORCEINLINE T* get(T* p, int) BOOST_NOEXCEPT {
return p;
}
};
#if !defined(BOOST_NO_CXX11_NULLPTR)
#if !defined(BOOST_NO_CXX11_DECLTYPE) && \
(defined(__INTEL_COMPILER) || \
(defined(__clang__) && !defined(_LIBCPP_VERSION)))
typedef decltype(nullptr) addrof_null_t;
#else
typedef std::nullptr_t addrof_null_t;
#endif
template<> struct addressof_impl< addr_nullptr_t >
{
typedef addr_nullptr_t T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
template<>
struct addrof<addrof_null_t> {
typedef addrof_null_t type;
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
return &o;
}
};
template<> struct addressof_impl< addr_nullptr_t const >
{
typedef addr_nullptr_t const T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
template<>
struct addrof<const addrof_null_t> {
typedef const addrof_null_t type;
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
return &o;
}
};
template<> struct addressof_impl< addr_nullptr_t volatile >
{
typedef addr_nullptr_t volatile T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
template<>
struct addrof<volatile addrof_null_t> {
typedef volatile addrof_null_t type;
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
return &o;
}
};
template<> struct addressof_impl< addr_nullptr_t const volatile >
{
typedef addr_nullptr_t const volatile T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
template<>
struct addrof<const volatile addrof_null_t> {
typedef const volatile addrof_null_t type;
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
return &o;
}
};
#endif
} // namespace detail
} /* detail */
#if defined(BOOST_NO_CXX11_SFINAE_EXPR) || \
defined(BOOST_NO_CXX11_CONSTEXPR) || \
defined(BOOST_NO_CXX11_DECLTYPE)
#define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF
template<class T>
BOOST_FORCEINLINE T*
addressof(T& o) BOOST_NOEXCEPT
{
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) || \
BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
return boost::detail::addrof<T>::get(o, 0);
#else
return boost::detail::addrof<T>::get(boost::detail::addrof_ref<T>(o), 0);
#endif
}
#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
namespace detail {
template<class T>
struct addrof_result {
typedef T* type;
};
} /* detail */
template<class T, std::size_t N>
BOOST_FORCEINLINE typename boost::detail::addrof_result<T[N]>::type
addressof(T (&o)[N]) BOOST_NOEXCEPT
{
return &o;
}
#endif
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
template<class T, std::size_t N>
BOOST_FORCEINLINE
T (*addressof(T (&o)[N]) BOOST_NOEXCEPT)[N]
{
return reinterpret_cast<T(*)[N]>(&o);
}
template<class T, std::size_t N>
BOOST_FORCEINLINE
const T (*addressof(const T (&o)[N]) BOOST_NOEXCEPT)[N]
{
return reinterpret_cast<const T(*)[N]>(&o);
}
#endif
#else
namespace detail {
template<class T>
T addrof_declval() BOOST_NOEXCEPT;
template<class>
struct addrof_void {
typedef void type;
};
template<class T, class E = void>
struct addrof_member_operator {
static constexpr bool value = false;
};
template<class T>
struct addrof_member_operator<T, typename
addrof_void<decltype(addrof_declval<T&>().operator&())>::type> {
static constexpr bool value = true;
};
#if BOOST_WORKAROUND(BOOST_INTEL, < 1600)
struct addrof_addressable { };
addrof_addressable*
operator&(addrof_addressable&) BOOST_NOEXCEPT;
#endif
template<class T, class E = void>
struct addrof_non_member_operator {
static constexpr bool value = false;
};
template<class T>
struct addrof_non_member_operator<T, typename
addrof_void<decltype(operator&(addrof_declval<T&>()))>::type> {
static constexpr bool value = true;
};
template<class T, class E = void>
struct addrof_expression {
static constexpr bool value = false;
};
template<class T>
struct addrof_expression<T,
typename addrof_void<decltype(&addrof_declval<T&>())>::type> {
static constexpr bool value = true;
};
template<class T>
struct addrof_is_constexpr {
static constexpr bool value = addrof_expression<T>::value &&
!addrof_member_operator<T>::value &&
!addrof_non_member_operator<T>::value;
};
template<bool E, class T>
struct addrof_if { };
template<class T>
struct addrof_if<true, T> {
typedef T* type;
};
template<class T>
BOOST_FORCEINLINE
T * addressof( T & v )
typename addrof_if<!addrof_is_constexpr<T>::value, T>::type
addressof(T& o) BOOST_NOEXCEPT
{
#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120))
return boost::detail::addressof_impl<T>::f( v, 0 );
#else
return boost::detail::addressof_impl<T>::f( boost::detail::addr_impl_ref<T>( v ), 0 );
#endif
return addrof<T>::get(addrof_ref<T>(o), 0);
}
#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) )
namespace detail
template<class T>
constexpr BOOST_FORCEINLINE
typename addrof_if<addrof_is_constexpr<T>::value, T>::type
addressof(T& o) BOOST_NOEXCEPT
{
template<class T> struct addressof_addp
{
typedef T * type;
};
} // namespace detail
template< class T, std::size_t N >
BOOST_FORCEINLINE
typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
{
return &t;
return &o;
}
#endif
} /* detail */
// Borland doesn't like casting an array reference to a char reference
// but these overloads work around the problem.
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template<typename T,std::size_t N>
BOOST_FORCEINLINE
T (*addressof(T (&t)[N]))[N]
template<class T>
constexpr BOOST_FORCEINLINE T*
addressof(T& o) BOOST_NOEXCEPT
{
return reinterpret_cast<T(*)[N]>(&t);
}
template<typename T,std::size_t N>
BOOST_FORCEINLINE
const T (*addressof(const T (&t)[N]))[N]
{
return reinterpret_cast<const T(*)[N]>(&t);
return boost::detail::addressof(o);
}
#endif
} // namespace boost
} /* boost */
#endif
#endif // BOOST_CORE_ADDRESSOF_HPP
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
namespace boost {
template<class T>
const T* addressof(const T&&) = delete;
} /* boost */
#endif
#endif

View File

@@ -0,0 +1,169 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP
#define BOOST_CORE_ALLOC_CONSTRUCT_HPP
#include <boost/core/noinit_adaptor.hpp>
namespace boost {
template<class A, class T>
inline void
alloc_destroy(A& a, T* p)
{
boost::allocator_destroy(a, p);
}
template<class A, class T>
inline void
alloc_destroy_n(A& a, T* p, std::size_t n)
{
while (n > 0) {
boost::allocator_destroy(a, p + --n);
}
}
template<class A, class T>
inline void
alloc_destroy(noinit_adaptor<A>&, T* p)
{
p->~T();
}
template<class A, class T>
inline void
alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n)
{
while (n > 0) {
p[--n].~T();
}
}
namespace detail {
template<class A, class T>
class alloc_destroyer {
public:
alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT
: a_(a),
p_(p),
n_(0) { }
~alloc_destroyer() {
boost::alloc_destroy_n(a_, p_, n_);
}
std::size_t& size() BOOST_NOEXCEPT {
return n_;
}
private:
alloc_destroyer(const alloc_destroyer&);
alloc_destroyer& operator=(const alloc_destroyer&);
A& a_;
T* p_;
std::size_t n_;
};
} /* detail */
template<class A, class T>
inline void
alloc_construct(A& a, T* p)
{
boost::allocator_construct(a, p);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class A, class T, class U, class... V>
inline void
alloc_construct(A& a, T* p, U&& u, V&&... v)
{
boost::allocator_construct(a, p, std::forward<U>(u),
std::forward<V>(v)...);
}
#else
template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, U&& u)
{
boost::allocator_construct(a, p, std::forward<U>(u));
}
#endif
#else
template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, const U& u)
{
boost::allocator_construct(a, p, u);
}
template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, U& u)
{
boost::allocator_construct(a, p, u);
}
#endif
template<class A, class T>
inline void
alloc_construct_n(A& a, T* p, std::size_t n)
{
detail::alloc_destroyer<A, T> hold(a, p);
for (std::size_t& i = hold.size(); i < n; ++i) {
boost::allocator_construct(a, p + i);
}
hold.size() = 0;
}
template<class A, class T>
inline void
alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
{
detail::alloc_destroyer<A, T> hold(a, p);
for (std::size_t& i = hold.size(); i < n; ++i) {
boost::allocator_construct(a, p + i, l[i % m]);
}
hold.size() = 0;
}
template<class A, class T, class I>
inline void
alloc_construct_n(A& a, T* p, std::size_t n, I b)
{
detail::alloc_destroyer<A, T> hold(a, p);
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
boost::allocator_construct(a, p + i, *b);
}
hold.size() = 0;
}
template<class A, class T>
inline void
alloc_construct(noinit_adaptor<A>&, T* p)
{
::new(static_cast<void*>(p)) T;
}
template<class A, class T>
inline void
alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
{
detail::alloc_destroyer<noinit_adaptor<A>, T> hold(a, p);
for (std::size_t& i = hold.size(); i < n; ++i) {
::new(static_cast<void*>(p + i)) T;
}
hold.size() = 0;
}
} /* boost */
#endif

View File

@@ -0,0 +1,601 @@
/*
Copyright 2020-2021 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/core/pointer_traits.hpp>
#include <limits>
#include <type_traits>
#endif
#include <new>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
#endif
#if defined(_STL_DISABLE_DEPRECATED_WARNING)
_STL_DISABLE_DEPRECATED_WARNING
#endif
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996)
#endif
namespace boost {
template<class A>
struct allocator_value_type {
typedef typename A::value_type type;
};
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_pointer {
typedef typename A::pointer type;
};
#else
template<class A, class = void>
struct allocator_pointer {
typedef typename A::value_type* type;
};
namespace detail {
template<class>
struct alloc_void {
typedef void type;
};
} /* detail */
template<class A>
struct allocator_pointer<A,
typename detail::alloc_void<typename A::pointer>::type> {
typedef typename A::pointer type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_const_pointer {
typedef typename A::const_pointer type;
};
#else
template<class A, class = void>
struct allocator_const_pointer {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::template
rebind_to<const typename A::value_type>::type type;
};
template<class A>
struct allocator_const_pointer<A,
typename detail::alloc_void<typename A::const_pointer>::type> {
typedef typename A::const_pointer type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_void_pointer {
typedef typename A::template rebind<void>::other::pointer type;
};
#else
template<class A, class = void>
struct allocator_void_pointer {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::template
rebind_to<void>::type type;
};
template<class A>
struct allocator_void_pointer<A,
typename detail::alloc_void<typename A::void_pointer>::type> {
typedef typename A::void_pointer type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_const_void_pointer {
typedef typename A::template rebind<void>::other::const_pointer type;
};
#else
template<class A, class = void>
struct allocator_const_void_pointer {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::template
rebind_to<const void>::type type;
};
template<class A>
struct allocator_const_void_pointer<A,
typename detail::alloc_void<typename A::const_void_pointer>::type> {
typedef typename A::const_void_pointer type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_difference_type {
typedef typename A::difference_type type;
};
#else
template<class A, class = void>
struct allocator_difference_type {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::difference_type type;
};
template<class A>
struct allocator_difference_type<A,
typename detail::alloc_void<typename A::difference_type>::type> {
typedef typename A::difference_type type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_size_type {
typedef typename A::size_type type;
};
#else
template<class A, class = void>
struct allocator_size_type {
typedef typename std::make_unsigned<typename
allocator_difference_type<A>::type>::type type;
};
template<class A>
struct allocator_size_type<A,
typename detail::alloc_void<typename A::size_type>::type> {
typedef typename A::size_type type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
namespace detail {
struct alloc_false {
BOOST_STATIC_CONSTEXPR bool value = false;
};
} /* detail */
template<class A>
struct allocator_propagate_on_container_copy_assignment {
typedef detail::alloc_false type;
};
#else
template<class A, class = void>
struct allocator_propagate_on_container_copy_assignment {
typedef std::false_type type;
};
template<class A>
struct allocator_propagate_on_container_copy_assignment<A,
typename detail::alloc_void<typename
A::propagate_on_container_copy_assignment>::type> {
typedef typename A::propagate_on_container_copy_assignment type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_propagate_on_container_move_assignment {
typedef detail::alloc_false type;
};
#else
template<class A, class = void>
struct allocator_propagate_on_container_move_assignment {
typedef std::false_type type;
};
template<class A>
struct allocator_propagate_on_container_move_assignment<A,
typename detail::alloc_void<typename
A::propagate_on_container_move_assignment>::type> {
typedef typename A::propagate_on_container_move_assignment type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_propagate_on_container_swap {
typedef detail::alloc_false type;
};
#else
template<class A, class = void>
struct allocator_propagate_on_container_swap {
typedef std::false_type type;
};
template<class A>
struct allocator_propagate_on_container_swap<A,
typename detail::alloc_void<typename
A::propagate_on_container_swap>::type> {
typedef typename A::propagate_on_container_swap type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
struct allocator_is_always_equal {
typedef detail::alloc_false type;
};
#else
template<class A, class = void>
struct allocator_is_always_equal {
typedef typename std::is_empty<A>::type type;
};
template<class A>
struct allocator_is_always_equal<A,
typename detail::alloc_void<typename A::is_always_equal>::type> {
typedef typename A::is_always_equal type;
};
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class T>
struct allocator_rebind {
typedef typename A::template rebind<T>::other type;
};
#else
namespace detail {
template<class, class>
struct alloc_to { };
template<template<class, class...> class A, class T, class U, class... V>
struct alloc_to<A<U, V...>, T> {
typedef A<T, V...> type;
};
} /* detail */
template<class A, class T, class = void>
struct allocator_rebind {
typedef typename detail::alloc_to<A, T>::type type;
};
template<class A, class T>
struct allocator_rebind<A, T,
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
typedef typename A::template rebind<T>::other type;
};
#endif
template<class A>
inline typename allocator_pointer<A>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n)
{
return a.allocate(n);
}
template<class A>
inline void
allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
typename allocator_size_type<A>::type n)
{
a.deallocate(p, n);
}
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
inline typename allocator_pointer<A>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
typename allocator_const_void_pointer<A>::type h)
{
return a.allocate(n, h);
}
#else
namespace detail {
struct alloc_none { };
template<class A>
class alloc_has_allocate {
template<class O>
static auto check(int) -> decltype(std::declval<O&>().allocate(
std::declval<typename allocator_size_type<A>::type>(),
std::declval<typename allocator_const_void_pointer<A>::type>()));
template<class>
static alloc_none check(long);
public:
BOOST_STATIC_CONSTEXPR bool value =
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
};
} /* detail */
template<class A>
inline typename std::enable_if<detail::alloc_has_allocate<A>::value,
typename allocator_pointer<A>::type>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
typename allocator_const_void_pointer<A>::type h)
{
return a.allocate(n, h);
}
template<class A>
inline typename std::enable_if<!detail::alloc_has_allocate<A>::value,
typename allocator_pointer<A>::type>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
typename allocator_const_void_pointer<A>::type)
{
return a.allocate(n);
}
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class T>
inline void
allocator_construct(A&, T* p)
{
::new((void*)p) T();
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class A, class T, class V, class... Args>
inline void
allocator_construct(A&, T* p, V&& v, Args&&... args)
{
::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...);
}
#else
template<class A, class T, class V>
inline void
allocator_construct(A&, T* p, V&& v)
{
::new((void*)p) T(std::forward<V>(v));
}
#endif
#else
template<class A, class T, class V>
inline void
allocator_construct(A&, T* p, const V& v)
{
::new((void*)p) T(v);
}
template<class A, class T, class V>
inline void
allocator_construct(A&, T* p, V& v)
{
::new((void*)p) T(v);
}
#endif
#else
namespace detail {
template<class A, class T, class... Args>
class alloc_has_construct {
template<class O>
static auto check(int)
-> decltype(std::declval<O&>().construct(std::declval<T*>(),
std::declval<Args&&>()...));
template<class>
static alloc_none check(long);
public:
BOOST_STATIC_CONSTEXPR bool value =
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
};
} /* detail */
template<class A, class T, class... Args>
inline typename std::enable_if<detail::alloc_has_construct<A, T,
Args...>::value>::type
allocator_construct(A& a, T* p, Args&&... args)
{
a.construct(p, std::forward<Args>(args)...);
}
template<class A, class T, class... Args>
inline typename std::enable_if<!detail::alloc_has_construct<A, T,
Args...>::value>::type
allocator_construct(A&, T* p, Args&&... args)
{
::new((void*)p) T(std::forward<Args>(args)...);
}
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class T>
inline void
allocator_destroy(A&, T* p)
{
p->~T();
(void)p;
}
#else
namespace detail {
template<class A, class T>
class alloc_has_destroy {
template<class O>
static auto check(int)
-> decltype(std::declval<O&>().destroy(std::declval<T*>()));
template<class>
static alloc_none check(long);
public:
BOOST_STATIC_CONSTEXPR bool value =
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
};
} /* detail */
template<class A, class T>
inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type
allocator_destroy(A& a, T* p)
{
a.destroy(p);
}
template<class A, class T>
inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type
allocator_destroy(A&, T* p)
{
p->~T();
(void)p;
}
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
inline typename allocator_size_type<A>::type
allocator_max_size(const A& a)
{
return a.max_size();
}
#else
namespace detail {
template<class A>
class alloc_has_max_size {
template<class O>
static auto check(int) -> decltype(std::declval<O&>().max_size());
template<class>
static alloc_none check(long);
public:
BOOST_STATIC_CONSTEXPR bool value =
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
};
} /* detail */
template<class A>
inline typename std::enable_if<detail::alloc_has_max_size<A>::value,
typename allocator_size_type<A>::type>::type
allocator_max_size(const A& a)
{
return a.max_size();
}
template<class A>
inline typename std::enable_if<!detail::alloc_has_max_size<A>::value,
typename allocator_size_type<A>::type>::type
allocator_max_size(const A&)
{
return (std::numeric_limits<typename
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
}
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
inline A
allocator_select_on_container_copy_construction(const A& a)
{
return a;
}
#else
namespace detail {
template<class A>
class alloc_has_soccc {
template<class O>
static auto check(int)
-> decltype(std::declval<O&>().select_on_container_copy_construction());
template<class>
static alloc_none check(long);
public:
BOOST_STATIC_CONSTEXPR bool value =
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
};
} /* detail */
template<class A>
inline typename std::enable_if<detail::alloc_has_soccc<A>::value, A>::type
allocator_select_on_container_copy_construction(const A& a)
{
return a.select_on_container_copy_construction();
}
template<class A>
inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type
allocator_select_on_container_copy_construction(const A& a)
{
return a;
}
#endif
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class A>
using allocator_value_type_t = typename allocator_value_type<A>::type;
template<class A>
using allocator_pointer_t = typename allocator_pointer<A>::type;
template<class A>
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
template<class A>
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
template<class A>
using allocator_const_void_pointer_t =
typename allocator_const_void_pointer<A>::type;
template<class A>
using allocator_difference_type_t =
typename allocator_difference_type<A>::type;
template<class A>
using allocator_size_type_t = typename allocator_size_type<A>::type;
template<class A>
using allocator_propagate_on_container_copy_assignment_t =
typename allocator_propagate_on_container_copy_assignment<A>::type;
template<class A>
using allocator_propagate_on_container_move_assignment_t =
typename allocator_propagate_on_container_move_assignment<A>::type;
template<class A>
using allocator_propagate_on_container_swap_t =
typename allocator_propagate_on_container_swap<A>::type;
template<class A>
using allocator_is_always_equal_t =
typename allocator_is_always_equal<A>::type;
template<class A, class T>
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
#endif
} /* boost */
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_POP)
_LIBCPP_SUPPRESS_DEPRECATED_POP
#endif
#if defined(_STL_RESTORE_DEPRECATED_WARNING)
_STL_RESTORE_DEPRECATED_WARNING
#endif
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif

581
include/boost/core/bit.hpp Normal file
View File

@@ -0,0 +1,581 @@
#ifndef BOOST_CORE_BIT_HPP_INCLUDED
#define BOOST_CORE_BIT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/core/bit.hpp
//
// A portable version of the C++20 standard header <bit>
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <limits>
#include <cstring>
#if defined(_MSC_VER)
# include <intrin.h>
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# if defined(_M_X64)
# pragma intrinsic(_BitScanForward64)
# pragma intrinsic(_BitScanReverse64)
# endif
#endif // defined(_MSC_VER)
namespace boost
{
namespace core
{
// bit_cast
template<class To, class From>
To bit_cast( From const & from ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(To) == sizeof(From) );
To to;
std::memcpy( &to, &from, sizeof(To) );
return to;
}
// countl
#if defined(__GNUC__) || defined(__clang__)
namespace detail
{
BOOST_CONSTEXPR inline int countl_impl( unsigned char x ) BOOST_NOEXCEPT
{
return x? __builtin_clz( x ) - ( std::numeric_limits<unsigned int>::digits - std::numeric_limits<unsigned char>::digits ): std::numeric_limits<unsigned char>::digits;
}
BOOST_CONSTEXPR inline int countl_impl( unsigned short x ) BOOST_NOEXCEPT
{
return x? __builtin_clz( x ) - ( std::numeric_limits<unsigned int>::digits - std::numeric_limits<unsigned short>::digits ): std::numeric_limits<unsigned short>::digits;
}
BOOST_CONSTEXPR inline int countl_impl( unsigned int x ) BOOST_NOEXCEPT
{
return x? __builtin_clz( x ): std::numeric_limits<unsigned int>::digits;
}
BOOST_CONSTEXPR inline int countl_impl( unsigned long x ) BOOST_NOEXCEPT
{
return x? __builtin_clzl( x ): std::numeric_limits<unsigned long>::digits;
}
BOOST_CONSTEXPR inline int countl_impl( unsigned long long x ) BOOST_NOEXCEPT
{
return x? __builtin_clzll( x ): std::numeric_limits<unsigned long long>::digits;
}
} // namespace detail
template<class T>
BOOST_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
{
return boost::core::detail::countl_impl( x );
}
#else // defined(__GNUC__) || defined(__clang__)
namespace detail
{
inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER)
unsigned long r;
if( _BitScanReverse( &r, x ) )
{
return 31 - static_cast<int>( r );
}
else
{
return 32;
}
#else
static unsigned char const mod37[ 37 ] = { 32, 31, 6, 30, 9, 5, 0, 29, 16, 8, 2, 4, 21, 0, 19, 28, 25, 15, 0, 7, 10, 1, 17, 3, 22, 20, 26, 0, 11, 18, 23, 27, 12, 24, 13, 14, 0 };
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return mod37[ x % 37 ];
#endif
}
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER) && defined(_M_X64)
unsigned long r;
if( _BitScanReverse64( &r, x ) )
{
return 63 - static_cast<int>( r );
}
else
{
return 64;
}
#else
return static_cast<boost::uint32_t>( x >> 32 ) != 0?
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ):
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32;
#endif
}
inline int countl_impl( boost::uint8_t x ) BOOST_NOEXCEPT
{
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 24;
}
inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
{
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 16;
}
} // namespace detail
template<class T>
int countl_zero( T x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
if( sizeof(T) == sizeof(boost::uint8_t) )
{
return boost::core::detail::countl_impl( static_cast<boost::uint8_t>( x ) );
}
else if( sizeof(T) == sizeof(boost::uint16_t) )
{
return boost::core::detail::countl_impl( static_cast<boost::uint16_t>( x ) );
}
else if( sizeof(T) == sizeof(boost::uint32_t) )
{
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) );
}
else
{
return boost::core::detail::countl_impl( static_cast<boost::uint64_t>( x ) );
}
}
#endif // defined(__GNUC__) || defined(__clang__)
template<class T>
BOOST_CONSTEXPR int countl_one( T x ) BOOST_NOEXCEPT
{
return boost::core::countl_zero( static_cast<T>( ~x ) );
}
// countr
#if defined(__GNUC__) || defined(__clang__)
namespace detail
{
BOOST_CONSTEXPR inline int countr_impl( unsigned char x ) BOOST_NOEXCEPT
{
return x? __builtin_ctz( x ): std::numeric_limits<unsigned char>::digits;
}
BOOST_CONSTEXPR inline int countr_impl( unsigned short x ) BOOST_NOEXCEPT
{
return x? __builtin_ctz( x ): std::numeric_limits<unsigned short>::digits;
}
BOOST_CONSTEXPR inline int countr_impl( unsigned int x ) BOOST_NOEXCEPT
{
return x? __builtin_ctz( x ): std::numeric_limits<unsigned int>::digits;
}
BOOST_CONSTEXPR inline int countr_impl( unsigned long x ) BOOST_NOEXCEPT
{
return x? __builtin_ctzl( x ): std::numeric_limits<unsigned long>::digits;
}
BOOST_CONSTEXPR inline int countr_impl( unsigned long long x ) BOOST_NOEXCEPT
{
return x? __builtin_ctzll( x ): std::numeric_limits<unsigned long long>::digits;
}
} // namespace detail
template<class T>
BOOST_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
{
return boost::core::detail::countr_impl( x );
}
#else // defined(__GNUC__) || defined(__clang__)
namespace detail
{
inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER)
unsigned long r;
if( _BitScanForward( &r, x ) )
{
return static_cast<int>( r );
}
else
{
return 32;
}
#else
static unsigned char const mod37[ 37 ] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };
return mod37[ ( -(boost::int32_t)x & x ) % 37 ];
#endif
}
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER) && defined(_M_X64)
unsigned long r;
if( _BitScanForward64( &r, x ) )
{
return static_cast<int>( r );
}
else
{
return 64;
}
#else
return static_cast<boost::uint32_t>( x ) != 0?
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ):
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32;
#endif
}
inline int countr_impl( boost::uint8_t x ) BOOST_NOEXCEPT
{
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x100 );
}
inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
{
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x10000 );
}
} // namespace detail
template<class T>
int countr_zero( T x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
if( sizeof(T) == sizeof(boost::uint8_t) )
{
return boost::core::detail::countr_impl( static_cast<boost::uint8_t>( x ) );
}
else if( sizeof(T) == sizeof(boost::uint16_t) )
{
return boost::core::detail::countr_impl( static_cast<boost::uint16_t>( x ) );
}
else if( sizeof(T) == sizeof(boost::uint32_t) )
{
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) );
}
else
{
return boost::core::detail::countr_impl( static_cast<boost::uint64_t>( x ) );
}
}
#endif // defined(__GNUC__) || defined(__clang__)
template<class T>
BOOST_CONSTEXPR int countr_one( T x ) BOOST_NOEXCEPT
{
return boost::core::countr_zero( static_cast<T>( ~x ) );
}
// popcount
#if defined(__GNUC__) || defined(__clang__)
#if defined(__clang__) && __clang_major__ * 100 + __clang_minor__ < 304
# define BOOST_CORE_POPCOUNT_CONSTEXPR
#else
# define BOOST_CORE_POPCOUNT_CONSTEXPR BOOST_CONSTEXPR
#endif
namespace detail
{
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned char x ) BOOST_NOEXCEPT
{
return __builtin_popcount( x );
}
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned short x ) BOOST_NOEXCEPT
{
return __builtin_popcount( x );
}
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned int x ) BOOST_NOEXCEPT
{
return __builtin_popcount( x );
}
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long x ) BOOST_NOEXCEPT
{
return __builtin_popcountl( x );
}
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long long x ) BOOST_NOEXCEPT
{
return __builtin_popcountll( x );
}
} // namespace detail
#undef BOOST_CORE_POPCOUNT_CONSTEXPR
template<class T>
BOOST_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
{
return boost::core::detail::popcount_impl( x );
}
#else // defined(__GNUC__) || defined(__clang__)
namespace detail
{
BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint32_t x ) BOOST_NOEXCEPT
{
x = x - ( ( x >> 1 ) & 0x55555555 );
x = ( x & 0x33333333 ) + ( ( x >> 2 ) & 0x33333333 );
x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F;
return static_cast<unsigned>( ( x * 0x01010101 ) >> 24 );
}
BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint64_t x ) BOOST_NOEXCEPT
{
x = x - ( ( x >> 1 ) & 0x5555555555555555 );
x = ( x & 0x3333333333333333 ) + ( ( x >> 2 ) & 0x3333333333333333 );
x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F0F0F0F0F;
return static_cast<unsigned>( ( x * 0x0101010101010101 ) >> 56 );
}
} // namespace detail
template<class T>
BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
if( sizeof(T) <= sizeof(boost::uint32_t) )
{
return boost::core::detail::popcount_impl( static_cast<boost::uint32_t>( x ) );
}
else
{
return boost::core::detail::popcount_impl( static_cast<boost::uint64_t>( x ) );
}
}
#endif // defined(__GNUC__) || defined(__clang__)
// rotating
template<class T>
BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT
{
unsigned const mask = std::numeric_limits<T>::digits - 1;
return x << (s & mask) | x >> ((-s) & mask);
}
template<class T>
BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT
{
unsigned const mask = std::numeric_limits<T>::digits - 1;
return x >> (s & mask) | x << ((-s) & mask);
}
// integral powers of 2
template<class T>
BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
{
return x != 0 && ( x & ( x - 1 ) ) == 0;
}
template<class T>
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
{
return std::numeric_limits<T>::digits - boost::core::countl_zero( x );
}
template<class T>
BOOST_CONSTEXPR T bit_floor( T x ) BOOST_NOEXCEPT
{
return x == 0? 0: T(1) << ( boost::core::bit_width( x ) - 1 );
}
namespace detail
{
BOOST_CXX14_CONSTEXPR inline boost::uint32_t bit_ceil_impl( boost::uint32_t x ) BOOST_NOEXCEPT
{
if( x == 0 )
{
return 0;
}
--x;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
++x;
return x;
}
BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x ) BOOST_NOEXCEPT
{
if( x == 0 )
{
return 0;
}
--x;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
x |= x >> 32;
++x;
return x;
}
} // namespace detail
template<class T>
BOOST_CXX14_CONSTEXPR T bit_ceil( T x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
if( sizeof(T) <= sizeof(boost::uint32_t) )
{
return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint32_t>( x ) ) );
}
else
{
return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint64_t>( x ) ) );
}
}
// endian
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =big
#elif defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
# define BOOST_CORE_BIT_NATIVE_INITIALIZER
#elif defined(__LITTLE_ENDIAN__)
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little
#elif defined(__BIG_ENDIAN__)
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =big
#elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__)
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little
#else
# define BOOST_CORE_BIT_NATIVE_INITIALIZER
#endif
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
enum class endian
{
big,
little,
native BOOST_CORE_BIT_NATIVE_INITIALIZER
};
typedef endian endian_type;
#else
namespace endian
{
enum type
{
big,
little,
native BOOST_CORE_BIT_NATIVE_INITIALIZER
};
} // namespace endian
typedef endian::type endian_type;
#endif
#undef BOOST_CORE_BIT_NATIVE_INITIALIZER
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_BIT_HPP_INCLUDED

View File

@@ -7,6 +7,8 @@
# pragma once
#endif
#include <boost/config.hpp>
//
// boost/checked_delete.hpp
//
@@ -26,7 +28,7 @@ namespace boost
// verify that types are complete for increased safety
template<class T> inline void checked_delete(T * x)
template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
{
// intentionally complex - simplification causes regressions
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
@@ -34,7 +36,7 @@ template<class T> inline void checked_delete(T * x)
delete x;
}
template<class T> inline void checked_array_delete(T * x)
template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
{
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
(void) sizeof(type_must_be_complete);
@@ -46,7 +48,7 @@ template<class T> struct checked_deleter
typedef void result_type;
typedef T * argument_type;
void operator()(T * x) const
void operator()(T * x) const BOOST_NOEXCEPT
{
// boost:: disables ADL
boost::checked_delete(x);
@@ -58,7 +60,7 @@ template<class T> struct checked_array_deleter
typedef void result_type;
typedef T * argument_type;
void operator()(T * x) const
void operator()(T * x) const BOOST_NOEXCEPT
{
boost::checked_array_delete(x);
}

View File

@@ -0,0 +1,199 @@
#ifndef BOOST_CORE_CMATH_HPP_INCLUDED
#define BOOST_CORE_CMATH_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/core/cmath.hpp
//
// Floating point classification and sign manipulation functions
// Extracted from https://github.com/boostorg/lexical_cast/pull/37
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <cmath>
#if defined(_MSC_VER) && _MSC_VER < 1800
# include <float.h>
#endif
namespace boost
{
namespace core
{
#if defined(_MSC_VER) && _MSC_VER < 1800
template<class T> T copysign( T x, T y )
{
return static_cast<T>( _copysign( static_cast<double>( x ), static_cast<double>( y ) ) );
}
template<class T> bool isnan( T x )
{
return _isnan( static_cast<double>( x ) ) != 0;
}
template<class T> bool isfinite( T x )
{
return _finite( static_cast<double>( x ) ) != 0;
}
template<class T> bool isinf( T x )
{
return ( _fpclass( static_cast<double>( x ) ) & ( _FPCLASS_PINF | _FPCLASS_NINF ) ) != 0;
}
inline bool isnormal( float x )
{
// no _fpclassf in 32 bit mode
unsigned y = reinterpret_cast< unsigned const& >( x );
unsigned exp = ( y >> 23 ) & 0xFF;
return exp != 0 && exp != 0xFF;
}
inline bool isnormal( double x )
{
return ( _fpclass( x ) & ( _FPCLASS_PN | _FPCLASS_NN ) ) != 0;
}
inline bool isnormal( long double x )
{
return boost::core::isnormal( static_cast<double>( x ) );
}
template<class T> bool signbit( T x )
{
return _copysign( 1.0, static_cast<double>( x ) ) < 0.0;
}
int const fp_zero = 0;
int const fp_subnormal = 1;
int const fp_normal = 2;
int const fp_infinite = 3;
int const fp_nan = 4;
inline int fpclassify( float x )
{
switch( _fpclass( x ) )
{
case _FPCLASS_SNAN:
case _FPCLASS_QNAN:
return fp_nan;
case _FPCLASS_NINF:
case _FPCLASS_PINF:
return fp_infinite;
case _FPCLASS_NZ:
case _FPCLASS_PZ:
return fp_zero;
default:
return boost::core::isnormal( x )? fp_normal: fp_subnormal;
}
}
inline int fpclassify( double x )
{
switch( _fpclass( x ) )
{
case _FPCLASS_SNAN:
case _FPCLASS_QNAN:
return fp_nan;
case _FPCLASS_NINF:
case _FPCLASS_PINF:
return fp_infinite;
case _FPCLASS_NZ:
case _FPCLASS_PZ:
return fp_zero;
case _FPCLASS_ND:
case _FPCLASS_PD:
return fp_subnormal;
default:
return fp_normal;
}
}
inline int fpclassify( long double x )
{
return boost::core::fpclassify( static_cast<double>( x ) );
}
#else
using std::isfinite;
using std::isnan;
using std::isinf;
using std::isnormal;
using std::fpclassify;
int const fp_zero = FP_ZERO;
int const fp_subnormal = FP_SUBNORMAL;
int const fp_normal = FP_NORMAL;
int const fp_infinite = FP_INFINITE;
int const fp_nan = FP_NAN;
using std::signbit;
// std::copysign doesn't exist in libstdc++ under -std=c++03
#if !defined(__GNUC__)
template<class T> T copysign( T x, T y )
{
return std::copysign( x, y );
}
#else
namespace detail
{
// ::copysignl is unreliable, use the built-ins
inline float copysign_impl( float x, float y )
{
return __builtin_copysignf( x, y );
}
inline double copysign_impl( double x, double y )
{
return __builtin_copysign( x, y );
}
inline long double copysign_impl( long double x, long double y )
{
return __builtin_copysignl( x, y );
}
} // namespace detail
template<class T> T copysign( T x, T y )
{
return boost::core::detail::copysign_impl( x, y );
}
#endif // !defined(__GNUC__)
#endif // #if defined(_MSC_VER) && _MSC_VER < 1800
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_CMATH_HPP_INCLUDED

View File

@@ -0,0 +1,148 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_DEFAULT_ALLOCATOR_HPP
#define BOOST_CORE_DEFAULT_ALLOCATOR_HPP
#include <boost/config.hpp>
#include <new>
namespace boost {
#if defined(BOOST_NO_EXCEPTIONS)
BOOST_NORETURN void throw_exception(const std::exception&);
#endif
namespace default_ {
struct true_type {
typedef bool value_type;
typedef true_type type;
BOOST_STATIC_CONSTANT(bool, value = true);
BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT {
return true;
}
BOOST_CONSTEXPR bool operator()() const BOOST_NOEXCEPT {
return true;
}
};
template<class T>
struct add_reference {
typedef T& type;
};
template<>
struct add_reference<void> {
typedef void type;
};
template<>
struct add_reference<const void> {
typedef const void type;
};
template<class T>
struct default_allocator {
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef typename add_reference<T>::type reference;
typedef typename add_reference<const T>::type const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
template<class U>
struct rebind {
typedef default_allocator<U> other;
};
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
default_allocator() = default;
#else
BOOST_CONSTEXPR default_allocator() BOOST_NOEXCEPT { }
#endif
template<class U>
BOOST_CONSTEXPR default_allocator(const default_allocator<U>&)
BOOST_NOEXCEPT { }
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
}
#if !defined(BOOST_NO_EXCEPTIONS)
T* allocate(std::size_t n) {
if (n > max_size()) {
throw std::bad_alloc();
}
return static_cast<T*>(::operator new(sizeof(T) * n));
}
void deallocate(T* p, std::size_t) {
::operator delete(p);
}
#else
T* allocate(std::size_t n) {
if (n > max_size()) {
boost::throw_exception(std::bad_alloc());
}
void* p = ::operator new(sizeof(T) * n, std::nothrow);
if (!p) {
boost::throw_exception(std::bad_alloc());
}
return static_cast<T*>(p);
}
void deallocate(T* p, std::size_t) {
::operator delete(p, std::nothrow);
}
#endif
#if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \
defined(BOOST_NO_CXX11_ALLOCATOR)
template<class U, class V>
void construct(U* p, const V& v) {
::new(p) U(v);
}
template<class U>
void destroy(U* p) {
p->~U();
(void)p;
}
#endif
};
template<class T, class U>
BOOST_CONSTEXPR inline bool
operator==(const default_allocator<T>&,
const default_allocator<U>&) BOOST_NOEXCEPT
{
return true;
}
template<class T, class U>
BOOST_CONSTEXPR inline bool
operator!=(const default_allocator<T>&,
const default_allocator<U>&) BOOST_NOEXCEPT
{
return false;
}
} /* default_ */
using default_::default_allocator;
} /* boost */
#endif

View File

@@ -17,7 +17,10 @@
# pragma once
#endif
#if defined( __clang__ ) && defined( __has_include )
// __has_include is currently supported by GCC and Clang. However GCC 4.9 may have issues and
// returns 1 for 'defined( __has_include )', while '__has_include' is actually not supported:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63662
#if defined( __has_include ) && (!defined( BOOST_GCC ) || (__GNUC__ + 0) >= 5)
# if __has_include(<cxxabi.h>)
# define BOOST_CORE_HAS_CXXABI_H
# endif
@@ -27,8 +30,15 @@
#if defined( BOOST_CORE_HAS_CXXABI_H )
# include <cxxabi.h>
# include <cstdlib>
# include <cstddef>
// For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library
// (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement
// abi::__cxa_demangle(). We detect this implementation by checking the include guard here.
# if defined( __GABIXX_CXXABI_H__ )
# undef BOOST_CORE_HAS_CXXABI_H
# else
# include <cstdlib>
# include <cstddef>
# endif
#endif
namespace boost
@@ -83,15 +93,10 @@ inline void demangle_free( char const * name ) BOOST_NOEXCEPT
inline std::string demangle( char const * name )
{
scoped_demangled_name demangled_name( name );
char const * const p = demangled_name.get();
if( p )
{
return p;
}
else
{
return name;
}
char const * p = demangled_name.get();
if( !p )
p = name;
return p;
}
#else

View File

@@ -0,0 +1,54 @@
#ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
#define BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// An implementation of splitmix64 for testing purposes,
// derived from Sebastiano Vigna's public domain implementation
// http://xorshift.di.unimi.it/splitmix64.c
#include <boost/cstdint.hpp>
namespace boost
{
namespace detail
{
class splitmix64
{
private:
boost::uint64_t x_;
public:
splitmix64(): x_( 0 )
{
}
explicit splitmix64( boost::uint64_t seed ): x_( seed )
{
}
boost::uint64_t operator()()
{
x_ += 0x9e3779b97f4a7c15;
boost::uint64_t z = x_;
z ^= z >> 30;
z *= 0xbf58476d1ce4e5b9;
z ^= z >> 27;
z *= 0x94d049bb133111eb;
z ^= z >> 31;
return z;
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED

View File

@@ -0,0 +1,146 @@
/*
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_EMPTY_VALUE_HPP
#define BOOST_CORE_EMPTY_VALUE_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700)
#define BOOST_DETAIL_EMPTY_VALUE_BASE
#elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1800)
#define BOOST_DETAIL_EMPTY_VALUE_BASE
#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1800)
#define BOOST_DETAIL_EMPTY_VALUE_BASE
#elif defined(BOOST_CLANG) && !defined(__CUDACC__)
#if __has_feature(is_empty) && __has_feature(is_final)
#define BOOST_DETAIL_EMPTY_VALUE_BASE
#endif
#endif
namespace boost {
template<class T>
struct use_empty_value_base {
enum {
#if defined(BOOST_DETAIL_EMPTY_VALUE_BASE)
value = __is_empty(T) && !__is_final(T)
#else
value = false
#endif
};
};
struct empty_init_t { };
namespace empty_ {
template<class T, unsigned N = 0,
bool E = boost::use_empty_value_base<T>::value>
class empty_value {
public:
typedef T type;
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
empty_value() = default;
#else
empty_value() { }
#endif
empty_value(boost::empty_init_t)
: value_() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class U, class... Args>
empty_value(boost::empty_init_t, U&& value, Args&&... args)
: value_(std::forward<U>(value), std::forward<Args>(args)...) { }
#else
template<class U>
empty_value(boost::empty_init_t, U&& value)
: value_(std::forward<U>(value)) { }
#endif
#else
template<class U>
empty_value(boost::empty_init_t, const U& value)
: value_(value) { }
template<class U>
empty_value(boost::empty_init_t, U& value)
: value_(value) { }
#endif
const T& get() const BOOST_NOEXCEPT {
return value_;
}
T& get() BOOST_NOEXCEPT {
return value_;
}
private:
T value_;
};
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template<class T, unsigned N>
class empty_value<T, N, true>
: T {
public:
typedef T type;
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
empty_value() = default;
#else
empty_value() { }
#endif
empty_value(boost::empty_init_t)
: T() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class U, class... Args>
empty_value(boost::empty_init_t, U&& value, Args&&... args)
: T(std::forward<U>(value), std::forward<Args>(args)...) { }
#else
template<class U>
empty_value(boost::empty_init_t, U&& value)
: T(std::forward<U>(value)) { }
#endif
#else
template<class U>
empty_value(boost::empty_init_t, const U& value)
: T(value) { }
template<class U>
empty_value(boost::empty_init_t, U& value)
: T(value) { }
#endif
const T& get() const BOOST_NOEXCEPT {
return *this;
}
T& get() BOOST_NOEXCEPT {
return *this;
}
};
#endif
} /* empty_ */
using empty_::empty_value;
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
} /* boost */
#endif

View File

@@ -23,6 +23,11 @@
namespace boost
{
template<typename T, typename R=void>
struct enable_if_has_type
{
typedef R type;
};
template <bool B, class T = void>
struct enable_if_c {
@@ -80,6 +85,10 @@ namespace boost {
template <typename T>
struct enable_if_does_not_work_on_this_compiler;
template<typename T, typename R=void>
struct enable_if_has_type : enable_if_does_not_work_on_this_compiler<T>
{ };
template <bool B, class T = detail::enable_if_default_T>
struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
{ };

View File

@@ -0,0 +1,49 @@
/*
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_EXCHANGE_HPP
#define BOOST_CORE_EXCHANGE_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <boost/config/workaround.hpp>
#include <utility>
#endif
namespace boost {
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T, class U>
inline T exchange(T& t, const U& u)
{
T v = t;
t = u;
return v;
}
#else
#if BOOST_WORKAROUND(BOOST_MSVC, < 1800)
template<class T, class U>
inline T exchange(T& t, U&& u)
{
T v = std::move(t);
t = std::forward<U>(u);
return v;
}
#else
template<class T, class U = T>
BOOST_CXX14_CONSTEXPR inline T exchange(T& t, U&& u)
{
T v = std::move(t);
t = std::forward<U>(u);
return v;
}
#endif
#endif
} /* boost */
#endif

View File

@@ -19,6 +19,7 @@
#define BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
@@ -52,6 +53,8 @@
return !this->operator! ();\
}
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
/*!
* \brief The macro defines a constexpr explicit operator of conversion to \c bool
*
@@ -65,6 +68,12 @@
return !this->operator! ();\
}
#else
#define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL() BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
#endif
#else // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
#if (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG)

View File

@@ -0,0 +1,45 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_FIRST_SCALAR_HPP
#define BOOST_CORE_FIRST_SCALAR_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace detail {
template<class T>
struct make_scalar {
typedef T type;
};
template<class T, std::size_t N>
struct make_scalar<T[N]> {
typedef typename make_scalar<T>::type type;
};
} /* detail */
template<class T>
BOOST_CONSTEXPR inline T*
first_scalar(T* p) BOOST_NOEXCEPT
{
return p;
}
template<class T, std::size_t N>
BOOST_CONSTEXPR inline typename detail::make_scalar<T>::type*
first_scalar(T (*p)[N]) BOOST_NOEXCEPT
{
return boost::first_scalar(&(*p)[0]);
}
} /* boost */
#endif

View File

@@ -11,56 +11,86 @@
namespace boost {
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename... Ts>
inline void ignore_unused(Ts const& ...)
{}
template <typename... Ts>
inline void ignore_unused()
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts&& ...)
{}
#else
template <typename... Ts>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts const& ...)
{}
#endif
template <typename... Ts>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <typename T1>
inline void ignore_unused(T1 const&)
{}
template <typename T1, typename T2>
inline void ignore_unused(T1 const&, T2 const&)
{}
template <typename T1, typename T2, typename T3>
inline void ignore_unused(T1 const&, T2 const&, T3 const&)
{}
template <typename T1, typename T2, typename T3, typename T4>
inline void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&)
{}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
inline void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&, T5 const&)
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&)
{}
template <typename T1>
inline void ignore_unused()
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&)
{}
template <typename T1, typename T2>
inline void ignore_unused()
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&)
{}
template <typename T1, typename T2>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&)
{}
template <typename T1, typename T2, typename T3>
inline void ignore_unused()
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&)
{}
template <typename T1, typename T2, typename T3>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&)
{}
template <typename T1, typename T2, typename T3, typename T4>
inline void ignore_unused()
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&, T4&)
{}
template <typename T1, typename T2, typename T3, typename T4>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&)
{}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
inline void ignore_unused()
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&, T4&, T5&)
{}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&, T5 const&)
{}
template <typename T1>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
template <typename T1, typename T2>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
template <typename T1, typename T2, typename T3>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
template <typename T1, typename T2, typename T3, typename T4>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
#endif

View File

@@ -14,15 +14,29 @@
// Copyright (2) Beman Dawes 2010, 2011
// Copyright (3) Ion Gaztanaga 2013
//
// Copyright 2018 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 <boost/assert.hpp>
#include <boost/current_function.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/config.hpp>
#include <exception>
#include <iostream>
#include <iterator>
#include <string>
#include <cstdlib>
#include <cstring>
#include <cstddef>
#include <cctype>
#include <cstdio>
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
# include <crtdbg.h>
#endif
// IDE's like Visual Studio perform better if output goes to std::cout or
// some other stream, so allow user to configure output stream:
@@ -36,37 +50,68 @@ namespace boost
namespace detail
{
struct report_errors_reminder
{
bool called_report_errors_function;
report_errors_reminder() : called_report_errors_function(false) {}
~report_errors_reminder()
{
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
class test_result {
public:
test_result()
: report_(false)
, errors_(0) {
#if defined(_MSC_VER) && (_MSC_VER > 1310)
// disable message boxes on assert(), abort()
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
// disable message boxes on iterator debugging violations
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
#endif
}
~test_result() {
if (!report_) {
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "main() should return report_errors()" << std::endl;
std::abort();
}
}
int& errors() {
return errors_;
}
void done() {
report_ = true;
}
private:
bool report_;
int errors_;
};
inline report_errors_reminder& report_errors_remind()
inline test_result& test_results()
{
static report_errors_reminder r;
return r;
static test_result instance;
return instance;
}
inline int & test_errors()
inline int& test_errors()
{
static int x = 0;
report_errors_remind();
return x;
return test_results().errors();
}
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_errors();
if( v )
{
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void error_impl(char const * msg, char const * file, int line, char const * function)
@@ -74,98 +119,467 @@ inline void error_impl(char const * msg, char const * file, int line, char const
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): " << msg << " in function '"
<< function << "'" << std::endl;
++test_errors();
++test_results().errors();
}
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
inline void throw_failed_impl(const char* expr, char const * excep, char const * file, int line, char const * function)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
<< file << "(" << line << "): expression '" << expr << "' did not throw exception '" << excep << "' in function '"
<< function << "'" << std::endl;
++test_errors();
++test_results().errors();
}
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
inline void no_throw_failed_impl(const char* expr, const char* file, int line, const char* function)
{
if( t == u )
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
<< function << "'" << std::endl;
++test_results().errors();
}
inline void no_throw_failed_impl(const char* expr, const char* what, const char* file, int line, const char* function)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
<< function << "': " << what << std::endl;
++test_results().errors();
}
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
// the dependency we just disable the warnings.
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-compare"
# endif
#elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
#endif
// specialize test output for char pointers to avoid printing as cstring
template <class T> inline const T& test_output_impl(const T& v) { return v; }
inline const void* test_output_impl(const char* v) { return v; }
inline const void* test_output_impl(const unsigned char* v) { return v; }
inline const void* test_output_impl(const signed char* v) { return v; }
inline const void* test_output_impl(char* v) { return v; }
inline const void* test_output_impl(unsigned char* v) { return v; }
inline const void* test_output_impl(signed char* v) { return v; }
template<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); }
#if !defined( BOOST_NO_CXX11_NULLPTR )
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
#endif
// print chars as numeric
inline int test_output_impl( signed char const& v ) { return v; }
inline unsigned test_output_impl( unsigned char const& v ) { return v; }
inline unsigned long test_output_impl( wchar_t const& v ) { return v; }
#if !defined( BOOST_NO_CXX11_CHAR16_T )
inline unsigned long test_output_impl( char16_t const& v ) { return v; }
#endif
#if !defined( BOOST_NO_CXX11_CHAR32_T )
inline unsigned long test_output_impl( char32_t const& v ) { return v; }
#endif
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4996)
#endif
inline std::string test_output_impl( char const& v )
{
if( std::isprint( static_cast<unsigned char>( v ) ) )
{
report_errors_remind();
return std::string( 1, v );
}
else
{
char buffer[ 8 ];
std::sprintf( buffer, "\\x%02X", static_cast<unsigned char>( v ) );
return buffer;
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
// predicates
struct lw_test_eq
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t == u; }
};
struct lw_test_ne
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t != u; }
};
struct lw_test_lt
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t < u; }
};
struct lw_test_le
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t <= u; }
};
struct lw_test_gt
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t > u; }
};
struct lw_test_ge
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t >= u; }
};
// lwt_predicate_name
template<class T> char const * lwt_predicate_name( T const& )
{
return "~=";
}
inline char const * lwt_predicate_name( lw_test_eq const& )
{
return "==";
}
inline char const * lwt_predicate_name( lw_test_ne const& )
{
return "!=";
}
inline char const * lwt_predicate_name( lw_test_lt const& )
{
return "<";
}
inline char const * lwt_predicate_name( lw_test_le const& )
{
return "<=";
}
inline char const * lwt_predicate_name( lw_test_gt const& )
{
return ">";
}
inline char const * lwt_predicate_name( lw_test_ge const& )
{
return ">=";
}
//
template<class BinaryPredicate, class T, class U>
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
char const * file, int line, char const * function,
T const & t, U const & u)
{
if( pred(t, u) )
{
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
<< "' failed in function '" << function << "': "
<< "'" << t << "' != '" << u << "'" << std::endl;
++test_errors();
<< file << "(" << line << "): test '" << expr1 << " " << lwt_predicate_name(pred) << " " << expr2
<< "' ('" << test_output_impl(t) << "' " << lwt_predicate_name(pred) << " '" << test_output_impl(u)
<< "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
inline bool test_cstr_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( t != u )
if( std::strcmp(t, u) == 0 )
{
report_errors_remind();
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " != " << expr2
<< "' failed in function '" << function << "': "
<< "'" << t << "' == '" << u << "'" << std::endl;
++test_errors();
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline bool test_cstr_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( std::strcmp(t, u) != 0 )
{
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2>
bool test_all_eq_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end)
{
InputIterator1 first_it = first_begin;
InputIterator2 second_it = second_begin;
typename std::iterator_traits<InputIterator1>::difference_type first_index = 0;
typename std::iterator_traits<InputIterator2>::difference_type second_index = 0;
std::size_t error_count = 0;
const std::size_t max_count = 8;
do
{
while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it))
{
++first_it;
++second_it;
++first_index;
++second_index;
}
if ((first_it == first_end) || (second_it == second_end))
{
break; // do-while
}
if (error_count == 0)
{
output << file << "(" << line << "): Container contents differ in function '" << function << "':";
}
else if (error_count >= max_count)
{
output << " ...";
break;
}
output << " [" << first_index << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'";
++first_it;
++second_it;
++first_index;
++second_index;
++error_count;
} while (first_it != first_end);
first_index += std::distance(first_it, first_end);
second_index += std::distance(second_it, second_end);
if (first_index != second_index)
{
if (error_count == 0)
{
output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")";
}
else
{
output << " [*] size(" << first_index << ") != size(" << second_index << ")";
}
++error_count;
}
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate>
bool test_all_with_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end,
BinaryPredicate predicate)
{
InputIterator1 first_it = first_begin;
InputIterator2 second_it = second_begin;
typename std::iterator_traits<InputIterator1>::difference_type first_index = 0;
typename std::iterator_traits<InputIterator2>::difference_type second_index = 0;
std::size_t error_count = 0;
const std::size_t max_count = 8;
do
{
while ((first_it != first_end) && (second_it != second_end) && predicate(*first_it, *second_it))
{
++first_it;
++second_it;
++first_index;
++second_index;
}
if ((first_it == first_end) || (second_it == second_end))
{
break; // do-while
}
if (error_count == 0)
{
output << file << "(" << line << "): Container contents differ in function '" << function << "':";
}
else if (error_count >= max_count)
{
output << " ...";
break;
}
output << " [" << first_index << "]";
++first_it;
++second_it;
++first_index;
++second_index;
++error_count;
} while (first_it != first_end);
first_index += std::distance(first_it, first_end);
second_index += std::distance(second_it, second_end);
if (first_index != second_index)
{
if (error_count == 0)
{
output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")";
}
else
{
output << " [*] size(" << first_index << ") != size(" << second_index << ")";
}
++error_count;
}
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic pop
# endif
#elif defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic pop
#endif
} // namespace detail
inline int report_errors()
{
boost::detail::report_errors_remind().called_report_errors_function = true;
boost::detail::test_result& result = boost::detail::test_results();
result.done();
int errors = boost::detail::test_errors();
int errors = result.errors();
if( errors == 0 )
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< "No errors detected." << std::endl;
return 0;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
return 1;
}
// `return report_errors();` from main only supports 8 bit exit codes
return errors < 256? errors: 255;
}
} // namespace boost
#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_WITH(expr1,expr2,predicate) ( ::boost::detail::test_with_impl(predicate, #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_lt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_le(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_gt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ge(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) )
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) )
#ifndef BOOST_NO_EXCEPTIONS
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
try { \
EXPR; \
::boost::detail::throw_failed_impl \
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
catch(EXCEP const&) { \
} \
catch(...) { \
::boost::detail::throw_failed_impl \
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
try { \
EXPR; \
::boost::detail::throw_failed_impl \
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
catch(EXCEP const&) { \
::boost::detail::test_results(); \
} \
catch(...) { \
::boost::detail::throw_failed_impl \
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
//
#else
#define BOOST_TEST_THROWS( EXPR, EXCEP )
#endif
#ifndef BOOST_NO_EXCEPTIONS
# define BOOST_TEST_NO_THROW(EXPR) \
try { \
EXPR; \
} catch (const std::exception& e) { \
::boost::detail::no_throw_failed_impl \
(#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} catch (...) { \
::boost::detail::no_throw_failed_impl \
(#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
}
//
#else
# define BOOST_TEST_NO_THROW(EXPR) { EXPR; }
#endif
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP

View File

@@ -9,16 +9,21 @@
// boost/core/lightweight_test_trait.hpp
//
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
//
// Copyright 2014 Peter Dimov
//
// Copyright 2019 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 <boost/core/lightweight_test.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/is_same.hpp>
#include <boost/config.hpp>
namespace boost
{
@@ -26,12 +31,56 @@ namespace boost
namespace detail
{
template<class, int = 0> struct test_print { };
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>)
{
return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T));
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>)
{
return o << test_print<T, 2>();
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>)
{
return o << test_print<T, 2>() << " const";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>)
{
return o << test_print<T, 2>() << " volatile";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>)
{
return o << test_print<T, 2>() << " const volatile";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>)
{
return o << test_print<T, 1>();
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>)
{
return o << test_print<T, 1>() << " &";
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>)
{
return o << test_print<T, 1>() << " &&";
}
#endif
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ),
bool expected, char const * file, int line, char const * function )
{
if( T::value == expected )
{
report_errors_remind();
test_results();
}
else
{
@@ -42,7 +91,32 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
<< "' (should have been " << ( expected? "true": "false" ) << ")"
<< std::endl;
++test_errors();
++test_results().errors();
}
}
template<class T> inline bool test_trait_same_impl_( T )
{
return T::value;
}
template<class T1, class T2> inline void test_trait_same_impl( char const * types,
boost::core::is_same<T1, T2> same, char const * file, int line, char const * function )
{
if( test_trait_same_impl_( same ) )
{
test_results();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test 'is_same<" << types << ">'"
<< " failed in function '" << function
<< "' ('" << test_print<T1>()
<< "' != '" << test_print<T2>() << "')"
<< std::endl;
++test_results().errors();
}
}
@@ -53,4 +127,11 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#if defined(__GNUC__)
// ignoring -Wvariadic-macros with #pragma doesn't work under GCC
# pragma GCC system_header
#endif
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP

View File

@@ -21,7 +21,7 @@
//----------------------------------------------------------------------
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
#if !(defined BOOST_NO_EXCEPTIONS)
# define BOOST_TRY { try
@@ -29,12 +29,24 @@
# define BOOST_RETHROW throw;
# define BOOST_CATCH_END }
#else
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
# define BOOST_TRY { if ("")
# define BOOST_CATCH(x) else if (!"")
# else
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
# define BOOST_TRY { if (true)
# define BOOST_CATCH(x) else if (false)
# else
// warning C4127: conditional expression is constant
# define BOOST_TRY { \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (true) \
__pragma(warning(pop))
# define BOOST_CATCH(x) else \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (false) \
__pragma(warning(pop))
# endif
# define BOOST_RETHROW
# define BOOST_CATCH_END }

View File

@@ -0,0 +1,87 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
#include <boost/core/allocator_access.hpp>
namespace boost {
template<class A>
struct noinit_adaptor
: A {
template<class U>
struct rebind {
typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
};
noinit_adaptor()
: A() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class U>
noinit_adaptor(U&& u) BOOST_NOEXCEPT
: A(std::forward<U>(u)) { }
#else
template<class U>
noinit_adaptor(const U& u) BOOST_NOEXCEPT
: A(u) { }
template<class U>
noinit_adaptor(U& u) BOOST_NOEXCEPT
: A(u) { }
#endif
template<class U>
noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
: A(static_cast<const A&>(u)) { }
template<class U>
void construct(U* p) {
::new((void*)p) U;
}
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class U, class V>
void construct(U* p, const V& v) {
::new((void*)p) U(v);
}
#endif
template<class U>
void destroy(U* p) {
p->~U();
}
};
template<class T, class U>
inline bool
operator==(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
{
return static_cast<const T&>(lhs) == static_cast<const U&>(rhs);
}
template<class T, class U>
inline bool
operator!=(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
{
return !(lhs == rhs);
}
template<class A>
inline noinit_adaptor<A>
noinit_adapt(const A& a) BOOST_NOEXCEPT
{
return noinit_adaptor<A>(a);
}
} /* boost */
#endif

View File

@@ -20,7 +20,22 @@ namespace boost {
namespace noncopyable_ // protection from unintended ADL
{
class noncopyable
#ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
#define BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
// noncopyable derives from base_token to enable Type Traits to detect
// whether a type derives from noncopyable without needing the definition
// of noncopyable itself.
//
// The definition of base_token is macro-guarded so that Type Trais can
// define it locally without including this header, to avoid a dependency
// on Core.
struct base_token {};
#endif // #ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
class noncopyable: base_token
{
protected:
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)

View File

@@ -0,0 +1,57 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_NVP_HPP
#define BOOST_CORE_NVP_HPP
#include <boost/core/addressof.hpp>
#include <boost/config.hpp>
namespace boost {
namespace serialization {
template<class T>
class nvp {
public:
nvp(const char* n, T& v) BOOST_NOEXCEPT
: n_(n)
, v_(boost::addressof(v)) { }
const char* name() const BOOST_NOEXCEPT {
return n_;
}
T& value() const BOOST_NOEXCEPT {
return *v_;
}
const T& const_value() const BOOST_NOEXCEPT {
return *v_;
}
private:
const char* n_;
T* v_;
};
template<class T>
inline const nvp<T>
make_nvp(const char* n, T& v) BOOST_NOEXCEPT
{
return nvp<T>(n, v);
}
} /* serialization */
using serialization::nvp;
using serialization::make_nvp;
} /* boost */
#define BOOST_NVP(v) boost::make_nvp(BOOST_STRINGIZE(v), v)
#endif

View File

@@ -0,0 +1,234 @@
/*
Copyright 2017-2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_POINTER_TRAITS_HPP
#define BOOST_CORE_POINTER_TRAITS_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
#include <memory>
#else
#include <boost/core/addressof.hpp>
#include <cstddef>
#endif
namespace boost {
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
template<class T>
struct pointer_traits
: std::pointer_traits<T> {
template<class U>
struct rebind_to {
typedef typename std::pointer_traits<T>::template rebind<U> type;
};
};
template<class T>
struct pointer_traits<T*>
: std::pointer_traits<T*> {
template<class U>
struct rebind_to {
typedef U* type;
};
};
#else
namespace detail {
template<class>
struct ptr_void {
typedef void type;
};
template<class T>
struct ptr_first;
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class, class...> class T, class U, class... Args>
struct ptr_first<T<U, Args...> > {
typedef U type;
};
#else
template<template<class> class T, class U>
struct ptr_first<T<U> > {
typedef U type;
};
template<template<class, class> class T, class U1, class U2>
struct ptr_first<T<U1, U2> > {
typedef U1 type;
};
template<template<class, class, class> class T, class U1, class U2, class U3>
struct ptr_first<T<U1, U2, U3> > {
typedef U1 type;
};
#endif
template<class T, class = void>
struct ptr_element {
typedef typename ptr_first<T>::type type;
};
template<class T>
struct ptr_element<T, typename ptr_void<typename T::element_type>::type> {
typedef typename T::element_type type;
};
template<class, class = void>
struct ptr_difference {
typedef std::ptrdiff_t type;
};
template<class T>
struct ptr_difference<T,
typename ptr_void<typename T::difference_type>::type> {
typedef typename T::difference_type type;
};
template<class T, class V>
struct ptr_transform;
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class, class...> class T, class U, class... Args, class V>
struct ptr_transform<T<U, Args...>, V> {
typedef T<V, Args...> type;
};
#else
template<template<class> class T, class U, class V>
struct ptr_transform<T<U>, V> {
typedef T<V> type;
};
template<template<class, class> class T, class U1, class U2, class V>
struct ptr_transform<T<U1, U2>, V> {
typedef T<V, U2> type;
};
template<template<class, class, class> class T,
class U1, class U2, class U3, class V>
struct ptr_transform<T<U1, U2, U3>, V> {
typedef T<V, U2, U3> type;
};
#endif
template<class T, class U, class = void>
struct ptr_rebind {
typedef typename ptr_transform<T, U>::type type;
};
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class T, class U>
struct ptr_rebind<T, U,
typename ptr_void<typename T::template rebind<U> >::type> {
typedef typename T::template rebind<U> type;
};
#endif
template<class T>
struct ptr_value {
typedef T type;
};
template<>
struct ptr_value<void> {
typedef struct { } type;
};
} /* detail */
template<class T>
struct pointer_traits {
typedef T pointer;
typedef typename detail::ptr_element<T>::type element_type;
typedef typename detail::ptr_difference<T>::type difference_type;
template<class U>
struct rebind_to {
typedef typename detail::ptr_rebind<T, U>::type type;
};
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class U>
using rebind = typename detail::ptr_rebind<T, U>::type;
#endif
static pointer
pointer_to(typename detail::ptr_value<element_type>::type& v) {
return pointer::pointer_to(v);
}
};
template<class T>
struct pointer_traits<T*> {
typedef T* pointer;
typedef T element_type;
typedef std::ptrdiff_t difference_type;
template<class U>
struct rebind_to {
typedef U* type;
};
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class U>
using rebind = U*;
#endif
static T*
pointer_to(typename detail::ptr_value<T>::type& v) BOOST_NOEXCEPT {
return boost::addressof(v);
}
};
#endif
template<class T>
BOOST_CONSTEXPR inline T*
to_address(T* v) BOOST_NOEXCEPT
{
return v;
}
#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
namespace detail {
template<class T>
inline T*
ptr_address(T* v, int) BOOST_NOEXCEPT
{
return v;
}
template<class T>
inline auto
ptr_address(const T& v, int) BOOST_NOEXCEPT
-> decltype(boost::pointer_traits<T>::to_address(v))
{
return boost::pointer_traits<T>::to_address(v);
}
template<class T>
inline auto
ptr_address(const T& v, long) BOOST_NOEXCEPT
{
return boost::detail::ptr_address(v.operator->(), 0);
}
} /* detail */
template<class T>
inline auto
to_address(const T& v) BOOST_NOEXCEPT
{
return boost::detail::ptr_address(v, 0);
}
#else
template<class T>
inline typename pointer_traits<T>::element_type*
to_address(const T& v) BOOST_NOEXCEPT
{
return boost::to_address(v.operator->());
}
#endif
} /* boost */
#endif

View File

@@ -0,0 +1,59 @@
#ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
#define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/core/quick_exit.hpp
//
// Copyright 2018 Peter Dimov
//
// 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 <stdlib.h>
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
extern "C" _CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN;
#endif
#if defined(__CYGWIN__) && __cplusplus < 201103L
extern "C" _Noreturn void quick_exit(int);
#endif
namespace boost
{
BOOST_NORETURN void quick_exit( int code ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER) && _MSC_VER < 1900
::_exit( code );
#elif defined(__MINGW32__)
::_exit( code );
#elif defined(__APPLE__)
::_Exit( code );
#else
::quick_exit( code );
#endif
}
} // namespace boost
#endif // #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED

View File

@@ -8,8 +8,9 @@
#endif
#include <boost/config.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
//
// ref.hpp - ref/cref, useful helper functions
@@ -19,7 +20,8 @@
// Copyright (C) 2002 David Abrahams
//
// Copyright (C) 2014 Glen Joseph Fernandes
// glenfe at live dot com
// (glenjofe@gmail.com)
//
// Copyright (C) 2014 Agustin Berge
//
// Distributed under the Boost Software License, Version 1.0. (See
@@ -45,6 +47,26 @@ namespace boost
#endif
namespace detail
{
template< class Y, class T > struct ref_convertible
{
typedef char (&yes) [1];
typedef char (&no) [2];
static yes f( T* );
static no f( ... );
enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
};
struct ref_empty
{
};
} // namespace detail
// reference_wrapper
/**
@@ -86,6 +108,21 @@ public:
public:
#endif
template<class Y> friend class reference_wrapper;
/**
Constructs a `reference_wrapper` object that stores the
reference stored in the compatible `reference_wrapper` `r`.
@remark Only enabled when `Y*` is convertible to `T*`.
@remark Does not throw.
*/
template<class Y> reference_wrapper( reference_wrapper<Y> r,
typename enable_if_c<boost::detail::ref_convertible<Y, T>::value,
boost::detail::ref_empty>::type = boost::detail::ref_empty() ): t_( r.t_ )
{
}
/**
@return The stored reference.
@remark Does not throw.
@@ -115,7 +152,7 @@ private:
/**
@cond
*/
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
#if defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
# define BOOST_REF_CONST
#else
# define BOOST_REF_CONST const

View File

@@ -43,7 +43,8 @@ namespace boost
* @throws No-throws.
*/
template <typename UnderlyingType, typename EnumType>
UnderlyingType underlying_cast(EnumType v)
inline
BOOST_CONSTEXPR UnderlyingType underlying_cast(EnumType v) BOOST_NOEXCEPT
{
return v.get_underlying_value_();
}
@@ -61,7 +62,7 @@ namespace boost
*/
template <typename EnumType>
inline
typename EnumType::enum_type native_value(EnumType e)
BOOST_CONSTEXPR typename EnumType::enum_type native_value(EnumType e) BOOST_NOEXCEPT
{
return e.get_native_value_();
}
@@ -75,14 +76,15 @@ namespace boost
};
template <typename UnderlyingType, typename EnumType>
UnderlyingType underlying_cast(EnumType v)
inline
BOOST_CONSTEXPR UnderlyingType underlying_cast(EnumType v) BOOST_NOEXCEPT
{
return static_cast<UnderlyingType>(v);
}
template <typename EnumType>
inline
EnumType native_value(EnumType e)
BOOST_CONSTEXPR EnumType native_value(EnumType e) BOOST_NOEXCEPT
{
return e;
}
@@ -96,7 +98,7 @@ namespace boost
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
explicit operator underlying_type() const BOOST_NOEXCEPT { return get_underlying_value_(); }
explicit BOOST_CONSTEXPR operator underlying_type() const BOOST_NOEXCEPT { return get_underlying_value_(); }
#else
@@ -115,8 +117,8 @@ namespace boost
typedef void is_boost_scoped_enum_tag; \
typedef UnderlyingType underlying_type; \
EnumType() BOOST_NOEXCEPT {} \
explicit EnumType(underlying_type v) BOOST_NOEXCEPT : v_(v) {} \
underlying_type get_underlying_value_() const BOOST_NOEXCEPT { return v_; } \
explicit BOOST_CONSTEXPR EnumType(underlying_type v) BOOST_NOEXCEPT : v_(v) {} \
BOOST_CONSTEXPR underlying_type get_underlying_value_() const BOOST_NOEXCEPT { return v_; } \
BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \
private: \
underlying_type v_; \
@@ -125,30 +127,30 @@ namespace boost
enum enum_type
#define BOOST_SCOPED_ENUM_DECLARE_END2() \
enum_type get_native_value_() const BOOST_NOEXCEPT { return enum_type(v_); } \
friend bool operator ==(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==enum_type(rhs.v_); } \
friend bool operator ==(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==rhs; } \
friend bool operator ==(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs==enum_type(rhs.v_); } \
friend bool operator !=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=enum_type(rhs.v_); } \
friend bool operator !=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=rhs; } \
friend bool operator !=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs!=enum_type(rhs.v_); } \
friend bool operator <(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<enum_type(rhs.v_); } \
friend bool operator <(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<rhs; } \
friend bool operator <(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<enum_type(rhs.v_); } \
friend bool operator <=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=enum_type(rhs.v_); } \
friend bool operator <=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=rhs; } \
friend bool operator <=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<=enum_type(rhs.v_); } \
friend bool operator >(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>enum_type(rhs.v_); } \
friend bool operator >(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>rhs; } \
friend bool operator >(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>enum_type(rhs.v_); } \
friend bool operator >=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=enum_type(rhs.v_); } \
friend bool operator >=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=rhs; } \
friend bool operator >=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>=enum_type(rhs.v_); } \
BOOST_CONSTEXPR enum_type get_native_value_() const BOOST_NOEXCEPT { return enum_type(v_); } \
friend BOOST_CONSTEXPR bool operator ==(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator ==(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==rhs; } \
friend BOOST_CONSTEXPR bool operator ==(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs==enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator !=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator !=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=rhs; } \
friend BOOST_CONSTEXPR bool operator !=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs!=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<rhs; } \
friend BOOST_CONSTEXPR bool operator <(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator <=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)<=rhs; } \
friend BOOST_CONSTEXPR bool operator <=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs<=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>rhs; } \
friend BOOST_CONSTEXPR bool operator >(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=enum_type(rhs.v_); } \
friend BOOST_CONSTEXPR bool operator >=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=rhs; } \
friend BOOST_CONSTEXPR bool operator >=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>=enum_type(rhs.v_); } \
};
#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) \
; \
EnumType(enum_type v) BOOST_NOEXCEPT : v_(v) {} \
BOOST_CONSTEXPR EnumType(enum_type v) BOOST_NOEXCEPT : v_(v) {} \
BOOST_SCOPED_ENUM_DECLARE_END2()
/**

View File

@@ -21,13 +21,22 @@
// avoid ambiguity when swapping objects of a Boost type that does
// not have its own boost::swap overload.
#include <utility> //for std::swap (C++11)
#include <algorithm> //for std::swap (C++98)
#include <cstddef> //for std::size_t
#include <boost/core/enable_if.hpp>
#include <boost/config.hpp>
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
#include <utility> // for std::swap (C++11)
#else
#include <algorithm> // for std::swap (C++98)
#endif
#include <cstddef> // for std::size_t
namespace boost_swap_impl
{
// we can't use type_traits here
template<class T> struct is_const { enum _vt { value = 0 }; };
template<class T> struct is_const<T const> { enum _vt { value = 1 }; };
template<class T>
BOOST_GPU_ENABLED
void swap_impl(T& left, T& right)
@@ -51,7 +60,8 @@ namespace boost
{
template<class T1, class T2>
BOOST_GPU_ENABLED
void swap(T1& left, T2& right)
typename enable_if_c< !boost_swap_impl::is_const<T1>::value && !boost_swap_impl::is_const<T2>::value >::type
swap(T1& left, T2& right)
{
::boost_swap_impl::swap_impl(left, right);
}

View File

@@ -21,6 +21,7 @@
#include <boost/current_function.hpp>
#include <functional>
#include <cstring>
namespace boost
{
@@ -36,26 +37,43 @@ private:
typeinfo& operator=( typeinfo const& );
char const * name_;
void (*lib_id_)();
public:
explicit typeinfo( char const * name ): name_( name )
typeinfo( char const * name, void (*lib_id)() ): name_( name ), lib_id_( lib_id )
{
}
bool operator==( typeinfo const& rhs ) const
{
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0;
#else
return this == &rhs;
#endif
}
bool operator!=( typeinfo const& rhs ) const
{
return this != &rhs;
return !( *this == rhs );
}
bool before( typeinfo const& rhs ) const
{
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0;
#else
return std::less< typeinfo const* >()( this, &rhs );
#endif
}
char const* name() const
@@ -74,7 +92,7 @@ inline char const * demangled_name( core::typeinfo const & ti )
namespace detail
{
template<class T> struct core_typeid_
template<class T> struct BOOST_SYMBOL_VISIBLE core_typeid_
{
static boost::core::typeinfo ti_;
@@ -84,13 +102,11 @@ template<class T> struct core_typeid_
}
};
#if defined(__SUNPRO_CC)
// see #4199, the Sun Studio compiler gets confused about static initialization
// constructor arguments. But an assignment works just fine.
template<class T> boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name();
#else
template<class T> boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name());
#endif
BOOST_SYMBOL_VISIBLE inline void core_typeid_lib_id()
{
}
template<class T> boost::core::typeinfo core_typeid_< T >::ti_( core_typeid_< T >::name(), &core_typeid_lib_id );
template<class T> struct core_typeid_< T & >: core_typeid_< T >
{

View File

@@ -0,0 +1,155 @@
/*
* Copyright Andrey Semashev 2018 - 2020.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file uncaught_exceptions.hpp
* \author Andrey Semashev
* \date 2018-11-10
*
* \brief This header provides an `uncaught_exceptions` function implementation, which was introduced in C++17.
*
* The code in this file is based on the implementation by Evgeny Panasyuk:
*
* https://github.com/panaseleus/stack_unwinding/blob/master/boost/exception/uncaught_exception_count.hpp
*/
#ifndef BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_
#define BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_
#include <exception>
#include <boost/config.hpp>
#if defined(BOOST_HAS_PRAGMA_ONCE)
#pragma once
#endif
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411)
#if defined(__APPLE__)
#include <Availability.h>
// Apple systems only support std::uncaught_exceptions starting with specific versions:
// - Mac OS >= 10.12
// - iOS >= 10.0
// - tvOS >= 10.0
// - watchOS >= 3.0
// https://github.com/boostorg/core/issues/80
#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#endif
#else
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#endif // defined(__APPLE__)
// Visual Studio 14.0 supports N4152 std::uncaught_exceptions() but doesn't define __cpp_lib_uncaught_exceptions
#elif (defined(_MSC_VER) && _MSC_VER >= 1900)
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#endif
#if !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS)
// cxxabi.h availability macro
#if defined(__has_include) && (!defined(BOOST_GCC) || (__GNUC__ >= 5))
# if __has_include(<cxxabi.h>)
# define BOOST_CORE_HAS_CXXABI_H
# endif
#elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
# define BOOST_CORE_HAS_CXXABI_H
#endif
#if defined(BOOST_CORE_HAS_CXXABI_H)
// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0.
// Just disable it for now and fall back to std::uncaught_exception().
// On AIX, xlclang++ does have cxxabi.h but doesn't have __cxa_get_globals (https://github.com/boostorg/core/issues/78).
#if !( \
(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405)) || \
defined(__ibmxl__) \
)
#include <cxxabi.h>
#include <cstring>
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
// At least on MinGW and Linux, only GCC since 4.7 declares __cxa_get_globals() in cxxabi.h. Older versions of GCC do not expose this function but it's there.
// On OpenBSD, it seems, the declaration is also missing.
// Note that at least on FreeBSD 11, cxxabi.h declares __cxa_get_globals with a different exception specification, so we can't declare the function unconditionally.
// On Linux with clang and libc++ and on OS X, there is a version of cxxabi.h from libc++abi that doesn't declare __cxa_get_globals, but provides __cxa_uncaught_exceptions.
// The function only appeared in version _LIBCPPABI_VERSION >= 1002 of the library. Unfortunately, there are linking errors about undefined reference to __cxa_uncaught_exceptions
// on Ubuntu Trusty and OS X, so we avoid using it and forward-declare __cxa_get_globals instead.
// On QNX SDP 7.0 (QCC 5.4.0), there are multiple cxxabi.h, one from glibcxx from gcc and another from libc++abi from LLVM. Which one is included will be determined by the qcc
// command line arguments (-V and/or -Y; http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.utilities/topic/q/qcc.html). The LLVM libc++abi is missing the declaration
// of __cxa_get_globals but it is also patched by QNX developers to not define _LIBCPPABI_VERSION. Older QNX SDP versions, up to and including 6.6, don't provide LLVM and libc++abi.
// See https://github.com/boostorg/core/issues/59.
#if !defined(__FreeBSD__) && \
( \
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \
defined(__OpenBSD__) || \
(defined(__QNXNTO__) && !defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || \
defined(_LIBCPPABI_VERSION) \
)
namespace __cxxabiv1 {
struct __cxa_eh_globals;
#if defined(__OpenBSD__)
extern "C" __cxa_eh_globals* __cxa_get_globals();
#else
extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __attribute__((__const__));
#endif
} // namespace __cxxabiv1
#endif
#endif
#endif // defined(BOOST_CORE_HAS_CXXABI_H)
#if defined(_MSC_VER) && _MSC_VER >= 1400
#include <cstring>
#define BOOST_CORE_HAS_GETPTD
namespace boost {
namespace core {
namespace detail {
extern "C" void* _getptd();
} // namespace detail
} // namespace core
} // namespace boost
#endif // defined(_MSC_VER) && _MSC_VER >= 1400
#endif // !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS)
#if !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS) && !defined(BOOST_CORE_HAS_CXA_GET_GLOBALS) && !defined(BOOST_CORE_HAS_GETPTD)
//! This macro is defined when `uncaught_exceptions` is not guaranteed to return values greater than 1 if multiple exceptions are pending
#define BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED
#endif
namespace boost {
namespace core {
//! Returns the number of currently pending exceptions
inline unsigned int uncaught_exceptions() BOOST_NOEXCEPT
{
#if defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS)
// C++17 implementation
return static_cast< unsigned int >(std::uncaught_exceptions());
#elif defined(BOOST_CORE_HAS_CXA_GET_GLOBALS)
// Tested on {clang 3.2,GCC 3.5.6,GCC 4.1.2,GCC 4.4.6,GCC 4.4.7}x{x32,x64}
unsigned int count;
std::memcpy(&count, reinterpret_cast< const unsigned char* >(::abi::__cxa_get_globals()) + sizeof(void*), sizeof(count)); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8
return count;
#elif defined(BOOST_CORE_HAS_GETPTD)
// MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}.
unsigned int count;
std::memcpy(&count, static_cast< const unsigned char* >(boost::core::detail::_getptd()) + (sizeof(void*) == 8u ? 0x100 : 0x90), sizeof(count)); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
return count;
#else
// Portable C++03 implementation. Does not allow to detect multiple nested exceptions.
return static_cast< unsigned int >(std::uncaught_exception());
#endif
}
} // namespace core
} // namespace boost
#undef BOOST_CORE_HAS_CXXABI_H
#undef BOOST_CORE_HAS_CXA_GET_GLOBALS
#undef BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#undef BOOST_CORE_HAS_GETPTD
#endif // BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_

View File

@@ -0,0 +1,17 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_USE_DEFAULT_HPP
#define BOOST_CORE_USE_DEFAULT_HPP
namespace boost {
struct use_default { };
} /* boost */
#endif

View File

@@ -6,9 +6,16 @@
#ifndef ITERATOR_DWA122600_HPP_
#define ITERATOR_DWA122600_HPP_
// This header is obsolete and will be deprecated.
// This header is obsolete and deprecated.
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("<iterator>")
#include <iterator>
#if defined(__SUNPRO_CC) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
#include <cstddef>
#endif
namespace boost
{
@@ -19,6 +26,16 @@ namespace detail
using std::iterator_traits;
using std::distance;
#if defined(__SUNPRO_CC) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
// std::distance from stlport with Oracle compiler 12.4 and 12.5 fails to deduce template parameters
// when one of the arguments is an array and the other one is a pointer.
template< typename T, std::size_t N >
inline typename std::iterator_traits< T* >::difference_type distance(T (&left)[N], T* right)
{
return std::distance(static_cast< T* >(left), right);
}
#endif
} // namespace detail
} // namespace boost

View File

@@ -12,6 +12,10 @@
// The header file at this path is deprecated;
// use boost/core/no_exceptions_support.hpp instead.
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("<boost/core/no_exceptions_support.hpp>")
#include <boost/core/no_exceptions_support.hpp>
#endif

View File

@@ -12,6 +12,10 @@
// The header file at this path is deprecated;
// use boost/core/scoped_enum.hpp instead.
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("<boost/core/scoped_enum.hpp>")
#include <boost/core/scoped_enum.hpp>
#endif

View File

@@ -18,6 +18,9 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/core/typeinfo.hpp>
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED( "<boost/core/typeinfo.hpp>" )
namespace boost
{

View File

@@ -24,11 +24,39 @@ template<class T> T * get_pointer(T * p)
// get_pointer(shared_ptr<T> const & p) has been moved to shared_ptr.hpp
#if !defined( BOOST_NO_AUTO_PTR )
#if defined( __GNUC__ ) && (defined( __GXX_EXPERIMENTAL_CXX0X__ ) || (__cplusplus >= 201103L))
#if defined( BOOST_GCC )
#if BOOST_GCC >= 40600
#define BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS
#endif // BOOST_GCC >= 40600
#elif defined( __clang__ ) && defined( __has_warning )
#if __has_warning("-Wdeprecated-declarations")
#define BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS
#endif // __has_warning("-Wdeprecated-declarations")
#endif
#endif // defined( __GNUC__ ) && (defined( __GXX_EXPERIMENTAL_CXX0X__ ) || (__cplusplus >= 201103L))
#if defined( BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS )
// Disable libstdc++ warnings about std::auto_ptr being deprecated in C++11 mode
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#define BOOST_CORE_DETAIL_DISABLED_DEPRECATED_WARNINGS
#endif
template<class T> T * get_pointer(std::auto_ptr<T> const& p)
{
return p.get();
}
#if defined( BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS )
#pragma GCC diagnostic pop
#undef BOOST_CORE_DETAIL_DISABLE_LIBSTDCXX_DEPRECATED_WARNINGS
#endif
#endif // !defined( BOOST_NO_AUTO_PTR )
#if !defined( BOOST_NO_CXX11_SMART_PTR )
template<class T> T * get_pointer( std::unique_ptr<T> const& p )

View File

@@ -1,43 +0,0 @@
/*
* Copyright Andrey Semashev 2007 - 2013.
* 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)
*/
/*!
* \file empty_deleter.hpp
* \author Andrey Semashev
* \date 22.04.2007
*
* This header contains an \c empty_deleter implementation. This is an empty
* function object that receives a pointer and does nothing with it.
* Such empty deletion strategy may be convenient, for example, when
* constructing <tt>shared_ptr</tt>s that point to some object that should not be
* deleted (i.e. a variable on the stack or some global singleton, like <tt>std::cout</tt>).
*/
#ifndef BOOST_UTILITY_EMPTY_DELETER_HPP
#define BOOST_UTILITY_EMPTY_DELETER_HPP
#include <boost/config.hpp>
#include <boost/core/null_deleter.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if defined(__GNUC__)
#pragma message "This header is deprecated, use boost/core/null_deleter.hpp instead."
#elif defined(_MSC_VER)
#pragma message("This header is deprecated, use boost/core/null_deleter.hpp instead.")
#endif
namespace boost {
//! A deprecated name for \c null_deleter
typedef null_deleter empty_deleter;
} // namespace boost
#endif // BOOST_UTILITY_EMPTY_DELETER_HPP

View File

@@ -8,14 +8,15 @@
"Andrey Semashev"
],
"maintainers": [
"Peter Dimov <pdimov -at- pdimov.com>",
"Glen Fernandes <glenfe -at- live.com>",
"Peter Dimov <pdimov -at- gmail.com>",
"Glen Fernandes <glenjofe -at- gmail.com>",
"Andrey Semashev <andrey.semashev -at- gmail.com>"
],
"description": "A collection of simple core utilities with minimal dependencies.",
"category": [
"Miscellaneous"
]
],
"cxxstd": "03"
},
{
"key": "utility/enable_if",
@@ -33,7 +34,8 @@
"maintainers": [
"Jaakko Jarvi <jarvi -at- cs.tamu.edu>",
"Jeremiah Willcock <jewillco -at- osl.iu.edu>"
]
],
"cxxstd": "03"
},
{
"key": "utility/swap",
@@ -49,7 +51,8 @@
],
"maintainers": [
"Joseph Gauterin <joseph.gauterin -at- googlemail.com>"
]
],
"cxxstd": "03"
},
{
"key": "bind/ref",
@@ -67,6 +70,7 @@
],
"category": [
"Function-objects"
]
],
"cxxstd": "03"
}
]

13
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,13 @@
# Copyright 2018, 2019 Peter Dimov
# 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits Boost::throw_exception)
endif()
add_subdirectory(swap)

View File

@@ -1,17 +1,24 @@
# Boost.Core Library test Jamfile
#
# Copyright (c) 2014 Peter Dimov
# Copyright (c) 2014, 2017 Peter Dimov
#
# 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 modules ;
import testing ;
# quick test (for CI)
run quick.cpp ;
# full test suite
run addressof_test.cpp ;
run addressof_test2.cpp ;
run addressof_np_test.cpp ;
run addressof_fn_test.cpp ;
compile addressof_constexpr_test.cpp ;
compile-fail addressof_fail_rvalue.cpp ;
run checked_delete_test.cpp ;
compile-fail checked_delete_fail.cpp ;
@@ -28,6 +35,10 @@ compile-fail ref_rv_fail4.cpp ;
compile-fail ref_rv_fail5.cpp ;
compile-fail ref_implicit_fail.cpp ;
compile-fail ref_implicit_fail2.cpp ;
compile-fail ref_implicit_fail3.cpp ;
compile-fail ref_implicit_fail4.cpp ;
run ref_cv_test.cpp ;
run ref_conversion_test.cpp ;
run eif_constructors.cpp ;
run eif_dummy_arg_disambiguation.cpp ;
@@ -47,10 +58,12 @@ compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ;
compile-fail explicit_operator_bool_compile_fail_delete.cpp ;
compile-fail explicit_operator_bool_compile_fail_shift.cpp ;
compile ignore_unused_test.cpp : <toolset>gcc-4.8:<cxxflags>"-Wunused-variable -Wunused-local-typedefs -Werror"
<toolset>gcc:<cxxflags>"-Wunused-variable -Werror"
<toolset>clang:<cxxflags>"-Wunused-variable -Werror"
<toolset>msvc:<cxxflags>"/we4100 /we4101" ;
compile ignore_unused_test.cpp
: <warnings>extra
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>msvc:<warnings-as-errors>on ;
run sp_typeinfo_test.cpp ;
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
@@ -58,10 +71,39 @@ run visit_each_test.cpp ;
run get_pointer_test.cpp ;
run lightweight_test_test.cpp ;
run lightweight_test_test.cpp : : : <exception-handling>off : lightweight_test_test_no_except ;
local pedantic-errors = <warnings>pedantic
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on ;
run lightweight_test_test2.cpp ;
run lightweight_test_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test.cpp : : :
<exception-handling>off $(pedantic-errors) : lightweight_test_test_no_except ;
run lightweight_test_test2.cpp
: : : $(pedantic-errors) ;
run lightweight_test_all_with_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_lt_le_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_gt_ge_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_eq_nullptr.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test3.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test4.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test5.cpp
: : : $(pedantic-errors)
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare
;
run lightweight_test_test6.cpp
: : : $(pedantic-errors) ;
run-fail lightweight_test_all_eq_test.cpp ;
run-fail lightweight_test_all_with_fail.cpp ;
run-fail lightweight_test_fail.cpp ;
run-fail lightweight_test_fail2.cpp ;
@@ -73,6 +115,24 @@ run-fail lightweight_test_fail7.cpp ;
run-fail lightweight_test_fail7.cpp : : : <rtti>off : lightweight_test_fail7_no_rtti ;
run-fail lightweight_test_fail8.cpp ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp : ;
run-fail lightweight_test_fail12.cpp ;
run-fail lightweight_test_fail13.cpp ;
run-fail lightweight_test_fail14.cpp ;
run-fail lightweight_test_fail15.cpp ;
run-fail lightweight_test_lt_fail.cpp ;
run-fail lightweight_test_le_fail.cpp ;
run-fail lightweight_test_gt_fail.cpp ;
run-fail lightweight_test_ge_fail.cpp ;
run lightweight_test_bool.cpp
: : : $(pedantic-errors) ;
run lightweight_test_with_test.cpp
: : : $(pedantic-errors) ;
run-fail lightweight_test_with_fail.cpp ;
run is_same_test.cpp ;
@@ -82,9 +142,12 @@ run typeinfo_test.cpp : : : <rtti>off : typeinfo_test_no_rtti ;
run iterator_test.cpp ;
run detail_iterator_test.cpp ;
run demangle_test.cpp : : : <test-info>always_show_run_output ;
run demangle_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
run scoped_enum.cpp ;
@@ -92,3 +155,94 @@ compile-fail scoped_enum_compile_fail_conv_from_int.cpp ;
compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
run underlying_type.cpp ;
run pointer_traits_pointer_test.cpp ;
run pointer_traits_element_type_test.cpp ;
run pointer_traits_difference_type_test.cpp ;
run pointer_traits_rebind_test.cpp ;
run pointer_traits_pointer_to_test.cpp ;
run to_address_test.cpp ;
run exchange_test.cpp ;
run exchange_move_test.cpp ;
run first_scalar_test.cpp ;
compile first_scalar_constexpr_test.cpp ;
run empty_value_test.cpp ;
run empty_value_size_test.cpp ;
run empty_value_final_test.cpp ;
run quick_exit_test.cpp ;
run-fail quick_exit_fail.cpp ;
compile use_default_test.cpp ;
run default_allocator_test.cpp
: : : <warnings>pedantic
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on ;
run noinit_adaptor_test.cpp ;
run alloc_construct_test.cpp ;
run alloc_construct_throws_test.cpp ;
run alloc_construct_cxx11_test.cpp ;
run nvp_test.cpp ;
run allocator_value_type_test.cpp ;
run allocator_pointer_test.cpp ;
run allocator_const_pointer_test.cpp ;
run allocator_void_pointer_test.cpp ;
run allocator_const_void_pointer_test.cpp ;
run allocator_difference_type_test.cpp ;
run allocator_size_type_test.cpp ;
run allocator_pocca_test.cpp ;
run allocator_pocma_test.cpp ;
run allocator_pocs_test.cpp ;
run allocator_is_always_equal_test.cpp ;
run allocator_rebind_test.cpp ;
run allocator_allocate_test.cpp ;
run allocator_allocate_hint_test.cpp ;
run allocator_deallocate_test.cpp ;
run allocator_max_size_test.cpp ;
run allocator_soccc_test.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run test_lib_typeid2.cpp lib_typeid : : : <link>shared : test_lib_typeid2_shared ;
run test_lib_typeid2.cpp lib_typeid : : : <link>static : test_lib_typeid2_static ;
run test_lib_typeid2.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid2_shared_no_rtti ;
run test_lib_typeid2.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid2_static_no_rtti ;
run uncaught_exceptions.cpp
: : : <exception-handling>on ;
run uncaught_exceptions_np.cpp
: : : <exception-handling>on ;
run no_exceptions_support_test.cpp ;
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;
run cmath_test.cpp ;
run bit_cast_test.cpp ;
run bit_rotate_test.cpp ;
run bit_countr_test.cpp ;
run bit_countl_test.cpp ;
run bit_width_test.cpp ;
run has_single_bit_test.cpp ;
run bit_floor_test.cpp ;
run bit_ceil_test.cpp ;
run bit_popcount_test.cpp ;
run bit_endian_test.cpp ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/addressof.hpp>
#include <boost/static_assert.hpp>
#if !defined(BOOST_CORE_NO_CONSTEXPR_ADDRESSOF)
struct Type { };
static int v1 = 0;
static Type v2 = { };
BOOST_STATIC_ASSERT(boost::addressof(v1) == &v1);
BOOST_STATIC_ASSERT(boost::addressof(v2) == &v2);
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/addressof.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
struct type { };
inline const type function()
{
return type();
}
int main()
{
(void)boost::addressof(function());
}
#else
#error Requires rvalue references and deleted functions
#endif

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void f0()

View File

@@ -7,7 +7,7 @@
//
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined( BOOST_NO_CXX11_NULLPTR )

View File

@@ -20,7 +20,7 @@
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{

View File

@@ -22,7 +22,7 @@
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{

View File

@@ -0,0 +1,78 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/core/alloc_construct.hpp>
#include <boost/core/lightweight_test.hpp>
class type {
public:
explicit type(int x)
: value_(x) { }
int value() const {
return value_;
}
static int count;
private:
type(const type&);
type& operator=(const type&);
int value_;
};
int type::count = 0;
template<class T>
struct creator {
typedef T value_type;
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
template<class V>
void construct(type* ptr, const V& value) {
::new(static_cast<void*>(ptr)) type(value + 1);
++type::count;
}
void destroy(type* ptr) {
ptr->~type();
--type::count;
}
};
int main()
{
creator<type> a;
type* p = a.allocate(1);
boost::alloc_construct(a, p, 1);
BOOST_TEST_EQ(type::count, 1);
BOOST_TEST_EQ(p->value(), 2);
boost::alloc_destroy(a, p);
BOOST_TEST_EQ(type::count, 0);
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,135 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/alloc_construct.hpp>
#include <boost/core/default_allocator.hpp>
#include <boost/core/lightweight_test.hpp>
class type {
public:
explicit type(int x = 0, int y = 0)
: value_(x + y) {
++count;
}
type(const type& other)
: value_(other.value_) {
++count;
}
~type() {
--count;
}
int value() const {
return value_;
}
static int count;
private:
int value_;
};
int type::count = 0;
void test_construct()
{
boost::default_allocator<type> a;
type* p = a.allocate(1);
boost::alloc_construct(a, p);
BOOST_TEST_EQ(type::count, 1);
BOOST_TEST_EQ(p->value(), 0);
boost::alloc_destroy(a, p);
BOOST_TEST_EQ(type::count, 0);
a.deallocate(p, 1);
}
void test_construct_value()
{
boost::default_allocator<type> a;
type* p = a.allocate(1);
boost::alloc_construct(a, p, 1);
BOOST_TEST_EQ(type::count, 1);
BOOST_TEST_EQ(p->value(), 1);
boost::alloc_destroy(a, p);
BOOST_TEST_EQ(type::count, 0);
a.deallocate(p, 1);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
void test_construct_args()
{
boost::default_allocator<type> a;
type* p = a.allocate(1);
boost::alloc_construct(a, p, 1, 2);
BOOST_TEST_EQ(type::count, 1);
BOOST_TEST_EQ(p->value(), 3);
boost::alloc_destroy(a, p);
BOOST_TEST_EQ(type::count, 0);
a.deallocate(p, 1);
}
#endif
void test_construct_n()
{
boost::default_allocator<type> a;
type* p = a.allocate(3);
boost::alloc_construct_n(a, p, 3);
BOOST_TEST_EQ(type::count, 3);
BOOST_TEST_EQ(p[0].value(), 0);
BOOST_TEST_EQ(p[1].value(), 0);
BOOST_TEST_EQ(p[2].value(), 0);
boost::alloc_destroy_n(a, p, 3);
BOOST_TEST_EQ(type::count, 0);
a.deallocate(p, 3);
}
void test_construct_n_list()
{
boost::default_allocator<type> a;
type* p = a.allocate(3);
type q(1);
boost::alloc_construct_n(a, p, 3, &q, 1);
BOOST_TEST_EQ(type::count, 4);
BOOST_TEST_EQ(p[0].value(), 1);
BOOST_TEST_EQ(p[1].value(), 1);
BOOST_TEST_EQ(p[2].value(), 1);
boost::alloc_destroy_n(a, p, 3);
BOOST_TEST_EQ(type::count, 1);
a.deallocate(p, 3);
}
void test_construct_n_iterator()
{
boost::default_allocator<type> a;
type* p = a.allocate(3);
type l[] = { type(1), type(2), type(3) };
boost::alloc_construct_n(a, p, 3, &l[0]);
BOOST_TEST_EQ(type::count, 6);
BOOST_TEST_EQ(p[0].value(), 1);
BOOST_TEST_EQ(p[1].value(), 2);
BOOST_TEST_EQ(p[2].value(), 3);
boost::alloc_destroy_n(a, p, 3);
BOOST_TEST_EQ(type::count, 3);
a.deallocate(p, 3);
}
int main()
{
test_construct();
test_construct_value();
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
test_construct_args();
#endif
test_construct_n();
test_construct_n_list();
test_construct_n_iterator();
return boost::report_errors();
}

View File

@@ -0,0 +1,46 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/alloc_construct.hpp>
#include <boost/core/default_allocator.hpp>
#include <boost/core/lightweight_test.hpp>
class type {
public:
type() {
if (count == 4) {
throw true;
}
++count;
}
~type() {
--count;
}
static int count;
private:
type(const type&);
type& operator=(const type&);
};
int type::count = 0;
int main()
{
boost::default_allocator<type> a;
type* p = a.allocate(5);
try {
boost::alloc_construct_n(a, p, 5);
BOOST_ERROR("construct_n did not throw");
} catch (...) {
BOOST_TEST_EQ(type::count, 0);
}
a.deallocate(p, 5);
return boost::report_errors();
}

View File

@@ -0,0 +1,59 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef std::size_t size_type;
typedef T* pointer;
typedef const T* const_pointer;
template<class U>
struct rebind {
typedef A1<U> other;
};
A1()
: value() { }
T* allocate(std::size_t n, const void*) {
value = n;
return 0;
}
std::size_t value;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
A2()
: value() { }
T* allocate(std::size_t n) {
value = n;
return 0;
}
std::size_t value;
};
#endif
int main()
{
{
A1<int> a;
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
BOOST_TEST_EQ(a.value, 5);
}
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
{
A2<int> a;
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
BOOST_TEST_EQ(a.value, 5);
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,31 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
struct A {
typedef T value_type;
typedef T* pointer;
typedef std::size_t size_type;
A()
: value() { }
T* allocate(std::size_t n) {
value = n;
return 0;
}
std::size_t value;
};
int main()
{
A<int> a;
BOOST_TEST_NOT(boost::allocator_allocate(a, 5));
BOOST_TEST_EQ(a.value, 5);
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int* const_pointer;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_const_pointer<A1<char> >::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
boost::allocator_const_pointer<A2<int> >::type>));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,39 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int* const_pointer;
typedef int* const_void_pointer;
template<class U>
struct rebind {
typedef A1<U> other;
};
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_const_void_pointer<A1<char> >::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
boost::allocator_const_void_pointer<A2<int> >::type>));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,46 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
struct A1 {
typedef T value_type;
A1() { }
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
A2() { }
template<class U, class V>
void construct(U* p, const V& v) {
::new((void*)p) U(v + 1);
}
};
#endif
int main()
{
{
A1<int> a;
int i = 0;
boost::allocator_construct(a, &i, 5);
BOOST_TEST_EQ(i, 5);
}
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
{
A1<int> a;
int i = 0;
boost::allocator_construct(a, &i, 5);
BOOST_TEST_EQ(i, 6);
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,30 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
struct A {
typedef T value_type;
typedef T* pointer;
typedef std::size_t size_type;
A()
: value() { }
void deallocate(T*, std::size_t n) {
value = n;
}
std::size_t value;
};
int main()
{
A<int> a;
boost::allocator_deallocate(a, 0, 5);
BOOST_TEST_EQ(a.value, 5);
return boost::report_errors();
}

View File

@@ -0,0 +1,62 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
struct S {
static int count;
S() {
++count;
}
S(const S&) {
++count;
}
~S() {
--count;
}
};
int S::count = 0;
template<class T>
struct A1 {
typedef T value_type;
A1() { }
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
A2() { }
template<class U>
void destroy(U* p) {
*p = U();
}
};
#endif
int main()
{
{
A1<int> a;
S s;
boost::allocator_destroy(a, &s);
BOOST_TEST_EQ(S::count, 0);
::new((void*)&s) S();
}
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
{
A1<int> a;
int i = 5;
boost::allocator_destroy(a, &i);
BOOST_TEST_EQ(i, 0);
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef short difference_type;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
boost::allocator_difference_type<A1<char> >::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::allocator_difference_type<A2<int> >::type>));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
int value;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
template<class T>
struct A3 {
typedef T value_type;
typedef std::false_type is_always_equal;
};
template<class T>
struct A4 {
typedef T value_type;
typedef std::true_type is_always_equal;
int value;
};
#endif
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1<int> >::type));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2<int> >::type));
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A3<int> >::type));
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A4<int> >::type));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,39 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
#include <limits>
template<class T>
struct A1 {
typedef T value_type;
typedef short size_type;
A1() { }
short max_size() const {
return 1;
}
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
typedef short size_type;
A2() { }
};
#endif
int main()
{
BOOST_TEST_EQ(boost::allocator_max_size(A1<int>()), 1);
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_LE(boost::allocator_max_size(A2<int>()),
(std::numeric_limits<short>::max)());
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
typedef std::true_type propagate_on_container_copy_assignment;
};
#endif
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_copy_assignment<A1<int> >::type));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_copy_assignment<A2<int> >::type));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
typedef std::true_type propagate_on_container_move_assignment;
};
#endif
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_move_assignment<A1<int> >::type));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_move_assignment<A2<int> >::type));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
typedef std::true_type propagate_on_container_swap;
};
#endif
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_swap<A1<int> >::type));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_swap<A2<int> >::type));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int* pointer;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_pointer<A1<char> >::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_pointer<A2<int> >::type>));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,37 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
template<class>
struct rebind {
typedef A1<int> other;
};
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
boost::allocator_rebind<A1<char>, bool>::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
boost::allocator_rebind<A2<char>, int>::type>));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,35 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int size_type;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::allocator_size_type<A1<char> >::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<
std::make_unsigned<std::ptrdiff_t>::type,
boost::allocator_size_type<A2<int> >::type>));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,41 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
struct A1 {
typedef T value_type;
A1(int n)
: value(n) { }
int value;
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
A2(int n)
: value(n) { }
A2 select_on_container_copy_construction() const {
return A2(value + 1);
}
int value;
};
#endif
int main()
{
BOOST_TEST_EQ(1, boost::
allocator_select_on_container_copy_construction(A1<int>(1)).value);
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_EQ(2, boost::
allocator_select_on_container_copy_construction(A2<int>(1)).value);
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,22 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::allocator_value_type<A<int> >::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,39 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int* pointer;
typedef int* void_pointer;
template<class U>
struct rebind {
typedef A1<U> other;
};
};
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T>
struct A2 {
typedef T value_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_void_pointer<A1<char> >::type>));
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
boost::allocator_void_pointer<A2<int> >::type>));
#endif
return boost::report_errors();
}

29
test/bit_cast_test.cpp Normal file
View File

@@ -0,0 +1,29 @@
// Test for boost/core/bit.hpp (bit_cast)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <cstring>
int main()
{
{
float x = 0.89f;
boost::uint32_t y = boost::core::bit_cast<boost::uint32_t>( x );
BOOST_TEST( std::memcmp( &x, &y, sizeof(x) ) == 0 );
}
{
double x = 0.89;
boost::uint64_t y = boost::core::bit_cast<boost::uint64_t>( x );
BOOST_TEST( std::memcmp( &x, &y, sizeof(x) ) == 0 );
}
return boost::report_errors();
}

65
test/bit_ceil_test.cpp Normal file
View File

@@ -0,0 +1,65 @@
// Test for boost/core/bit.hpp (bit_ceil)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/detail/splitmix64.hpp>
#include <boost/cstdint.hpp>
#include <limits>
template<class T> void test_bit_ceil( T x )
{
if( !boost::core::has_single_bit( x ) )
{
x >>= 1;
}
T y = boost::core::bit_ceil( x );
if( x == 0 )
{
BOOST_TEST_EQ( y, 0 );
}
else
{
BOOST_TEST( boost::core::has_single_bit( y ) );
BOOST_TEST_GE( +y, +x );
BOOST_TEST_LT( y >> 1, +x );
}
}
int main()
{
{
test_bit_ceil( static_cast<unsigned char>( 0 ) );
test_bit_ceil( static_cast<unsigned short>( 0 ) );
test_bit_ceil( static_cast<unsigned int>( 0 ) );
test_bit_ceil( static_cast<unsigned long>( 0 ) );
test_bit_ceil( static_cast<unsigned long long>( 0 ) );
}
{
test_bit_ceil( static_cast<boost::uint8_t>( 0x80 ) );
test_bit_ceil( static_cast<boost::uint16_t>( 0x8000 ) );
test_bit_ceil( static_cast<boost::uint32_t>( 0x80000000 ) );
test_bit_ceil( static_cast<boost::uint64_t>( 0x8000000000000000 ) );
}
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_bit_ceil( static_cast<unsigned char>( x ) );
test_bit_ceil( static_cast<unsigned short>( x ) );
test_bit_ceil( static_cast<unsigned int>( x ) );
test_bit_ceil( static_cast<unsigned long>( x ) );
test_bit_ceil( static_cast<unsigned long long>( x ) );
}
return boost::report_errors();
}

46
test/bit_countl_test.cpp Normal file
View File

@@ -0,0 +1,46 @@
// Test for boost/core/bit.hpp (countl_zero, countl_one)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/detail/splitmix64.hpp>
#include <boost/cstdint.hpp>
#include <limits>
template<class T> void test_countl( T x )
{
x |= static_cast<T>( 1 ) << ( std::numeric_limits<T>::digits - 1 );
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x >>= 1 )
{
BOOST_TEST_EQ( boost::core::countl_zero( x ), i );
BOOST_TEST_EQ( boost::core::countl_one( static_cast<T>( ~x ) ), i );
}
}
int main()
{
test_countl( static_cast<unsigned char>( 0 ) );
test_countl( static_cast<unsigned short>( 0 ) );
test_countl( static_cast<unsigned int>( 0 ) );
test_countl( static_cast<unsigned long>( 0 ) );
test_countl( static_cast<unsigned long long>( 0 ) );
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_countl( static_cast<unsigned char>( x ) );
test_countl( static_cast<unsigned short>( x ) );
test_countl( static_cast<unsigned int>( x ) );
test_countl( static_cast<unsigned long>( x ) );
test_countl( static_cast<unsigned long long>( x ) );
}
return boost::report_errors();
}

46
test/bit_countr_test.cpp Normal file
View File

@@ -0,0 +1,46 @@
// Test for boost/core/bit.hpp (countr_zero, countr_one)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/detail/splitmix64.hpp>
#include <boost/cstdint.hpp>
#include <limits>
template<class T> void test_countr( T x )
{
x |= 1;
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x <<= 1 )
{
BOOST_TEST_EQ( boost::core::countr_zero( x ), i );
BOOST_TEST_EQ( boost::core::countr_one( static_cast<T>( ~x ) ), i );
}
}
int main()
{
test_countr( static_cast<unsigned char>( 0 ) );
test_countr( static_cast<unsigned short>( 0 ) );
test_countr( static_cast<unsigned int>( 0 ) );
test_countr( static_cast<unsigned long>( 0 ) );
test_countr( static_cast<unsigned long long>( 0 ) );
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_countr( static_cast<unsigned char>( x ) );
test_countr( static_cast<unsigned short>( x ) );
test_countr( static_cast<unsigned int>( x ) );
test_countr( static_cast<unsigned long>( x ) );
test_countr( static_cast<unsigned long long>( x ) );
}
return boost::report_errors();
}

36
test/bit_endian_test.cpp Normal file
View File

@@ -0,0 +1,36 @@
// Test for boost/core/bit.hpp (bit_ceil)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <cstring>
int main()
{
boost::uint64_t v = static_cast<boost::uint64_t>( 0x0102030405060708ull );
if( boost::core::endian::native == boost::core::endian::little )
{
unsigned char w[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
BOOST_TEST( std::memcmp( &v, w, 8 ) == 0 );
}
else if( boost::core::endian::native == boost::core::endian::big )
{
unsigned char w[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
BOOST_TEST( std::memcmp( &v, w, 8 ) == 0 );
}
else
{
unsigned char w1[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
BOOST_TEST( std::memcmp( &v, w1, 8 ) != 0 );
unsigned char w2[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
BOOST_TEST( std::memcmp( &v, w2, 8 ) != 0 );
}
return boost::report_errors();
}

53
test/bit_floor_test.cpp Normal file
View File

@@ -0,0 +1,53 @@
// Test for boost/core/bit.hpp (bit_floor)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/detail/splitmix64.hpp>
#include <boost/cstdint.hpp>
#include <limits>
template<class T> void test_bit_floor( T x )
{
T y = boost::core::bit_floor( x );
if( x == 0 )
{
BOOST_TEST_EQ( y, 0 );
}
else
{
BOOST_TEST( boost::core::has_single_bit( y ) );
BOOST_TEST_LE( +y, +x );
BOOST_TEST_GT( +y, x >> 1 );
}
}
int main()
{
{
test_bit_floor( static_cast<unsigned char>( 0 ) );
test_bit_floor( static_cast<unsigned short>( 0 ) );
test_bit_floor( static_cast<unsigned int>( 0 ) );
test_bit_floor( static_cast<unsigned long>( 0 ) );
test_bit_floor( static_cast<unsigned long long>( 0 ) );
}
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_bit_floor( static_cast<unsigned char>( x ) );
test_bit_floor( static_cast<unsigned short>( x ) );
test_bit_floor( static_cast<unsigned int>( x ) );
test_bit_floor( static_cast<unsigned long>( x ) );
test_bit_floor( static_cast<unsigned long long>( x ) );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,46 @@
// Test for boost/core/bit.hpp (bit_ceil)
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/bit.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/detail/splitmix64.hpp>
#include <boost/cstdint.hpp>
#include <limits>
#include <iostream>
template<class T> void test_popcount( T x )
{
int k = 0;
for( T y = x; y; y &= y - 1, ++k );
BOOST_TEST_EQ( boost::core::popcount( x ), k ) || ( std::cerr << "x: " << +x << std::endl );
}
int main()
{
{
test_popcount( static_cast<unsigned char>( 0 ) );
test_popcount( static_cast<unsigned short>( 0 ) );
test_popcount( static_cast<unsigned int>( 0 ) );
test_popcount( static_cast<unsigned long>( 0 ) );
test_popcount( static_cast<unsigned long long>( 0 ) );
}
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_popcount( static_cast<unsigned char>( x ) );
test_popcount( static_cast<unsigned short>( x ) );
test_popcount( static_cast<unsigned int>( x ) );
test_popcount( static_cast<unsigned long>( x ) );
test_popcount( static_cast<unsigned long long>( x ) );
}
return boost::report_errors();
}

Some files were not shown because too many files have changed in this diff Show More