1
0
forked from boostorg/core

Compare commits

...

391 Commits

Author SHA1 Message Date
47dab0d545 glob headers 2022-07-05 10:48:07 +02:00
17513d123b Rework as esp-idf component 2022-07-04 19:41:22 +02:00
ac9d79992e Update ci.yml 2022-06-24 14:09:47 +03:00
b6c3190468 Add tn_holder specializations for __int128 (avoids macOS link errors for missing typeinfo for same) 2022-05-30 04:03:18 +03:00
f941d2e1f7 Add tests for __int128 to type_name_test.cpp 2022-05-30 03:00:37 +03:00
c0e2211c2b Simplify test 2022-05-14 13:05:56 -04:00
eec8689d58 Merge pull request #116 from boostorg/feature/span_boost_begin_test
Add test around the MSVC defect
2022-05-14 01:59:39 -04:00
45e5b1ebcf Add test around the MSVC defect 2022-05-14 00:51:05 -04:00
8645bcb06e Merge pull request #101 from boostorg/feature/bit_use_if_constexpr
bit.hpp: Use C++17 if constexpr where possible
2022-05-14 04:35:13 +03:00
ebff02a932 Merge pull request #115 from glenfe/develop
Remove inline friend begin and end functions
2022-05-13 20:45:27 -04:00
42ed795866 Remove inline friend begin and end functions 2022-05-13 18:26:08 -04:00
0212774324 Avoid -Wshadow warning under g++ 4.8 2022-04-29 02:43:37 +03:00
43d0da03f3 Remove msvc-14.1 from ci.yml 2022-04-28 21:28:11 +03:00
0011697492 Add hash_value (refs #110) 2022-04-28 20:42:48 +03:00
d74140983d Correct definition of C++11 alias rebind 2022-04-26 14:11:31 -04:00
1e5c86eb9d Add tests for the C++11 alias rebind 2022-04-26 14:10:21 -04:00
00cc660f28 Merge pull request #108 from Aiee/fix-typo
[Minor] Fix typo
2022-04-19 11:17:52 +03:00
44610b65ba Fix typo 2022-04-19 15:26:36 +08:00
5e0ff1680f Use a different workaround for supporting noinit_adaptor in C++03 2022-03-15 14:47:39 -04:00
4defdfd233 Add allocator_construct_n to allocator_access and deprecate alloc_construct 2022-03-12 10:45:05 -05:00
c4deb479fd Add detection support for single argument construct and destroy 2022-03-12 01:31:31 -05:00
f326683d42 Add allocator_construct and allocator_destroy tests to Jamfile 2022-03-12 00:51:52 -05:00
dbefea9631 Update revision history 2022-02-15 20:54:37 +02:00
a32c1ee7ac Disable test under CMake, CTest doesn't like crashing tests 2022-02-15 06:49:46 +02:00
230dd83002 Add newlines, fflush 2022-02-15 06:49:46 +02:00
ec91f29d56 Disable msvc warnings 2022-02-15 06:49:46 +02:00
188ca25bf3 Mark verbose_terminate_handler as inline 2022-02-15 06:49:46 +02:00
ed84fc4e23 Document verbose_terminate_handler 2022-02-15 06:49:46 +02:00
622b7a398a Add core/verbose_terminate_handler.hpp 2022-02-15 06:49:46 +02:00
35a4e09854 Add clang-win to GHA 2022-02-15 05:46:09 +02:00
b7c987f83c Mark quick_exit as inline 2022-02-15 02:08:30 +02:00
89d8efb7ff Avoid -Wlong-long in bit_ceil_test.cpp 2022-02-08 22:58:45 +02:00
f12eeb6b9f Avoid -Wlong-long in bit_rotate_test.cpp 2022-02-08 22:55:08 +02:00
ad63dcda9f Fix -Wlong-long warnings in splitmix64.hpp 2022-02-08 22:49:44 +02:00
6a5f726602 Add splitmix64_test.cpp 2022-02-08 22:48:01 +02:00
cf619432a7 Fix GCC -Wlong-long warnings 2022-02-08 22:00:42 +02:00
b38c148969 Enable -pedantic for the cmath.hpp and bit.hpp tests 2022-02-08 21:37:34 +02:00
bae7c049b0 Avoid conversion warning in bit_width 2022-01-19 17:20:39 +02:00
ea7b623b7d Use consistent section titles in documentation 2022-01-07 11:16:44 -05:00
6ae6ff79f1 Deprecated boost/iterator.hpp, emit warnings on inclusion.
The header defines boost::iterator template, which is an alias for
std::iterator, which is itself deprecated since C++17.

Updated test to avoid testing the definition in C++17 onwards
to avoid failures due to deprecation warnings from libc++-13.
2021-12-23 16:46:29 +03:00
06976ccad7 Use path-constant to specify path to headers in docs Jamfile. 2021-12-23 15:10:58 +03:00
65723e0e1f Added clang-13 CI jobs. 2021-12-23 14:50:35 +03:00
df3b9827cf Enclose std::min in parentheses to guard against <windows.h> 2021-12-20 01:35:55 +02:00
392cc988dd Add sv_windows_h_test 2021-12-20 01:30:32 +02:00
0ef1c06fd8 Add cxxstd=20 to msvc-14.2, msvc-14.3 2021-12-18 21:59:21 +02:00
0b9624d047 Add sv_common_reference_test2 2021-12-18 18:53:42 +02:00
574c7cf86e Update string_view.hpp to use BOOST_NO_CXX20_HDR_CONCEPTS 2021-12-18 18:39:03 +02:00
6e6af5fc90 Update sv_common_reference_test to check BOOST_NO_CXX20_HDR_CONCEPTS 2021-12-18 18:18:19 +02:00
95f2a76c90 Specialize std::basic_common_reference to enable std::common_reference and std::common_reference_with 2021-12-18 07:43:33 +02:00
28d26d13f1 Add sv_common_reference_test 2021-12-18 07:34:16 +02:00
ac71c55b4e Remove msvc-14.2 from appveyor.yml (in GHA); use clang-win from VS2019 2021-12-18 05:07:12 +02:00
c83e682b7e Update ci.yml 2021-12-18 05:05:36 +02:00
7a79d17da2 Add conversions from and to boost::string_view 2021-12-18 04:15:06 +02:00
02b3f91fc3 Use same style of detection in pointer_traits and allocator_traits 2021-12-15 15:30:57 -05:00
a2b37091eb Update documentation 2021-12-15 11:36:02 -05:00
78dd0cce2f Make pointer_to SFINAE friendlier 2021-12-15 09:31:34 -05:00
a121ab0278 Update release notes for 1.79 2021-12-14 07:52:42 -05:00
0e62373aa2 Make pointer_traits SFINAE friendly 2021-12-13 13:13:12 -05:00
6da7958281 Update unit tests 2021-12-08 10:26:49 -05:00
c8479b4eca Simplify C++03 detection traits slightly 2021-12-07 21:17:28 -05:00
f5ab83efe8 Merge pull request #104 from boostorg/feature/allocator_access
Support additional is_empty intrinsics
2021-12-07 11:02:04 -05:00
eb7bc1ff53 Support additional is_empty intrinsics 2021-12-07 10:10:07 -05:00
d038633f98 Correct spelling of detail macro 2021-12-07 02:57:14 -05:00
ac4bdcc4c5 Update documentation 2021-12-06 23:43:03 -05:00
85a3183c01 Update bool constant 2021-12-06 23:36:48 -05:00
0c9675cf56 Add partial C++03 support for C++11 allocator model 2021-12-06 19:56:57 -05:00
5abadf4472 Change A::value_type to allocator_value_type 2021-12-06 16:41:16 -05:00
6b3fb219cc Minor refactoring in allocator access 2021-12-06 15:58:48 -05:00
febc195093 Add default_allocator allocate hint overload in C++03 mode 2021-12-04 14:41:23 -05:00
8985ce604e Simplify test 2021-12-04 14:39:36 -05:00
15c884438c Correct note in documentation 2021-12-04 14:38:18 -05:00
15f7fb7eaa Move Notes to a top level section 2021-12-04 00:32:27 -05:00
46f37b2f16 Make max_size noexcept 2021-12-04 00:24:45 -05:00
c1be2097d7 Minor documentation changes 2021-12-04 00:22:51 -05:00
c8b989d80b Add allocator_traits that uses allocator_access 2021-12-03 23:55:40 -05:00
74c770206a Allow all individual traits to be specialized 2021-12-02 23:09:09 -05:00
a1ad1784bf Updated check for apt-add-repository capabilities.
In Ubuntu 20.04 there appeared an updated version of the
software-properties-common package in focal-updates, which ships a newer
apt-add-repository version that doesn't support -P/-S/-U command line arguments.

Since we cannot rely on package version checks to determine apt-add-repository
capabilities, we have to parse its --help output instead.

Also, made source list processing more protected against spaces.
2021-11-16 00:36:15 +03:00
213e4695bf Use C++17 if constexpr where possible. 2021-11-01 22:35:28 +03:00
a4172b4319 MSVC warning workaround for empty_value 2021-11-01 06:33:44 -04:00
e4fb94b73c Merge branch 'develop' into feature/warnings-as-errors 2021-11-01 05:12:33 +02:00
ef3505db59 Disable -Wtype-limits for g++ 4.4 in Jamfile 2021-11-01 04:44:07 +02:00
f94db671f6 Disable C4702 in lightweight_test_fail6, no_exceptions_support_test 2021-11-01 04:17:51 +02:00
7b45315af1 Avoid C4996 in sv_copy_test.cpp 2021-11-01 04:15:33 +02:00
bdd4bf7d9a #pragma GCC diagnostic push requires g++ 4.6 2021-11-01 04:04:52 +02:00
9f2cdfa7d2 Disable C4244 in scoped_enum.cpp, underlying_type.cpp 2021-11-01 03:58:37 +02:00
964ef98eee Avoid streamsize -> size_t warning in string_view.hpp 2021-11-01 03:52:09 +02:00
f09ab90243 Disable -Wsign-compare for g++ 4.4 2021-11-01 03:14:53 +02:00
d2e897fd60 MSVC warning workaround for dynamic_extent 2021-10-31 21:14:40 -04:00
66f6ea594a Disable -Wtype-limits in string_view.hpp 2021-11-01 03:10:42 +02:00
6a91536da6 Disable -Wunused-function in swap_array(_of_array)_of_class.cpp 2021-11-01 03:05:47 +02:00
c3a398b9a0 Merge branch 'develop' into feature/warnings-as-errors 2021-11-01 02:56:47 +02:00
e73e8bfc83 Disable C4512 in uncaught_exceptions(_np).cpp 2021-11-01 02:55:52 +02:00
633a47f85b MSVC warning workaround for destroy 2021-10-31 20:52:44 -04:00
eae98e909e MSVC warning workaround for as_bytes 2021-10-31 20:52:23 -04:00
a581a42c4f Disable C4577 in no_exceptions_support_test.cpp 2021-11-01 02:50:16 +02:00
e44781e290 Avoid C4101 in explicit_operator_bool_noexcept.cpp 2021-11-01 02:44:24 +02:00
11958e9568 Avoid C4101 in scoped_enum.cpp 2021-11-01 02:42:03 +02:00
56566d9abc Disable C4100 in alloc_construct_cxx11_test.cpp 2021-11-01 02:38:19 +02:00
9efeed68cb Disable C4530 in no_exceptions_support_test.cpp 2021-11-01 02:32:49 +02:00
da3c89dc5b Apply a better fix to iterator_test.cpp 2021-11-01 02:26:06 +02:00
ba208ad7fc Avoid signed/unsigned mismatch warning in span.hpp 2021-11-01 02:20:26 +02:00
bbfa6344fa Avoid ptrdiff_t -> int warning in eif_constructors.cpp 2021-11-01 02:18:51 +02:00
bf4354a3a4 Disable C4127 in bit_endian_test.cpp 2021-11-01 02:16:31 +02:00
a4b661068d Disable C4127, C4244 in bit.hpp 2021-11-01 02:14:43 +02:00
8299d25eb2 Avoid size_t to int conversion warning in visit_each_test.cpp 2021-11-01 02:06:42 +02:00
847f9d43fe Disable C4702 in quick_exit_test.cpp, quick_exit_fail.cpp 2021-11-01 02:04:45 +02:00
44e294fff1 Avoid unused parameter warning in to_address_test.cpp 2021-11-01 01:58:05 +02:00
b5f59858b9 Avoid unused parameter warning in visit_each_test.cpp 2021-11-01 01:56:27 +02:00
bed07e7d5b Disable -Wdeprecated-declarations in iterator_test.cpp 2021-11-01 01:47:28 +02:00
971cda2e4c Avoid -Wmissing-braces in swap_array_of_template.cpp 2021-11-01 01:45:15 +02:00
d81c61abb4 Disable -Wstring-plus-int in lightweight_test_fail10.cpp 2021-11-01 01:43:50 +02:00
370a74c249 Avoid self-assignment warning in ref_ct_test.cpp 2021-11-01 01:41:54 +02:00
62d1b1bb59 Avoid sturct/class mismatch warning in use_default_test.cpp 2021-11-01 01:39:13 +02:00
bb99544852 Use warnings-as-errors=off for compile-fail tests 2021-11-01 01:35:57 +02:00
9b5bf05fae Disable -Wdeprecated-declarations in get_pointer_test.cpp 2021-11-01 01:29:15 +02:00
309a6bb797 Fix unused parameter 't' warnings in eif_*.cpp 2021-11-01 01:27:01 +02:00
9d1b59ec6c Enable warnings=extra, warnings-as-errors=on 2021-11-01 01:24:02 +02:00
12f5f51427 Switch tests to not rely on requires checks 2021-10-27 01:41:40 -04:00
0565456622 Use boost::(u)long_long_type to avoid g++ warning 2021-10-27 04:45:40 +03:00
fda0f87576 Add void, move nullptr_t to fundamental type section 2021-10-27 03:46:06 +03:00
e9718374ac Hardcode all integral and floating point types 2021-10-27 03:41:40 +03:00
79b7c49fb3 Refactor typeid_name<T> slighlty 2021-10-27 03:20:22 +03:00
585ac9ace1 Move string_view.hpp to boost/core/detail 2021-10-27 03:08:10 +03:00
493832a570 Remove string_view from documentation 2021-10-27 02:57:55 +03:00
8942e8ecc9 Update cmake_subdir_test/CMakeLists.txt 2021-10-26 01:00:15 +03:00
cbf03c4b9c Add msvc-14.3 to GHA 2021-10-26 00:54:37 +03:00
5cf3569218 Correct documentation 2021-10-20 22:26:25 -04:00
d5bd40e528 Update test/Jamfile and test/CMakeLists.txt so that missing dependencies are caught 2021-10-16 18:10:13 +03:00
0e57df5aab Regenerate CMakeLists.txt 2021-10-16 17:55:35 +03:00
62b23df9ef Update revision history 2021-10-15 19:00:57 -04:00
fdf1ed78a7 Contribute span implementation 2021-10-14 21:16:19 -04:00
e02c333706 Update string_view.qbk 2021-10-11 02:09:45 +03:00
b677d1eeae Only update the necessary submodules in ci.yml 2021-10-10 19:35:26 +03:00
0f7d02de01 Update revision history 2021-10-10 19:29:46 +03:00
773499db5e Remove concurrency section from ci.yml 2021-10-10 18:23:21 +03:00
ce912859aa Change cancel-in-progress to false in ci.yml 2021-10-10 18:22:08 +03:00
bfeee019dd Update revision history 2021-10-10 18:20:46 +03:00
220d4ae0a9 Improve starts_with/ends_with 2021-10-10 17:47:57 +03:00
5d7b469e29 Improve .find 2021-10-10 03:09:53 +03:00
3cec508460 Update string_view.qbk 2021-10-10 02:25:50 +03:00
a47fac1449 Update string_view.qbk 2021-10-10 02:04:43 +03:00
7340f123fe Update string_view.qbk 2021-10-10 01:46:32 +03:00
038064e824 Update string_view.qbk 2021-10-10 00:44:00 +03:00
52c58efc36 Improve operator== 2021-10-09 21:04:38 +03:00
15fdc0ab39 Test std::pmr::string in sv_lt_test 2021-10-09 20:14:06 +03:00
b520289660 Test std::pmr::string in sv_eq_test 2021-10-09 20:12:32 +03:00
9b22937647 g++ 11 has <memory_resource> but not std::pmr::string 2021-10-09 20:06:20 +03:00
903d44c0c5 Test std::pmr::string in sv_conversion_test 2021-10-09 19:52:10 +03:00
88eee0c628 Test std::pmr::string in sv_construct_test 2021-10-09 19:50:34 +03:00
54965f567d Add an allocator argument to operator string() 2021-10-09 19:50:15 +03:00
c43a172ded Use os << "" for the padding instead of os << p[0] 2021-10-09 19:31:41 +03:00
ddf9b5087b Add sv_conversion_test 2021-10-09 18:36:05 +03:00
d17313d407 Add missing #include <ios> 2021-10-09 18:00:58 +03:00
c8b860704e Add sv_stream_insert_test 2021-10-09 17:36:06 +03:00
e9ffc4336c Remove unused npos variables 2021-10-09 17:10:52 +03:00
a121d5a000 Add sv_lt_test 2021-10-09 17:09:23 +03:00
5c82e38c93 Add other relational operators; update sv_eq_test 2021-10-09 16:55:33 +03:00
db15c7419d Add sv_eq_test 2021-10-09 16:50:14 +03:00
62e9d9b868 Update tests 2021-10-09 07:13:56 +03:00
b01f2fe4d2 Add optimized implementation of find_last_not_of 2021-10-09 07:08:48 +03:00
408cd96595 Update sv_find_last_not_of_test 2021-10-09 07:00:32 +03:00
9f2ec3bfca Update find_first_not_of_test 2021-10-09 06:58:11 +03:00
63f3a97a15 Update find_last_of_test 2021-10-09 06:54:23 +03:00
b70bbf14db Update sv_find_first_of_test 2021-10-09 06:52:08 +03:00
b251310a8f Update implementation of find_last_of 2021-10-09 06:47:39 +03:00
969a201c75 Update implementation of find_first_of 2021-10-09 06:43:48 +03:00
b9f1b9f39a Add optimized implementation of find_first_not_of 2021-10-09 06:40:59 +03:00
3d4eb536cd Add optimized implementation of find_last_of 2021-10-09 05:13:23 +03:00
a51364c5d3 sv_find_last_not_of_test 2021-10-09 03:33:10 +03:00
ab3950fdfb Add sv_find_first_not_of_test 2021-10-09 03:09:32 +03:00
fe9c0164c0 Add sv_find_last_of_test 2021-10-09 02:32:00 +03:00
8ec0e7f68a Merge branch 'develop' into feature/string-view 2021-10-09 01:50:17 +03:00
85e24f0483 Disable std::tuple tests on msvc-10.0 2021-10-08 18:21:04 +03:00
be820fea2e Remove uint64_t mask path from find_first_of; no longer a win after fix 2021-10-08 10:28:06 +03:00
af3e6a667b Update sv_find_first_of_test 2021-10-08 10:21:07 +03:00
c3cfe7a861 Merge branch 'develop' into feature/string-view 2021-10-08 10:15:05 +03:00
d87766a768 Remove no longer necessary workarounds 2021-10-08 10:14:21 +03:00
706747ab08 Work around g++'s instantiating X on typeid(X*) 2021-10-08 09:44:23 +03:00
41c3b6a7dd Reimplement type_name with class templates to avoid instantiating types such as pair<void, void> and tuple<void> 2021-10-08 09:23:26 +03:00
8223ff03e4 Add char8_t tests to sv_find_first_of_test 2021-10-08 07:14:54 +03:00
18334b1614 Add optimized implementation of find_first_of 2021-10-08 07:03:39 +03:00
df65ea6600 Update sv_find_first_of_test 2021-10-08 06:21:52 +03:00
d1ad50cefb Add sv_contains_test 2021-10-08 05:50:00 +03:00
09870f0739 Add sv_find_first_of_test 2021-10-08 05:39:24 +03:00
95e64ef71f Fix msvc-14.0 failure 2021-10-06 17:45:10 +03:00
673e3c302c Add sv_rfind_test 2021-10-06 05:49:09 +03:00
a8e7a3395e Add sv_iteration_test 2021-10-06 05:36:12 +03:00
09044f58d6 Add sv_find_test 2021-10-06 05:04:32 +03:00
f9fa1772f2 Add sv_ends_with_test 2021-10-06 04:39:16 +03:00
c7dfa29f29 Add sv_starts_with_test 2021-10-06 04:38:27 +03:00
93c18fb937 Use BOOST_TEST_TRAIT_SAME in sv_types_test 2021-10-06 03:36:40 +03:00
c005ad5e55 Merge branch 'develop' into feature/string-view 2021-10-06 03:32:05 +03:00
8cf4d16297 Merge branch 'feature/type-name' into feature/lwt-type-name 2021-10-05 19:47:11 +03:00
0deaa2d502 Update msvc-12.0 workaround 2021-10-05 19:22:20 +03:00
22de922125 Merge branch 'develop' into feature/type-name 2021-10-05 19:17:39 +03:00
3ec157eb6f Disable cmath_test_generic on msvc-8.0 2021-10-05 19:16:24 +03:00
531726eb09 Update msvc workarounds in type_name_test 2021-10-05 19:05:40 +03:00
31a9336778 Merge branch 'develop' into feature/lwt-type-name 2021-10-05 18:47:25 +03:00
75fc48ad32 Add a revision history section to documentation 2021-10-05 18:46:47 +03:00
87c21a23bb Update copyright 2021-10-05 17:32:50 +03:00
3e9cc2153b Disable no-rtti tests for g++ 4.4 because <memory> breaks 2021-10-05 17:11:31 +03:00
98630095f3 Merge branch 'develop' into feature/lwt-type-name 2021-10-05 16:24:49 +03:00
6985b1ae25 Remove extra semicolons 2021-10-05 15:53:16 +03:00
8ab119135c Add overload for char8_t because Mac has no typeinfo for char8_t 2021-10-05 15:46:22 +03:00
1fd2cadddd g++ 4.4 has no string::front 2021-10-05 15:38:33 +03:00
bb0c6381f6 Add msvc workarounds 2021-10-05 08:04:01 +03:00
4f6f7c3799 Add tests for all fundamental types 2021-10-05 07:50:52 +03:00
cd1a8fd238 Support pointers to members 2021-10-05 07:25:35 +03:00
b0b48c5783 Support qualified function types 2021-10-05 07:05:34 +03:00
ccdf5ce031 Track the type suffix independently for better decomposition of functions and arrays 2021-10-05 06:45:41 +03:00
b3906601f7 Merge branch 'feature/type-name' into feature/lwt-type-name 2021-10-05 05:43:01 +03:00
f833040d48 Disable msvc warnings around tn_is_function 2021-10-05 05:42:41 +03:00
3b5595e940 Merge branch 'feature/type-name' into feature/lwt-type-name 2021-10-05 05:31:09 +03:00
b93317815c Apply msvc-12.0 (and below) workarounds 2021-10-05 05:30:37 +03:00
01bd23df5d Add tests for function types 2021-10-05 05:04:56 +03:00
36cec9a5cc Handle references to functions 2021-10-05 05:01:05 +03:00
290340fd27 Use core::type_name in lightweight_test_trait 2021-10-05 04:58:52 +03:00
31e2caef12 Add sv_compare_test 2021-10-04 22:11:14 +03:00
042bb98142 Add sv_substr_test 2021-10-04 20:57:10 +03:00
c65c05c006 Add sv_copy_test 2021-10-04 20:45:10 +03:00
1aa8341bd7 Add sv_modifiers_test 2021-10-04 20:36:40 +03:00
e206cddc6f Fix line endings 2021-10-04 20:27:14 +03:00
c8b55f1bde Change BOOST_CONSTEXPR to BOOST_CXX14_CONSTEXPR appropriately 2021-10-04 19:12:05 +03:00
62ba7ca18b Define npos as BOOST_CONSTEXPR_OR_CONST 2021-10-04 19:08:12 +03:00
964dfe2b74 Fix line endings 2021-10-04 17:45:24 +03:00
016ae92ecf Add sv_element_access_test 2021-10-04 17:33:04 +03:00
7d05dfa87d Add sv_construct_test 2021-10-04 17:25:34 +03:00
95924b1329 Add boost/core/string_view.hpp 2021-10-04 16:49:46 +03:00
5e382efa84 Fix std::ostream failure on libstdc++ 2021-10-01 15:51:13 +03:00
e260bb865d Add support for string_view 2021-10-01 15:07:19 +03:00
f884833b42 Add workaround for msvc-10.0 2021-09-30 03:21:31 +03:00
8265fe6405 Minor documentation fix 2021-09-29 21:55:40 +03:00
f7b04afe4d Add documentation for type_name 2021-09-29 21:34:23 +03:00
2c1eb07a68 Add test for scoped enums 2021-09-29 21:12:54 +03:00
a5cbddc466 Add test for enums 2021-09-29 21:09:19 +03:00
91a64b3bcf Add support for std::array 2021-09-29 21:02:39 +03:00
a039f8c318 Support -fno-rtti 2021-09-29 20:53:38 +03:00
bebb7349ba Add workarounds for msvc-12.0 and earlier 2021-09-29 20:05:23 +03:00
dc6e3261ec Use typedef instead of using 2021-09-29 19:51:16 +03:00
15a7d84858 Use basic_string<char8_t> instead of u8string 2021-09-29 19:50:14 +03:00
06023d4ffe Strip libstdc++ and libc++ inline namespaces 2021-09-29 19:34:37 +03:00
3e0bc52c32 Add <boost/core/type_name.hpp> 2021-09-29 19:13:12 +03:00
b83f27a9e0 Another fix in git version check. 2021-09-26 20:35:37 +03:00
578e3105b8 Fixed git version check on Mac OS. 2021-09-26 20:31:43 +03:00
f34c4986c1 Added a timeout for GHA CI. 2021-09-15 20:45:23 +03:00
cfd469d858 Removed unused reference to extra_tests variable in GHA config. 2021-09-15 18:27:17 +03:00
b1e01b53f3 Merge branch 'develop' into feature/cmath 2021-09-14 19:15:41 +03:00
177c093151 Automatically use generic cmath if FP_SUBNORMAL isn't defined 2021-09-14 18:57:33 +03:00
cffaabead8 Update and fix CMake test jobs 2021-09-14 18:49:03 +03:00
2715f9b5d8 Add a workaround for g++ 4.4, 4.6 2021-09-14 18:35:31 +03:00
8043bafb6b Add a generic cmath.hpp implementation, enabled when BOOST_CORE_USE_GENERIC_CMATH is defined 2021-09-14 16:50:34 +03:00
f6bdb17fd9 Updated GitHub Actions config for better configurability.
Reworked extra package installation and added explicit specification
of external package sources. Moved some common constants to environment
variables. Removed installation of unneeded packages in the containers.
2021-09-12 18:28:02 +03:00
cd6847aee8 Update GitHub Actions config to switch Ubuntu 16.04 jobs to Docker containers.
The Ubuntu 16.04 environment is scheduled to be removed from GitHub Actions
in September 2021. Migrate those jobs to Docker containers or Ubuntu 18.04.

Also, added some older compilers. Ported CMake tests from Travis CI.

Based on https://github.com/boostorg/core/pull/95.
Closes https://github.com/boostorg/core/pull/95.
2021-09-06 02:00:12 +03:00
9ff312e2fb Updated README.md to refer to GitHub Actions instead of Travis. 2021-09-06 01:24:19 +03:00
494927312d Removed Travis CI config file.
Travis CI no longer provides (adequate) service to open source projects,
so we have switched to GitHub Actions as a replacement.
2021-09-06 01:24:19 +03:00
df91243a1d Whether wchar_t is signed is implementation-defined 2021-08-21 20:28:47 +03:00
f4b3d5dba6 Merge pull request #93 from sdarwin/feature/gha_fix
Small GHA fix, create destination dir
2021-07-27 23:53:44 +03:00
9f0b97c80b Small GHA fix, create destination dir 2021-07-27 13:35:51 -05:00
ce53cc1f8f Changed quotes in format() expression. 2021-07-02 20:38:22 +03:00
8fad14b804 Use gcc-7 toolchain for clang-8 CI job. 2021-07-02 20:35:45 +03:00
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
ffd79a28e1 Added concurrency settings to auto-cancel redundant CI jobs. 2021-07-02 20:03:50 +03:00
aa97e418f2 Increased git fetch jobs on Windows and use CPU count for build jobs. 2021-07-02 19:33:06 +03:00
f563d50d42 Use more git fetch jobs to speed up clones. 2021-07-02 19:19:48 +03:00
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
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
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
8e7ee90080 Merge pull request #92 from evanmiller/develop
Restore support for ancient Mac OS
2021-07-02 01:59:50 +03:00
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
012d96a72b Use non-const references in non-variadic branch as well 2021-06-10 10:09:46 +03:00
27d700ec01 Use non-const references in ignore_unused to avoid g++-11 warning 2021-06-10 09:54:51 +03:00
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
1a011cde56 Initialize variables in ignore_unused_test to avoid a g++-11 warning 2021-06-10 08:25:28 +03:00
71c3d320d5 Update ci.yml 2021-06-10 07:20:24 +03:00
b3fa7ca565 Take care of gcc-4.4 in addition to gcc-4.4.7 2021-06-10 04:58:17 +03:00
d3aa4a2f12 Update .travis.yml 2021-06-10 04:56:26 +03:00
67107dbaf9 Update ci.yml 2021-06-10 04:22:36 +03:00
0b74f0d394 Update CMakeLists.txt 2021-06-10 02:03:10 +03:00
e53393357f Update .github/workflows 2021-04-19 18:11:37 +03:00
7daee1d41b Add -DBUILD_TESTING=ON to .yml files; it's not default anymore 2021-03-19 03:53:31 +02:00
ddbaa242a9 Update copyright comments 2021-02-16 02:14:14 -05:00
86bff4c2d3 Revise allocator access utilities
Now supports MSVC 2013, and no workarounds use allocator_traits.
2021-02-15 22:11:41 -05:00
2e5ecbe6f6 Add test for typeid(struct X) across libraries 2021-02-11 04:43:05 +02:00
1c43651533 Test (signed char)-1 instead of 1 2021-01-20 02:40:37 +02:00
afba04cf7f Output non-printable chars as \xXY 2021-01-20 02:38:57 +02:00
0ae16756eb Add run-fail test for BOOST_TEST_NE and character types 2021-01-20 02:04:30 +02:00
2729beab83 Print char types as numeric values (C++20 deletes these ostream overloads) 2021-01-20 01:54:37 +02:00
71d60a3fb7 Fix typos in macro names 2021-01-20 01:39:09 +02:00
2642ad4562 Add test for BOOST_TEST_EQ and character types 2021-01-20 01:10:57 +02:00
f7c1f6c6ab Merge pull request #85 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 00:28:10 +02:00
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
82a51aea40 Merge branch 'develop' into feature/update-travis 2020-12-31 13:54:01 -05:00
5726534f6d Correct unit test for allocator_size_type 2020-12-31 11:41:04 -05:00
a13a82f8c1 Fix Travis configurations 2020-12-31 17:48:48 +02:00
cb94f76a5e Remove redundant configurations from Travis; add non-redundant ones 2020-12-30 20:58:04 +02:00
a6cab03127 Add documentation for bit.hpp 2020-12-30 20:34:34 +02:00
fa82b680cf Work around clang++ 3.3 failure 2020-12-30 19:40:52 +02:00
16e9536146 Implement boost::core::endian 2020-12-29 02:41:15 +02:00
919b98d425 Use __builtin_popcount 2020-12-29 02:06:56 +02:00
e8aa0c75b4 Use _BitScanForward 2020-12-29 02:02:33 +02:00
8bd2239b0b Use __builtin_ctz 2020-12-29 01:56:34 +02:00
c838ebc003 Use _BitScanReverse 2020-12-29 01:53:30 +02:00
aca46fae91 Use __builtin_clz 2020-12-29 01:28:59 +02:00
409c809cd8 Add popcount 2020-12-29 01:06:22 +02:00
dc8aa5eb39 Update test_bit_floor 2020-12-29 00:30:54 +02:00
26728848b4 Add bit_ceil 2020-12-29 00:29:44 +02:00
3e41929dfb Update bit_floor_test 2020-12-29 00:22:45 +02:00
579cb8f7f3 Add bit_floor_test 2020-12-29 00:06:25 +02:00
3b14a3677d Add has_single_bit_test 2020-12-28 23:59:58 +02:00
26991f0c75 Add bit_width_test 2020-12-28 23:52:39 +02:00
cc877e6b5b Add countl_zero, countl_one 2020-12-28 23:40:59 +02:00
123b567051 Add missing unsigned short tests to bit_rotate_test 2020-12-28 21:54:42 +02:00
a47eebf41a Add countr_zero, countr_one 2020-12-28 21:52:02 +02:00
045487ba96 Add boost/core/bit.hpp (bit_cast, rotl, rotr) 2020-12-28 21:12:22 +02:00
804c5b250d Add documentation for cmath.hpp 2020-12-24 01:20:32 +02:00
bee040b8cc Add fpclassify. 2020-12-24 00:58:56 +02:00
c307f86520 Add core/cmath.hpp 2020-12-24 00:19:20 +02:00
0364b64927 Compute LIBRARY from GITHUB_REPOSITORY 2020-12-23 06:47:00 +02:00
a04803b6cb Fix BOOST_BRANCH 2020-12-23 05:15:04 +02:00
88896d0805 Update ci.yml 2020-12-19 17:54:04 +02:00
bff4172486 Move windows.yml into ci.yml 2020-12-19 17:45:30 +02:00
ea0b1dc8a9 Rename posix.yml to ci.yml 2020-12-19 17:44:32 +02:00
3d6683edb5 Update maintainer e-mail 2020-12-12 01:01:07 +02:00
72089753f7 Add Doxygen annotation 2020-11-21 18:18:31 +02:00
156a016865 Add matrix.addrmd, toolset=gcc to windows.yml 2020-11-20 05:22:06 +02:00
0dcd164a12 Add .github/workflows 2020-11-20 04:23:22 +02:00
54671134ae Add implicit conversion between compatible reference wrappers (refs #83) 2020-11-19 18:57:56 +02:00
7bc2873e38 Update appveyor.yml 2020-11-14 22:02:03 +02:00
ca4893063f Switch to from c++2a to c++20 for gcc-10 and clang-10. 2020-08-20 15:10:47 +03:00
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
484487f958 MSVC2017 /std:c++17 warnings in allocator access 2020-07-17 09:30:00 -04:00
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
35a025d59b Untabify lightweight_test_with_fail 2020-06-15 21:32:50 +03:00
c6d72da515 Document BOOST_TEST_WITH 2020-06-07 01:32:19 +03:00
f96fb31850 Rename lw_predicate_name to lwt_predicate_name 2020-06-06 22:53:20 +03:00
b414be98c9 Add lightweight_test_with_fail 2020-06-06 21:54:16 +03:00
544fd495e5 Remove unnecessary includes, add const 2020-06-06 21:49:09 +03:00
e155e13084 Change lw_name_traits to lw_predicate_name 2020-06-06 21:48:16 +03:00
6e36923915 Added BOOST_TEST_WITH macro to verify test results with custom predicate 2020-06-06 18:52:43 +02:00
b67cce85c8 Correct spelling mistake in documentation 2020-05-28 09:20:01 -04:00
376aa7aa31 Revise allocator_access implementation 2020-05-25 16:14:40 -04:00
65901249d5 Workarounds for MSVC 2013 expression detection 2020-05-24 13:10:24 -04:00
1c16d5ed87 Workaround for MSVC 2017 warning
MSVC provides deprecated members on allocator which we detect.
2020-05-24 10:48:36 -04:00
27715ed01a Simplify alloc_construct using allocator_access 2020-05-24 02:45:11 -04:00
9f2dbba2fc Workaround for MSVC 2015 expression SFINAE 2020-05-24 02:45:00 -04:00
0159b6d8e5 Revise construction in allocator_access 2020-05-24 02:43:33 -04:00
0dbd5aaadd Update empty_value constructors 2020-05-23 19:53:16 -04:00
34373b0127 Avoid defining a macro in default_allocator 2020-05-23 15:28:10 -04:00
6a33e879dd Simplify noinit_adaptor using allocator_access 2020-05-23 12:26:33 -04:00
15db54983b Added a workaround for MSVC macro max. 2020-05-23 02:39:59 +03:00
fa6e38a9aa Upgraded clang UBSan jobs to clang 10 in Travis CI. 2020-05-22 18:35:41 +03:00
38f827e092 Added gcc 10 build jobs to Travis CI. 2020-05-22 18:33:43 +03:00
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
9c33851420 Change cxxstd to 2a on clang 10 until Boost.Build is merged to master. 2020-05-08 17:17:14 +03:00
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
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
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
d3a64554f4 Fix Travis 2020-05-06 15:28:12 +03:00
a57c1e0a80 Added clang-10 jobs to Travis CI. 2020-05-05 23:17:39 +03:00
e9ff763d79 Evaluate expression when BOOST_NO_EXCEPTIONS is defined 2020-05-02 09:34:29 -04:00
6069fea76d Add documentation for BOOST_TEST_NO_THROW 2020-05-01 15:20:25 -04:00
3ca745f400 Add BOOST_TEST_NO_THROW and print expression in BOOST_TEST_THROWS 2020-05-01 14:34:02 -04:00
94def8a3a6 Merge branch 'feature/lwt-pedantic' into develop 2020-04-28 04:21:59 +03:00
295b72cbc0 Disable -Waddress in lightweight_test_test.cpp 2020-04-28 02:04:29 +03:00
eb86df4a04 Remove duplicate test run 2020-04-27 15:56:35 -04:00
0a6b8e667b Add warnings=pedantic to the rest of the lwt tests 2020-04-27 22:29:28 +03:00
4d08e709fe Pedantic tests for default_allocator 2020-04-27 14:27:20 -04:00
12ff209bf7 Revise max_size implementation in default_allocator 2020-04-27 14:27:12 -04:00
bb0ef6d41e Disable variadic macros warning in lightweight_test_trait.hpp 2020-04-27 19:17:48 +03:00
2dd51f248b Use warnings=pedantic for some lwt tests 2020-04-27 18:47:45 +03:00
8fe9805792 Avoid C99 stdint macros in default_allocator 2020-04-26 19:49:01 -04:00
6624532550 Correct spelling in documentation 2020-04-14 19:40:41 -04:00
c31e23b362 Implement allocator access utilities 2020-04-14 14:52:30 -04:00
690514e87c Use BOOST_INLINE_CONSTEXPR in empty_value 2020-04-05 19:55:24 -04:00
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
10c01d0d56 Use std::quick_exit instead of ::quick_exit 2020-03-23 05:21:08 +02:00
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
b5c2726d1b Include cstddef in pointer_traits 2020-02-17 22:13:10 -05:00
0eecbda0b1 Remove unnecessary struct 2020-02-17 05:21:20 +02:00
2a471c3417 Add test for BOOST_TEST_* macros return values 2020-02-16 20:52:59 +02:00
5ca752323f Return a bool result from the BOOST_TEST_* macros, f.ex. to allow chaining with && 2020-02-16 20:52:12 +02:00
13e9d3d4d9 Fix typo in test/Jamfile 2020-02-16 20:17:52 +02:00
f3cd812ccb Disable 'should return report_errors()' test on CMake, because CTest doesn't like abort() 2020-01-02 21:05:07 +02:00
8f2841de83 Restrict clang-3.5 to 03/11 to avoid ::gets error 2020-01-02 21:04:06 +02:00
bf5778403e Update tools/cmake 2020-01-02 20:30:03 +02:00
fc285464aa Update Travis to Xenial 2020-01-02 20:23:07 +02:00
750625272f Add CMake tests 2020-01-02 20:00:11 +02:00
bda2b9b4b1 Disable _CrtDbgReport message boxes, displayed on debug iterator violations 2020-01-01 17:17:43 +02:00
ac4c781cac Include lightweight_test from core and workaround from config 2020-01-01 09:02:46 -05:00
72ca0d8664 Add CMake install support 2019-12-28 18:47:11 +02:00
080e8581d5 Add deprecation warnings for headers in detail dir 2019-11-23 16:53:32 +03:00
209 changed files with 17239 additions and 1200 deletions

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

@ -0,0 +1,684 @@
# Copyright 2020-2021 Peter Dimov
# Copyright 2021 Andrey Semashev
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.4
cxxstd: "98,0x"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.4
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.6
cxxstd: "03,0x"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.6
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install:
- g++-7
- 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
install:
- g++-9
- toolset: gcc-10
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- g++-11
- toolset: gcc-12
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install:
- g++-12
- name: UBSAN
toolset: gcc-12
cxxstd: "03,11,14,17,20"
ubsan: 1
os: ubuntu-22.04
install:
- g++-12
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "03,11,14"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "03,11,14"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.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
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install:
- clang-8
- g++-7
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
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-12
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
os: ubuntu-20.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install:
- clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install:
- clang-14
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-13
- libc++-13-dev
- libc++abi-13-dev
sources:
- "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"
source_keys:
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
- name: UBSAN
toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
os: ubuntu-20.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
timeout-minutes: 120
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 perl git cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
declare -a SOURCE_KEYS SOURCES
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
then
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
fi
if [ -n "${{join(matrix.sources, ' ')}}" ]
then
SOURCES=("${{join(matrix.sources, '" "')}}")
fi
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
echo "Adding key: $key"
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(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
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
then
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
then
GIT_HAS_JOBS=0
fi
else
declare -a GIT_VER=(${GIT_VERSION//./ })
declare -a GIT_MIN_VER=(2 8 0)
for ((i=0; i<${#GIT_VER[@]}; i++))
do
if [ -z "${GIT_MIN_VER[i]}" ]
then
GIT_MIN_VER[i]=0
fi
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
then
GIT_HAS_JOBS=0
break
fi
done
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
GIT_ARGS="--jobs $GIT_FETCH_JOBS"
fi
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 init tools/boost_install
git submodule init libs/headers
git submodule init tools/build
git submodule init tools/cmake
git submodule init libs/assert
git submodule init libs/config
git submodule init libs/static_assert
git submodule init libs/throw_exception
git submodule init libs/type_traits
git submodule init libs/utility
git submodule init libs/io
git submodule update $GIT_ARGS
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
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
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd ../boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: "14"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: 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 init tools/boost_install
git submodule init libs/headers
git submodule init tools/build
git submodule init tools/cmake
git submodule init libs/assert
git submodule init libs/config
git submodule init libs/static_assert
git submodule init libs/throw_exception
git submodule init libs/type_traits
git submodule init libs/utility
git submodule init libs/io
git submodule update --jobs %GIT_FETCH_JOBS%
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 embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- 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
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- 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
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- 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
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error

View File

@ -1,344 +0,0 @@
# 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
sudo: false
dist: trusty
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
- 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
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-7
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
- os: linux
dist: xenial
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-6.0
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: linux
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode7.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode8.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode9.4
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode10.1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
script:
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- 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 update --jobs 4
- 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 ${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

View File

@ -1,13 +1,13 @@
# Copyright 2018 Peter Dimov
# Generated by `boostdep --cmake core`
# Copyright 2020, 2021 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
# https://www.boost.org/LICENSE_1_0.txt
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
if(NOT DEFINED IDF_TARGET)
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.5...3.20)
project(BoostCore LANGUAGES CXX)
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_core INTERFACE)
add_library(Boost::core ALIAS boost_core)
@ -15,7 +15,34 @@ add_library(Boost::core ALIAS boost_core)
target_include_directories(boost_core INTERFACE include)
target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
INTERFACE
Boost::assert
Boost::config
Boost::static_assert
Boost::throw_exception
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()
else()
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
idf_component_register(
SRCS
${headers}
INCLUDE_DIRS
include
REQUIRES
boost_assert
boost_config
boost_static_assert
boost_throw_exception
)
endif()

View File

@ -8,12 +8,12 @@ The criteria for inclusion is that the utility component be:
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core itself, Config, Assert, Static Assert, or Predef.
### CI Status
### Build 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)
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
---------|----------------|--------- | ----------- | ------------ |
Develop | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/filesystem/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/core) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/core.html)
Master | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/filesystem/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/core) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/core.html)
### Directories

View File

@ -1,4 +1,4 @@
# Copyright 2016-2019 Peter Dimov
# Copyright 2016-2021 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)
@ -16,6 +16,7 @@ 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
@ -28,15 +29,10 @@ environment:
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
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
CXXSTD: 14,17,latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
@ -76,6 +72,8 @@ install:
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init libs/utility
- git submodule init libs/io
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule update --jobs 4
@ -89,4 +87,4 @@ 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
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker

View File

@ -5,12 +5,15 @@
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://boost.org/LICENSE_1_0.txt)
import project ;
import doxygen ;
import quickbook ;
path-constant INCLUDES : ../../.. ;
doxygen ref_reference
:
[ glob ../../../boost/core/ref.hpp ]
$(INCLUDES)/boost/core/ref.hpp
:
<doxygen:param>ENABLE_PREPROCESSING=YES
<doxygen:param>EXPAND_ONLY_PREDEF=YES

View File

@ -1,149 +0,0 @@
[/
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]

302
doc/allocator_access.qbk Normal file
View File

@ -0,0 +1,302 @@
[/
Copyright 2020-2022 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.
It also adds additional functionality for allocator aware exception safe
construction and destruction of arrays.
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`.
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::allocator_construct_n(a, boost::to_address(p), n);
} catch (...) {
a.deallocate(p, n);
throw;
}
return p;
}
```
[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_construct_n(A& a, T* p, std::size_t n);
template<class A, class T>
void allocator_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 allocator_construct_n(A& a, T* p, std::size_t n, I begin);
template<class A, class T>
void allocator_destroy(A& a, T* p);
template<class A, class T>
void allocator_destroy_n(A& a, T* p, std::size_t n);
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
`allocator_value_type_t<A>*`.]]
[[`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 alloc_construct_n(A& a, T* p, std::size_t n);`]
[Constructs each `i`-th element in order by calling
`boost::allocator_construct(a, &p[i])`.
If an exception is thrown destroys each already constructed `j`-th element in
reverse order by calling `boost::allocator_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);`]
[Constructs each `i`-th element in order by calling
`boost::allocator_construct(a, &p[i], l[i % m])`.
If an exception is thrown destroys each already constructed `j`-th element in
reverse order by calling `boost::allocator_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);`]
[Constructs each `i`-th element in order by calling
`boost::allocator_construct(a, &p[i], *begin++)`.
If an exception is thrown destroys each already constructed `j`-th element in
reverse order by calling `boost::allocator_destroy(a, &p[j])`.]]
[[`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, class T>
void allocator_destroy_n(A& a, T* p, std::size_t n);`]
[Destroys each `i`-th element in reverse order by calling
`boost::allocator_destroy(a, &p[i])`.]]
[[`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(allocator_value_type_t<A>)`.]]
[[`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]

116
doc/allocator_traits.qbk Normal file
View File

@ -0,0 +1,116 @@
[/
Copyright 2021 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_traits allocator_traits]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
This header <boost/core/allocator_traits.hpp> provides an implementation of the
C++ standard library class template `allocator_traits` based on the facilities
in [link core.allocator_access Allocator Access]. Users should still prefer the
individual traits, but this utility exists to simplify migration.
[endsect]
[section Reference]
```
namespace boost {
template<class A>
struct allocator_traits {
using allocator_type = A;
using value_type = allocator_value_type_t<A>;
using pointer = allocator_pointer_t<A>;
using const_pointer = allocator_const_pointer_t<A>;
using void_pointer = allocator_void_pointer_t<A>;
using const_pointer = allocator_const_void_pointer_t<A>;
using difference_type = allocator_difference_type_t<A>;
using size_type = allocator_size_type_t<A>;
using propagate_on_container_copy_assignment =
allocator_propagate_on_container_copy_assignment_t<A>;
using propagate_on_container_move_assignment =
allocator_propagate_on_container_move_assignment_t<A>;
using propagate_on_container_swap =
allocator_propagate_on_container_swap_t<A>;
using is_always_equal = allocator_is_always_equal_t<A>;
template<class T>
using rebind_traits = allocator_traits<allocator_rebind_t<A, T> >;
static pointer allocate(A& a, size_type n);
static pointer allocate(A& a, size_type n, const_void_pointer h);
static void deallocate(A& a, pointer p, size_type n);
template<class T, class... Args>
static void construct(A& a, T* p, Args&&... args);
static void destroy(A& a, T* p);
static size_type max_size(const A& a) noexcept;
static A select_on_container_copy_construction(const A& a);
};
} /* boost */
```
[section Static member functions]
[variablelist
[[`static pointer allocate(A& a, size_type n);`]
[Equivalent to: `return boost::allocator_allocate(a, n);`]]
[[`static pointer allocate(A& a, size_type n, const_void_pointer h);`]
[Equivalent to: `return boost::allocator_allocate(a, n, h);`]]
[[`static void deallocate(A& a, pointer p, size_type n);`]
[Equivalent to: `boost::allocator_deallocate(a, n, h);`]]
[[`template<class T, class... Args>
static void construct(A& a, T* p, Args&&... args);`]
[Equivalent to:
`boost::allocator_construct(a, p, std::forward<Args>(args)...);`]]
[[`static void destroy(A& a, T* p);`]
[Equivalent to: `boost::allocator_destroy(a, p);`]]
[[`static size_type max_size(const A& a) noexcept;`]
[Equivalent to: `return boost::allocator_max_size(a);`]]
[[`static A select_on_container_copy_construction(const A& a);`]
[Equivalent to:
`return boost::allocator_select_on_container_copy_construction(a);`]]]
[endsect]
[endsect]
[section Notes]
# The member `rebind_alloc` is not provided for parity with C++03 where it is
unimplementable. Instead of `allocator_traits<A>::rebind_alloc<U>` you can
express the same with `allocator_traits<A>::rebind_traits<U>::allocator_type`
or more simply with `allocator_rebind_t<A, U>`.
[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]

101
doc/changes.qbk Normal file
View File

@ -0,0 +1,101 @@
[/
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt)
]
[section Revision History]
[section Changes in 1.79.0]
* Added `boost::allocator_traits`, an implementation of `std::allocator_traits`.
* Made `boost::pointer_traits` SFINAE friendly.
* `boost/iterator.hpp` is deprecated and will be removed in a future release. The header defines `boost::iterator` template, which is equivalent to `std::iterator` in `<iterator>` header. However, since `std::iterator` is itself deprecated in C++17, users are advised to remove `boost::iterator` or `std::iterator` use from their code.
* Added `boost::core::verbose_terminate_handler`, a utility function intended
to be passed to `std::set_terminate` that prints information about the
uncaught exception to `stderr`.
[endsect]
[section Changes in 1.78.0]
* Added a generic implementation to `boost/core/cmath.hpp`, enabled when `BOOST_CORE_USE_GENERIC_CMATH`
is defined or when the platform does not provide the necessary facilities in `<cmath>`.
* Added `boost::core::type_name`, a utility function that returns the name of a type as a string.
* Added `boost::span`, a C++11 implementation of C++20's `std::span`.
[endsect]
[section Changes in 1.77.0]
* `boost/core/uncaught_exceptions.hpp` has been modified for compatibility with Mac OS 10.4 and older.
[endsect]
[section Changes in 1.76.0]
* Added implicit conversion between compatible reference wrappers.
* Added `boost/core/cmath.hpp`, a portable implementation of the floating point classification functions from `<cmath>`.
* Added `boost/core/bit.hpp`, a portable implementation of the C++20 standard header `<bit>`.
* Fixed `BOOST_TEST_EQ`, `BOOST_TEST_NE` for character types under C++20.
* Revised allocator access utilities (now support VS2013, and no workarounds use `allocator_traits`.)
[endsect]
[section Changes in 1.74.0]
* Implemented the allocator access utilities which provide a replacement for `allocator_traits`
with individual traits and functions for each facility. They support the C++11 allocator model
when possible and provide a fallback for C++98 compatibility.
* Added `BOOST_TEST_WITH` to Lightweight Test.
[endsect]
[section Changes in 1.71.0]
* Added functions `alloc_construct`, `alloc_construct_n`, `alloc_destroy`, and `alloc_destroy_n`
in `<boost/core/alloc_construct.hpp>` for allocator aware and exception safe construction and
destruction of objects and arrays.
* Added constexpr functions `first_scalar` in `<boost/core/first_scalar.hpp>` for obtaining 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>*`.
* Added class template `noinit_adaptor` in `<boost/core/noinit_adaptor.hpp>` which is an allocator adaptor
that converts any allocator into one whose `construct(ptr)` performs default initialization via placement
`new`, and whose `destroy(ptr)` invokes the `value_type` destructor directly.
* Added class template `default_allocator` in `<boost/core/default_allocator.hpp>`, which can serve as a minimal
default allocator that has interface similar to C++20 `std::allocator`, supports configurations with disabled
exceptions and does not have `std` as an associated namespace. The allocator uses `operator new` and
`operator delete` for allocation.
* In `<boost/core/uncaught_exceptions.hpp>` header, added workarounds for better compatibility with QNX SDP 7.0
when libc++/libc++abi libraries are used.
* The `<boost/detail/sp_typeinfo.hpp>` header is now marked as deprecated and will be removed in a future release.
`<boost/core/typeinfo.hpp>` should be used instead.
[endsect]
[section Changes in 1.69.0]
* Implemented `boost::empty_value`, for library authors to conveniently leverage the Empty Base Optimization to
store objects of potentially empty types.
* Implemented `boost::quick_exit` to provide the C++11 standard library facility `std::quick_exit` functionality.
* Reduced the number of statics in Lightweight Test, and employ lighter abort behavior for MSVC compilers upon
failure to call `boost::report_errors`.
[endsect]
[section Changes in 1.67.0]
* Updated `to_address` and `pointer_traits` to reflect the design adopted for C++20 in
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r2.html P0653R2].
[endsect]
[section Changes in 1.65.0]
* Implemented `pointer_traits` for C++03 and higher, that implements
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r0.html P0653r0].
* Added `BOOST_TEST_GT` and `BOOST_TEST_GE` to Lightweight Test.
[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

@ -34,13 +34,18 @@ 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.
itself, Config, Assert, StaticAssert, or ThrowException.
[endsect]
[include changes.qbk]
[include addressof.qbk]
[include alloc_construct.qbk]
[include allocator_access.qbk]
[include allocator_traits.qbk]
[include bit.qbk]
[include checked_delete.qbk]
[include cmath.qbk]
[include default_allocator.qbk]
[include demangle.qbk]
[include empty_value.qbk]
@ -60,7 +65,10 @@ criteria for inclusion is that the utility component be:
[include quick_exit.qbk]
[include ref.qbk]
[include scoped_enum.qbk]
[include span.qbk]
[include swap.qbk]
[include typeinfo.qbk]
[include type_name.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]
[include verbose_terminate_handler.qbk]

View File

@ -90,7 +90,7 @@ public:
empty_value() = default;
template<class... Args>
explicit empty_value(empty_init_t, Args&&... args);
empty_value(empty_init_t, Args&&... args);
const T& get() const noexcept;

View File

@ -43,9 +43,11 @@ When using `lightweight_test.hpp`, *do not forget* to
#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
{
@ -174,6 +176,17 @@ Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointe
[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]
``
@ -209,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]
``

View File

@ -71,8 +71,7 @@ struct noinit_adaptor
: A {
template<class U>
struct rebind {
typedef noinit_adaptor<typename std::allocator_traits<A>::template
rebind_alloc<U> > other;
typedef noinit_adaptor<allocator_rebind_t<A, U> > other;
};
noinit_adaptor() noexcept;
@ -86,9 +85,6 @@ struct noinit_adaptor
template<class U>
void construct(U* p);
template<class U, class V, class... Args>
void construct(U* p, V&& v, Args&&... args);
template<class U>
void destroy(U* p);
};
@ -121,7 +117,7 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
[[variablelist
[[Requires][`A` shall be constructible from `U`.]]
[[Effects][Initializes the `A` base class with
`static_cast<const U&>(u)`.]]]]]]
`static_cast<const A&>(u)`.]]]]]]
[endsect]
@ -131,11 +127,6 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
[[`template<class U> void construct(U* p);`]
[[variablelist
[[Effects][`::new((void*)p) U`.]]]]]
[[`template<class U, class V, class... Args> void construct(U* p, V&& v,
Args&&... args);`]
[[variablelist
[[Effects][`::new(void*)p) U(std::forward<V>(v),
std::forward<Args>(args)...)`.]]]]]
[[`template<class U> void destroy(U* p);`]
[[variablelist
[[Effects][`p->~U()`.]]]]]]

View File

@ -1,5 +1,5 @@
[/
Copyright 2017-2018 Glen Joseph Fernandes
Copyright 2017-2021 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
@ -47,68 +47,88 @@ void function(Allocator& a)
```
namespace boost {
template<class T> struct pointer_traits {
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;
template<class U>
struct rebind_to {
typedef ``['see below]`` type;
};
static pointer pointer_to(``['see below]`` v);
};
template<class U>
using rebind = typename rebind_to<U>::type;
template<class T> struct pointer_traits<T*> {
static pointer pointer_to(element_type& 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;
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>
constexpr T* to_address(T* v) noexcept;
template<class T>
auto to_address(const T& v) noexcept;
}
template<class T>
auto to_address(const T& v) noexcept;
} // boost
```
[section Overview]
If the member type `element_type` is not defined, then all other members are
also not defined (`pointer_traits` is SFINAE-friendly).
[endsect]
[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.]]
or more type arguments; otherwise the member is not defined.]]
[[`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.]]]
where `Args` is zero or more type arguments; otherwise, the member is not
defined.]]]
[endsect]
[section Member functions]
[variablelist
[[`static pointer pointer_traits::pointer_to(`['see below] `v);`]
[[`static pointer pointer_traits::pointer_to(element_type& v);`]
[[variablelist
[[Remark]
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
it is `element_type&`.]]
[If `element_type` is a void type, or if `T::pointer_to(v)` is not well formed,
this member is not defined.]]
[[Returns]
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
[[`static pointer pointer_traits<T*>::pointer_to(`['see below] `v) noexcept;`]
[[`static pointer pointer_traits<T*>::pointer_to(element_type& v) noexcept;`]
[[variablelist
[[Remark]
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
it is `element_type&`.]]
[If `element_type` is a void type, this member is not defined.]]
[[Returns][`addressof(v)`.]]]]]]
[endsect]

396
doc/span.qbk Normal file
View File

@ -0,0 +1,396 @@
[/
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:span span]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
This header <boost/core/span.hpp> provides class template `span`, which is a
view over a sequence of objects. It implements the C++20 standard library
`std::span` facility. This implementation supports C++11 and higher.
In addition to referencing the sequence of objects, the span knows the count of
objects. There are two kinds of spans:
* Dynamic size (`span<T>` or `span<T, dynamic_extent>`)
* Static size (`span<T, N>`)
Dynamic size spans have a count that can be a value known at run time. Static
size spans have a count that must be known at compile time.
[endsect]
[section Examples]
The following snippet shows a function to compute a SHA1 hash whose parameters
and return type use spans.
```
auto sha1(boost::span<const unsigned char> input,
boost::span<unsigned char, SHA_DIGEST_LENGTH> ouput)
{
SHA_CTX context;
SHA1_Init(&context);
SHA1_Update(&context, input.data(), input.size());
SHA1_Final(output.data(), &context);
return output;
}
```
[endsect]
[section Reference]
```
namespace boost {
constexpr std::size_t dynamic_extent = -1;
template<class T, std::size_t E = dynamic_extent>
class span {
public:
typedef T element_type;
typedef std::remove_cv_t<T> value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T* iterator;
typedef const T* const_iterator;
typedef std::reverse_iterator<T*> reverse_iterator;
typedef std::reverse_iterator<const T*> const_reverse_iterator;
static constexpr std::size_t extent = E;
constexpr span() noexcept;
explicit(E != dynamic_extent)
template<class I>
constexpr span(I* f, size_type c);
explicit(E != dynamic_extent)
template<class I, class L>
constexpr span(I* f, L* l);
template<std::size_t N>
constexpr span(type_identity_t<T> (&a)[N]);
template<class U, std::size_t N>
constexpr span(std::array<U, N>& a) noexcept;
template<class U, std::size_t N>
constexpr span(const std::array<U, N>& a) noexcept;
explicit(E != dynamic_extent)
template<class R>
constexpr span(R&& r);
explicit(E != dynamic_extent && N == dynamic_extent)
template<class U, std::size_t N>
constexpr span(const span<U, N>& s) noexcept;
template<std::size_t C>
constexpr span<T, C> first() const;
template<std::size_t C>
constexpr span<T, C> last() const;
template<std::size_t O, std::size_t C = dynamic_extent>
constexpr span<T, see below> subspan() const;
constexpr span<T, dynamic_extent> first(size_type c) const;
constexpr span<T, dynamic_extent> last(size_type c) const;
constexpr span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const;
constexpr size_type size() const noexcept;
constexpr size_type size_bytes() const noexcept;
constexpr bool empty() const noexcept;
constexpr reference operator[](size_type i) const;
constexpr reference front() const;
constexpr reference back() const;
constexpr pointer data() const noexcept;
constexpr iterator begin() const noexcept;
constexpr iterator end() const noexcept;
constexpr reverse_iterator rbegin() const noexcept;
constexpr reverse_iterator rend() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
};
template<class I, class L>
span(I*, L) -> span<I>;
template<class T, std::size_t N>
span(T(&)[N]) -> span<T, N>;
template<class T, std::size_t N>
span(std::array<T, N>&) -> span<T, N>;
template<class T, std::size_t N>
span(const std::array<T, N>&) -> span<const T, N>;
template<class R>
span(R&&) -> span<std::remove_pointer_t<decltype(std::declval<R&>().data())> >;
template<class T, std::size_t E>
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_bytes(span<T, E> s) noexcept;
template<class T, std::size_t E>
span<std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_writable_bytes(span<T, E> s) noexcept;
} /* boost */
```
[section Constructors]
[variablelist
[[`constexpr span() noexcept;`]
[[variablelist
[[Constraints][`E == dynamic_extent || E == 0` is `true`.]]
[[Postconditions][`size() == 0 && data() == nullptr`.]]]]]
[[`explicit(E != dynamic_extent)
template<class I>
constexpr span(I* f, size_type c);`]
[[variablelist
[[Constraints]
[`is_convertible_v<I(*)[], T(*)[]>` is `true`.]]
[[Preconditions]
[[itemized_list
[`[f, f + c)` is a valid range.]
[If `E` is not equal to `dynamic_extent`, then `c` is equal to `E`.]]]]
[[Effects][Constructs a `span` with data `f` and size `c`.]]
[[Throws][Nothing.]]]]]
[[`explicit(E != dynamic_extent)
template<class I, class L>
constexpr span(I* f, L* l);`]
[[variablelist
[[Constraints]
[`is_convertible_v<I(*)[], T(*)[]>` is `true`.]]
[[Preconditions]
[[itemized_list
[If `E` is not equal to `dynamic_extent`, then `l - f` is equal to `E`.]
[`[f, l)` is a valid range.]]]]
[[Effects][Constructs a `span` with data `f` and size `l - f`.]]
[[Throws][Nothing.]]]]]
[[`template<std::size_t N>
constexpr span(type_identity_t<T> (&a)[N]);`]
[[variablelist
[[Constraints][`E == dynamic_extent || E == N` is `true`.]]
[[Effects][Constructs a `span` that is a view over the supplied array.]]
[[Postconditions][`size() == N && data() == &a[0]` is `true`.]]]]]
[[`template<class U, std::size_t N>
constexpr span(std::array<U, N>& a) noexcept;`]
[[variablelist
[[Constraints]
[[itemized_list
[`E == dynamic_extent || E == N` is `true`, and]
[`U(*)[]` is convertible to `T(*)[]`.]]]]
[[Effects][Constructs a `span` that is a view over the supplied array.]]
[[Postconditions][`size() == N && data() == a.data()` is `true`.]]]]]
[[`template<class U, std::size_t N>
constexpr span(const std::array<U, N>& a) noexcept;`]
[[variablelist
[[Constraints]
[[itemized_list
[`E == dynamic_extent || E == N` is `true`, and]
[`U(*)[]` is convertible to `T(*)[]`.]]]]
[[Effects][Constructs a `span` that is a view over the supplied array.]]
[[Postconditions][`size() == N && data() == a.data()` is `true`.]]]]]
[[`explicit(E != dynamic_extent)
template<class R>
constexpr span(R&& r);`]
[[variablelist
[[Constraints]
[[itemized_list
[`is_lvalue_reference_v<R> || is_const_v<T>` is `true`]
[`remove_cvref_t<R>` is not a specialization of `span`,]
[`remove_cvref_t<R>` is not a specialization of `array`,]
[`is_array_v<remove_cvref_t<R>>` is `false`,]
[`r.data()` is well-formed and
`is_convertible_v<remove_pointer_t<decltype(declval<R&>().data())>(*)[],
T(*)[]>` is `true`, and]
[`r.size()` is well-formed and
`is_convertible_v<decltype(declval<R&>().size()), size_t>` is `true`.]]]]
[[Effects][Constructs a `span` with data `r.data()` and size `r.size()`.]]
[[Throws][What and when r.data() and r.size() throw.]]]]]
[[`explicit(E != dynamic_extent && N == dynamic_extent)
template<class U, std::size_t N>
constexpr span(const span<U, N>& s) noexcept;`]
[[variablelist
[[Constraints]
[[itemized_list
[`E == dynamic_extent || N == dynamic_extent || E == N` is `true`, and]
[`is_convertible_v<U(*)[], T(*)[]>` is `true`.]]]]
[[Preconditions]
[If `E` is not equal to `dynamic_extent`, then `s.size()` is equal to `E`.]]
[[Effects]
[Constructs a `span` that is a view over the range
`[s.data(), s.data() + s.size())`.]]
[[Postconditions][`size() == s.size() && data() == s.data()`.]]]]]]
[endsect]
[section Subviews]
[variablelist
[[`template<std::size_t C> constexpr span<T, C> first() const;`]
[[variablelist
[[Mandates][`C <= E` is `true`.]]
[[Preconditions][`C <= size()` is `true`.]]
[[Effects]
[Equivalent to `return R{data(), C};` where `R` is the return type.]]]]]
[[`template<std::size_t C> constexpr span<T, C> last() const;`]
[[variablelist
[[Mandates][`C <= E` is `true`.]]
[[Preconditions][`C <= size()` is `true`.]]
[[Effects]
[Equivalent to `return R{data() + (size() - C), C};` where `R` is the return
type.]]]]]
[[`template<std::size_t O, std::size_t C = dynamic_extent>
constexpr span<T, see below> subspan() const;`]
[[variablelist
[[Mandates][`O <= E && (C == dynamic_extent || C <= E - O)` is `true`.]]
[[Preconditions]
[`O <= size() && (C == dynamic_extent || C <= size() - O)` is `true`.]]
[[Effects]
[Equivalent to
`return span<T, see below>(data() + O,
C != dynamic_extent ? C : size() - O);`.]]
[[Remarks]
[The second template argument of the returned span type is:
`C != dynamic_extent ? C : (E != dynamic_extent ? E - O :
dynamic_extent)`]]]]]
[[`constexpr span<T, dynamic_extent> first(size_type c) const;`]
[[variablelist
[[Preconditions][`c <= size()` is `true`.]]
[[Effects][Equivalent to: `return {data(), c};`]]]]]
[[`constexpr span<T, dynamic_extent> last(size_type c) const;`]
[[variablelist
[[Preconditions][`c <= size()` is `true`.]]
[[Effects][Equivalent to: `return {data() + (size() - c), c};`]]]]]
[[`constexpr span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const;`]
[[variablelist
[[Preconditions]
[`o <= size() && (c == dynamic_extent || o + c <= size())` is `true`.]]
[[Effects]
[Equivalent to:
`return {data() + o, c == dynamic_extent ? size() - o : c};`]]]]]]
[endsect]
[section Observers]
[variablelist
[[`constexpr size_type size() const noexcept;`]
[[variablelist
[[Returns][The number of elements in the span.]]]]]
[[`constexpr size_type size_bytes() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return size() * sizeof(T);`]]]]]
[[`constexpr bool empty() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return size() == 0;`]]]]]]
[endsect]
[section Element access]
[variablelist
[[`constexpr reference operator[](size_type i) const;`]
[[variablelist
[[Preconditions][`i < size()` is `true`.]]
[[Effects][Equivalent to: `return *(data() + i);`]]]]]
[[`constexpr reference front() const;`]
[[variablelist
[[Preconditions][`empty()` is `false`.]]
[[Effects][Equivalent to: `return *data();`]]]]]
[[`constexpr reference back() const;`]
[[variablelist
[[Preconditions][`empty()` is `false`.]]
[[Effects][Equivalent to: `return *(data() + (size() - 1);`]]]]]
[[`constexpr pointer data() const noexcept;`]
[[variablelist
[[Returns][A pointer to the first element in the span.]]]]]]
[endsect]
[section Iterator support]
[variablelist
[[`constexpr iterator begin() const noexcept;`]
[[variablelist
[[Returns][A constant iterator referring to the first element in the span. If `empty()`,
then it returns the same value as `cend()`.]]]]]
[[`constexpr iterator end() const noexcept;`]
[[variablelist
[[Returns][A constant iterator which is the past-the-end value.]]]]]
[[`constexpr reverse_iterator rbegin() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return reverse_iterator(end());`]]]]]
[[`constexpr reverse_iterator rend() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return reverse_iterator(begin());`]]]]]
[[`constexpr const_iterator cbegin() const noexcept;`]
[[variablelist
[[Returns]
[A constant iterator referring to the first element in the span. If `empty()`,
then it returns the same value as `cend()`.]]]]]
[[`constexpr const_iterator cend() const noexcept;`]
[[variablelist
[[Returns][A constant iterator which is the past-the-end value.]]]]]
[[`constexpr const_reverse_iterator crbegin() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return const_reverse_iterator(cend());`]]]]]
[[`constexpr const_reverse_iterator crend() const noexcept;`]
[[variablelist
[[Effects]
[Equivalent to: `return const_reverse_iterator(cbegin());`]]]]]]
[endsect]
[section Views of object representation]
[variablelist
[[`template<class T, std::size_t E>
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_bytes(span<T, E> s) noexcept;`]
[[variablelist
[[Effects]
[Equivalent to:
`return {reinterpret_cast<const byte*>(s.data()), s.size_bytes()};`.]]]]]
[[`template<class T, std::size_t E>
span<std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_writable_bytes(span<T, E> s) noexcept;`]
[[variablelist
[[Constraints][`is_const_v<T>` is `false`.]]
[[Effects]
[Equivalent to: `return R{reinterpret_cast<byte*>(s.data()), s.size_bytes()};`
where `R` is the return type.]]]]]]
[endsect]
[endsect]
[endsect]

768
doc/string_view.qbk Normal file
View File

@ -0,0 +1,768 @@
[/
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:string_view string_view]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/string_view.hpp>]
The header `<boost/core/string_view.hpp>` defines `boost::core::string_view`,
a portable and interoperable implementation of `std::string_view`.
Unlike `boost::string_view`, `boost::core::string_view` has implicit
conversions from and to `std::string_view`, which allows Boost libraries that
support C++11/C++14 to use it in interfaces without forcing users to forgo the
use of `std::string_view` in their code.
[section Synopsis]
``
namespace boost
{
namespace core
{
template<class Ch> class basic_string_view
{
public:
// types
typedef std::char_traits<Ch> traits_type;
typedef Ch value_type;
typedef Ch* pointer;
typedef Ch const* const_pointer;
typedef Ch& reference;
typedef Ch const& const_reference;
typedef Ch const* const_iterator;
typedef const_iterator iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// npos
static constexpr size_type npos = static_cast<size_type>( -1 );
public:
// construction and assignment
constexpr basic_string_view() noexcept;
constexpr basic_string_view( basic_string_view const& ) noexcept = default;
constexpr basic_string_view& operator=( basic_string_view const& ) noexcept & = default;
constexpr basic_string_view( Ch const* str ) noexcept;
constexpr basic_string_view( Ch const* str, size_type len ) noexcept;
constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;
template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;
basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;
// conversions
template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;
template<class Ch2> operator std::basic_string_view<Ch2>() const noexcept;
// iterator support
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// capacity
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
constexpr size_type max_size() const noexcept;
constexpr bool empty() const noexcept;
// element access
constexpr const_reference operator[]( size_type pos ) const noexcept;
constexpr const_reference at( size_type pos ) const;
constexpr const_reference front() const noexcept;
constexpr const_reference back() const noexcept;
constexpr const_pointer data() const noexcept;
// modifiers
constexpr void remove_prefix( size_type n ) noexcept;
constexpr void remove_suffix( size_type n ) noexcept;
constexpr void swap( basic_string_view& s ) noexcept;
// string operations
constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const;
constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const;
// compare
constexpr int compare( basic_string_view str ) const noexcept;
constexpr int compare( size_type pos1, size_type n1, basic_string_view str ) const;
constexpr int compare( size_type pos1, size_type n1, basic_string_view str, size_type pos2, size_type n2 ) const;
constexpr int compare( Ch const* s ) const;
constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const;
constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const;
// starts_with
constexpr bool starts_with( basic_string_view x ) const noexcept;
constexpr bool starts_with( Ch x ) const noexcept;
constexpr bool starts_with( Ch const* x ) const noexcept;
// ends_with
constexpr bool ends_with( basic_string_view x ) const noexcept;
constexpr bool ends_with( Ch x ) const noexcept;
constexpr bool ends_with( Ch const* x ) const noexcept;
// find
constexpr size_type find( basic_string_view str, size_type pos = 0 ) const noexcept;
constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept;
constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find( Ch const* s, size_type pos = 0 ) const noexcept;
// rfind
constexpr size_type rfind( basic_string_view str, size_type pos = npos ) const noexcept;
constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept;
constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type rfind( Ch const* s, size_type pos = npos ) const noexcept;
// find_first_of
constexpr size_type find_first_of( basic_string_view str, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const noexcept;
// find_last_of
constexpr size_type find_last_of( basic_string_view str, size_type pos = npos ) const noexcept;
constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept;
constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const noexcept;
// find_first_not_of
constexpr size_type find_first_not_of( basic_string_view str, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const noexcept;
// find_last_not_of
constexpr size_type find_last_not_of( basic_string_view str, size_type pos = npos ) const noexcept;
constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept;
constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const noexcept;
// contains
constexpr bool contains( basic_string_view sv ) const noexcept;
constexpr bool contains( Ch c ) const noexcept;
constexpr bool contains( Ch const* s ) const noexcept;
// relational operators
constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
};
// stream inserter
template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str );
// typedef names
typedef basic_string_view<char> string_view;
typedef basic_string_view<wchar_t> wstring_view;
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<char8_t> u8string_view;
} // namespace core
} // namespace boost
``
[endsect]
[section Construction]
[section `constexpr basic_string_view() noexcept;`]
* *Ensures:* `data() == 0`; `size() == 0`.
[endsect]
[section `constexpr basic_string_view( Ch const* str ) noexcept;`]
* *Ensures:* `data() == str`; `size() == traits_type::length( str )`.
[endsect]
[section `constexpr basic_string_view( Ch const* str, size_type len ) noexcept;`]
* *Ensures:* `data() == str`; `size() == len`.
[endsect]
[section `constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;`]
* *Requires:* `end >= begin`.
* *Ensures:* `data() == begin`; `size() == end - begin`.
[endsect]
[section `template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;`]
* *Ensures:* `data() == str.data()`; `size() == str.size()`.
[endsect]
[section `basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;`]
* *Ensures:* `data() == str.data()`; `size() == str.size()`.
[endsect]
[endsect]
[section Conversions]
[section `template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;`]
* *Returns:* `std::basic_string<Ch, std::char_traits<Ch>, A>( data(), size() )`.
[endsect]
[section `template<class Ch2> operator std::basic_string_view<Ch2>() const noexcept;`]
* *Constraints:* `Ch2` is the same type as `Ch`.
* *Returns:* `std::basic_string_view<Ch2>( data(), size() )`.
[endsect]
[endsect]
[section Iterator Support]
[section `constexpr const_iterator begin() const noexcept;`]
* *Returns:* `data()`.
[endsect]
[section `constexpr const_iterator end() const noexcept;`]
* *Returns:* `data() + size()`.
[endsect]
[section `constexpr const_iterator cbegin() const noexcept;`]
* *Returns:* `begin()`.
[endsect]
[section `constexpr const_iterator cend() const noexcept;`]
* *Returns:* `end()`.
[endsect]
[section `constexpr const_reverse_iterator rbegin() const noexcept;`]
* *Returns:* `const_reverse_iterator( end() )`.
[endsect]
[section `constexpr const_reverse_iterator rend() const noexcept;`]
* *Returns:* `const_reverse_iterator( begin() )`.
[endsect]
[section `constexpr const_reverse_iterator crbegin() const noexcept;`]
* *Returns:* `rbegin()`.
[endsect]
[section `constexpr const_reverse_iterator crend() const noexcept;`]
* *Returns:* `rend()`.
[endsect]
[endsect]
[section Capacity]
[section `constexpr size_type size() const noexcept;`]
* *Returns:* the length of the referenced character sequence.
[endsect]
[section `constexpr size_type length() const noexcept;`]
* *Returns:* `size()`.
[endsect]
[section `constexpr size_type max_size() const noexcept;`]
* *Returns:* `std::numeric_limits<size_type>::max() / sizeof(Ch)`.
[endsect]
[section `constexpr bool empty() const noexcept;`]
* *Returns:* `size() == 0`.
[endsect]
[endsect]
[section Element Access]
[section `constexpr const_reference operator[]( size_type pos ) const noexcept;`]
* *Requires:* `pos < size()`.
* *Returns:* `data()[ pos ]`.
[endsect]
[section `constexpr const_reference at( size_type pos ) const;`]
* *Returns:* `data()[ pos ]`.
* *Throws:* `std::out_of_range` when `pos >= size()`.
[endsect]
[section `constexpr const_reference front() const noexcept;`]
* *Requires:* `!empty()`.
* *Returns:* `data()[ 0 ]`.
[endsect]
[section `constexpr const_reference back() const noexcept;`]
* *Requires:* `!empty()`.
* *Returns:* `data()[ size() - 1 ]`.
[endsect]
[section `constexpr const_pointer data() const noexcept;`]
* *Returns:* a pointer to the beginning of the referenced character sequence.
[endsect]
[endsect]
[section Modifiers]
[section `constexpr void remove_prefix( size_type n ) noexcept;`]
* *Requires:* `n <= size()`.
* *Effects:* advances `data()` by `n` and decreases `size()` by `n`.
[endsect]
[section `constexpr void remove_suffix( size_type n ) noexcept;`]
* *Requires:* `n <= size()`.
* *Effects:* decreases `size()` by `n`.
[endsect]
[section `constexpr void swap( basic_string_view& s ) noexcept;`]
* *Effects:* exchanges the contents of `*this` and `s`.
[endsect]
[endsect]
[section String Operations]
[section copy]
[section `constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const;`]
* *Effects:* copies to `s` the contents of `substr( pos, n )`.
* *Throws:* `std::out_of_range` when `pos >= size()`.
[endsect]
[endsect]
[section substr]
[section `constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const;`]
* *Returns:* `basic_string_view( data() + pos, std::min( size() - pos, n ) )`.
* *Throws:* `std::out_of_range` when `pos >= size()`.
[endsect]
[endsect]
[section compare]
[section `constexpr int compare( basic_string_view str ) const noexcept;`]
* *Returns:*
* if `traits_type::compare( data(), str.data(), std::min( size(), str.size() ) )` is not zero, returns it. Otherwise,
* if `size() < str.size()`, returns a negative number. Otherwise,
* if `size() > str.size()`, returns a positive number. Otherwise,
* returns 0.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, basic_string_view str ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( str )`.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, basic_string_view str, size_type pos2, size_type n2 ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( str.substr( pos2, n2 ) )`.
[endsect]
[section `constexpr int compare( Ch const* s ) const noexcept;`]
* *Returns:* `compare( basic_string_view( s ) )`.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( basic_string_view( s ) )`.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( basic_string_view( s, n2 ) )`.
[endsect]
[endsect]
[section starts_with]
[section `constexpr bool starts_with( basic_string_view x ) const noexcept;`]
* *Returns:* `substr( 0, x.size() ) == x`.
[endsect]
[section `constexpr bool starts_with( Ch x ) const noexcept;`]
* *Returns:* `starts_with( basic_string_view( &x, 1 ) )`.
[endsect]
[section `constexpr bool starts_with( Ch const* x ) const noexcept;`]
* *Returns:* `starts_with( basic_string_view( x ) )`.
[endsect]
[endsect]
[section ends_with]
[section `constexpr bool ends_with( basic_string_view x ) const noexcept;`]
* *Returns:* `size() >= x.size() && substr( size() - x.size(), x.size() ) == x`.
[endsect]
[section `constexpr bool ends_with( Ch x ) const noexcept;`]
* *Returns:* `ends_with( basic_string_view( &x, 1 ) )`.
[endsect]
[section `constexpr bool ends_with( Ch const* x ) const noexcept;`]
* *Returns:* `ends_with( basic_string_view( x ) )`.
[endsect]
[endsect]
[endsect]
[section Searching]
[section find]
[section `constexpr size_type find( basic_string_view str, size_type pos = 0 ) const noexcept;`]
* *Returns:* The lowest position `i` such that `i >= pos` and `substr( i, str.size() ) == str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find( Ch const* s, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section rfind]
[section `constexpr size_type rfind( basic_string_view str, size_type pos = npos ) const noexcept;`]
* *Returns:* The highest position `i` such that `i <= pos` and `substr( i, str.size() ) == str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept;`]
* *Returns:* `rfind( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `rfind( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type rfind( Ch const* s, size_type pos = npos ) const noexcept;`]
* *Returns:* `rfind( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_first_of]
[section `constexpr size_type find_first_of( basic_string_view str, size_type pos = 0 ) const noexcept;`]
* *Returns:* The lowest position `i` such that `i >= pos` and the character at position `i` is equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_first_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_last_of]
[section `constexpr size_type find_last_of( basic_string_view str, size_type pos = npos ) const noexcept;`]
* *Returns:* The highest position `i` such that `i <= pos` and the character at position `i` is equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_last_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_first_not_of]
[section `constexpr size_type find_first_not_of( basic_string_view str, size_type pos = 0 ) const noexcept;`]
* *Returns:* The lowest position `i` such that `i >= pos` and the character at position `i` is not equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_not_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_first_not_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_not_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_last_not_of]
[section `constexpr size_type find_last_not_of( basic_string_view str, size_type pos = npos ) const noexcept;`]
* *Returns:* The highest position `i` such that `i <= pos` and the character at position `i` is not equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_not_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_last_not_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_not_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section contains]
[section `constexpr bool contains( basic_string_view sv ) const noexcept;`]
* *Returns:* `find( sv ) != npos`.
[endsect]
[section `constexpr bool contains( Ch c ) const noexcept;`]
* *Returns:* `find( c ) != npos`.
[endsect]
[section `constexpr bool contains( Ch const* s ) const noexcept;`]
* *Returns:* `find( s ) != npos`.
[endsect]
[endsect]
[endsect]
[section Relational Operators]
[section `constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) == 0`.
[endsect]
[section `constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) != 0`.
[endsect]
[section `constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) < 0`.
[endsect]
[section `constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) <= 0`.
[endsect]
[section `constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) > 0`.
[endsect]
[section `constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) >= 0`.
[endsect]
[endsect]
[section Stream Inserter]
[section `template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str );`]
* *Effects:* equivalent to `os << x`, where `x` is a pointer to a null-terminated character sequence with the same contents as `str`.
[endsect]
[endsect]
[endsect]
[endsect]

77
doc/type_name.qbk Normal file
View File

@ -0,0 +1,77 @@
[/
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:type_name type_name]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/type_name.hpp>]
The header `<boost/core/type_name.hpp>` defines the function
template `boost::core::type_name<T>()` that returns a string
representation of the name of `T`, suitable for logging or
diagnostic display purposes.
The result is similar to `boost::core::demangle( typeid(T).name() )`,
but it's made more regular by eliminating some of the platform-specific
differences and extra template parameters of the standard library
container types.
For example, `type_name< std::map<std::string, int> >()` returns
`"std::map<std::string, int>"` and not
```
std::map<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >, int, std::less<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, std::allocator<
std::pair<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const, int> > >
```
or
```
class std::map<class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> >,int,struct std::less<class std::basic_string<
char,struct std::char_traits<char>,class std::allocator<char> > >,class
std::allocator<struct std::pair<class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const ,int> > >
```
The return values aren't guaranteed to be stable across Boost releases.
Compilation with `-fno-rtti` is supported, but the returned type names aren't
guaranteed to be particularly useful or unique.
[section Synopsis]
``
namespace boost
{
namespace core
{
template<class T> std::string type_name();
} // namespace core
} // namespace boost
``
[endsect]
[section template<class T> std::string type_name();]
* *Returns:* A string representation of the name of `T`.
[endsect]
[endsect]
[endsect]

View File

@ -0,0 +1,70 @@
[/
Copyright 2022 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:verbose_terminate_handler verbose_terminate_handler]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/verbose_terminate_handler.hpp>]
The header `<boost/core/verbose_terminate_handler.hpp>` defines
the function `void boost::core::verbose_terminate_handler()`. Its
purpose is to be set as a terminate handler as in
```
std::set_terminate( boost::core::verbose_terminate_handler );
```
When invoked, the function prints information about the current
uncaught exception to `stderr` and then calls `std::abort`.
[section Synopsis]
``
namespace boost
{
namespace core
{
[[noreturn]] void verbose_terminate_handler();
} // namespace core
} // namespace boost
``
[endsect]
[section Example]
```
#include <boost/core/verbose_terminate_handler.hpp>
#include <boost/throw_exception.hpp>
#include <exception>
int main()
{
std::set_terminate( boost::core::verbose_terminate_handler );
boost::throw_with_location( std::exception() );
}
```
Sample output:
```
std::terminate called after throwing an exception:
type: class boost::detail::with_throw_location<class std::exception>
what(): Unknown exception
location: example.cpp:8:12 in function 'main'
```
[endsect]
[endsect]
[endsect]

View File

@ -125,7 +125,7 @@ template<class T>
BOOST_FORCEINLINE T*
addressof(T& o) BOOST_NOEXCEPT
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) || \
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) || \
BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
return boost::detail::addrof<T>::get(o, 0);
#else
@ -151,7 +151,7 @@ addressof(T (&o)[N]) BOOST_NOEXCEPT
}
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#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]

View File

@ -8,79 +8,32 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP
#define BOOST_CORE_ALLOC_CONSTRUCT_HPP
/*
This functionality is now in <boost/core/allocator_access.hpp>.
*/
#include <boost/core/noinit_adaptor.hpp>
namespace boost {
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class T>
inline void
alloc_destroy(A& a, T* p)
{
std::allocator_traits<A>::destroy(a, 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) {
std::allocator_traits<A>::destroy(a, p + --n);
}
}
#else
template<class A, class T>
inline void
alloc_destroy(A&, T* p)
{
p->~T();
boost::allocator_destroy_n(a, p, n);
}
template<class A, class T>
inline void
alloc_destroy_n(A&, T* p, std::size_t n)
{
while (n > 0) {
p[--n].~T();
}
}
#endif
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 */
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class T>
inline void
alloc_construct(A& a, T* p)
{
std::allocator_traits<A>::construct(a, p);
boost::allocator_construct(a, p);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@ -89,7 +42,7 @@ template<class A, class T, class U, class... V>
inline void
alloc_construct(A& a, T* p, U&& u, V&&... v)
{
std::allocator_traits<A>::construct(a, p, std::forward<U>(u),
boost::allocator_construct(a, p, std::forward<U>(u),
std::forward<V>(v)...);
}
#else
@ -97,7 +50,7 @@ template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, U&& u)
{
std::allocator_traits<A>::construct(a, p, std::forward<U>(u));
boost::allocator_construct(a, p, std::forward<U>(u));
}
#endif
#else
@ -105,14 +58,14 @@ template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, const U& u)
{
std::allocator_traits<A>::construct(a, p, u);
boost::allocator_construct(a, p, u);
}
template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, U& u)
{
std::allocator_traits<A>::construct(a, p, u);
boost::allocator_construct(a, p, u);
}
#endif
@ -120,125 +73,22 @@ 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) {
std::allocator_traits<A>::construct(a, p + i);
}
hold.size() = 0;
boost::allocator_construct_n(a, p, n);
}
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) {
std::allocator_traits<A>::construct(a, p + i, l[i % m]);
}
hold.size() = 0;
boost::allocator_construct_n(a, p, n, l, m);
}
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)) {
std::allocator_traits<A>::construct(a, p + i, *b);
}
hold.size() = 0;
boost::allocator_construct_n(a, p, n, b);
}
#else
template<class A, class T>
inline void
alloc_construct(A&, T* p)
{
::new(static_cast<void*>(p)) T();
}
template<class A, class T>
inline void
alloc_construct(noinit_adaptor<A>&, T* p)
{
::new(static_cast<void*>(p)) T;
}
#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&, T* p, U&& u, V&&... v)
{
::new(static_cast<void*>(p)) T(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)
{
::new(static_cast<void*>(p)) T(std::forward<U>(u));
}
#endif
#else
template<class A, class T, class U>
inline void
alloc_construct(A&, T* p, const U& u)
{
::new(static_cast<void*>(p)) T(u);
}
template<class A, class T, class U>
inline void
alloc_construct(A&, T* p, U& u)
{
::new(static_cast<void*>(p)) T(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) {
::new(static_cast<void*>(p + i)) T();
}
hold.size() = 0;
}
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;
}
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) {
::new(static_cast<void*>(p + i)) T(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)) {
::new(static_cast<void*>(p + i)) T(*b);
}
hold.size() = 0;
}
#endif
} /* boost */

View File

@ -0,0 +1,820 @@
/*
Copyright 2020-2022 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>
#include <boost/core/pointer_traits.hpp>
#include <limits>
#include <new>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <type_traits>
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40300)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
#elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
#elif defined(BOOST_CLANG) && !defined(__CUDACC__)
#if __has_feature(is_empty)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
#endif
#elif defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __oracle_is_empty(T)
#elif defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
#elif defined(BOOST_CODEGEARC)
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
#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;
};
namespace detail {
template<class A, class = void>
struct alloc_ptr {
typedef typename boost::allocator_value_type<A>::type* type;
};
template<class>
struct alloc_void {
typedef void type;
};
template<class A>
struct alloc_ptr<A,
typename alloc_void<typename A::pointer>::type> {
typedef typename A::pointer type;
};
} /* detail */
template<class A>
struct allocator_pointer {
typedef typename detail::alloc_ptr<A>::type type;
};
namespace detail {
template<class A, class = void>
struct alloc_const_ptr {
typedef typename boost::pointer_traits<typename
boost::allocator_pointer<A>::type>::template rebind_to<const typename
boost::allocator_value_type<A>::type>::type type;
};
template<class A>
struct alloc_const_ptr<A,
typename alloc_void<typename A::const_pointer>::type> {
typedef typename A::const_pointer type;
};
} /* detail */
template<class A>
struct allocator_const_pointer {
typedef typename detail::alloc_const_ptr<A>::type type;
};
namespace detail {
template<class, class>
struct alloc_to { };
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class> class A, class T, class U>
struct alloc_to<A<U>, T> {
typedef A<T> type;
};
template<template<class, class> class A, class T, class U, class V>
struct alloc_to<A<U, V>, T> {
typedef A<T, V> type;
};
template<template<class, class, class> class A, class T, class U, class V1,
class V2>
struct alloc_to<A<U, V1, V2>, T> {
typedef A<T, V1, V2> type;
};
#else
template<template<class, class...> class A, class T, class U, class... V>
struct alloc_to<A<U, V...>, T> {
typedef A<T, V...> type;
};
#endif
template<class A, class T, class = void>
struct alloc_rebind {
typedef typename alloc_to<A, T>::type type;
};
template<class A, class T>
struct alloc_rebind<A, T,
typename alloc_void<typename A::template rebind<T>::other>::type> {
typedef typename A::template rebind<T>::other type;
};
} /* detail */
template<class A, class T>
struct allocator_rebind {
typedef typename detail::alloc_rebind<A, T>::type type;
};
namespace detail {
template<class A, class = void>
struct alloc_void_ptr {
typedef typename boost::pointer_traits<typename
boost::allocator_pointer<A>::type>::template
rebind_to<void>::type type;
};
template<class A>
struct alloc_void_ptr<A,
typename alloc_void<typename A::void_pointer>::type> {
typedef typename A::void_pointer type;
};
} /* detail */
template<class A>
struct allocator_void_pointer {
typedef typename detail::alloc_void_ptr<A>::type type;
};
namespace detail {
template<class A, class = void>
struct alloc_const_void_ptr {
typedef typename boost::pointer_traits<typename
boost::allocator_pointer<A>::type>::template
rebind_to<const void>::type type;
};
template<class A>
struct alloc_const_void_ptr<A,
typename alloc_void<typename A::const_void_pointer>::type> {
typedef typename A::const_void_pointer type;
};
} /* detail */
template<class A>
struct allocator_const_void_pointer {
typedef typename detail::alloc_const_void_ptr<A>::type type;
};
namespace detail {
template<class A, class = void>
struct alloc_diff_type {
typedef typename boost::pointer_traits<typename
boost::allocator_pointer<A>::type>::difference_type type;
};
template<class A>
struct alloc_diff_type<A,
typename alloc_void<typename A::difference_type>::type> {
typedef typename A::difference_type type;
};
} /* detail */
template<class A>
struct allocator_difference_type {
typedef typename detail::alloc_diff_type<A>::type type;
};
namespace detail {
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class = void>
struct alloc_size_type {
typedef std::size_t type;
};
#else
template<class A, class = void>
struct alloc_size_type {
typedef typename std::make_unsigned<typename
boost::allocator_difference_type<A>::type>::type type;
};
#endif
template<class A>
struct alloc_size_type<A,
typename alloc_void<typename A::size_type>::type> {
typedef typename A::size_type type;
};
} /* detail */
template<class A>
struct allocator_size_type {
typedef typename detail::alloc_size_type<A>::type type;
};
namespace detail {
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<bool V>
struct alloc_bool {
typedef bool value_type;
typedef alloc_bool type;
static const bool value = V;
operator bool() const BOOST_NOEXCEPT {
return V;
}
bool operator()() const BOOST_NOEXCEPT {
return V;
}
};
template<bool V>
const bool alloc_bool<V>::value;
typedef alloc_bool<false> alloc_false;
#else
typedef std::false_type alloc_false;
#endif
template<class A, class = void>
struct alloc_pocca {
typedef alloc_false type;
};
template<class A>
struct alloc_pocca<A,
typename alloc_void<typename
A::propagate_on_container_copy_assignment>::type> {
typedef typename A::propagate_on_container_copy_assignment type;
};
} /* detail */
template<class A, class = void>
struct allocator_propagate_on_container_copy_assignment {
typedef typename detail::alloc_pocca<A>::type type;
};
namespace detail {
template<class A, class = void>
struct alloc_pocma {
typedef alloc_false type;
};
template<class A>
struct alloc_pocma<A,
typename alloc_void<typename
A::propagate_on_container_move_assignment>::type> {
typedef typename A::propagate_on_container_move_assignment type;
};
} /* detail */
template<class A>
struct allocator_propagate_on_container_move_assignment {
typedef typename detail::alloc_pocma<A>::type type;
};
namespace detail {
template<class A, class = void>
struct alloc_pocs {
typedef alloc_false type;
};
template<class A>
struct alloc_pocs<A,
typename alloc_void<typename A::propagate_on_container_swap>::type> {
typedef typename A::propagate_on_container_swap type;
};
} /* detail */
template<class A>
struct allocator_propagate_on_container_swap {
typedef typename detail::alloc_pocs<A>::type type;
};
namespace detail {
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class = void>
struct alloc_equal {
typedef typename std::is_empty<A>::type type;
};
#elif defined(BOOST_DETAIL_ALLOC_EMPTY)
template<class A, class = void>
struct alloc_equal {
typedef alloc_bool<BOOST_DETAIL_ALLOC_EMPTY(A)> type;
};
#else
template<class A, class = void>
struct alloc_equal {
typedef alloc_false type;
};
#endif
template<class A>
struct alloc_equal<A,
typename alloc_void<typename A::is_always_equal>::type> {
typedef typename A::is_always_equal type;
};
} /* detail */
template<class A>
struct allocator_is_always_equal {
typedef typename detail::alloc_equal<A>::type type;
};
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 {
template<class>
struct alloc_no {
char x, y;
};
template<class A>
class alloc_has_allocate {
template<class O>
static auto check(int)
-> alloc_no<decltype(std::declval<O&>().allocate(std::declval<typename
boost::allocator_size_type<A>::type>(), std::declval<typename
boost::allocator_const_void_pointer<A>::type>()))>;
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
} /* 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
namespace detail {
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class = void>
struct alloc_has_construct {
BOOST_STATIC_CONSTEXPR bool value = false;
};
template<class A>
struct alloc_has_construct<A,
typename alloc_void<typename A::_default_construct_destroy>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#else
template<class A, class T, class... Args>
class alloc_has_construct {
template<class O>
static auto check(int)
-> alloc_no<decltype(std::declval<O&>().construct(std::declval<T*>(),
std::declval<Args&&>()...))>;
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
#endif
template<bool, class = void>
struct alloc_if { };
template<class T>
struct alloc_if<true, T> {
typedef T type;
};
} /* detail */
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class T>
inline typename detail::alloc_if<detail::alloc_has_construct<A>::value>::type
allocator_construct(A& a, T* p)
{
a.construct(p);
}
template<class A, class T>
inline typename detail::alloc_if<!detail::alloc_has_construct<A>::value>::type
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
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
namespace detail {
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A, class, class = void>
struct alloc_has_destroy {
BOOST_STATIC_CONSTEXPR bool value = false;
};
template<class A, class T>
struct alloc_has_destroy<A, T,
typename alloc_void<typename A::_default_construct_destroy>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#else
template<class A, class T>
class alloc_has_destroy {
template<class O>
static auto check(int)
-> alloc_no<decltype(std::declval<O&>().destroy(std::declval<T*>()))>;
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
#endif
} /* detail */
template<class A, class T>
inline typename detail::alloc_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 detail::alloc_if<!detail::alloc_has_destroy<A, T>::value>::type
allocator_destroy(A&, T* p)
{
p->~T();
(void)p;
}
namespace detail {
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class T, T>
struct alloc_no {
char x, y;
};
template<class A>
class alloc_has_max_size {
template<class O>
static alloc_no<typename boost::allocator_size_type<O>::type(O::*)(),
&O::max_size> check(int);
template<class O>
static alloc_no<typename boost::allocator_size_type<O>::type(O::*)() const,
&O::max_size> check(int);
template<class O>
static alloc_no<typename boost::allocator_size_type<O>::type(*)(),
&O::max_size> check(int);
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
#else
template<class A>
class alloc_has_max_size {
template<class O>
static auto check(int)
-> alloc_no<decltype(std::declval<const O&>().max_size())>;
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
#endif
} /* detail */
template<class A>
inline typename detail::alloc_if<detail::alloc_has_max_size<A>::value,
typename allocator_size_type<A>::type>::type
allocator_max_size(const A& a) BOOST_NOEXCEPT
{
return a.max_size();
}
template<class A>
inline typename detail::alloc_if<!detail::alloc_has_max_size<A>::value,
typename allocator_size_type<A>::type>::type
allocator_max_size(const A&) BOOST_NOEXCEPT
{
return (std::numeric_limits<typename
allocator_size_type<A>::type>::max)() /
sizeof(typename allocator_value_type<A>::type);
}
namespace detail {
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class A>
class alloc_has_soccc {
template<class O>
static alloc_no<O(O::*)(), &O::select_on_container_copy_construction>
check(int);
template<class O>
static alloc_no<O(O::*)() const, &O::select_on_container_copy_construction>
check(int);
template<class O>
static alloc_no<O(*)(), &O::select_on_container_copy_construction>
check(int);
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
#else
template<class A>
class alloc_has_soccc {
template<class O>
static auto check(int) -> alloc_no<decltype(std::declval<const
O&>().select_on_container_copy_construction())>;
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
};
#endif
} /* detail */
template<class A>
inline typename detail::alloc_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 detail::alloc_if<!detail::alloc_has_soccc<A>::value, A>::type
allocator_select_on_container_copy_construction(const A& a)
{
return a;
}
template<class A, class T>
inline void
allocator_destroy_n(A& a, T* p, std::size_t n)
{
while (n > 0) {
boost::allocator_destroy(a, p + --n);
}
}
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::allocator_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
allocator_construct_n(A& a, T* p, std::size_t n)
{
detail::alloc_destroyer<A, T> d(a, p);
for (std::size_t& i = d.size(); i < n; ++i) {
boost::allocator_construct(a, p + i);
}
d.size() = 0;
}
template<class A, class T>
inline void
allocator_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
{
detail::alloc_destroyer<A, T> d(a, p);
for (std::size_t& i = d.size(); i < n; ++i) {
boost::allocator_construct(a, p + i, l[i % m]);
}
d.size() = 0;
}
template<class A, class T, class I>
inline void
allocator_construct_n(A& a, T* p, std::size_t n, I b)
{
detail::alloc_destroyer<A, T> d(a, p);
for (std::size_t& i = d.size(); i < n; void(++i), void(++b)) {
boost::allocator_construct(a, p + i, *b);
}
d.size() = 0;
}
#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

View File

@ -0,0 +1,112 @@
/*
Copyright 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_TRAITS_HPP
#define BOOST_CORE_ALLOCATOR_TRAITS_HPP
#include <boost/core/allocator_access.hpp>
namespace boost {
template<class A>
struct allocator_traits {
typedef A allocator_type;
typedef typename allocator_value_type<A>::type value_type;
typedef typename allocator_pointer<A>::type pointer;
typedef typename allocator_const_pointer<A>::type const_pointer;
typedef typename allocator_void_pointer<A>::type void_pointer;
typedef typename allocator_const_void_pointer<A>::type const_void_pointer;
typedef typename allocator_difference_type<A>::type difference_type;
typedef typename allocator_size_type<A>::type size_type;
typedef typename allocator_propagate_on_container_copy_assignment<A>::type
propagate_on_container_copy_assignment;
typedef typename allocator_propagate_on_container_move_assignment<A>::type
propagate_on_container_move_assignment;
typedef typename allocator_propagate_on_container_swap<A>::type
propagate_on_container_swap;
typedef typename allocator_is_always_equal<A>::type is_always_equal;
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class T>
using rebind_traits = allocator_traits<typename
allocator_rebind<A, T>::type>;
#else
template<class T>
struct rebind_traits
: allocator_traits<typename allocator_rebind<A, T>::type> { };
#endif
static pointer allocate(A& a, size_type n) {
return boost::allocator_allocate(a, n);
}
static pointer allocate(A& a, size_type n, const_void_pointer h) {
return boost::allocator_allocate(a, n, h);
}
static void deallocate(A& a, pointer p, size_type n) {
return boost::allocator_deallocate(a, p, n);
}
template<class T>
static void 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 T, class V, class... Args>
static void construct(A& a, T* p, V&& v, Args&&... args) {
boost::allocator_construct(a, p, std::forward<V>(v),
std::forward<Args>(args)...);
}
#else
template<class T, class V>
static void construct(A& a, T* p, V&& v) {
boost::allocator_construct(a, p, std::forward<V>(v));
}
#endif
#else
template<class T, class V>
static void construct(A& a, T* p, const V& v) {
boost::allocator_construct(a, p, v);
}
template<class T, class V>
static void construct(A& a, T* p, V& v) {
boost::allocator_construct(a, p, v);
}
#endif
template<class T>
static void destroy(A& a, T* p) {
boost::allocator_destroy(a, p);
}
static size_type max_size(const A& a) BOOST_NOEXCEPT {
return boost::allocator_max_size(a);
}
static A select_on_container_copy_construction(const A& a) {
return boost::allocator_select_on_container_copy_construction(a);
}
};
} /* boost */
#endif

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

@ -0,0 +1,595 @@
#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
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
# pragma warning(disable: 4244) // conversion from int to T
#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( boost::ulong_long_type x ) BOOST_NOEXCEPT
{
return x? __builtin_clzll( x ): std::numeric_limits<boost::ulong_long_type>::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) );
BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) )
{
return boost::core::detail::countl_impl( static_cast<boost::uint8_t>( x ) );
}
else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint16_t) )
{
return boost::core::detail::countl_impl( static_cast<boost::uint16_t>( x ) );
}
else BOOST_IF_CONSTEXPR ( 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( boost::ulong_long_type x ) BOOST_NOEXCEPT
{
return x? __builtin_ctzll( x ): std::numeric_limits<boost::ulong_long_type>::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) );
BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) )
{
return boost::core::detail::countr_impl( static_cast<boost::uint8_t>( x ) );
}
else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint16_t) )
{
return boost::core::detail::countr_impl( static_cast<boost::uint16_t>( x ) );
}
else BOOST_IF_CONSTEXPR ( 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( boost::ulong_long_type 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) );
BOOST_IF_CONSTEXPR ( 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;
}
// bit_width should return int, https://cplusplus.github.io/LWG/issue3656
template<class T>
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
{
return static_cast<T>(
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) );
BOOST_IF_CONSTEXPR ( 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
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // #ifndef BOOST_CORE_BIT_HPP_INCLUDED

View File

@ -0,0 +1,298 @@
#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, 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <cmath>
#if defined(BOOST_CORE_USE_GENERIC_CMATH) || (!defined(_MSC_VER) && !defined(FP_SUBNORMAL))
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <limits>
#include <cstring>
namespace boost
{
namespace core
{
// fpclassify return values
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;
// Classification functions
template<class T> bool isfinite( T x )
{
return x <= (std::numeric_limits<T>::max)() && x >= -(std::numeric_limits<T>::max)();
}
template<class T> bool isinf( T x )
{
return x > (std::numeric_limits<T>::max)() || x < -(std::numeric_limits<T>::max)();
}
template<class T> bool isnan( T x )
{
return !isfinite( x ) && !isinf( x );
}
template<class T> bool isnormal( T x )
{
return isfinite( x ) && ( x >= (std::numeric_limits<T>::min)() || x <= -(std::numeric_limits<T>::min)() );
}
template<class T> int fpclassify( T x )
{
if( x == 0 ) return fp_zero;
if( x < 0 ) x = -x;
if( x > (std::numeric_limits<T>::max)() ) return fp_infinite;
if( x >= (std::numeric_limits<T>::min)() ) return fp_normal;
if( x < (std::numeric_limits<T>::min)() ) return fp_subnormal;
return fp_nan;
}
// Sign manipulation functions
inline bool signbit( float x )
{
boost::int32_t y;
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
std::memcpy( &y, &x, sizeof( y ) );
return y < 0;
}
inline bool signbit( double x )
{
boost::int64_t y;
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
std::memcpy( &y, &x, sizeof( y ) );
return y < 0;
}
inline bool signbit( long double x )
{
return signbit( static_cast<double>( x ) );
}
template<class T> T copysign( T x, T y )
{
return signbit( x ) == signbit( y )? x: -x;
}
} // namespace core
} // namespace boost
#else // defined(BOOST_CORE_USE_GENERIC_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 // defined(BOOST_CORE_USE_GENERIC_CMATH)
#endif // #ifndef BOOST_CORE_CMATH_HPP_INCLUDED

View File

@ -10,11 +10,6 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#include <new>
#include <climits>
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
#define BOOST_CORE_NO_CXX11_ALLOCATOR
#endif
namespace boost {
@ -24,21 +19,25 @@ BOOST_NORETURN void throw_exception(const std::exception&);
namespace default_ {
struct true_type {
template<bool V>
struct bool_constant {
typedef bool value_type;
typedef true_type type;
typedef bool_constant type;
BOOST_STATIC_CONSTANT(bool, value = true);
static const bool value = V;
BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT {
return true;
operator bool() const BOOST_NOEXCEPT {
return V;
}
BOOST_CONSTEXPR bool operator()() const BOOST_NOEXCEPT {
return true;
bool operator()() const BOOST_NOEXCEPT {
return V;
}
};
template<bool V>
const bool bool_constant<V>::value;
template<class T>
struct add_reference {
typedef T& type;
@ -63,8 +62,8 @@ struct default_allocator {
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;
typedef bool_constant<true> propagate_on_container_move_assignment;
typedef bool_constant<true> is_always_equal;
template<class U>
struct rebind {
@ -81,16 +80,9 @@ struct default_allocator {
BOOST_CONSTEXPR default_allocator(const default_allocator<U>&)
BOOST_NOEXCEPT { }
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
}
#else
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
return ~static_cast<std::size_t>(0) / sizeof(T);
}
#endif
#if !defined(BOOST_NO_EXCEPTIONS)
T* allocate(std::size_t n) {
@ -120,7 +112,14 @@ struct default_allocator {
}
#endif
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_CORE_NO_CXX11_ALLOCATOR)
#if defined(BOOST_NO_CXX11_ALLOCATOR)
T* allocate(std::size_t n, const void*) {
return allocate(n);
}
#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);
@ -129,6 +128,7 @@ struct default_allocator {
template<class U>
void destroy(U* p) {
p->~U();
(void)p;
}
#endif
};

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_ += ( boost::uint64_t(0x9e3779b9u) << 32 ) + 0x7f4a7c15u;
boost::uint64_t z = x_;
z ^= z >> 30;
z *= ( boost::uint64_t(0xbf58476du) << 32 ) + 0x1ce4e5b9u;
z ^= z >> 27;
z *= ( boost::uint64_t(0x94d049bbu) << 32 ) + 0x133111ebu;
z ^= z >> 31;
return z;
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,11 @@ Distributed under the Boost Software License, Version 1.0.
#endif
#endif
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4510)
#endif
namespace boost {
template<class T>
@ -59,9 +64,9 @@ public:
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class... Args>
explicit empty_value(boost::empty_init_t, Args&&... args)
: value_(std::forward<Args>(args)...) { }
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)
@ -107,9 +112,9 @@ public:
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class... Args>
explicit empty_value(boost::empty_init_t, Args&&... args)
: T(std::forward<Args>(args)...) { }
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)
@ -139,9 +144,12 @@ public:
using empty_::empty_value;
BOOST_INLINE_VARIABLE
BOOST_CONSTEXPR_OR_CONST empty_init_t empty_init = empty_init_t();
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
} /* boost */
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif

View File

@ -11,34 +11,64 @@
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>
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
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <typename T1>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&)
{}
template <typename T1>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&)
{}
template <typename T1, typename T2>
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>
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>
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>
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&)
{}

View File

@ -24,11 +24,19 @@
#include <boost/current_function.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:
@ -48,7 +56,13 @@ public:
: 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
}
@ -83,12 +97,21 @@ inline int& test_errors()
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_results().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)
@ -99,14 +122,30 @@ inline void error_impl(char const * msg, char const * file, int line, char const
++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_results().errors();
}
inline void no_throw_failed_impl(const char* expr, const char* file, int line, const char* function)
{
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.
@ -137,67 +176,156 @@ template<class T> inline const void* test_output_impl(T volatile* v) { return co
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
#endif
struct lw_test_eq {
// 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; }
// Whether wchar_t is signed is implementation-defined
template<bool Signed> struct lwt_long_type {};
template<> struct lwt_long_type<true> { typedef long type; };
template<> struct lwt_long_type<false> { typedef unsigned long type; };
inline lwt_long_type<(static_cast<wchar_t>(-1) < static_cast<wchar_t>(0))>::type 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 ) ) )
{
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; }
static const char* op() { return "=="; }
};
struct lw_test_ne {
struct lw_test_ne
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t != u; }
static const char* op() { return "!="; }
};
struct lw_test_lt {
struct lw_test_lt
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t < u; }
static const char* op() { return "<"; }
};
struct lw_test_le {
struct lw_test_le
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t <= u; }
static const char* op() { return "<="; }
};
struct lw_test_gt {
struct lw_test_gt
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t > u; }
static const char* op() { return ">"; }
};
struct lw_test_ge {
struct lw_test_ge
{
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t >= u; }
static const char* op() { return ">="; }
};
// 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 void test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
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 << " " << pred.op() << " " << expr2
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
<< 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;
}
}
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
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( std::strcmp(t, u) == 0 )
{
test_results();
return true;
}
else
{
@ -205,15 +333,17 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
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
{
@ -221,11 +351,12 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
<< 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>
void test_all_eq_impl(FormattedOutputFunction& output,
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)
@ -284,16 +415,18 @@ void test_all_eq_impl(FormattedOutputFunction& output,
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>
void test_all_with_impl(FormattedOutputFunction& output,
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,
@ -353,11 +486,13 @@ void test_all_with_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
@ -397,11 +532,13 @@ inline int report_errors()
} // namespace boost
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::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_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) )
@ -417,22 +554,38 @@ inline int report_errors()
#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&) { \
::boost::detail::test_results(); \
} \
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

@ -11,7 +11,7 @@
//
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
//
// Copyright 2014 Peter Dimov
// Copyright 2014, 2021 Peter Dimov
//
// Copyright 2019 Glen Joseph Fernandes
// (glenjofe@gmail.com)
@ -21,60 +21,15 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/lightweight_test.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/type_name.hpp>
#include <boost/core/is_same.hpp>
#include <boost/config.hpp>
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 )
{
@ -86,7 +41,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): predicate '" << trait << "' ["
<< boost::core::demangled_name( BOOST_CORE_TYPEID(T) ) << "]"
<< boost::core::type_name<T>() << "]"
<< " test failed in function '" << function
<< "' (should have been " << ( expected? "true": "false" ) << ")"
<< std::endl;
@ -112,8 +67,8 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test 'is_same<" << types << ">'"
<< " failed in function '" << function
<< "' ('" << test_print<T1>()
<< "' != '" << test_print<T2>() << "')"
<< "' ('" << boost::core::type_name<T1>()
<< "' != '" << boost::core::type_name<T2>() << "')"
<< std::endl;
++test_results().errors();
@ -121,11 +76,16 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
}
} // namespace detail
} // namespace boost
#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

@ -29,7 +29,7 @@
# 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 (!"")
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900

View File

@ -8,28 +8,18 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <memory>
#endif
#include <new>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
#include <boost/core/allocator_access.hpp>
namespace boost {
template<class A>
struct noinit_adaptor
: A {
typedef void _default_construct_destroy;
template<class U>
struct rebind {
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
typedef noinit_adaptor<typename std::allocator_traits<A>::template
rebind_alloc<U> > other;
#else
typedef noinit_adaptor<typename A::template rebind<U>::other> other;
#endif
typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
};
noinit_adaptor()
@ -43,44 +33,32 @@ struct noinit_adaptor
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 U&>(u)) { }
: A(static_cast<const A&>(u)) { }
template<class U>
void construct(U* p) {
::new((void*)p) U;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class U, class V, class... Args>
void construct(U* p, V&& v, Args&&... args) {
::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
}
#else
template<class U, class V>
void construct(U* p, V&& v) {
::new((void*)p) U(std::forward<V>(v));
}
#endif
#else
#if defined(BOOST_NO_CXX11_ALLOCATOR)
template<class U, class V>
void construct(U* p, const V& v) {
::new((void*)p) U(v);
}
template<class U, class V>
void construct(U* p, V& v) {
::new((void*)p) U(v);
}
#endif
template<class U>
void destroy(U* p) {
p->~U();
(void)p;
}
};

View File

@ -27,7 +27,7 @@ namespace noncopyable_ // protection from unintended ADL
// 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
// The definition of base_token is macro-guarded so that Type Traits can
// define it locally without including this header, to avoid a dependency
// on Core.

View File

@ -1,5 +1,5 @@
/*
Copyright 2017-2018 Glen Joseph Fernandes
Copyright 2017-2021 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
@ -9,42 +9,23 @@ Distributed under the Boost Software License, Version 1.0.
#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>
#endif
#include <cstddef>
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 {
struct ptr_none { };
template<class>
struct ptr_void {
struct ptr_valid {
typedef void type;
};
template<class T>
struct ptr_first;
template<class>
struct ptr_first {
typedef ptr_none type;
};
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class, class...> class T, class U, class... Args>
@ -74,7 +55,7 @@ struct ptr_element {
};
template<class T>
struct ptr_element<T, typename ptr_void<typename T::element_type>::type> {
struct ptr_element<T, typename ptr_valid<typename T::element_type>::type> {
typedef typename T::element_type type;
};
@ -85,12 +66,12 @@ struct ptr_difference {
template<class T>
struct ptr_difference<T,
typename ptr_void<typename T::difference_type>::type> {
typename ptr_valid<typename T::difference_type>::type> {
typedef typename T::difference_type type;
};
template<class T, class V>
struct ptr_transform;
template<class, class>
struct ptr_transform { };
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class, class...> class T, class U, class... Args, class V>
@ -116,68 +97,131 @@ struct ptr_transform<T<U1, U2, U3>, V> {
#endif
template<class T, class U, class = void>
struct ptr_rebind {
typedef typename ptr_transform<T, U>::type type;
};
struct ptr_rebind
: ptr_transform<T, U> { };
#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> {
typename ptr_valid<typename T::template rebind<U> >::type> {
typedef typename T::template rebind<U> type;
};
#if !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
template<class T, class E>
class ptr_to_expr {
template<class>
struct result {
char x, y;
};
static E& source();
template<class O>
static auto check(int) -> result<decltype(O::pointer_to(source()))>;
template<class>
static char check(long);
public:
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<T>(0)) > 1;
};
template<class T, class E>
struct ptr_to_expr<T*, E> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
template<class T, class E>
struct ptr_has_to {
BOOST_STATIC_CONSTEXPR bool value = ptr_to_expr<T, E>::value;
};
#else
template<class, class>
struct ptr_has_to {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#endif
template<class T>
struct ptr_value {
typedef T type;
struct ptr_has_to<T, void> {
BOOST_STATIC_CONSTEXPR bool value = false;
};
template<>
struct ptr_value<void> {
typedef struct { } type;
template<class T>
struct ptr_has_to<T, const void> {
BOOST_STATIC_CONSTEXPR bool value = false;
};
template<class T>
struct ptr_has_to<T, volatile void> {
BOOST_STATIC_CONSTEXPR bool value = false;
};
template<class T>
struct ptr_has_to<T, const volatile void> {
BOOST_STATIC_CONSTEXPR bool value = false;
};
template<class T, class E, bool = ptr_has_to<T, E>::value>
struct ptr_to { };
template<class T, class E>
struct ptr_to<T, E, true> {
static T pointer_to(E& v) {
return T::pointer_to(v);
}
};
template<class T>
struct ptr_to<T*, T, true> {
static T* pointer_to(T& v) BOOST_NOEXCEPT {
return boost::addressof(v);
}
};
template<class T, class E>
struct ptr_traits
: ptr_to<T, E> {
typedef T pointer;
typedef E element_type;
typedef typename ptr_difference<T>::type difference_type;
template<class U>
struct rebind_to
: ptr_rebind<T, U> { };
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class U>
using rebind = typename rebind_to<U>::type;
#endif
};
template<class T>
struct ptr_traits<T, ptr_none> { };
} /* 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);
}
};
struct pointer_traits
: detail::ptr_traits<T, typename detail::ptr_element<T>::type> { };
template<class T>
struct pointer_traits<T*> {
struct pointer_traits<T*>
: detail::ptr_to<T*, 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*;
using rebind = typename rebind_to<U>::type;
#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*

View File

@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <cstdlib>
#include <stdlib.h>
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
@ -33,7 +33,7 @@ extern "C" _Noreturn void quick_exit(int);
namespace boost
{
BOOST_NORETURN void quick_exit( int code ) BOOST_NOEXCEPT
BOOST_NORETURN inline void quick_exit( int code ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER) && _MSC_VER < 1900

View File

@ -10,6 +10,7 @@
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
//
// ref.hpp - ref/cref, useful helper functions
@ -46,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
/**
@ -87,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.
@ -116,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

399
include/boost/core/span.hpp Normal file
View File

@ -0,0 +1,399 @@
/*
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_SPAN_HPP
#define BOOST_CORE_SPAN_HPP
#include <array>
#include <iterator>
#include <type_traits>
#include <cstddef>
namespace boost {
constexpr std::size_t dynamic_extent = static_cast<std::size_t>(-1);
template<class T, std::size_t E = dynamic_extent>
class span;
namespace detail {
template<class U, class T>
struct span_convertible {
static constexpr bool value = std::is_convertible<U(*)[], T(*)[]>::value;
};
template<std::size_t E, std::size_t N>
struct span_capacity {
static constexpr bool value = E == boost::dynamic_extent || E == N;
};
template<class T, std::size_t E, class U, std::size_t N>
struct span_compatible {
static constexpr bool value = span_capacity<E, N>::value &&
span_convertible<U, T>::value;
};
template<class T>
struct span_uncvref {
typedef typename std::remove_cv<typename
std::remove_reference<T>::type>::type type;
};
template<class>
struct span_is_span {
static constexpr bool value = false;
};
template<class T, std::size_t E>
struct span_is_span<boost::span<T, E> > {
static constexpr bool value = true;
};
template<class T>
struct span_is_array {
static constexpr bool value = false;
};
template<class T, std::size_t N>
struct span_is_array<std::array<T, N> > {
static constexpr bool value = true;
};
template<class, class = void>
struct span_data { };
template<class T>
struct span_data<T,
typename std::enable_if<std::is_pointer<decltype(std::declval<T
&>().data())>::value>::type> {
typedef typename std::remove_pointer<decltype(std::declval<T
&>().data())>::type type;
};
template<class, class, class = void>
struct span_has_data {
static constexpr bool value = false;
};
template<class R, class T>
struct span_has_data<R, T, typename std::enable_if<span_convertible<typename
span_data<R>::type, T>::value>::type> {
static constexpr bool value = true;
};
template<class, class = void>
struct span_has_size {
static constexpr bool value = false;
};
template<class R>
struct span_has_size<R, typename
std::enable_if<std::is_convertible<decltype(std::declval<R&>().size()),
std::size_t>::value>::type> {
static constexpr bool value = true;
};
template<class R, class T>
struct span_is_range {
static constexpr bool value = (std::is_const<T>::value ||
std::is_lvalue_reference<R>::value) &&
!span_is_span<typename span_uncvref<R>::type>::value &&
!span_is_array<typename span_uncvref<R>::type>::value &&
!std::is_array<typename span_uncvref<R>::type>::value &&
span_has_data<R, T>::value &&
span_has_size<R>::value;
};
template<std::size_t E, std::size_t N>
struct span_implicit {
static constexpr bool value = E == boost::dynamic_extent ||
N != boost::dynamic_extent;
};
template<class T, std::size_t E, class U, std::size_t N>
struct span_copyable {
static constexpr bool value = (N == boost::dynamic_extent ||
span_capacity<E, N>::value) && span_convertible<U, T>::value;
};
template<std::size_t E, std::size_t O>
struct span_sub {
static constexpr std::size_t value = E == boost::dynamic_extent ?
boost::dynamic_extent : E - O;
};
template<class T, std::size_t E>
struct span_store {
constexpr span_store(T* p_, std::size_t) noexcept
: p(p_) { }
static constexpr std::size_t n = E;
T* p;
};
template<class T>
struct span_store<T, boost::dynamic_extent> {
constexpr span_store(T* p_, std::size_t n_) noexcept
: p(p_)
, n(n_) { }
T* p;
std::size_t n;
};
template<class T, std::size_t E>
struct span_bytes {
static constexpr std::size_t value = sizeof(T) * E;
};
template<class T>
struct span_bytes<T, boost::dynamic_extent> {
static constexpr std::size_t value = boost::dynamic_extent;
};
} /* detail */
template<class T, std::size_t E>
class span {
public:
typedef T element_type;
typedef typename std::remove_cv<T>::type value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T* iterator;
typedef const T* const_iterator;
typedef std::reverse_iterator<T*> reverse_iterator;
typedef std::reverse_iterator<const T*> const_reverse_iterator;
static constexpr std::size_t extent = E;
template<std::size_t N = E,
typename std::enable_if<N == dynamic_extent || N == 0, int>::type = 0>
constexpr span() noexcept
: s_(0, 0) { }
template<class I,
typename std::enable_if<E == dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
constexpr span(I* f, size_type c)
: s_(f, c) { }
template<class I,
typename std::enable_if<E != dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
explicit constexpr span(I* f, size_type c)
: s_(f, c) { }
template<class I, class L,
typename std::enable_if<E == dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
constexpr span(I* f, L* l)
: s_(f, l - f) { }
template<class I, class L,
typename std::enable_if<E != dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
explicit constexpr span(I* f, L* l)
: s_(f, l - f) { }
template<std::size_t N,
typename std::enable_if<detail::span_capacity<E, N>::value,
int>::type = 0>
constexpr span(typename std::enable_if<true, T>::type (&a)[N]) noexcept
: s_(a, N) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_compatible<T, E, U, N>::value,
int>::type = 0>
constexpr span(std::array<U, N>& a) noexcept
: s_(a.data(), N) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_compatible<T, E, const U,
N>::value, int>::type = 0>
constexpr span(const std::array<U, N>& a) noexcept
: s_(a.data(), N) { }
template<class R,
typename std::enable_if<E == dynamic_extent &&
detail::span_is_range<R, T>::value, int>::type = 0>
constexpr span(R&& r) noexcept(noexcept(r.data()) && noexcept(r.size()))
: s_(r.data(), r.size()) { }
template<class R,
typename std::enable_if<E != dynamic_extent &&
detail::span_is_range<R, T>::value, int>::type = 0>
explicit constexpr span(R&& r) noexcept(noexcept(r.data()) &&
noexcept(r.size()))
: s_(r.data(), r.size()) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_implicit<E, N>::value &&
detail::span_copyable<T, E, U, N>::value, int>::type = 0>
constexpr span(const span<U, N>& s) noexcept
: s_(s.data(), s.size()) { }
template<class U, std::size_t N,
typename std::enable_if<!detail::span_implicit<E, N>::value &&
detail::span_copyable<T, E, U, N>::value, int>::type = 0>
explicit constexpr span(const span<U, N>& s) noexcept
: s_(s.data(), s.size()) { }
template<std::size_t C>
constexpr span<T, C> first() const {
static_assert(C <= E, "Count <= Extent");
return span<T, C>(s_.p, C);
}
template<std::size_t C>
constexpr span<T, C> last() const {
static_assert(C <= E, "Count <= Extent");
return span<T, C>(s_.p + (s_.n - C), C);
}
template<std::size_t O, std::size_t C = dynamic_extent>
constexpr typename std::enable_if<C == dynamic_extent,
span<T, detail::span_sub<E, O>::value> >::type subspan() const {
static_assert(O <= E, "Offset <= Extent");
return span<T, detail::span_sub<E, O>::value>(s_.p + O, s_.n - O);
}
template<std::size_t O, std::size_t C = dynamic_extent>
constexpr typename std::enable_if<C != dynamic_extent,
span<T, C> >::type subspan() const {
static_assert(O <= E && C <= E - O,
"Offset <= Extent && Count <= Extent - Offset");
return span<T, C>(s_.p + O, C);
}
constexpr span<T, dynamic_extent> first(size_type c) const {
return span<T, dynamic_extent>(s_.p, c);
}
constexpr span<T, dynamic_extent> last(size_type c) const {
return span<T, dynamic_extent>(s_.p + (s_.n - c), c);
}
constexpr span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const {
return span<T, dynamic_extent>(s_.p + o,
c == dynamic_extent ? s_.n - o : c);
}
constexpr size_type size() const noexcept {
return s_.n;
}
constexpr size_type size_bytes() const noexcept {
return s_.n * sizeof(T);
}
constexpr bool empty() const noexcept {
return s_.n == 0;
}
constexpr reference operator[](size_type i) const {
return s_.p[i];
}
constexpr reference front() const {
return *s_.p;
}
constexpr reference back() const {
return s_.p[s_.n - 1];
}
constexpr pointer data() const noexcept {
return s_.p;
}
constexpr iterator begin() const noexcept {
return s_.p;
}
constexpr iterator end() const noexcept {
return s_.p + s_.n;
}
constexpr reverse_iterator rbegin() const noexcept {
return reverse_iterator(s_.p + s_.n);
}
constexpr reverse_iterator rend() const noexcept {
return reverse_iterator(s_.p);
}
constexpr const_iterator cbegin() const noexcept {
return s_.p;
}
constexpr const_iterator cend() const noexcept {
return s_.p + s_.n;
}
constexpr const_reverse_iterator crbegin() const noexcept {
return const_reverse_iterator(s_.p + s_.n);
}
constexpr const_reverse_iterator crend() const noexcept {
return const_reverse_iterator(s_.p);
}
private:
detail::span_store<T, E> s_;
};
template<class T, std::size_t E>
constexpr std::size_t span<T, E>::extent;
#ifdef __cpp_deduction_guides
template<class I, class L>
span(I*, L) -> span<I>;
template<class T, std::size_t N>
span(T(&)[N]) -> span<T, N>;
template<class T, std::size_t N>
span(std::array<T, N>&) -> span<T, N>;
template<class T, std::size_t N>
span(const std::array<T, N>&) -> span<const T, N>;
template<class R>
span(R&&) -> span<typename detail::span_data<R>::type>;
template<class T, std::size_t E>
span(span<T, E>) -> span<T, E>;
#endif
#ifdef __cpp_lib_byte
template<class T, std::size_t E>
inline span<const std::byte, detail::span_bytes<T, E>::value>
as_bytes(span<T, E> s) noexcept
{
return span<const std::byte, detail::span_bytes<T,
E>::value>(reinterpret_cast<const std::byte*>(s.data()),
s.size_bytes());
}
template<class T, std::size_t E>
inline typename std::enable_if<!std::is_const<T>::value,
span<std::byte, detail::span_bytes<T, E>::value> >::type
as_writable_bytes(span<T, E> s) noexcept
{
return span<std::byte, detail::span_bytes<T,
E>::value>(reinterpret_cast<std::byte*>(s.data()), s.size_bytes());
}
#endif
} /* boost */
#endif

View File

@ -23,12 +23,12 @@
#include <boost/core/enable_if.hpp>
#include <boost/config.hpp>
#if __cplusplus >= 201103L || defined(BOOST_MSVC)
#include <utility> //for std::swap (C++11)
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
#include <utility> // for std::swap (C++11)
#else
#include <algorithm> //for std::swap (C++98)
#include <algorithm> // for std::swap (C++98)
#endif
#include <cstddef> //for std::size_t
#include <cstddef> // for std::size_t
namespace boost_swap_impl
{

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright Andrey Semashev 2018.
* 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)
@ -26,9 +26,24 @@
#pragma once
#endif
// Visual Studio 14 supports N4152 std::uncaught_exceptions()
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
(defined(_MSC_VER) && _MSC_VER >= 1900)
#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
@ -46,7 +61,11 @@
#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().
#if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
// 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
@ -76,7 +95,7 @@ extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __att
#endif
} // namespace __cxxabiv1
#endif
#endif // !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
#endif
#endif // defined(BOOST_CORE_HAS_CXXABI_H)
#if defined(_MSC_VER) && _MSC_VER >= 1400

View File

@ -0,0 +1,88 @@
#ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
#define BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/demangle.hpp>
#include <boost/throw_exception.hpp>
#include <boost/config.hpp>
#include <exception>
#include <typeinfo>
#include <cstdlib>
#include <cstdio>
namespace boost
{
namespace core
{
BOOST_NORETURN inline void verbose_terminate_handler()
{
std::set_terminate( 0 );
#if defined(BOOST_NO_EXCEPTIONS)
std::fputs( "std::terminate called with exceptions disabled\n", stderr );
#else
try
{
throw;
}
catch( std::exception const& x )
{
#if defined(BOOST_NO_RTTI)
char const * typeid_name = "unknown (RTTI is disabled)";
#else
char const * typeid_name = typeid( x ).name();
boost::core::scoped_demangled_name typeid_demangled_name( typeid_name );
if( typeid_demangled_name.get() != 0 )
{
typeid_name = typeid_demangled_name.get();
}
#endif
boost::source_location loc = boost::get_throw_location( x );
std::fprintf( stderr,
"std::terminate called after throwing an exception:\n\n"
" type: %s\n"
" what(): %s\n"
" location: %s:%lu:%lu in function '%s'\n",
typeid_name,
x.what(),
loc.file_name(), static_cast<unsigned long>( loc.line() ),
static_cast<unsigned long>( loc.column() ), loc.function_name()
);
}
catch( ... )
{
std::fputs( "std::terminate called after throwing an unknown exception\n", stderr );
}
#endif
std::fflush( stdout );
std::abort();
}
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED

View File

@ -6,7 +6,11 @@
#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))

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

@ -5,7 +5,9 @@
#ifndef BOOST_ITERATOR_HPP
#define BOOST_ITERATOR_HPP
// This header is obsolete and will be deprecated.
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("<iterator>")
#include <iterator>
#include <cstddef> // std::ptrdiff_t

View File

@ -8,14 +8,15 @@
"Andrey Semashev"
],
"maintainers": [
"Peter Dimov <pdimov -at- pdimov.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"
}
]

32
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
# Copyright 2018-2021 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)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::type_traits)
boost_test(TYPE run SOURCES eif_constructors.cpp)
boost_test(TYPE run SOURCES eif_dummy_arg_disambiguation.cpp)
boost_test(TYPE run SOURCES eif_lazy.cpp)
boost_test(TYPE run SOURCES eif_lazy_test.cpp)
boost_test(TYPE run SOURCES eif_member_templates.cpp)
boost_test(TYPE run SOURCES eif_namespace_disambiguation.cpp)
boost_test(TYPE run SOURCES eif_no_disambiguation.cpp)
boost_test(TYPE run SOURCES eif_partial_specializations.cpp)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::throw_exception)
boost_test(TYPE run SOURCES no_exceptions_support_test.cpp)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::utility)
boost_test(TYPE run SOURCES sv_conversion_test2.cpp)
endif()
add_subdirectory(swap)

View File

@ -1,6 +1,6 @@
# Boost.Core Library test Jamfile
#
# Copyright (c) 2014, 2017 Peter Dimov
# Copyright (c) 2014-2021 Peter Dimov
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at
@ -9,6 +9,19 @@
import modules ;
import testing ;
project : requirements
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare ;
local warning-as-errors-off =
"-<toolset>msvc:<warnings-as-errors>on"
"-<toolset>gcc:<warnings-as-errors>on"
"-<toolset>clang:<warnings-as-errors>on" ;
# quick test (for CI)
run quick.cpp ;
@ -18,47 +31,65 @@ 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 ;
compile-fail addressof_fail_rvalue.cpp
: $(warning-as-errors-off) ;
run checked_delete_test.cpp ;
compile-fail checked_delete_fail.cpp ;
compile-fail checked_delete_fail2.cpp ;
compile-fail checked_delete_fail.cpp
: $(warning-as-errors-off) ;
compile-fail checked_delete_fail2.cpp
: $(warning-as-errors-off) ;
compile ref_ct_test.cpp ;
run ref_test.cpp ;
run ref_ref_test.cpp ;
run ref_fn_test.cpp ;
compile-fail ref_rv_fail1.cpp ;
compile-fail ref_rv_fail2.cpp ;
compile-fail ref_rv_fail3.cpp ;
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_rv_fail1.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail2.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail3.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail4.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail5.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail2.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail3.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail4.cpp
: $(warning-as-errors-off) ;
run ref_cv_test.cpp ;
run ref_conversion_test.cpp ;
run eif_constructors.cpp ;
run eif_dummy_arg_disambiguation.cpp ;
run eif_lazy.cpp ;
run eif_lazy_test.cpp ;
run eif_member_templates.cpp ;
run eif_namespace_disambiguation.cpp ;
run eif_no_disambiguation.cpp ;
run eif_partial_specializations.cpp ;
run eif_constructors.cpp : ;
run eif_dummy_arg_disambiguation.cpp : ;
run eif_lazy.cpp : ;
run eif_lazy_test.cpp : ;
run eif_member_templates.cpp : ;
run eif_namespace_disambiguation.cpp : ;
run eif_no_disambiguation.cpp : ;
run eif_partial_specializations.cpp : ;
compile-fail noncopyable_compile_fail.cpp ;
compile-fail noncopyable_compile_fail.cpp
: $(warning-as-errors-off) ;
run explicit_operator_bool.cpp ;
run explicit_operator_bool_noexcept.cpp ;
compile-fail explicit_operator_bool_compile_fail_conv_int.cpp ;
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-fail explicit_operator_bool_compile_fail_conv_int.cpp
: $(warning-as-errors-off) ;
compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp
: $(warning-as-errors-off) ;
compile-fail explicit_operator_bool_compile_fail_delete.cpp
: $(warning-as-errors-off) ;
compile-fail explicit_operator_bool_compile_fail_shift.cpp
: $(warning-as-errors-off) ;
compile ignore_unused_test.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" ;
run sp_typeinfo_test.cpp ;
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
@ -66,21 +97,36 @@ 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 ;
run lightweight_test_test2.cpp ;
run lightweight_test_all_with_test.cpp ;
run lightweight_test_lt_le_test.cpp ;
run lightweight_test_gt_ge_test.cpp ;
run lightweight_test_eq_nullptr.cpp ;
run lightweight_test_test3.cpp ;
run lightweight_test_test4.cpp ;
run lightweight_test_test5.cpp : : :
<warnings>extra
local pedantic-errors = <warnings>pedantic
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
<toolset>clang:<warnings-as-errors>on ;
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 ;
@ -92,18 +138,28 @@ run-fail lightweight_test_fail4.cpp ;
run-fail lightweight_test_fail5.cpp ;
run-fail lightweight_test_fail6.cpp ;
run-fail lightweight_test_fail7.cpp ;
run-fail lightweight_test_fail7.cpp : : : <rtti>off : lightweight_test_fail7_no_rtti ;
run-fail lightweight_test_fail7.cpp : : : <rtti>off <toolset>gcc-4.4:<build>no : 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_fail8.cpp : : : <rtti>off <toolset>gcc-4.4:<build>no : 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_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 ;
run typeinfo_test.cpp ;
@ -112,14 +168,19 @@ 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 ;
compile-fail scoped_enum_compile_fail_conv_from_int.cpp ;
compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
compile-fail scoped_enum_compile_fail_conv_from_int.cpp
: $(warning-as-errors-off) ;
compile-fail scoped_enum_compile_fail_conv_to_int.cpp
: $(warning-as-errors-off) ;
run underlying_type.cpp ;
@ -128,6 +189,9 @@ 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 pointer_traits_sfinae_test.cpp ;
run pointer_traits_rebind_sfinae_test.cpp ;
run pointer_traits_pointer_to_sfinae_test.cpp ;
run to_address_test.cpp ;
run exchange_test.cpp ;
@ -145,7 +209,13 @@ run-fail quick_exit_fail.cpp ;
compile use_default_test.cpp ;
run default_allocator_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 default_allocator_allocate_hint_test.cpp ;
run noinit_adaptor_test.cpp ;
run alloc_construct_test.cpp ;
run alloc_construct_throws_test.cpp ;
@ -153,6 +223,29 @@ 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 ;
run allocator_construct_test.cpp ;
run allocator_destroy_test.cpp ;
run allocator_construct_n_test.cpp ;
run allocator_destroy_n_test.cpp ;
run allocator_traits_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 ;
@ -161,11 +254,92 @@ 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 uncaught_exceptions.cpp : : : <exception-handling>on ;
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
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 no_exceptions_support_test.cpp ;
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
: : : $(pedantic-errors) ;
run cmath_test.cpp : : : <define>BOOST_CORE_USE_GENERIC_CMATH <toolset>msvc-8.0:<build>no : cmath_test_generic ;
run bit_cast_test.cpp
: : : $(pedantic-errors) ;
run bit_rotate_test.cpp
: : : $(pedantic-errors) ;
run bit_countr_test.cpp
: : : $(pedantic-errors) ;
run bit_countl_test.cpp
: : : $(pedantic-errors) ;
run bit_width_test.cpp
: : : $(pedantic-errors) ;
run has_single_bit_test.cpp
: : : $(pedantic-errors) ;
run bit_floor_test.cpp
: : : $(pedantic-errors) ;
run bit_ceil_test.cpp
: : : $(pedantic-errors) ;
run bit_popcount_test.cpp
: : : $(pedantic-errors) ;
run bit_endian_test.cpp
: : : $(pedantic-errors) ;
run type_name_test.cpp ;
run sv_types_test.cpp ;
run sv_construct_test.cpp ;
run sv_iteration_test.cpp ;
run sv_element_access_test.cpp ;
run sv_modifiers_test.cpp ;
run sv_copy_test.cpp ;
run sv_substr_test.cpp ;
run sv_compare_test.cpp ;
run sv_starts_with_test.cpp ;
run sv_ends_with_test.cpp ;
run sv_find_test.cpp ;
run sv_rfind_test.cpp ;
run sv_find_first_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_find_last_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_find_first_not_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_find_last_not_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_contains_test.cpp ;
run sv_eq_test.cpp ;
run sv_lt_test.cpp ;
run sv_stream_insert_test.cpp ;
run sv_conversion_test.cpp ;
run sv_conversion_test2.cpp : ;
run sv_common_reference_test.cpp ;
compile sv_common_reference_test2.cpp ;
compile sv_windows_h_test.cpp ;
run span_test.cpp ;
run span_types_test.cpp ;
run span_constructible_test.cpp ;
run span_deduction_guide_test.cpp ;
run as_bytes_test.cpp ;
run as_writable_bytes_test.cpp ;
compile span_boost_begin_test.cpp ;
run splitmix64_test.cpp
: : : $(pedantic-errors) ;
run-fail verbose_terminate_handler_fail.cpp : ;
run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off : verbose_terminate_handler_fail_nx ;
run-fail verbose_terminate_handler_fail.cpp : : : <rtti>off : verbose_terminate_handler_fail_nr ;
run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off <rtti>off : verbose_terminate_handler_fail_nxr ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

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

@ -10,6 +10,10 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/alloc_construct.hpp>
#include <boost/core/lightweight_test.hpp>
#if defined(_MSC_VER)
# pragma warning(disable: 4100) // unreferenced parameter 'ptr'
#endif
class type {
public:
explicit type(int x)

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,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/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int* const_pointer;
};
template<class T>
struct A2 {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_const_pointer<A1<char> >::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
boost::allocator_const_pointer<A2<int> >::type>));
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* const_pointer;
typedef int* const_void_pointer;
template<class U>
struct rebind {
typedef A1<U> other;
};
};
template<class T>
struct A2 {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_const_void_pointer<A1<char> >::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
boost::allocator_const_void_pointer<A2<int> >::type>));
return boost::report_errors();
}

View File

@ -0,0 +1,47 @@
/*
Copyright 2022 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;
A() { }
};
int main()
{
{
A<int> a;
int i[3] = { 5, 5, 5 };
boost::allocator_construct_n(a, &i[0], 3);
BOOST_TEST_EQ(i[0], 0);
BOOST_TEST_EQ(i[1], 0);
BOOST_TEST_EQ(i[2], 0);
}
{
A<int> a;
int i[4] = { 5, 5, 5, 5 };
int j[2] = { 1, 2 };
boost::allocator_construct_n(a, &i[0], 4, &j[0], 2);
BOOST_TEST_EQ(i[0], 1);
BOOST_TEST_EQ(i[1], 2);
BOOST_TEST_EQ(i[2], 1);
BOOST_TEST_EQ(i[3], 2);
}
{
A<int> a;
int i[3] = { 5, 5, 5 };
int j[3] = { 1, 2, 3 };
boost::allocator_construct_n(a, &i[0], 3, &j[0]);
BOOST_TEST_EQ(i[0], 1);
BOOST_TEST_EQ(i[1], 2);
BOOST_TEST_EQ(i[2], 3);
}
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)
{
A2<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,66 @@
/*
Copyright 2022 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[3];
boost::allocator_destroy_n(a, &s[0], 3);
BOOST_TEST_EQ(S::count, 0);
::new((void*)&s[0]) S();
::new((void*)&s[1]) S();
::new((void*)&s[2]) S();
}
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
{
A2<int> a;
int i[3] = { 5, 5, 5 };
boost::allocator_destroy_n(a, &i[0], 3);
BOOST_TEST_EQ(i[0], 0);
BOOST_TEST_EQ(i[1], 0);
BOOST_TEST_EQ(i[2], 0);
}
#endif
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)
{
A2<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,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/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef short difference_type;
};
template<class T>
struct A2 {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
boost::allocator_difference_type<A1<char> >::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::allocator_difference_type<A2<int> >::type>));
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;
};
template<class T>
struct A2 {
typedef T value_type;
};
template<class T>
struct A3 {
typedef T value_type;
struct is_always_equal {
static const bool value = false;
};
};
template<class T>
struct A4 {
typedef T value_type;
struct is_always_equal {
static const bool value = true;
};
int value;
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1<int> >::type));
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));
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/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;
}
};
template<class T>
struct A2 {
typedef T value_type;
typedef short size_type;
A2() { }
};
int main()
{
BOOST_TEST_EQ(boost::allocator_max_size(A1<int>()), 1);
BOOST_TEST_LE(boost::allocator_max_size(A2<int>()),
(std::numeric_limits<short>::max)());
return boost::report_errors();
}

View File

@ -0,0 +1,32 @@
/*
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 T>
struct A2 {
typedef T value_type;
struct propagate_on_container_copy_assignment {
static const bool value = true;
};
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_copy_assignment<A1<int> >::type));
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_copy_assignment<A2<int> >::type));
return boost::report_errors();
}

View File

@ -0,0 +1,32 @@
/*
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 T>
struct A2 {
typedef T value_type;
struct propagate_on_container_move_assignment {
static const bool value = true;
};
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_move_assignment<A1<int> >::type));
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_move_assignment<A2<int> >::type));
return boost::report_errors();
}

View File

@ -0,0 +1,32 @@
/*
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 T>
struct A2 {
typedef T value_type;
struct propagate_on_container_swap {
static const bool value = true;
};
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_swap<A1<int> >::type));
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_swap<A2<int> >::type));
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/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct A1 {
typedef T value_type;
typedef int* pointer;
};
template<class T>
struct A2 {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_pointer<A1<char> >::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_pointer<A2<int> >::type>));
return boost::report_errors();
}

View File

@ -0,0 +1,33 @@
/*
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;
};
};
template<class T>
struct A2 {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
boost::allocator_rebind<A1<char>, bool>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
boost::allocator_rebind<A2<char>, int>::type>));
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,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/lightweight_test.hpp>
template<class T>
struct A1 {
typedef T value_type;
A1(int n)
: value(n) { }
int value;
};
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;
};
int main()
{
BOOST_TEST_EQ(1, boost::
allocator_select_on_container_copy_construction(A1<int>(1)).value);
BOOST_TEST_EQ(2, boost::
allocator_select_on_container_copy_construction(A2<int>(1)).value);
return boost::report_errors();
}

View File

@ -0,0 +1,114 @@
/*
Copyright 2021 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_traits.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
class creator {
public:
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef void* void_pointer;
typedef const void* const_void_pointer;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
explicit creator(int value) BOOST_NOEXCEPT
: state_(value) { }
template<class U>
creator(const creator<U>& other) BOOST_NOEXCEPT
: state_(other.state) { }
std::size_t max_size() const BOOST_NOEXCEPT {
return static_cast<std::size_t>(-1) / sizeof(T);
}
T* allocate(std::size_t n, const void* = 0) {
return static_cast<T*>(::operator new(sizeof(T) * n));
}
void deallocate(T* p, std::size_t) {
::operator delete(p);
}
int state() const {
return state_;
}
private:
int state_;
};
template<class T, class U>
inline bool operator==(const creator<T>& lhs,
const creator<U>& rhs) BOOST_NOEXCEPT
{
return lhs.state() == rhs.state();
}
template<class T, class U>
inline bool operator!=(const creator<T>& lhs,
const creator<U>& rhs) BOOST_NOEXCEPT
{
return !(lhs == rhs);
}
int main()
{
BOOST_TEST_TRAIT_SAME(creator<int>,
boost::allocator_traits<creator<int> >::allocator_type);
BOOST_TEST_TRAIT_SAME(int,
boost::allocator_traits<creator<int> >::value_type);
BOOST_TEST_TRAIT_SAME(int*,
boost::allocator_traits<creator<int> >::pointer);
BOOST_TEST_TRAIT_SAME(const int*,
boost::allocator_traits<creator<int> >::const_pointer);
BOOST_TEST_TRAIT_SAME(void*,
boost::allocator_traits<creator<int> >::void_pointer);
BOOST_TEST_TRAIT_SAME(const void*,
boost::allocator_traits<creator<int> >::const_void_pointer);
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::allocator_traits<creator<int> >::difference_type);
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::allocator_traits<creator<int> >::size_type);
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
propagate_on_container_copy_assignment));
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
propagate_on_container_move_assignment));
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
propagate_on_container_swap));
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
is_always_equal));
BOOST_TEST_TRAIT_SAME(creator<char>,
boost::allocator_traits<creator<int> >::
rebind_traits<char>::allocator_type);
creator<int> a(1);
int* p1 = boost::allocator_traits<creator<int> >::allocate(a, 1);
if (BOOST_TEST(p1)) {
boost::allocator_traits<creator<int> >::construct(a, p1, 5);
BOOST_TEST_EQ(*p1, 5);
boost::allocator_traits<creator<int> >::destroy(a, p1);
boost::allocator_traits<creator<int> >::deallocate(a, p1, 1);
}
int* p2 = boost::allocator_traits<creator<int> >::allocate(a, 1, 0);
if (BOOST_TEST(p2)) {
boost::allocator_traits<creator<int> >::deallocate(a, p2, 1);
}
BOOST_TEST_EQ(boost::allocator_traits<creator<int> >::max_size(a),
static_cast<std::size_t>(-1) / sizeof(int));
BOOST_TEST(boost::allocator_traits<creator<int> >::
select_on_container_copy_construction(a) == a);
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,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* pointer;
typedef int* void_pointer;
template<class U>
struct rebind {
typedef A1<U> other;
};
};
template<class T>
struct A2 {
typedef T value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_void_pointer<A1<char> >::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
boost::allocator_void_pointer<A2<int> >::type>));
return boost::report_errors();
}

42
test/as_bytes_test.cpp Normal file
View File

@ -0,0 +1,42 @@
/*
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 <cstddef>
#ifdef __cpp_lib_byte
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
void test_dynamic()
{
int a[4];
boost::span<const std::byte> s =
boost::as_bytes(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<const std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
void test_static()
{
int a[4];
boost::span<const std::byte, sizeof(int) * 4> s =
boost::as_bytes(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<const std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
int main()
{
test_dynamic();
test_static();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@ -0,0 +1,42 @@
/*
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 <cstddef>
#ifdef __cpp_lib_byte
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
void test_dynamic()
{
int a[4];
boost::span<std::byte> s =
boost::as_writable_bytes(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
void test_static()
{
int a[4];
boost::span<std::byte, sizeof(int) * 4> s =
boost::as_writable_bytes(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
int main()
{
test_dynamic();
test_static();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

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<boost::ulong_long_type>( 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( boost::uint64_t( 1 ) << 63 );
}
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<boost::ulong_long_type>( 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<boost::ulong_long_type>( 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<boost::ulong_long_type>( 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<boost::ulong_long_type>( 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<boost::ulong_long_type>( x ) );
}
return boost::report_errors();
}

40
test/bit_endian_test.cpp Normal file
View File

@ -0,0 +1,40 @@
// 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>
#if defined(_MSC_VER)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
int main()
{
boost::uint64_t v = ( static_cast<boost::uint64_t>( 0x01020304u ) << 32 ) + 0x05060708u;
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<boost::ulong_long_type>( 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<boost::ulong_long_type>( 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<boost::ulong_long_type>( 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<boost::ulong_long_type>( x ) );
}
return boost::report_errors();
}

177
test/bit_rotate_test.cpp Normal file
View File

@ -0,0 +1,177 @@
// Test for boost/core/bit.hpp (rotl, rotr)
//
// 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>
int const M = 256;
template<class T> void test_rotate( T x )
{
for( int i = 0; i < M; ++i )
{
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +boost::core::rotr( x, -i ) );
BOOST_TEST_EQ( +boost::core::rotl( x, -i ), +boost::core::rotr( x, i ) );
unsigned const width = std::numeric_limits<T>::digits;
unsigned r = i & ( width - 1 );
if( r == 0 )
{
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +x );
BOOST_TEST_EQ( +boost::core::rotr( x, i ), +x );
}
else
{
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +static_cast<T>( (x << r) | (x >> (width - r)) ) );
BOOST_TEST_EQ( +boost::core::rotr( x, i ), +static_cast<T>( (x >> r) | (x << (width - r)) ) );
}
}
}
int main()
{
{
boost::uint8_t x = 0x11;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x22 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x88 );
x = 0x22;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x44 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x11 );
x = 0x44;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x88 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x22 );
x = 0x88;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x11 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x44 );
}
{
boost::uint16_t x = 0x1111;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x2222 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x8888 );
x = 0x2222;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x4444 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x1111 );
x = 0x4444;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x8888 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x2222 );
x = 0x8888;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x1111 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x4444 );
}
{
boost::uint32_t x = 0x11111111;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x22222222 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x88888888 );
x = 0x22222222;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x44444444 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x11111111 );
x = 0x44444444;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x88888888 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x22222222 );
x = 0x88888888;
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x11111111 );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x44444444 );
}
#define CONST64(x) ((boost::uint64_t(x) << 32) + (x))
{
boost::uint64_t x = CONST64(0x11111111);
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x22222222) );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x88888888) );
x = CONST64(0x22222222);
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x44444444) );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x11111111) );
x = CONST64(0x44444444);
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x88888888) );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x22222222) );
x = CONST64(0x88888888);
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x11111111) );
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x44444444) );
}
for( int i = -M; i <= M; ++i )
{
{
unsigned char x = 0;
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +x );
BOOST_TEST_EQ( +boost::core::rotr( x, i ), +x );
}
{
unsigned short x = 0;
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
}
{
unsigned int x = 0;
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
}
{
unsigned long x = 0;
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
}
{
boost::ulong_long_type x = 0;
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
}
}
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_rotate( static_cast<unsigned char>( x ) );
test_rotate( static_cast<unsigned short>( x ) );
test_rotate( static_cast<unsigned int>( x ) );
test_rotate( static_cast<unsigned long>( x ) );
test_rotate( static_cast<boost::ulong_long_type>( x ) );
}
return boost::report_errors();
}

94
test/bit_width_test.cpp Normal file
View File

@ -0,0 +1,94 @@
// Test for boost/core/bit.hpp (bit_width)
//
// 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_width( T x )
{
BOOST_TEST_EQ( boost::core::bit_width( x ), std::numeric_limits<T>::digits - boost::core::countl_zero( x ) );
}
int main()
{
{
boost::uint8_t x = 0;
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
x = 1;
for( int i = 0; i < 8; ++i, x <<= 1 )
{
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint8_t>( x | ( x >> 1 ) ) ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint8_t>( x | ( x >> 2 ) ) ), i+1 );
}
}
{
boost::uint16_t x = 0;
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
x = 1;
for( int i = 0; i < 16; ++i, x <<= 1 )
{
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint16_t>( x | ( x >> 1 ) ) ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint16_t>( x | ( x >> 2 ) ) ), i+1 );
}
}
{
boost::uint32_t x = 0;
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
x = 1;
for( int i = 0; i < 32; ++i, x <<= 1 )
{
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint32_t>( x | ( x >> 1 ) ) ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint32_t>( x | ( x >> 2 ) ) ), i+1 );
}
}
{
boost::uint64_t x = 0;
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
x = 1;
for( int i = 0; i < 64; ++i, x <<= 1 )
{
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint64_t>( x | ( x >> 1 ) ) ), i+1 );
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint64_t>( x | ( x >> 2 ) ) ), i+1 );
}
}
boost::detail::splitmix64 rng;
for( int i = 0; i < 1000; ++i )
{
boost::uint64_t x = rng();
test_width( static_cast<unsigned char>( x ) );
test_width( static_cast<unsigned short>( x ) );
test_width( static_cast<unsigned int>( x ) );
test_width( static_cast<unsigned long>( x ) );
test_width( static_cast<boost::ulong_long_type>( x ) );
}
return boost::report_errors();
}

View File

@ -0,0 +1,17 @@
# 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(cmake_install_test LANGUAGES CXX)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -1,14 +1,16 @@
# Copyright 2018, 2019 Peter Dimov
# Copyright 2018, 2019, 2021 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)
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/core)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_subdirectory(../../../static_assert boostorg/static_assert)
add_subdirectory(../../../throw_exception boostorg/throw_exception)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::core)

296
test/cmath_test.cpp Normal file
View File

@ -0,0 +1,296 @@
// Test for boost/core/cmath.hpp
//
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/cmath.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <limits>
#include <cfloat>
template<class T> void test_positive_normal( T x )
{
BOOST_TEST( boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_normal );
BOOST_TEST( !boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
}
template<class T> void test_negative_normal( T x )
{
BOOST_TEST( boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_normal );
BOOST_TEST( boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
}
template<class T> void test_positive_zero( T x )
{
BOOST_TEST( boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_zero );
BOOST_TEST( !boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
}
template<class T> void test_negative_zero( T x )
{
BOOST_TEST( boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_zero );
#if defined(BOOST_CORE_USE_GENERIC_CMATH) && BOOST_WORKAROUND(BOOST_GCC, < 40700)
// g++ 4.4, 4.6 fail these tests with optimizations on
#else
BOOST_TEST( boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
#endif
}
template<class T> void test_positive_infinity( T x )
{
BOOST_TEST( !boost::core::isfinite( x ) );
BOOST_TEST( boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_infinite );
BOOST_TEST( !boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
}
template<class T> void test_negative_infinity( T x )
{
BOOST_TEST( !boost::core::isfinite( x ) );
BOOST_TEST( boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_infinite );
BOOST_TEST( boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
}
template<class T> void test_positive_nan( T x )
{
BOOST_TEST( !boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_nan );
BOOST_TEST( !boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
}
template<class T> void test_negative_nan( T x )
{
BOOST_TEST( !boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_nan );
BOOST_TEST( boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
}
template<class T> void test_positive_subnormal( T x )
{
BOOST_TEST( boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_subnormal );
BOOST_TEST( !boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
}
template<class T> void test_negative_subnormal( T x )
{
BOOST_TEST( boost::core::isfinite( x ) );
BOOST_TEST( !boost::core::isinf( x ) );
BOOST_TEST( !boost::core::isnan( x ) );
BOOST_TEST( !boost::core::isnormal( x ) );
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_subnormal );
BOOST_TEST( boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
}
template<class T> void test_positive_normal_( T x )
{
test_positive_normal( x );
test_positive_normal( boost::core::copysign( x, T(+1) ) );
test_negative_normal( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_negative_normal_( T x )
{
test_negative_normal( x );
test_positive_normal( boost::core::copysign( x, T(+1) ) );
test_negative_normal( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_positive_zero_( T x )
{
test_positive_zero( x );
test_positive_zero( boost::core::copysign( x, T(+1) ) );
test_negative_zero( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_negative_zero_( T x )
{
test_negative_zero( x );
test_positive_zero( boost::core::copysign( x, T(+1) ) );
test_negative_zero( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_positive_infinity_( T x )
{
test_positive_infinity( x );
test_positive_infinity( boost::core::copysign( x, T(+1) ) );
test_negative_infinity( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_negative_infinity_( T x )
{
test_negative_infinity( x );
test_positive_infinity( boost::core::copysign( x, T(+1) ) );
test_negative_infinity( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_positive_nan_( T x )
{
test_positive_nan( x );
test_positive_nan( boost::core::copysign( x, T(+1) ) );
test_negative_nan( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_negative_nan_( T x )
{
test_negative_nan( x );
test_positive_nan( boost::core::copysign( x, T(+1) ) );
test_negative_nan( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_positive_subnormal_( T x )
{
test_positive_subnormal( x );
test_positive_subnormal( boost::core::copysign( x, T(+1) ) );
test_negative_subnormal( boost::core::copysign( x, T(-1) ) );
}
template<class T> void test_negative_subnormal_( T x )
{
test_negative_subnormal( x );
test_positive_subnormal( boost::core::copysign( x, T(+1) ) );
test_negative_subnormal( boost::core::copysign( x, T(-1) ) );
}
int main()
{
// float
test_positive_normal_( +1.0f );
test_negative_normal_( -1.0f );
test_positive_normal_( FLT_MIN );
test_negative_normal_( -FLT_MIN );
test_positive_normal_( FLT_MAX );
test_negative_normal_( -FLT_MAX );
test_positive_zero_( +0.0f );
test_negative_zero_( -0.0f );
test_positive_infinity_( std::numeric_limits<float>::infinity() );
test_negative_infinity_( -std::numeric_limits<float>::infinity() );
test_positive_nan_( std::numeric_limits<float>::quiet_NaN() );
test_negative_nan_( boost::core::copysign( std::numeric_limits<float>::quiet_NaN(), -1.0f ) );
test_positive_subnormal_( FLT_MIN / 2 );
test_negative_subnormal_( -FLT_MIN / 2 );
// double
test_positive_normal_( +1.0 );
test_negative_normal_( -1.0 );
test_positive_normal_( DBL_MIN );
test_negative_normal_( -DBL_MIN );
test_positive_normal_( DBL_MAX );
test_negative_normal_( -DBL_MAX );
test_positive_zero_( +0.0 );
test_negative_zero_( -0.0 );
test_positive_infinity_( std::numeric_limits<double>::infinity() );
test_negative_infinity_( -std::numeric_limits<double>::infinity() );
test_positive_nan_( std::numeric_limits<double>::quiet_NaN() );
test_negative_nan_( boost::core::copysign( std::numeric_limits<double>::quiet_NaN(), -1.0 ) );
test_positive_subnormal_( DBL_MIN / 2 );
test_negative_subnormal_( -DBL_MIN / 2 );
// long double
test_positive_normal_( +1.0l );
test_negative_normal_( -1.0l );
test_positive_normal_( LDBL_MIN );
test_negative_normal_( -LDBL_MIN );
test_positive_normal_( LDBL_MAX );
test_negative_normal_( -LDBL_MAX );
test_positive_zero_( +0.0l );
test_negative_zero_( -0.0l );
test_positive_infinity_( std::numeric_limits<long double>::infinity() );
test_negative_infinity_( -std::numeric_limits<long double>::infinity() );
test_positive_nan_( std::numeric_limits<long double>::quiet_NaN() );
test_negative_nan_( boost::core::copysign( std::numeric_limits<long double>::quiet_NaN(), -1.0l ) );
test_positive_subnormal_( LDBL_MIN / 2 );
test_negative_subnormal_( -LDBL_MIN / 2 );
return boost::report_errors();
}

View File

@ -0,0 +1,19 @@
/*
Copyright 2021 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/default_allocator.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
boost::default_allocator<int> a;
int* p = boost::allocator_allocate(a, 1, 0);
BOOST_TEST(p != 0);
a.deallocate(p, 1);
return boost::report_errors();
}

View File

@ -173,20 +173,11 @@ void test_construct_other()
(void)a5;
}
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
template<class T>
std::size_t max_size()
{
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
}
#else
template<class T>
std::size_t max_size()
{
return ~static_cast<std::size_t>(0) / sizeof(T);
}
#endif
void test_max_size()
{

View File

@ -8,6 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#define BOOST_ALLOW_DEPRECATED_HEADERS
#include <boost/detail/iterator.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>

View File

@ -12,7 +12,8 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
using boost::enable_if;
using boost::disable_if;
@ -39,7 +40,7 @@ struct xstring
disable_if<is_arithmetic<It> >::type* = 0)
: data(end-begin) {}
int data;
std::ptrdiff_t data;
};
@ -58,4 +59,3 @@ int main()
return boost::report_errors();
}

View File

@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;
@ -24,11 +24,11 @@ template <int N> struct dummy {
template<class T>
typename enable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t, dummy<0> = 0) { return true; }
arithmetic_object(T /*t*/, dummy<0> = 0) { return true; }
template<class T>
typename disable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t, dummy<1> = 0) { return false; }
arithmetic_object(T /*t*/, dummy<1> = 0) { return false; }
int main()
@ -42,4 +42,3 @@ int main()
return boost::report_errors();
}

View File

@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if_c;
using boost::lazy_enable_if_c;

View File

@ -14,7 +14,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::lazy_enable_if;
using boost::lazy_disable_if;
@ -60,21 +60,21 @@ namespace A {
template<class T>
typename lazy_enable_if<is_int_or_double<T>, some_traits<T> >::type
foo(T t) { return true; }
foo(T /*t*/) { return true; }
template<class T>
typename lazy_enable_if_c<is_int_or_double<T>::value, some_traits<T> >::type
foo2(T t) { return true; }
foo2(T /*t*/) { return true; }
}
namespace B {
template<class T>
typename lazy_disable_if<is_int_or_double<T>, make_bool<T> >::type
foo(T t) { return false; }
foo(T /*t*/) { return false; }
template<class T>
typename lazy_disable_if_c<is_int_or_double<T>::value, make_bool<T> >::type
foo2(T t) { return false; }
foo2(T /*t*/) { return false; }
}
int main()
@ -95,4 +95,3 @@ int main()
return boost::report_errors();
}

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