Compare commits

...

151 Commits

Author SHA1 Message Date
882a792856 Add 2019 to Appveyor 2019-10-11 18:50:35 +03:00
130c8f2439 Disable Wsign-compare on gcc 4.4.7 2019-10-11 17:19:01 +03:00
e38997be4d Reorder conditions to support clang-cl 2019-10-11 16:43:48 +03:00
d112d23e9d Test that BOOST_TEST_EQ doesn't emit sign-compare warnings 2019-10-11 16:02:45 +03:00
e94af0d41a Also define make_nvp in boost::serialization 2019-10-01 08:14:07 -04:00
ac427ad64a Define nvp inside boost::serialization and bring it into boost 2019-10-01 07:28:25 -04:00
f2644886f5 Update section title in documentation 2019-10-01 07:28:06 -04:00
0591b1d855 Add BOOST_NVP convenience macro 2019-09-16 02:15:53 -04:00
7cc1047ab7 Update NVP implementation, tests, docs 2019-09-15 21:12:16 -04:00
f52dec58c2 Add a definition for nvp_bool 2019-09-10 08:04:40 -04:00
26497003f2 Remove save and load helpers and update documentation for NVP 2019-09-04 21:47:39 -04:00
5fb5a3e292 Update nvp tests and documentation 2019-09-04 12:28:00 -04:00
7b8385afc3 Implement NVP in Core for Serialization and other libraries 2019-09-04 09:58:04 -04:00
106a7c0939 Mark throw_exception BOOST_NORETURN 2019-08-27 07:28:28 -04:00
f2ee17fa24 Update .travis.yml 2019-07-25 12:27:19 +03:00
eba08e936a Only return an 8 bit result from report_errors 2019-06-26 19:53:58 +03:00
7e1d028958 Updated comment about QNX workaround in uncaught_exceptions.hpp. 2019-06-18 12:48:18 +03:00
420dff80b5 Added a workaround for QNX in uncaught_exceptions.hpp.
QNX provides cxxabi.h from LLVM libc++abi, which does not declare
__cxa_get_globals but provides its implementation in the library.
To make things more fun, QNX developers commented _LIBCPPABI_VERSION
definition, which breaks detection of libc++abi in uncaught_exceptions.hpp.

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

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

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

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

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

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

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

* adding tests

* missing header

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

* renamed predicates and removed close_to predicate

* removing now superfluous headers

* unpatching the fix to put in a separate PR

* move predicate to first argument

* call op and anti_op as normal methods
2018-08-08 15:37:51 +03:00
5c10ee4517 explicit_operator_bool: fix g++ 4.6 workaround 2018-08-08 00:27:59 +03:00
b7ad896707 explicit_operator_bool: under g++ 4.6 the operator can't be constexpr 2018-08-07 22:59:25 +03:00
70413b0568 Add more Travis configurations 2018-08-07 18:50:14 +03:00
b8a9b2c234 Add lightweight_test_test3 2018-08-07 17:58:23 +03:00
e11fa9ac03 In lightweight_test_eq_nullptr, test with nullptr as first argument as well 2018-08-07 17:43:38 +03:00
e1d50a1de2 Fix typo in lightweight_test.hpp 2018-08-07 17:40:47 +03:00
73 changed files with 4070 additions and 239 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2016, 2017 Peter Dimov
# 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)
@ -6,7 +6,7 @@ language: cpp
sudo: false
python: "2.7"
dist: trusty
branches:
only:
@ -28,6 +28,26 @@ matrix:
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
@ -79,7 +99,6 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
@ -89,6 +108,36 @@ matrix:
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
@ -103,7 +152,6 @@ matrix:
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
@ -112,20 +160,9 @@ matrix:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.8
@ -137,7 +174,6 @@ matrix:
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.9
@ -149,7 +185,6 @@ matrix:
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-4.0
@ -173,22 +208,114 @@ matrix:
- 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
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 && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- 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 update
- git submodule init tools/boost_install
- git submodule update --jobs 4
- cp -r $TRAVIS_BUILD_DIR/* libs/core
- ./bootstrap.sh
- ./b2 headers
@ -196,7 +323,8 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j 3 libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD
- 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:

21
CMakeLists.txt Normal file
View File

@ -0,0 +1,21 @@
# Copyright 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
cmake_minimum_required(VERSION 3.5)
project(BoostCore LANGUAGES CXX)
add_library(boost_core INTERFACE)
add_library(Boost::core ALIAS boost_core)
target_include_directories(boost_core INTERFACE include)
target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
)

View File

@ -1,7 +1,7 @@
Boost.Core
==========
Boost.Core, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
Boost.Core, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
The criteria for inclusion is that the utility component be:
* simple,
@ -23,10 +23,10 @@ Master | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=maste
### More information
* [Documentation](http://boost.org/libs/core)
* [Documentation](https://boost.org/libs/core)
* [Report bugs](https://svn.boost.org/trac/boost/newticket?component=core;version=Boost%20Release%20Branch). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
### License
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).

View File

@ -1,4 +1,4 @@
# Copyright 2016, 2017 Peter Dimov
# 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)
@ -14,45 +14,65 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
TOOLSET: msvc-14.1,clang-win
ADDRMD: 32,64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/headers
- git submodule init libs/assert
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule update
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core
- git submodule init tools/boost_install
- git submodule update --jobs 4
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core\
- cmd /c bootstrap
- b2 headers
@ -61,4 +81,5 @@ build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j 3 libs/core/test toolset=%TOOLSET% %CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release

3
doc/.gitignore vendored Normal file
View File

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

View File

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

149
doc/alloc_construct.qbk Normal file
View File

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

View File

@ -1,10 +1,10 @@
[/
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
]
[library Boost.Core
@ -39,19 +39,28 @@ criteria for inclusion is that the utility component be:
[endsect]
[include addressof.qbk]
[include alloc_construct.qbk]
[include checked_delete.qbk]
[include default_allocator.qbk]
[include demangle.qbk]
[include empty_value.qbk]
[include enable_if.qbk]
[include exchange.qbk]
[include explicit_operator_bool.qbk]
[include first_scalar.qbk]
[include ignore_unused.qbk]
[include is_same.qbk]
[include lightweight_test.qbk]
[include no_exceptions_support.qbk]
[include noinit_adaptor.qbk]
[include noncopyable.qbk]
[include null_deleter.qbk]
[include nvp.qbk]
[include pointer_traits.qbk]
[include quick_exit.qbk]
[include ref.qbk]
[include scoped_enum.qbk]
[include swap.qbk]
[include typeinfo.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]

140
doc/default_allocator.qbk Normal file
View File

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

138
doc/empty_value.qbk Normal file
View File

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

View File

@ -18,7 +18,8 @@ Distributed under the Boost Software License, Version 1.0.
The header <boost/core/exchange.hpp> provides the function template
`boost::exchange` which is an implementation of the `std::exchange`
function introduced in C++14.
function introduced in C++14. `boost::exchange(o, v)` replaces the
value of `o` with `v` and returns the old value of `o`.
[endsect]

91
doc/first_scalar.qbk Normal file
View File

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

View File

@ -1,7 +1,7 @@
[/
Copyright 2010, 2011 Beman Dawes
Copyright 2013 Ion Gaztanaga
Copyright 2014, 2017 Peter Dimov
Copyright 2014-2019 Peter Dimov
Copyright 2017 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0.
@ -253,6 +253,7 @@ return a boolean value.
``
#define BOOST_TEST_TRAIT_TRUE((Trait)) /*unspecified*/
#define BOOST_TEST_TRAIT_FALSE((Trait)) /*unspecified*/
#define BOOST_TEST_TRAIT_SAME(Type1, Type2) /*unspecified*/
``
[endsect]
@ -280,6 +281,20 @@ message containing `Trait`. Note the double set of parentheses.
[endsect]
[section BOOST_TEST_TRAIT_SAME]
``
BOOST_TEST_TRAIT_SAME(Type1, Type2)
``
If the two types are not the same, increases the error count and outputs a
message containing them. This macro requires that the compiler supports
variadic macros and `__VA_ARGS__`. (Note that unlike `BOOST_TEST_TRAIT_TRUE`
and `BOOST_TEST_TRAIT_FALSE`, this macro only requires a single set of
parentheses.)
[endsect]
[section Example]
``
@ -297,6 +312,8 @@ int main()
{
BOOST_TEST_TRAIT_TRUE(( is_same<X<int, long>::type, int> ));
BOOST_TEST_TRAIT_SAME( X<int, long>::type, int );
return boost::report_errors();
}
``

172
doc/noinit_adaptor.qbk Normal file
View File

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

108
doc/nvp.qbk Normal file
View File

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

View File

@ -109,7 +109,7 @@ namespace boost {
[[Remark]
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
it is `element_type&`.]]
[[Returns] [`addressof(v)`.]]]]]]
[[Returns][`addressof(v)`.]]]]]]
[endsect]
@ -131,9 +131,11 @@ namespace boost {
[variablelist
[[`template<class T> constexpr T* to_address(T* v) noexcept;`]
[[variablelist [[Returns] [`v`.]]]]]
[[variablelist
[[Returns][`v`.]]]]]
[[`template<class T> auto to_address(const T& v) noexcept;`]
[[variablelist [[Returns] [`pointer_traits<T>::to_address(v)` if that
[[variablelist
[[Returns][`pointer_traits<T>::to_address(v)` if that
expression is well-formed, otherwise `to_address(v.operator->())`.]]]]]]
[endsect]

40
doc/quick_exit.qbk Normal file
View File

@ -0,0 +1,40 @@
[/
Copyright 2018 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt
]
[section:quick_exit quick_exit]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/quick_exit.hpp>]
The header `<boost/core/quick_exit.hpp>` defines the function
`void boost::quick_exit(int code)`. It calls the standard C++11 function
[@https://en.cppreference.com/w/cpp/utility/program/quick_exit
`std::quick_exit(code)`], if that is available, and otherwise exits the
process via [@https://en.cppreference.com/w/cpp/utility/program/_Exit
`std::_Exit(code)`] or equivalent.
[section Synopsis]
``
namespace boost
{
[[noreturn]] void quick_exit(int code) noexcept;
}
``
[endsect]
[endsect]
[endsect]

View File

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

View File

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

47
doc/use_default.qbk Normal file
View File

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

View File

@ -0,0 +1,245 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP
#define BOOST_CORE_ALLOC_CONSTRUCT_HPP
#include <boost/core/noinit_adaptor.hpp>
namespace boost {
#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);
}
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();
}
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);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class A, class T, class U, class... V>
inline void
alloc_construct(A& a, T* p, U&& u, V&&... v)
{
std::allocator_traits<A>::construct(a, p, std::forward<U>(u),
std::forward<V>(v)...);
}
#else
template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, U&& u)
{
std::allocator_traits<A>::construct(a, p, std::forward<U>(u));
}
#endif
#else
template<class A, class T, class U>
inline void
alloc_construct(A& a, T* p, const U& u)
{
std::allocator_traits<A>::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);
}
#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) {
std::allocator_traits<A>::construct(a, p + i);
}
hold.size() = 0;
}
template<class A, class T>
inline void
alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
{
detail::alloc_destroyer<A, T> hold(a, p);
for (std::size_t& i = hold.size(); i < n; ++i) {
std::allocator_traits<A>::construct(a, p + i, l[i % m]);
}
hold.size() = 0;
}
template<class A, class T, class I>
inline void
alloc_construct_n(A& a, T* p, std::size_t n, I b)
{
detail::alloc_destroyer<A, T> hold(a, p);
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
std::allocator_traits<A>::construct(a, p + i, *b);
}
hold.size() = 0;
}
#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 */
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,16 +14,19 @@
// Copyright (2) Beman Dawes 2010, 2011
// Copyright (3) Ion Gaztanaga 2013
//
// Copyright 2018 Glen Joseph Fernandes
// (glenjofe@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/no_exceptions_support.hpp>
#include <boost/assert.hpp>
#include <boost/current_function.hpp>
#include <boost/config.hpp>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <cstddef>
@ -39,29 +42,45 @@ namespace boost
namespace detail
{
struct report_errors_reminder
{
bool called_report_errors_function;
report_errors_reminder() : called_report_errors_function(false) {}
~report_errors_reminder()
{
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
class test_result {
public:
test_result()
: report_(false)
, errors_(0) {
#if defined(_MSC_VER) && (_MSC_VER > 1310)
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
}
~test_result() {
if (!report_) {
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "main() should return report_errors()" << std::endl;
std::abort();
}
}
int& errors() {
return errors_;
}
void done() {
report_ = true;
}
private:
bool report_;
int errors_;
};
inline report_errors_reminder& report_errors_remind()
inline test_result& test_results()
{
static report_errors_reminder r;
return r;
static test_result instance;
return instance;
}
inline int & test_errors()
inline int& test_errors()
{
static int x = 0;
report_errors_remind();
return x;
return test_results().errors();
}
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
@ -69,7 +88,7 @@ inline void test_failed_impl(char const * expr, char const * file, int line, cha
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_errors();
++test_results().errors();
}
inline void error_impl(char const * msg, char const * file, int line, char const * function)
@ -77,7 +96,7 @@ inline void error_impl(char const * msg, char const * file, int line, char const
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): " << msg << " in function '"
<< function << "'" << std::endl;
++test_errors();
++test_results().errors();
}
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
@ -85,20 +104,20 @@ inline void throw_failed_impl(char const * excep, char const * file, int line, c
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
<< function << "'" << std::endl;
++test_errors();
++test_results().errors();
}
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
// the dependency we just disable the warnings.
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__clang__) && defined(__has_warning)
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-compare"
# endif
#elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
@ -118,105 +137,58 @@ 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
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t == u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' != '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
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 "=="; }
};
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t != u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " != " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' == '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
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 "!="; }
};
template<class T, class U> inline void test_lt_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t < u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " < " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' >= '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
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 "<"; }
};
template<class T, class U> inline void test_le_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t <= u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " <= " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' > '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
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 "<="; }
};
template<class T, class U> inline void test_gt_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t > u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " > " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' <= '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
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 ">"; }
};
template<class T, class U> inline void test_ge_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
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 ">="; }
};
template<class BinaryPredicate, class T, class U>
inline void 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( t >= u )
if( pred(t, u) )
{
report_errors_remind();
test_results();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " >= " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' < '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
<< file << "(" << line << "): test '" << expr1 << " " << pred.op() << " " << expr2
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
<< "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
}
}
@ -225,15 +197,14 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
{
if( std::strcmp(t, u) == 0 )
{
report_errors_remind();
test_results();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
<< "' failed in function '" << function << "': "
<< "'" << t << "' != '" << u << "'" << std::endl;
++test_errors();
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
}
}
@ -242,15 +213,14 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
{
if( std::strcmp(t, u) != 0 )
{
report_errors_remind();
test_results();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
<< "' failed in function '" << function << "': "
<< "'" << t << "' == '" << u << "'" << std::endl;
++test_errors();
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
}
}
@ -313,12 +283,12 @@ void test_all_eq_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
boost::detail::report_errors_remind();
test_results();
}
else
{
output << std::endl;
++boost::detail::test_errors();
++test_results().errors();
}
}
@ -382,21 +352,21 @@ void test_all_with_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
report_errors_remind();
test_results();
}
else
{
output << std::endl;
++test_errors();
++test_results().errors();
}
}
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__) && defined(__has_warning)
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic pop
# endif
#elif defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic pop
#endif
@ -405,38 +375,40 @@ void test_all_with_impl(FormattedOutputFunction& output,
inline int report_errors()
{
boost::detail::report_errors_remind().called_report_errors_function = true;
boost::detail::test_result& result = boost::detail::test_results();
result.done();
int errors = boost::detail::test_errors();
int errors = result.errors();
if( errors == 0 )
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< "No errors detected." << std::endl;
return 0;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
return 1;
}
// `return report_errors();` from main only supports 8 bit exit codes
return errors < 256? errors: 255;
}
} // namespace boost
#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_lt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_le_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_gt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_ge_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_lt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_le(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_gt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ge(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
@ -452,6 +424,7 @@ inline int report_errors()
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
catch(EXCEP const&) { \
::boost::detail::test_results(); \
} \
catch(...) { \
::boost::detail::throw_failed_impl \

View File

@ -9,16 +9,21 @@
// boost/core/lightweight_test_trait.hpp
//
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
//
// Copyright 2014 Peter Dimov
//
// Copyright 2019 Glen Joseph Fernandes
// (glenjofe@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/lightweight_test.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/is_same.hpp>
#include <boost/config.hpp>
namespace boost
{
@ -26,12 +31,56 @@ namespace boost
namespace detail
{
template<class, int = 0> struct test_print { };
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>)
{
return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T));
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>)
{
return o << test_print<T, 2>();
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>)
{
return o << test_print<T, 2>() << " const";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>)
{
return o << test_print<T, 2>() << " volatile";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>)
{
return o << test_print<T, 2>() << " const volatile";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>)
{
return o << test_print<T, 1>();
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>)
{
return o << test_print<T, 1>() << " &";
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>)
{
return o << test_print<T, 1>() << " &&";
}
#endif
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ),
bool expected, char const * file, int line, char const * function )
{
if( T::value == expected )
{
report_errors_remind();
test_results();
}
else
{
@ -42,7 +91,32 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
<< "' (should have been " << ( expected? "true": "false" ) << ")"
<< std::endl;
++test_errors();
++test_results().errors();
}
}
template<class T> inline bool test_trait_same_impl_( T )
{
return T::value;
}
template<class T1, class T2> inline void test_trait_same_impl( char const * types,
boost::core::is_same<T1, T2> same, char const * file, int line, char const * function )
{
if( test_trait_same_impl_( same ) )
{
test_results();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test 'is_same<" << types << ">'"
<< " failed in function '" << function
<< "' ('" << test_print<T1>()
<< "' != '" << test_print<T2>() << "')"
<< std::endl;
++test_results().errors();
}
}
@ -52,5 +126,6 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#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

@ -32,9 +32,21 @@
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# define BOOST_TRY { if ("")
# define BOOST_CATCH(x) else if (!"")
# else
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
# define BOOST_TRY { if (true)
# define BOOST_CATCH(x) else if (false)
# else
// warning C4127: conditional expression is constant
# define BOOST_TRY { \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (true) \
__pragma(warning(pop))
# define BOOST_CATCH(x) else \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (false) \
__pragma(warning(pop))
# endif
# define BOOST_RETHROW
# define BOOST_CATCH_END }

View File

@ -0,0 +1,112 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <memory>
#endif
#include <new>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
namespace boost {
template<class A>
struct noinit_adaptor
: A {
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
};
noinit_adaptor()
: A() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class U>
noinit_adaptor(U&& u) BOOST_NOEXCEPT
: A(std::forward<U>(u)) { }
#else
template<class U>
noinit_adaptor(const U& u) BOOST_NOEXCEPT
: A(u) { }
#endif
template<class U>
noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
: A(static_cast<const U&>(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
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();
}
};
template<class T, class U>
inline bool
operator==(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
{
return static_cast<const T&>(lhs) == static_cast<const U&>(rhs);
}
template<class T, class U>
inline bool
operator!=(const noinit_adaptor<T>& lhs,
const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
{
return !(lhs == rhs);
}
template<class A>
inline noinit_adaptor<A>
noinit_adapt(const A& a) BOOST_NOEXCEPT
{
return noinit_adaptor<A>(a);
}
} /* boost */
#endif

View File

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

View File

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

View File

@ -0,0 +1,59 @@
#ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
#define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/core/quick_exit.hpp
//
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <cstdlib>
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
extern "C" _CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN;
#endif
#if defined(__CYGWIN__) && __cplusplus < 201103L
extern "C" _Noreturn void quick_exit(int);
#endif
namespace boost
{
BOOST_NORETURN void quick_exit( int code ) BOOST_NOEXCEPT
{
#if defined(_MSC_VER) && _MSC_VER < 1900
::_exit( code );
#elif defined(__MINGW32__)
::_exit( code );
#elif defined(__APPLE__)
::_Exit( code );
#else
::quick_exit( code );
#endif
}
} // namespace boost
#endif // #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED

View File

@ -19,7 +19,8 @@
// Copyright (C) 2002 David Abrahams
//
// Copyright (C) 2014 Glen Joseph Fernandes
// glenfe at live dot com
// (glenjofe@gmail.com)
//
// Copyright (C) 2014 Agustin Berge
//
// Distributed under the Boost Software License, Version 1.0. (See

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
],
"maintainers": [
"Peter Dimov <pdimov -at- pdimov.com>",
"Glen Fernandes <glenfe -at- live.com>",
"Glen Fernandes <glenjofe -at- gmail.com>",
"Andrey Semashev <andrey.semashev -at- gmail.com>"
],
"description": "A collection of simple core utilities with minimal dependencies.",

View File

@ -68,15 +68,22 @@ 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_eq_test.cpp ;
run lightweight_test_all_with_test.cpp ;
run lightweight_test_all_with_fail.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
<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 ;
run-fail lightweight_test_all_eq_test.cpp ;
run-fail lightweight_test_all_with_fail.cpp ;
run-fail lightweight_test_fail.cpp ;
run-fail lightweight_test_fail2.cpp ;
@ -90,6 +97,8 @@ run-fail lightweight_test_fail8.cpp ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp ;
run-fail lightweight_test_fail12.cpp ;
run-fail lightweight_test_lt_fail.cpp ;
run-fail lightweight_test_le_fail.cpp ;
run-fail lightweight_test_gt_fail.cpp ;
@ -124,5 +133,39 @@ run to_address_test.cpp ;
run exchange_test.cpp ;
run exchange_move_test.cpp ;
run first_scalar_test.cpp ;
compile first_scalar_constexpr_test.cpp ;
run empty_value_test.cpp ;
run empty_value_size_test.cpp ;
run empty_value_final_test.cpp ;
run quick_exit_test.cpp ;
run-fail quick_exit_fail.cpp ;
compile use_default_test.cpp ;
run default_allocator_test.cpp ;
run noinit_adaptor_test.cpp ;
run alloc_construct_test.cpp ;
run alloc_construct_throws_test.cpp ;
run alloc_construct_cxx11_test.cpp ;
run nvp_test.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run 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 ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View File

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

View File

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

View File

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

View File

@ -0,0 +1,19 @@
# 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)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/core)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
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

@ -0,0 +1,277 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/default_allocator.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <vector>
#include <list>
class type {
public:
explicit type(double value)
: value_(value) { }
private:
type(const type&);
type& operator=(const type&);
double value_;
};
void test_value_type()
{
BOOST_TEST_TRAIT_SAME(int,
boost::default_allocator<int>::value_type);
BOOST_TEST_TRAIT_SAME(type,
boost::default_allocator<type>::value_type);
BOOST_TEST_TRAIT_SAME(int[5],
boost::default_allocator<int[5]>::value_type);
BOOST_TEST_TRAIT_SAME(void,
boost::default_allocator<void>::value_type);
}
void test_pointer()
{
BOOST_TEST_TRAIT_SAME(int*,
boost::default_allocator<int>::pointer);
BOOST_TEST_TRAIT_SAME(type*,
boost::default_allocator<type>::pointer);
BOOST_TEST_TRAIT_SAME(int(*)[5],
boost::default_allocator<int[5]>::pointer);
BOOST_TEST_TRAIT_SAME(void*,
boost::default_allocator<void>::pointer);
}
void test_const_pointer()
{
BOOST_TEST_TRAIT_SAME(const int*,
boost::default_allocator<int>::const_pointer);
BOOST_TEST_TRAIT_SAME(const type*,
boost::default_allocator<type>::const_pointer);
BOOST_TEST_TRAIT_SAME(const int(*)[5],
boost::default_allocator<int[5]>::const_pointer);
BOOST_TEST_TRAIT_SAME(const void*,
boost::default_allocator<void>::const_pointer);
}
void test_reference()
{
BOOST_TEST_TRAIT_SAME(int&,
boost::default_allocator<int>::reference);
BOOST_TEST_TRAIT_SAME(type&,
boost::default_allocator<type>::reference);
BOOST_TEST_TRAIT_SAME(int(&)[5],
boost::default_allocator<int[5]>::reference);
BOOST_TEST_TRAIT_SAME(void,
boost::default_allocator<void>::reference);
}
void test_const_reference()
{
BOOST_TEST_TRAIT_SAME(const int&,
boost::default_allocator<int>::const_reference);
BOOST_TEST_TRAIT_SAME(const type&,
boost::default_allocator<type>::const_reference);
BOOST_TEST_TRAIT_SAME(const int(&)[5],
boost::default_allocator<int[5]>::const_reference);
BOOST_TEST_TRAIT_SAME(const void,
boost::default_allocator<void>::const_reference);
}
void test_size_type()
{
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::default_allocator<int>::size_type);
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::default_allocator<type>::size_type);
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::default_allocator<int[5]>::size_type);
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::default_allocator<void>::size_type);
}
void test_difference_type()
{
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::default_allocator<int>::difference_type);
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::default_allocator<type>::difference_type);
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::default_allocator<int[5]>::difference_type);
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::default_allocator<void>::difference_type);
}
void test_propagate_on_container_move_assignment()
{
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int>::
propagate_on_container_move_assignment));
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<type>::
propagate_on_container_move_assignment));
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int[5]>::
propagate_on_container_move_assignment));
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<void>::
propagate_on_container_move_assignment));
}
void test_is_always_equal()
{
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int>::is_always_equal));
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<type>::is_always_equal));
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int[5]>::is_always_equal));
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<void>::is_always_equal));
}
void test_rebind()
{
BOOST_TEST_TRAIT_SAME(boost::default_allocator<type>,
boost::default_allocator<int>::rebind<type>::other);
BOOST_TEST_TRAIT_SAME(boost::default_allocator<int[5]>,
boost::default_allocator<type>::rebind<int[5]>::other);
BOOST_TEST_TRAIT_SAME(boost::default_allocator<void>,
boost::default_allocator<int[5]>::rebind<void>::other);
BOOST_TEST_TRAIT_SAME(boost::default_allocator<int>,
boost::default_allocator<void>::rebind<int>::other);
}
void test_default_construct()
{
boost::default_allocator<int> a1;
(void)a1;
boost::default_allocator<type> a2;
(void)a2;
boost::default_allocator<int[5]> a3;
(void)a3;
boost::default_allocator<void> a4;
(void)a4;
}
void test_copy()
{
boost::default_allocator<int> a1;
boost::default_allocator<int> a2(a1);
(void)a2;
boost::default_allocator<int[5]> a3;
boost::default_allocator<int[5]> a4(a3);
(void)a4;
boost::default_allocator<void> a5;
boost::default_allocator<void> a6(a5);
(void)a6;
}
void test_construct_other()
{
boost::default_allocator<int> a1;
boost::default_allocator<type> a2(a1);
boost::default_allocator<int[5]> a3(a2);
boost::default_allocator<void> a4(a3);
boost::default_allocator<int> a5(a4);
(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);
}
#else
template<class T>
std::size_t max_size()
{
return ~static_cast<std::size_t>(0) / sizeof(T);
}
#endif
void test_max_size()
{
BOOST_TEST_EQ(max_size<int>(),
boost::default_allocator<int>().max_size());
BOOST_TEST_EQ(max_size<type>(),
boost::default_allocator<type>().max_size());
BOOST_TEST_EQ(max_size<int[5]>(),
boost::default_allocator<int[5]>().max_size());
}
template<class T>
void test_allocate()
{
boost::default_allocator<T> a;
T* p = a.allocate(1);
BOOST_TEST(p != 0);
a.deallocate(p, 1);
p = a.allocate(0);
a.deallocate(p, 0);
BOOST_TEST_THROWS(a.allocate(a.max_size() + 1), std::bad_alloc);
}
void test_allocate_deallocate()
{
test_allocate<int>();
test_allocate<type>();
test_allocate<int[5]>();
}
void test_equals()
{
BOOST_TEST(boost::default_allocator<int>() ==
boost::default_allocator<type>());
BOOST_TEST(boost::default_allocator<type>() ==
boost::default_allocator<int[5]>());
BOOST_TEST(boost::default_allocator<int[5]>() ==
boost::default_allocator<void>());
BOOST_TEST(boost::default_allocator<void>() ==
boost::default_allocator<int>());
}
void test_not_equals()
{
BOOST_TEST(!(boost::default_allocator<int>() !=
boost::default_allocator<type>()));
BOOST_TEST(!(boost::default_allocator<type>() !=
boost::default_allocator<int[5]>()));
BOOST_TEST(!(boost::default_allocator<int[5]>() !=
boost::default_allocator<void>()));
BOOST_TEST(!(boost::default_allocator<void>() !=
boost::default_allocator<int>()));
}
void test_container()
{
std::vector<int, boost::default_allocator<int> > v;
v.push_back(1);
BOOST_TEST(v.size() == 1);
BOOST_TEST(v.front() == 1);
std::list<int, boost::default_allocator<int> > l;
l.push_back(1);
BOOST_TEST(l.size() == 1);
BOOST_TEST(l.front() == 1);
}
int main()
{
test_value_type();
test_pointer();
test_const_pointer();
test_reference();
test_const_reference();
test_size_type();
test_difference_type();
test_propagate_on_container_move_assignment();
test_is_always_equal();
test_rebind();
test_default_construct();
test_copy();
test_construct_other();
test_max_size();
test_allocate_deallocate();
test_equals();
test_not_equals();
test_container();
return boost::report_errors();
}

View File

@ -0,0 +1,62 @@
/*
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/empty_value.hpp>
#include <boost/core/lightweight_test.hpp>
#if !defined(BOOST_NO_CXX11_FINAL)
class type final {
public:
explicit type(int count)
: value_(count) { }
int value() const {
return value_ + 1;
}
int value() {
return value_ + 2;
}
private:
int value_;
};
struct empty final {
int value() const {
return 1;
}
int value() {
return 2;
}
};
void test_type()
{
const boost::empty_value<type> v1(boost::empty_init_t(), 3);
BOOST_TEST(v1.get().value() == 4);
boost::empty_value<type> v2(boost::empty_init_t(), 3);
BOOST_TEST(v2.get().value() == 5);
}
void test_empty()
{
const boost::empty_value<empty> v1 = boost::empty_init_t();
BOOST_TEST(v1.get().value() == 1);
boost::empty_value<empty> v2;
BOOST_TEST(v2.get().value() == 2);
}
int main()
{
test_type();
test_empty();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@ -0,0 +1,60 @@
/*
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
#include <boost/core/empty_value.hpp>
#include <boost/core/lightweight_test.hpp>
struct T1 { };
struct S1
: boost::empty_value<T1, 0, true> { };
struct T2 {
int value;
};
struct S2
: boost::empty_value<T1, 0, true>
, boost::empty_value<T2, 1, true> { };
struct S3
: boost::empty_value<T1, 0, false>
, boost::empty_value<T2, 1, true> { };
struct T3 { };
struct S4
: boost::empty_value<T1, 0, true>
, boost::empty_value<T3, 1, true> { };
struct S5
: boost::empty_value<T1, 0, false>
, boost::empty_value<T3, 1, false> { };
struct S6
: boost::empty_value<T1, 0, true>
, boost::empty_value<T2, 1, true>
, boost::empty_value<T3, 2, true> { };
int main()
{
BOOST_TEST(sizeof(S1) == sizeof(T1));
BOOST_TEST(sizeof(S2) == sizeof(T2));
BOOST_TEST(sizeof(S3) > sizeof(T2));
BOOST_TEST(sizeof(S4) == sizeof(T1));
BOOST_TEST(sizeof(S5) > sizeof(T1));
BOOST_TEST(sizeof(S6) == sizeof(T2));
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

72
test/empty_value_test.cpp Normal file
View File

@ -0,0 +1,72 @@
/*
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/empty_value.hpp>
#include <boost/core/lightweight_test.hpp>
struct empty {
int value() const {
return 1;
}
int value() {
return 2;
}
};
class type {
public:
explicit type(int count)
: value_(count) { }
int value() const {
return value_ + 1;
}
int value() {
return value_ + 2;
}
private:
int value_;
};
void test_int()
{
const boost::empty_value<int> v1(boost::empty_init_t(), 7);
BOOST_TEST(v1.get() == 7);
boost::empty_value<int> v2 = boost::empty_init_t();
BOOST_TEST(v2.get() == 0);
v2 = v1;
BOOST_TEST(v2.get() == 7);
v2.get() = 8;
BOOST_TEST(v2.get() == 8);
}
void test_empty()
{
const boost::empty_value<empty> v1 = boost::empty_init_t();
BOOST_TEST(v1.get().value() == 1);
boost::empty_value<empty> v2;
BOOST_TEST(v2.get().value() == 2);
}
void test_type()
{
const boost::empty_value<type> v1(boost::empty_init_t(), 2);
BOOST_TEST(v1.get().value() == 3);
boost::empty_value<type> v2(boost::empty_init_t(), 3);
BOOST_TEST(v2.get().value() == 5);
v2 = v1;
BOOST_TEST(v2.get().value() == 4);
v2.get() = type(4);
BOOST_TEST(v2.get().value() == 6);
}
int main()
{
test_int();
test_empty();
test_type();
return boost::report_errors();
}

View File

@ -0,0 +1,19 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
#include <boost/core/first_scalar.hpp>
#include <boost/static_assert.hpp>
static int i1 = 0;
BOOST_STATIC_ASSERT(boost::first_scalar(&i1) == &i1);
static int i2[4] = { };
BOOST_STATIC_ASSERT(boost::first_scalar(i2) == &i2[0]);
static int i3[2][4][6] = { };
BOOST_STATIC_ASSERT(boost::first_scalar(i3) == &i3[0][0][0]);
#endif

View File

@ -0,0 +1,20 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/first_scalar.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
int i1 = 0;
BOOST_TEST_EQ(boost::first_scalar(&i1), &i1);
int i2[4] = { };
BOOST_TEST_EQ(boost::first_scalar(i2), &i2[0]);
int i3[2][4][6] = { };
BOOST_TEST_EQ(boost::first_scalar(i3), &i3[0][0][0]);
return boost::report_errors();
}

17
test/lib_typeid.cpp Normal file
View File

@ -0,0 +1,17 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/typeinfo.hpp>
#include <boost/config.hpp>
#if defined(LIB_TYPEID_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
EXPORT boost::core::typeinfo const & get_typeid_int()
{
return BOOST_CORE_TYPEID( int );
}

View File

@ -120,7 +120,5 @@ int main()
++test_cases;
}
boost::report_errors();
return boost::detail::test_errors() != test_cases;
return boost::report_errors() == test_cases;
}

View File

@ -101,7 +101,5 @@ int main()
test_cases += fail_vector();
test_cases += fail_tolerance_predicate();
boost::report_errors();
return boost::detail::test_errors() != test_cases;
return boost::report_errors() == test_cases;
}

View File

@ -22,6 +22,9 @@ int main()
BOOST_TEST_EQ( p1, nullptr );
BOOST_TEST_NE( p2, nullptr );
BOOST_TEST_EQ( nullptr, p1 );
BOOST_TEST_NE( nullptr, p2 );
#endif
return boost::report_errors();

View File

@ -0,0 +1,14 @@
/*
Copyright 2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/lightweight_test.hpp>
int main()
{
BOOST_TEST(true);
return 0;
}

View File

@ -0,0 +1,68 @@
//
// Negative test for BOOST_TEST_TRAIT_SAME
//
// Copyright 2014, 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/config.hpp>
struct X
{
typedef int type;
};
template<class T1, class T2> struct Y
{
typedef T1 type;
};
typedef int I1;
typedef const int I2;
typedef volatile int I3;
typedef const volatile int I4;
typedef int& I5;
typedef const int& I6;
typedef volatile int& I7;
typedef const volatile int& I8;
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
typedef int&& I9;
typedef const int&& I10;
typedef volatile int&& I11;
typedef const volatile int&& I12;
#endif
int main()
{
BOOST_TEST_TRAIT_SAME(char[1], char[2]);
BOOST_TEST_TRAIT_SAME(char[1], char[]);
BOOST_TEST_TRAIT_SAME(char[1], char*);
BOOST_TEST_TRAIT_SAME(void(), void(int));
BOOST_TEST_TRAIT_SAME(void(), void(*)());
BOOST_TEST_TRAIT_SAME(X, void);
BOOST_TEST_TRAIT_SAME(X::type, void);
BOOST_TEST_TRAIT_SAME(X, Y<void, void>);
BOOST_TEST_TRAIT_SAME(X::type, Y<float, int>::type);
BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, double>);
BOOST_TEST_TRAIT_SAME(I1, I2);
BOOST_TEST_TRAIT_SAME(I3, I4);
BOOST_TEST_TRAIT_SAME(I5, I6);
BOOST_TEST_TRAIT_SAME(I7, I8);
int expected = 14;
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_TEST_TRAIT_SAME(I9, I10);
BOOST_TEST_TRAIT_SAME(I11, I12);
expected += 2;
#endif
return boost::report_errors() == expected;
}

View File

@ -0,0 +1,147 @@
//
// Test for lightweight_test.hpp
//
// Copyright (c) 2014, 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test.hpp>
#include <boost/core/noncopyable.hpp>
#include <ostream>
// EQ
struct eq1: private boost::noncopyable {};
struct eq2: private boost::noncopyable {};
std::ostream& operator<<( std::ostream& os, eq1 const& )
{
return os << "eq1()";
}
std::ostream& operator<<( std::ostream& os, eq2 const& )
{
return os << "eq2()";
}
bool operator==( eq1 const&, eq2 const& )
{
return true;
}
// NE
struct ne1: private boost::noncopyable {};
struct ne2: private boost::noncopyable {};
std::ostream& operator<<( std::ostream& os, ne1 const& )
{
return os << "ne1()";
}
std::ostream& operator<<( std::ostream& os, ne2 const& )
{
return os << "ne2()";
}
bool operator!=( ne1 const&, ne2 const& )
{
return true;
}
// LT
struct lt1: private boost::noncopyable {};
struct lt2: private boost::noncopyable {};
std::ostream& operator<<( std::ostream& os, lt1 const& )
{
return os << "lt1()";
}
std::ostream& operator<<( std::ostream& os, lt2 const& )
{
return os << "lt2()";
}
bool operator<( lt1 const&, lt2 const& )
{
return true;
}
// LE
struct le1: private boost::noncopyable {};
struct le2: private boost::noncopyable {};
std::ostream& operator<<( std::ostream& os, le1 const& )
{
return os << "le1()";
}
std::ostream& operator<<( std::ostream& os, le2 const& )
{
return os << "le2()";
}
bool operator<=( le1 const&, le2 const& )
{
return true;
}
// GT
struct gt1: private boost::noncopyable {};
struct gt2: private boost::noncopyable {};
std::ostream& operator<<( std::ostream& os, gt1 const& )
{
return os << "gt1()";
}
std::ostream& operator<<( std::ostream& os, gt2 const& )
{
return os << "gt2()";
}
bool operator>( gt1 const&, gt2 const& )
{
return true;
}
// GE
struct ge1: private boost::noncopyable {};
struct ge2: private boost::noncopyable {};
std::ostream& operator<<( std::ostream& os, ge1 const& )
{
return os << "ge1()";
}
std::ostream& operator<<( std::ostream& os, ge2 const& )
{
return os << "ge2()";
}
bool operator>=( ge1 const&, ge2 const& )
{
return true;
}
//
int main()
{
BOOST_TEST_EQ( eq1(), eq2() );
BOOST_TEST_NE( ne1(), ne2() );
BOOST_TEST_LT( lt1(), lt2() );
BOOST_TEST_LE( le1(), le2() );
BOOST_TEST_GT( gt1(), gt2() );
BOOST_TEST_GE( ge1(), ge2() );
return boost::report_errors();
}

View File

@ -0,0 +1,36 @@
//
// Test for BOOST_TEST_TRAIT_SAME
//
// Copyright 2014, 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test_trait.hpp>
struct X
{
typedef int type;
};
template<class T1, class T2> struct Y
{
typedef T1 type;
};
int main()
{
BOOST_TEST_TRAIT_SAME(X, X);
BOOST_TEST_TRAIT_SAME(void, void);
BOOST_TEST_TRAIT_SAME(char[1], char[1]);
BOOST_TEST_TRAIT_SAME(char[], char[]);
BOOST_TEST_TRAIT_SAME(void(), void());
BOOST_TEST_TRAIT_SAME(X::type, X::type);
BOOST_TEST_TRAIT_SAME(X::type, Y<int, float>::type);
BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, float>);
BOOST_TEST_TRAIT_SAME(Y<void, float>::type, void);
return boost::report_errors();
}

View File

@ -0,0 +1,19 @@
//
// Test that BOOST_TEST_EQ doesn't emit sign compare warnings
//
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test.hpp>
int main()
{
BOOST_TEST_EQ(1, 1u);
BOOST_TEST_EQ(~0u, -1);
return boost::report_errors();
}

View File

@ -0,0 +1,52 @@
//
// Test for no_exceptions_support.hpp
//
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/no_exceptions_support.hpp>
#include <boost/core/quick_exit.hpp>
#include <boost/throw_exception.hpp>
#include <exception>
void f()
{
boost::throw_exception( std::exception() );
}
int main()
{
BOOST_TRY
{
f();
}
BOOST_CATCH( std::exception const& )
{
return 0;
}
BOOST_CATCH( ... )
{
return 1;
}
BOOST_CATCH_END
return 1;
}
#if defined(BOOST_NO_EXCEPTIONS)
namespace boost
{
void throw_exception( std::exception const& )
{
boost::quick_exit( 0 );
}
}
#endif

View File

@ -0,0 +1,100 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/noinit_adaptor.hpp>
#include <boost/core/default_allocator.hpp>
#include <boost/core/lightweight_test.hpp>
#include <vector>
template<class T>
class creator
: public boost::default_allocator<T> {
public:
template<class U>
struct rebind {
typedef creator<U> other;
};
creator(int state)
: state_(state) { }
template<class U>
creator(const creator<U>& other)
: state_(other.state()) { }
template<class U, class V>
void construct(U*, const V&) {
BOOST_ERROR("construct");
}
template<class U>
void destroy(U*) {
BOOST_ERROR("destroy");
}
int state() const {
return state_;
}
private:
int state_;
};
template<class T, class U>
inline bool
operator==(const creator<T>& lhs, const creator<U>& rhs)
{
return lhs.state() == rhs.state();
}
template<class T, class U>
inline bool
operator!=(const creator<T>& lhs, const creator<U>& rhs)
{
return !(lhs == rhs);
}
class type {
public:
type() { }
type(int value)
: value_(value) { }
int value() const {
return value_;
}
private:
int value_;
};
inline bool
operator==(const type& lhs, const type& rhs)
{
return lhs.value() == rhs.value();
}
template<class A>
void test(const A& allocator)
{
std::vector<typename A::value_type, A> v(allocator);
v.push_back(1);
BOOST_TEST(v.front() == 1);
v.clear();
v.resize(5);
v.front() = 1;
}
int main()
{
test(boost::noinit_adaptor<creator<int> >(1));
test(boost::noinit_adaptor<creator<type> >(2));
test(boost::noinit_adapt(creator<int>(3)));
test(boost::noinit_adapt(creator<type>(4)));
return boost::report_errors();
}

46
test/nvp_test.cpp Normal file
View File

@ -0,0 +1,46 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/nvp.hpp>
#include <boost/core/lightweight_test.hpp>
void test()
{
const char* n = "name";
int v = 1;
boost::nvp<int> p(n, v);
BOOST_TEST_EQ(p.name(), n);
BOOST_TEST_EQ(p.value(), 1);
BOOST_TEST_EQ(&p.value(), &v);
}
void test_factory()
{
const char* n = "name";
int v = 1;
boost::nvp<int> p = boost::make_nvp(n, v);
BOOST_TEST_EQ(p.name(), n);
BOOST_TEST_EQ(p.value(), 1);
BOOST_TEST_EQ(&p.value(), &v);
}
void test_macro()
{
int v = 1;
boost::nvp<int> p = BOOST_NVP(v);
BOOST_TEST_CSTR_EQ(p.name(), "v");
BOOST_TEST_EQ(p.value(), 1);
BOOST_TEST_EQ(&p.value(), &v);
}
int main()
{
test();
test_factory();
test_macro();
return boost::report_errors();
}

View File

@ -24,7 +24,6 @@
#include <boost/core/pointer_traits.hpp>
#include <boost/ref.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/detail/sp_typeinfo.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/underlying_type.hpp>
#include <boost/visit_each.hpp>

17
test/quick_exit_fail.cpp Normal file
View File

@ -0,0 +1,17 @@
// Test for quick_exit.hpp
//
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/quick_exit.hpp>
int main()
{
boost::quick_exit( 1 );
return 0;
}

17
test/quick_exit_test.cpp Normal file
View File

@ -0,0 +1,17 @@
// Test for quick_exit.hpp
//
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/quick_exit.hpp>
int main()
{
boost::quick_exit( 0 );
return 1;
}

View File

@ -8,6 +8,8 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#define BOOST_ALLOW_DEPRECATED_HEADERS
#include <boost/detail/sp_typeinfo.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>

View File

@ -16,6 +16,9 @@ local compile_tests =
mixed_headers_2.cpp
;
local compile_fail_tests =
const_wrapper_fail.cpp ;
local run_tests =
primitive.cpp
specialized_in_boost.cpp
@ -49,6 +52,12 @@ rule test_all
all_rules += [ compile $(file) : : "swap-$(test_name)" ] ;
}
for file in $(compile_fail_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ compile-fail $(file) : : "swap-$(test_name)" ] ;
}
for file in $(run_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;

View File

@ -0,0 +1,28 @@
// Copyright 2018 Andrzej Krzemieński
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/swap.hpp>
namespace boost
{
template<class T> struct Wrapper
{
T value;
};
template<class T> inline void swap( Wrapper<T> & w, Wrapper<T> & v )
{
boost::swap( w, v );
}
} // namespace boost
int main()
{
boost::Wrapper<int> const w = { 2 };
boost::Wrapper<int> const v = { 3 };
swap( w, v );
}

26
test/test_lib_typeid.cpp Normal file
View File

@ -0,0 +1,26 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/typeinfo.hpp>
#include <boost/core/lightweight_test.hpp>
boost::core::typeinfo const & get_typeid_int();
int main()
{
boost::core::typeinfo const & ti = BOOST_CORE_TYPEID( int );
boost::core::typeinfo const & tf = BOOST_CORE_TYPEID( float );
boost::core::typeinfo const & ti2 = get_typeid_int();
BOOST_TEST( ti2 == ti );
BOOST_TEST( ti2 != tf );
BOOST_TEST( !ti2.before( ti ) );
BOOST_TEST( !ti.before( ti2 ) );
BOOST_TEST( ti2.before( tf ) != tf.before( ti2 ) );
return boost::report_errors();
}

View File

@ -0,0 +1,55 @@
/*
* Copyright Andrey Semashev 2018.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file uncaught_exceptions.cpp
* \author Andrey Semashev
* \date 2018-11-10
*
* \brief This file contains tests for the uncaught_exceptions function.
*
* This file only contains the very basic checks of functionality that can be portably achieved
* through C++03 std::uncaught_exception.
*/
#include <boost/core/uncaught_exceptions.hpp>
#include <boost/core/lightweight_test.hpp>
struct my_exception {};
class exception_watcher
{
unsigned int& m_count;
public:
explicit exception_watcher(unsigned int& count) : m_count(count) {}
~exception_watcher() { m_count = boost::core::uncaught_exceptions(); }
};
// Tests for uncaught_exceptions when used in a destructor while an exception propagates
void test_in_destructor()
{
const unsigned int root_count = boost::core::uncaught_exceptions();
unsigned int level1_count = root_count;
try
{
exception_watcher watcher(level1_count);
throw my_exception();
}
catch (...)
{
}
BOOST_TEST_NE(root_count, level1_count);
}
int main()
{
test_in_destructor();
return boost::report_errors();
}

View File

@ -0,0 +1,90 @@
/*
* Copyright Andrey Semashev 2018.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file uncaught_exceptions_np.cpp
* \author Andrey Semashev
* \date 2018-11-10
*
* \brief This file contains tests for the uncaught_exceptions function.
*
* This file contains checks that are compiler specific and not quite portable or require C++17.
*/
#include <boost/core/uncaught_exceptions.hpp>
#if !defined(BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED)
#include <boost/core/lightweight_test.hpp>
struct my_exception1 {};
struct my_exception2 {};
class exception_watcher2
{
unsigned int& m_count;
public:
explicit exception_watcher2(unsigned int& count) : m_count(count) {}
~exception_watcher2() { m_count = boost::core::uncaught_exceptions(); }
};
class exception_watcher1
{
unsigned int& m_count1;
unsigned int& m_count2;
public:
exception_watcher1(unsigned int& count1, unsigned int& count2) : m_count1(count1), m_count2(count2) {}
~exception_watcher1()
{
m_count1 = boost::core::uncaught_exceptions();
try
{
exception_watcher2 watcher2(m_count2);
throw my_exception2();
}
catch (...)
{
}
}
};
// Tests for uncaught_exceptions when used in nested destructors while an exception propagates
void test_in_nested_destructors()
{
const unsigned int root_count = boost::core::uncaught_exceptions();
unsigned int level1_count = root_count, level2_count = root_count;
try
{
exception_watcher1 watcher1(level1_count, level2_count);
throw my_exception1();
}
catch (...)
{
}
BOOST_TEST_NE(root_count, level1_count);
BOOST_TEST_NE(root_count, level2_count);
BOOST_TEST_NE(level1_count, level2_count);
}
int main()
{
test_in_nested_destructors();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

15
test/use_default_test.cpp Normal file
View File

@ -0,0 +1,15 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/use_default.hpp>
template<class, class = boost::use_default>
struct type { };
template class type<int>;
template class type<void, boost::use_default>;