1
0
forked from boostorg/core

Compare commits

..

233 Commits

Author SHA1 Message Date
Peter Dimov
8ea2ac50fe Document BOOST_TEST_TRAIT_SAME 2019-02-06 18:12:25 +02:00
Peter Dimov
7f96d56eff Simplify implementation of BOOST_TEST_TRAIT_SAME 2019-02-06 04:38:27 +02:00
Peter Dimov
dcbe62c6bf Add BOOST_TEST_TRAIT_SAME 2019-02-06 02:02:40 +02:00
Peter Dimov
a8ef600c30 Remove duplicate Travis job 2019-01-28 23:16:52 +02:00
Peter Dimov
d8895bab46 Mark checked_delete as noexcept 2019-01-28 19:15:24 +02:00
Andrey Semashev
a8c870e2e7 Merge branch 'develop' 2019-01-15 13:34:33 +03:00
Peter Dimov
9db11ce554 Add more xcode configurations to Travis 2019-01-13 04:26:10 +02:00
Peter Dimov
3f3bba7869 Add test/cmake_subdir_test 2019-01-12 21:25:10 +02:00
Andrey Semashev
61b4e1a45d Use multiple jobs to checkout submodules in CI. 2019-01-12 21:24:45 +02:00
Andrey Semashev
b1949c0509 Added tools/boost_install and libs/headers manual init to CI jobs. 2019-01-12 21:24:28 +02:00
Andrey Semashev
7d70451b49 Updated the comment about __cxa_uncaught_exceptions. 2019-01-08 04:47:51 +03:00
Andrey Semashev
bf932b4908 Removed the use of __cxa_uncaught_exceptions.
Travis CI shows linking errors on Linux and OS X when __cxa_uncaught_exceptions
is used to implement uncaught_exceptions. There's probably some library missing,
which should be linked in implicitly by the compiler, or the library indeed
does not export the symbol. In any case, __cxa_get_globals-based implementation
should provide the same effect.
2019-01-08 04:17:24 +03:00
Andrey Semashev
e3629dd1c1 Added libc++abi-dev package installation, changed OS X image to xcode10.1.
This is in attempt to debug/work around strange issues in CI with cxxabi.h
provided by libc++abi-dev. The header declares __cxa_uncaught_exceptions
function, but on linking stage the function is missing. The current theory
is that the header and the libc++abi library do not match on CI machines for
some reason, and this commit tries to mitigate or verify that.
2019-01-08 00:29:53 +03:00
Andrey Semashev
dea6b04157 Added workarounds for gcc < 4.7 on Linux and OpenBSD.
Apparently, gcc < 4.7 on Linux also don't have __cxa_get_globals
declaration in cxxabi.h. Declare the function ourselves.

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

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

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

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

* adding tests

* missing header

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

* renamed predicates and removed close_to predicate

* removing now superfluous headers

* unpatching the fix to put in a separate PR

* move predicate to first argument

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

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

It has been used here and there in various boost library but it's
useful enough to warrant an autonomous existence.
2015-08-10 16:55:44 +02:00
89 changed files with 4462 additions and 296 deletions

310
.travis.yml Normal file
View File

@@ -0,0 +1,310 @@
# Copyright 2016-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)
language: cpp
sudo: false
python: "2.7"
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-7
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-6.0
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: linux
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode7.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode8.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode9.4
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode10.1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
script:
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/headers
- git submodule init libs/assert
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule update --jobs 4
- cp -r $TRAVIS_BUILD_DIR/* libs/core
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
- ./b2 -j $BUILD_JOBS libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:
on_success: always

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,13 +1,20 @@
Boost.Core
==========
Boost.Core, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
Boost.Core, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
The criteria for inclusion is that the utility component be:
* simple,
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core itself, Config, Assert, Static Assert, or Predef.
### CI Status
Branch | Travis | Appveyor
---------|--------|---------
Develop | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=develop)](https://travis-ci.org/boostorg/core) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/core)
Master | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=master)](https://travis-ci.org/boostorg/core) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/core)
### Directories
* **doc** - Documentation of the components
@@ -16,8 +23,10 @@ The criteria for inclusion is that the utility component be:
### More information
* [Documentation](http://boostorg.github.io/core)
* [Documentation](https://boost.org/libs/core)
* [Report bugs](https://svn.boost.org/trac/boost/newticket?component=core;version=Boost%20Release%20Branch). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
### License
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).

76
appveyor.yml Normal file
View File

@@ -0,0 +1,76 @@
# Copyright 2016, 2017 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- 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,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
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/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule update --jobs 4
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core
- cmd /c bootstrap
- b2 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD%

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
@@ -51,3 +51,9 @@ boostbook standalone
<xsl:param>toc.max.depth=1
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/core/doc/html
;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

View File

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

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
@@ -41,7 +41,9 @@ criteria for inclusion is that the utility component be:
[include addressof.qbk]
[include checked_delete.qbk]
[include demangle.qbk]
[include empty_value.qbk]
[include enable_if.qbk]
[include exchange.qbk]
[include explicit_operator_bool.qbk]
[include ignore_unused.qbk]
[include is_same.qbk]
@@ -49,7 +51,10 @@ criteria for inclusion is that the utility component be:
[include no_exceptions_support.qbk]
[include noncopyable.qbk]
[include null_deleter.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]

137
doc/empty_value.qbk Normal file
View File

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

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

62
doc/exchange.qbk Normal file
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)
]
[section:exchange exchange]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/exchange.hpp> provides the function template
`boost::exchange` which is an implementation of the `std::exchange`
function introduced in C++14.
[endsect]
[section Examples]
The following example shows `boost::exchange` used to simplify the
implementation of a move constructor.
```
Node(Node&& other)
: head_(boost::exchange(other.head_, nullptr))
, tail_(boost::exchange(other.tail_, nullptr)) { }
```
[endsect]
[section Reference]
```
namespace boost {
template<class T, class U = T>
constexpr T exchange(T& t, U&& u);
}
```
[section Functions]
[*`template<class T, class U = T> constexpr T exchange(T& t, U&& u);`]
Equivalent to:
```
T v = std::move(t);
t = std::forward<U>(u);
return v;
```
[endsect]
[endsect]
[endsect]

View File

@@ -1,7 +1,8 @@
[/
Copyright 2010, 2011 Beman Dawes
Copyright 2013 Ion Gaztanaga
Copyright 2014 Peter Dimov
Copyright 2014-2019 Peter Dimov
Copyright 2017 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0.
@@ -32,9 +33,18 @@ When using `lightweight_test.hpp`, *do not forget* to
``
#define BOOST_TEST(expression) /*unspecified*/
#define BOOST_TEST_NOT(expression) /*unspecified*/
#define BOOST_ERROR(message) /*unspecified*/
#define BOOST_TEST_EQ(expr1, expr2) /*unspecified*/
#define BOOST_TEST_NE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_LT(expr1, expr2) /*unspecified*/
#define BOOST_TEST_LE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_GT(expr1, expr2) /*unspecified*/
#define BOOST_TEST_GE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/
#define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) /* unspecified */
#define BOOST_TEST_THROWS(expr, excep) /*unspecified*/
namespace boost
@@ -56,6 +66,17 @@ message containing `expression`.
[endsect]
[section BOOST_TEST_NOT]
``
BOOST_TEST_NOT(expression)
``
If expression is true increases the error count and outputs a
message containing `!(expression)`.
[endsect]
[section BOOST_ERROR]
``
@@ -73,7 +94,7 @@ Increases error count and outputs a message containing
BOOST_TEST_EQ(expr1, expr2)
``
If `expr1 != expr2` increases the error count and outputs a
If `expr1 == expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
@@ -84,11 +105,95 @@ message containing both expressions.
BOOST_TEST_NE(expr1, expr2)
``
If `expr1 == expr2` increases the error count and outputs a
If `expr1 != expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_LT]
``
BOOST_TEST_LT(expr1, expr2)
``
If `expr1 < expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_LE]
``
BOOST_TEST_LE(expr1, expr2)
``
If `expr1 <= expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_GT]
``
BOOST_TEST_GT(expr1, expr2)
``
If `expr1 > expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_GE]
``
BOOST_TEST_GE(expr1, expr2)
``
If `expr1 >= expr2` is not true increases the error count and outputs a
message containing both expressions.
[endsect]
[section BOOST_TEST_CSTR_EQ]
``
BOOST_TEST_CSTR_EQ(expr1, expr2)
``
Specialization of `BOOST_TEST_EQ` which interprets `expr1` and `expr2` as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) != 0`, increase the error count and output a message containing both expressions.
[endsect]
[section BOOST_TEST_CSTR_NE]
``
BOOST_TEST_CSTR_NE(expr1, expr2)
``
Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) == 0`, increase the error count and output a message containing both expressions.
[endsect]
[section BOOST_TEST_ALL_EQ]
``
BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2)
``
Compares the content of two sequences. If they have different sizes, or if any pairwise element differs, increases the error count and outputs a message containing at most 8 differing elements.
[endsect]
[section BOOST_TEST_ALL_WITH]
``
BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate)
``
Compares the content of two sequences. If they have different sizes, or if any pairwise element do not fulfill the binary predicate, increases the error count and outputs a message containing at most 8 differing elements.
[endsect]
[section BOOST_TEST_THROWS]
``
@@ -148,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]
@@ -175,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]
``
@@ -192,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();
}
``

View File

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

150
doc/pointer_traits.qbk Normal file
View File

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

40
doc/quick_exit.qbk Normal file
View File

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

View File

@@ -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]

View File

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

View File

@@ -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

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

View File

@@ -0,0 +1,136 @@
/*
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) { }
#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) { }
#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

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

View File

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

View File

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

View File

@@ -14,15 +14,21 @@
// Copyright (2) Beman Dawes 2010, 2011
// Copyright (3) Ion Gaztanaga 2013
//
// Copyright 2018 Glen Joseph Fernandes
// (glenjofe@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/assert.hpp>
#include <boost/current_function.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/current_function.hpp>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <cstddef>
// IDE's like Visual Studio perform better if output goes to std::cout or
// some other stream, so allow user to configure output stream:
@@ -36,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)
@@ -66,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)
@@ -74,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)
@@ -82,51 +104,281 @@ 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();
}
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 )
// 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 __has_warning("-Wsign-compare")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-compare"
# endif
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
#endif
// specialize test output for char pointers to avoid printing as cstring
template <class T> inline const T& test_output_impl(const T& v) { return v; }
inline const void* test_output_impl(const char* v) { return v; }
inline const void* test_output_impl(const unsigned char* v) { return v; }
inline const void* test_output_impl(const signed char* v) { return v; }
inline const void* test_output_impl(char* v) { return v; }
inline const void* test_output_impl(unsigned char* v) { return v; }
inline const void* test_output_impl(signed char* v) { return v; }
template<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); }
#if !defined( BOOST_NO_CXX11_NULLPTR )
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
#endif
struct lw_test_eq {
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t == u; }
static const char* op() { return "=="; }
};
struct lw_test_ne {
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t != u; }
static const char* op() { return "!="; }
};
struct lw_test_lt {
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t < u; }
static const char* op() { return "<"; }
};
struct lw_test_le {
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t <= u; }
static const char* op() { return "<="; }
};
struct lw_test_gt {
template <typename T, typename U>
bool operator()(const T& t, const U& u) const { return t > u; }
static const char* op() { return ">"; }
};
struct lw_test_ge {
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 << "': "
<< "'" << t << "' != '" << 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();
}
}
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( t != u )
if( std::strcmp(t, u) == 0 )
{
report_errors_remind();
test_results();
}
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();
}
}
inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( std::strcmp(t, u) != 0 )
{
test_results();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2>
void test_all_eq_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end)
{
InputIterator1 first_it = first_begin;
InputIterator2 second_it = second_begin;
typename std::iterator_traits<InputIterator1>::difference_type first_index = 0;
typename std::iterator_traits<InputIterator2>::difference_type second_index = 0;
std::size_t error_count = 0;
const std::size_t max_count = 8;
do
{
while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it))
{
++first_it;
++second_it;
++first_index;
++second_index;
}
if ((first_it == first_end) || (second_it == second_end))
{
break; // do-while
}
if (error_count == 0)
{
output << file << "(" << line << "): Container contents differ in function '" << function << "':";
}
else if (error_count >= max_count)
{
output << " ...";
break;
}
output << " [" << first_index << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'";
++first_it;
++second_it;
++first_index;
++second_index;
++error_count;
} while (first_it != first_end);
first_index += std::distance(first_it, first_end);
second_index += std::distance(second_it, second_end);
if (first_index != second_index)
{
if (error_count == 0)
{
output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")";
}
else
{
output << " [*] size(" << first_index << ") != size(" << second_index << ")";
}
++error_count;
}
if (error_count == 0)
{
test_results();
}
else
{
output << std::endl;
++test_results().errors();
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate>
void test_all_with_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end,
BinaryPredicate predicate)
{
InputIterator1 first_it = first_begin;
InputIterator2 second_it = second_begin;
typename std::iterator_traits<InputIterator1>::difference_type first_index = 0;
typename std::iterator_traits<InputIterator2>::difference_type second_index = 0;
std::size_t error_count = 0;
const std::size_t max_count = 8;
do
{
while ((first_it != first_end) && (second_it != second_end) && predicate(*first_it, *second_it))
{
++first_it;
++second_it;
++first_index;
++second_index;
}
if ((first_it == first_end) || (second_it == second_end))
{
break; // do-while
}
if (error_count == 0)
{
output << file << "(" << line << "): Container contents differ in function '" << function << "':";
}
else if (error_count >= max_count)
{
output << " ...";
break;
}
output << " [" << first_index << "]";
++first_it;
++second_it;
++first_index;
++second_index;
++error_count;
} while (first_it != first_end);
first_index += std::distance(first_it, first_end);
second_index += std::distance(second_it, second_end);
if (first_index != second_index)
{
if (error_count == 0)
{
output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")";
}
else
{
output << " [*] size(" << first_index << ") != size(" << second_index << ")";
}
++error_count;
}
if (error_count == 0)
{
test_results();
}
else
{
output << std::endl;
++test_results().errors();
}
}
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic pop
# endif
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic pop
#endif
} // namespace detail
inline int report_errors()
{
boost::detail::report_errors_remind().called_report_errors_function = true;
int errors = boost::detail::test_errors();
boost::detail::test_result& result = boost::detail::test_results();
result.done();
int errors = result.errors();
if( errors == 0 )
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
@@ -143,12 +395,24 @@ inline int report_errors()
} // 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_with_impl(::boost::detail::lw_test_lt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_le(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_gt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ge(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) )
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) )
#ifndef BOOST_NO_EXCEPTIONS
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
@@ -158,6 +422,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,7 +9,7 @@
// 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
//
@@ -19,6 +19,7 @@
#include <boost/core/lightweight_test.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/is_same.hpp>
namespace boost
{
@@ -31,7 +32,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
{
if( T::value == expected )
{
report_errors_remind();
test_results();
}
else
{
@@ -42,7 +43,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
<< "' ('" << boost::core::demangled_name( BOOST_CORE_TYPEID(T1) )
<< "' != '" << boost::core::demangled_name( BOOST_CORE_TYPEID(T2) ) << "')"
<< std::endl;
++test_results().errors();
}
}
@@ -52,5 +78,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

@@ -21,7 +21,7 @@
//----------------------------------------------------------------------
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
#if !(defined BOOST_NO_EXCEPTIONS)
# define BOOST_TRY { try

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

View File

@@ -0,0 +1,59 @@
#ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
#define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/core/quick_exit.hpp
//
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <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

@@ -8,8 +8,8 @@
#endif
#include <boost/config.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/addressof.hpp>
//
// ref.hpp - ref/cref, useful helper functions
@@ -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

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

View File

@@ -21,13 +21,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(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(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,131 @@
/*
* 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_exception` 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.
#if !defined(__FreeBSD__) && \
( \
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \
defined(__OpenBSD__) || \
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

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

View File

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

View File

@@ -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

@@ -1,17 +1,24 @@
# Boost.Core Library test Jamfile
#
# Copyright (c) 2014 Peter Dimov
# Copyright (c) 2014, 2017 Peter Dimov
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
import modules ;
import testing ;
# quick test (for CI)
run quick.cpp ;
# full test suite
run addressof_test.cpp ;
run addressof_test2.cpp ;
run addressof_np_test.cpp ;
run addressof_fn_test.cpp ;
compile addressof_constexpr_test.cpp ;
compile-fail addressof_fail_rvalue.cpp ;
run checked_delete_test.cpp ;
compile-fail checked_delete_fail.cpp ;
@@ -28,6 +35,7 @@ compile-fail ref_rv_fail4.cpp ;
compile-fail ref_rv_fail5.cpp ;
compile-fail ref_implicit_fail.cpp ;
compile-fail ref_implicit_fail2.cpp ;
run ref_cv_test.cpp ;
run eif_constructors.cpp ;
run eif_dummy_arg_disambiguation.cpp ;
@@ -60,8 +68,16 @@ 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 ;
run-fail lightweight_test_fail.cpp ;
run-fail lightweight_test_fail2.cpp ;
@@ -73,6 +89,13 @@ run-fail lightweight_test_fail7.cpp ;
run-fail lightweight_test_fail7.cpp : : : <rtti>off : lightweight_test_fail7_no_rtti ;
run-fail lightweight_test_fail8.cpp ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp ;
run-fail lightweight_test_lt_fail.cpp ;
run-fail lightweight_test_le_fail.cpp ;
run-fail lightweight_test_gt_fail.cpp ;
run-fail lightweight_test_ge_fail.cpp ;
run is_same_test.cpp ;
@@ -92,3 +115,33 @@ compile-fail scoped_enum_compile_fail_conv_from_int.cpp ;
compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
run underlying_type.cpp ;
run pointer_traits_pointer_test.cpp ;
run pointer_traits_element_type_test.cpp ;
run pointer_traits_difference_type_test.cpp ;
run pointer_traits_rebind_test.cpp ;
run pointer_traits_pointer_to_test.cpp ;
run to_address_test.cpp ;
run exchange_test.cpp ;
run exchange_move_test.cpp ;
run empty_value_test.cpp ;
run empty_value_size_test.cpp ;
run quick_exit_test.cpp ;
run-fail quick_exit_fail.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 ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View File

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

View File

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

View File

@@ -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

@@ -10,16 +10,19 @@
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
#include <boost/mpl/not.hpp>
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
using boost::enable_if;
using boost::mpl::not_;
using boost::is_arithmetic;
template<class T> struct not_
{
BOOST_STATIC_CONSTANT( bool, value = !T::value );
};
namespace A {
template<class T>
typename enable_if<is_arithmetic<T>, bool>::type

View File

@@ -10,16 +10,19 @@
// Jeremiah Willcock (jewillco at osl.iu.edu)
// Andrew Lumsdaine (lums at osl.iu.edu)
#include <boost/mpl/not.hpp>
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
using boost::mpl::not_;
using boost::enable_if;
using boost::is_arithmetic;
template<class T> struct not_
{
BOOST_STATIC_CONSTANT( bool, value = !T::value );
};
template<class T>
typename enable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t) { return true; }

View File

@@ -14,6 +14,7 @@
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
using boost::enable_if_has_type;
using boost::enable_if_c;
using boost::disable_if_c;
using boost::enable_if;
@@ -46,9 +47,28 @@ struct tester2<T, typename disable_if<is_arithmetic<T> >::type> {
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T, class Enable = void>
struct tester3
{
typedef T type;
BOOST_STATIC_CONSTANT(bool, value = false);
};
template <class T>
struct tester3<T, typename enable_if_has_type<typename T::value_type>::type>
{
typedef typename T::value_type type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
struct sample_value_type
{
typedef float***& value_type;
};
int main()
{
BOOST_TEST(tester<int>::value);
BOOST_TEST(tester<double>::value);
@@ -61,6 +81,9 @@ int main()
BOOST_TEST(!tester2<char*>::value);
BOOST_TEST(!tester2<void*>::value);
BOOST_TEST(!tester3<char*>::value);
BOOST_TEST(tester3<sample_value_type>::value);
return boost::report_errors();
}

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

76
test/empty_value_test.cpp Normal file
View File

@@ -0,0 +1,76 @@
/*
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 {
operator bool() const {
return false;
}
operator bool() {
return true;
}
};
class type {
public:
type()
: value_(false) { }
explicit type(bool value)
: value_(value) { }
operator bool() const {
return value_;
}
private:
bool value_;
};
void test_bool()
{
const boost::empty_value<bool> v1(boost::empty_init_t(), true);
BOOST_TEST(v1.get());
boost::empty_value<bool> v2 = boost::empty_init_t();
BOOST_TEST(!v2.get());
v2 = v1;
BOOST_TEST(v2.get());
v2.get() = false;
BOOST_TEST(!v2.get());
}
void test_empty()
{
empty e;
const boost::empty_value<empty> v1(boost::empty_init_t(), e);
BOOST_TEST(!v1.get());
boost::empty_value<empty> v2;
BOOST_TEST(v2.get());
v2 = v1;
BOOST_TEST(v2.get());
v2.get() = empty();
BOOST_TEST(v2.get());
}
void test_type()
{
const boost::empty_value<type> v1(boost::empty_init_t(), true);
BOOST_TEST(v1.get());
boost::empty_value<type> v2;
BOOST_TEST(!v2.get());
v2 = v1;
BOOST_TEST(v2.get());
v2.get() = type();
BOOST_TEST(!v2.get());
}
int main()
{
test_bool();
test_empty();
test_type();
return boost::report_errors();
}

100
test/exchange_move_test.cpp Normal file
View File

@@ -0,0 +1,100 @@
/*
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_CXX11_RVALUE_REFERENCES)
#include <boost/core/exchange.hpp>
#include <boost/core/lightweight_test.hpp>
class C1 {
public:
explicit C1(int i)
: i_(i) { }
C1(C1&& c)
: i_(c.i_) { }
C1& operator=(C1&& c) {
i_ = c.i_;
return *this;
}
int i() const {
return i_;
}
private:
C1(const C1&);
C1& operator=(const C1&);
int i_;
};
void test1()
{
C1 x(1);
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
BOOST_TEST(x.i() == 2);
}
class C2 {
public:
explicit C2(int i)
: i_(i) { }
operator C1() const {
return C1(i_);
}
int i() const {
return i_;
}
private:
C2(const C2&);
C2& operator=(const C2&);
int i_;
};
void test2()
{
C1 x(1);
BOOST_TEST(boost::exchange(x, C2(2)).i() == 1);
BOOST_TEST(x.i() == 2);
}
class C3 {
public:
explicit C3(int i)
: i_(i) { }
C3(C3&& c)
: i_(c.i_) { }
C3& operator=(C1&& c) {
i_ = c.i();
return *this;
}
int i() const {
return i_;
}
private:
C3(const C3&);
C3& operator=(const C3&);
int i_;
};
void test3()
{
C3 x(1);
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
BOOST_TEST(x.i() == 2);
}
int main()
{
test1();
test2();
test3();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

89
test/exchange_test.cpp Normal file
View File

@@ -0,0 +1,89 @@
/*
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/exchange.hpp>
#include <boost/core/lightweight_test.hpp>
void test1()
{
int i = 1;
BOOST_TEST(boost::exchange(i, 2) == 1);
BOOST_TEST(i == 2);
}
class C1 {
public:
explicit C1(int i)
: i_(i) { }
int i() const {
return i_;
}
private:
int i_;
};
void test2()
{
C1 x(1);
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
BOOST_TEST(x.i() == 2);
}
class C2 {
public:
explicit C2(int i)
: i_(i) { }
operator C1() const {
return C1(i_);
}
int i() const {
return i_;
}
private:
int i_;
};
void test3()
{
C1 x(1);
BOOST_TEST(boost::exchange(x, C2(2)).i() == 1);
BOOST_TEST(x.i() == 2);
}
class C3 {
public:
explicit C3(int i)
: i_(i) { }
C3(const C3& c)
: i_(c.i_) { }
C3& operator=(const C1& c) {
i_ = c.i();
return *this;
}
int i() const {
return i_;
}
private:
C3& operator=(const C3&);
int i_;
};
void test4()
{
C3 x(1);
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
BOOST_TEST(x.i() == 2);
}
int main()
{
test1();
test2();
test3();
test4();
return boost::report_errors();
}

View File

@@ -35,6 +35,7 @@ int main(int, char*[])
{
checkable val;
int n = val;
(void)n;
return 0;
}

View File

@@ -35,6 +35,7 @@ int main(int, char*[])
{
checkable val;
void* p = val;
(void)p;
return 0;
}

View File

@@ -1,7 +1,7 @@
//
// get_pointer_test.cpp
//
// Copyright 2014 Peter Dimov
// Copyright 2014, 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
@@ -27,11 +27,25 @@ int main()
delete p;
}
{
X * p = 0;
BOOST_TEST( get_pointer( p ) == 0 );
}
#if !defined( BOOST_NO_AUTO_PTR )
{
std::auto_ptr< X > p( new X );
BOOST_TEST( get_pointer( p ) == p.get() );
}
{
std::auto_ptr< X > p;
BOOST_TEST( get_pointer( p ) == 0 );
}
#endif
#if !defined( BOOST_NO_CXX11_SMART_PTR )
{
@@ -39,11 +53,21 @@ int main()
BOOST_TEST( get_pointer( p ) == p.get() );
}
{
std::unique_ptr< X > p;
BOOST_TEST( get_pointer( p ) == 0 );
}
{
std::shared_ptr< X > p( new X );
BOOST_TEST( get_pointer( p ) == p.get() );
}
{
std::shared_ptr< X > p;
BOOST_TEST( get_pointer( p ) == 0 );
}
#endif
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

@@ -0,0 +1,124 @@
//
// Negative test for BOOST_TEST_ALL_EQ
//
// Copyright (c) 2017 Bjorn Reese
//
// 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 <vector>
#include <set>
#include <boost/core/lightweight_test.hpp>
int main()
{
int test_cases = 0;
// Array
{
int x[] = { 1 };
int y[] = { 1, 2 };
BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
++test_cases;
}
{
int x[] = { 1, 2 };
int y[] = { 1 };
BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
++test_cases;
}
{
int x[] = { 2 };
int y[] = { 1, 2 };
BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
++test_cases;
}
{
int x[] = { 1, 2, 3, 4 };
int y[] = { 1, 3, 2, 4 };
BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
++test_cases;
}
// Vector
{
std::vector<int> x, y;
x.push_back( 1 );
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::vector<int> x, y;
y.push_back( 1 );
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 );
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::vector<float> x, y;
x.push_back( 1.0f ); x.push_back( 2.0f ); x.push_back( 3.0f ); x.push_back( 4.0f );
y.push_back( 4.0f ); y.push_back( 2.0f ); y.push_back( 3.0f ); y.push_back( 1.0f );
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 );
y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 );
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 );;
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
// Set
{
std::set<int> x, y;
x.insert(1);
y.insert(1); y.insert(3);
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::set<int> x, y;
x.insert(1); x.insert(2);
y.insert(1);
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
{
std::set<int> x, y;
x.insert(1); x.insert(2);
y.insert(1); y.insert(3);
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
++test_cases;
}
return !boost::report_errors();
}

View File

@@ -0,0 +1,105 @@
//
// Negative est for BOOST_TEST_ALL_WITH
//
// Copyright (c) 2017 Bjorn Reese
//
// 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 <cmath>
#include <functional>
#include <vector>
#include <boost/core/lightweight_test.hpp>
int fail_vector()
{
int test_cases = 0;
{
std::vector<int> x, y;
x.push_back( 1 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::equal_to<int>() );
++test_cases;
}
{
std::vector<int> x, y;
y.push_back( 1 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::equal_to<int>() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 1 ); y.push_back( 2 ); y.push_back( 3 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::equal_to<int>() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 );
y.push_back( 1 ); y.push_back( 2 ); y.push_back( 3 ); y.push_back( 4 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::equal_to<int>() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::equal_to<int>() );
++test_cases;
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::less<int>() );
++test_cases;
}
return test_cases;
}
template <typename T>
struct with_tolerance
{
with_tolerance(T tolerance) : tolerance(tolerance) {}
bool operator()(T lhs, T rhs)
{
return (std::abs(lhs - rhs) <= tolerance);
}
private:
T tolerance;
};
int fail_tolerance_predicate()
{
int test_cases = 0;
{
std::vector<double> x, y;
x.push_back( 1.0 ); x.push_back( 1.0 );
y.push_back( 1.0 - 1e-4 ); y.push_back( 1.0 + 1e-4 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), with_tolerance<double>(1e-5) );
++test_cases;
}
return test_cases;
}
int main()
{
int test_cases = 0;
test_cases += fail_vector();
test_cases += fail_tolerance_predicate();
return !boost::report_errors();
}

View File

@@ -0,0 +1,76 @@
//
// Test for BOOST_TEST_ALL_WITH
//
// Copyright (c) 2017 Bjorn Reese
//
// 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 <cmath>
#include <functional>
#include <vector>
#include <boost/core/lightweight_test.hpp>
void test_vector()
{
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 1 ); y.push_back( 2 ); y.push_back( 3 ); y.push_back( 4 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::equal_to<int>() );
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 2 ); y.push_back( 3 ); y.push_back( 4 ); y.push_back( 5 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::not_equal_to<int>() );
}
{
std::vector<int> x, y;
x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
y.push_back( 2 ); y.push_back( 3 ); y.push_back( 4 ); y.push_back( 5 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), std::less<int>() );
}
}
template <typename T>
struct with_tolerance
{
with_tolerance(T tolerance) : tolerance(tolerance) {}
bool operator()(T lhs, T rhs)
{
return (std::abs(lhs - rhs) <= tolerance);
}
private:
T tolerance;
};
void test_tolerance_predicate()
{
{
std::vector<double> x, y;
x.push_back( 1.0 ); x.push_back( 2.0 ); x.push_back( 3.0 ); x.push_back( 4.0 );
y.push_back( 1.0 ); y.push_back( 2.0 ); y.push_back( 3.0 ); y.push_back( 4.0 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), with_tolerance<double>(1e-5) );
}
{
std::vector<double> x, y;
x.push_back( 1.0 ); x.push_back( 1.0 );
y.push_back( 1.0 - 1e-6 ); y.push_back( 1.0 + 1e-6 );
BOOST_TEST_ALL_WITH( x.begin(), x.end(), y.begin(), y.end(), with_tolerance<double>(1e-5) );
}
}
int main()
{
test_vector();
test_tolerance_predicate();
return boost::report_errors();
}

View File

@@ -0,0 +1,31 @@
//
// Test BOOST_TEST_EQ( p, nullptr )
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/config.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
#if !defined( BOOST_NO_CXX11_NULLPTR )
int x = 0;
int* p1 = 0;
int* p2 = &x;
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,18 @@
//
// Negative test for BOOST_TEST_EQ on const char*
//
// Copyright (c) 2017 Hans Dembinski
//
// 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("xab"+1 , "yab"+1); // compares addresses, not cstrings
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,18 @@
//
// Negative test for BOOST_TEST_CSTR_EQ
//
// Copyright (c) 2017 Hans Dembinski
//
// 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_CSTR_EQ("x" , "y");
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
//
// Negative test for BOOST_TEST_GE
//
// Copyright 2017 Kohei Takahashi
//
// 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()
{
int x = 0;
BOOST_TEST_GE( x, 1 );
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
//
// Negative test for BOOST_TEST_GT
//
// Copyright 2017 Kohei Takahashi
//
// 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()
{
int x = 0;
BOOST_TEST_GT( x, 0 );
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
//
// Test for BOOST_TEST_GT, BOOST_TEST_GE
//
// Copyright 2017 Kohei Takahashi
//
// 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()
{
int x = 0;
BOOST_TEST_GT( x, -1 );
BOOST_TEST_GT( ++x, 0 );
BOOST_TEST_GT( x++, 0 );
BOOST_TEST_GE( x, 2 );
BOOST_TEST_GE( ++x, 3 );
BOOST_TEST_GE( x++, 3 );
int y = 5;
BOOST_TEST_GT( ++y, ++x );
BOOST_TEST_GT( y++, x++ );
BOOST_TEST_GE( ++y, x );
BOOST_TEST_GE( y++, x++ );
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
//
// Negative test for BOOST_TEST_LE
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test.hpp>
int main()
{
int x = 1;
BOOST_TEST_LE( x, 0 );
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
//
// Negative test for BOOST_TEST_LT
//
// Copyright 2014, 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test.hpp>
int main()
{
int x = 0;
BOOST_TEST_LT( x, 0 );
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
//
// Test for BOOST_TEST_LT, BOOST_TEST_LE
//
// Copyright 2014, 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/lightweight_test.hpp>
int main()
{
int x = 0;
BOOST_TEST_LT( x, 1 );
BOOST_TEST_LT( ++x, 2 );
BOOST_TEST_LT( x++, 3 );
BOOST_TEST_LE( x, 2 );
BOOST_TEST_LE( ++x, 3 );
BOOST_TEST_LE( x++, 4 );
int y = 3;
BOOST_TEST_LT( ++y, ++x );
BOOST_TEST_LT( y++, x++ );
BOOST_TEST_LE( ++y, x );
BOOST_TEST_LE( y++, x++ );
return boost::report_errors();
}

View File

@@ -8,6 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <vector>
#include <boost/detail/lightweight_test.hpp>
struct X
@@ -43,6 +44,16 @@ int main()
BOOST_TEST( x++ == 1 );
BOOST_TEST( x == 2? true: false );
BOOST_TEST( x == 2? &x: 0 );
// BOOST_TEST_NOT
BOOST_TEST_NOT( x == 1 );
BOOST_TEST_NOT( ++x == 2 );
BOOST_TEST_NOT( x++ == 2 );
BOOST_TEST_NOT( --x == 2 );
BOOST_TEST_NOT( x-- == 2 );
BOOST_TEST_NOT( x == 2? false: true );
BOOST_TEST_NOT( x == 2? 0: &x );
// BOOST_TEST_EQ
@@ -54,11 +65,24 @@ int main()
BOOST_TEST_EQ( ++x, ++y );
BOOST_TEST_EQ( x++, y++ );
BOOST_TEST_CSTR_EQ("xabc"+1, "yabc"+1); // equal cstrings, different addresses
BOOST_TEST_EQ( &y, &y );
// BOOST_TEST_NE
BOOST_TEST_NE( ++x, y );
BOOST_TEST_NE( &x, &y );
BOOST_TEST_NE("xabc"+1, "yabc"+1); // equal cstrings, different addresses
BOOST_TEST_CSTR_NE("x", "y");
// BOOST_TEST_ALL_EQ
{
std::vector<int> xarray;
xarray.push_back(1);
xarray.push_back(2);
std::vector<int> yarray(xarray);
BOOST_TEST_ALL_EQ(xarray.begin(), xarray.end(), yarray.begin(), yarray.end());
}
// BOOST_TEST_THROWS

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,37 @@
//
// 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>
struct X
{
typedef int type;
};
template<class T1, class T2> struct Y
{
typedef T1 type;
};
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>);
return boost::report_errors() == 10;
}

View File

@@ -0,0 +1,41 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/pointer_traits.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct P { };
template<class T>
struct E {
typedef long difference_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::pointer_traits<int*>::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::pointer_traits<P<int> >::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
boost::pointer_traits<E<int> >::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::pointer_traits<void*>::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::pointer_traits<P<void> >::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
boost::pointer_traits<E<void> >::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::pointer_traits<const int*>::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::pointer_traits<P<const int> >::difference_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
boost::pointer_traits<E<const int> >::difference_type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,83 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/pointer_traits.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct P1 { };
template<class T1, class T2>
struct P2 { };
template<class T1, class T2, class T3>
struct P3 { };
template<class T>
struct E1 {
typedef bool element_type;
};
template<class T1, class T2>
struct E2 {
typedef bool element_type;
};
template<class T1, class T2, class T3>
struct E3 {
typedef bool element_type;
};
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T, class... U>
struct P { };
template<class T, class... U>
struct E {
typedef bool element_type;
};
#endif
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::pointer_traits<int*>::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::pointer_traits<P1<int> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::pointer_traits<P2<int, char> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::pointer_traits<P3<int, char, char> >::element_type>));
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::pointer_traits<P<int, char, char, char> >::element_type>));
#endif
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
boost::pointer_traits<E1<int> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
boost::pointer_traits<E2<int, int> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
boost::pointer_traits<E3<int, int, int> >::element_type>));
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
boost::pointer_traits<E<int, int, int, int> >::element_type>));
#endif
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
boost::pointer_traits<void*>::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
boost::pointer_traits<P1<void> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
boost::pointer_traits<E1<void> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
boost::pointer_traits<const int*>::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
boost::pointer_traits<P1<const int> >::element_type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
boost::pointer_traits<E1<const int> >::element_type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,30 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/pointer_traits.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct P { };
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::pointer_traits<int*>::pointer>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<int>,
boost::pointer_traits<P<int> >::pointer>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
boost::pointer_traits<void*>::pointer>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<void>,
boost::pointer_traits<P<void> >::pointer>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
boost::pointer_traits<const int*>::pointer>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<const int>,
boost::pointer_traits<P<const int> >::pointer>));
return boost::report_errors();
}

View File

@@ -0,0 +1,63 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/pointer_traits.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
class pointer {
public:
typedef typename boost::pointer_traits<T>::element_type element_type;
pointer(T value)
: value_(value) { }
T get() const BOOST_NOEXCEPT {
return value_;
}
static pointer<T> pointer_to(element_type& value) {
return pointer<T>(&value);
}
private:
T value_;
};
template<class T>
inline bool
operator==(const pointer<T>& lhs, const pointer<T>& rhs) BOOST_NOEXCEPT
{
return lhs.get() == rhs.get();
}
int main()
{
int i = 0;
{
typedef int* type;
type p = &i;
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
}
{
typedef pointer<int*> type;
type p(&i);
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
}
{
typedef pointer<pointer<int*> > type;
type p(&i);
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
}
{
typedef const int* type;
type p = &i;
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
}
{
typedef pointer<const int*> type;
type p(&i);
BOOST_TEST(boost::pointer_traits<type>::pointer_to(i) == p);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,107 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/pointer_traits.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct P1 { };
template<class T1, class T2>
struct P2 { };
template<class T1, class T2, class T3>
struct P3 { };
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class T>
struct E1 {
template<class U>
using rebind = E1<bool>;
};
template<class T1, class T2>
struct E2 {
template<class U>
using rebind = E2<bool, T2>;
};
template<class T1, class T2, class T3>
struct E3 {
template<class U>
using rebind = E3<bool, T2, T3>;
};
#endif
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T, class... U>
struct P { };
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class T, class... U>
struct E {
template<class V>
using rebind = E<bool, U...>;
};
#endif
#endif
struct R { };
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
boost::pointer_traits<R*>::rebind_to<char>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<char>,
boost::pointer_traits<P1<R> >::rebind_to<char>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P2<char, R>,
boost::pointer_traits<P2<R, R> >::rebind_to<char>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P3<char, R, R>,
boost::pointer_traits<P3<R, R, R> >::rebind_to<char>::type>));
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<char, R, R, R>,
boost::pointer_traits<P<R, R, R, R> >::rebind_to<char>::type>));
#endif
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
boost::pointer_traits<R*>::rebind_to<void>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<void>,
boost::pointer_traits<P1<R> >::rebind_to<void>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<R*,
boost::pointer_traits<void*>::rebind_to<R>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<R>,
boost::pointer_traits<P1<void> >::rebind_to<R>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
boost::pointer_traits<R*>::rebind_to<const int>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<const int>,
boost::pointer_traits<P1<R> >::rebind_to<const int>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::pointer_traits<const R*>::rebind_to<int>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
boost::pointer_traits<P1<const R> >::rebind_to<int>::type>));
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
boost::pointer_traits<E1<R> >::rebind_to<char>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
boost::pointer_traits<E2<R, R> >::rebind_to<char>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
boost::pointer_traits<E3<R, R, R> >::rebind_to<char>::type>));
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
boost::pointer_traits<E<R, R, R, R> >::rebind_to<char>::type>));
#endif
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
boost::pointer_traits<E1<R> >::rebind_to<void>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
boost::pointer_traits<E1<void> >::rebind_to<R>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
boost::pointer_traits<E1<R> >::rebind_to<const int>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
boost::pointer_traits<E1<const R> >::rebind_to<int>::type>));
#endif
return boost::report_errors();
}

34
test/quick.cpp Normal file
View File

@@ -0,0 +1,34 @@
//
// quick.cpp - a quick (CI) test for Boost.Core
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/addressof.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/core/demangle.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/core/explicit_operator_bool.hpp>
#include <boost/get_pointer.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/noncopyable.hpp>
#include <boost/core/null_deleter.hpp>
#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>
int main()
{
}

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;
}

35
test/ref_cv_test.cpp Normal file
View File

@@ -0,0 +1,35 @@
// ref_cv_test.cpp: ref( x ) where x is of a cv-qualified type
//
// Copyright (c) 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/ref.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_TEST_REF( x ) BOOST_TEST( &boost::ref( x ).get() == &x )
#define BOOST_TEST_CREF( x ) BOOST_TEST( &boost::cref( x ).get() == &x )
int main()
{
int x1 = 1;
int const x2 = 2;
int volatile x3 = 3;
int const volatile x4 = 4;
BOOST_TEST_REF( x1 );
BOOST_TEST_CREF( x1 );
BOOST_TEST_REF( x2 );
BOOST_TEST_CREF( x2 );
BOOST_TEST_REF( x3 );
BOOST_TEST_CREF( x3 );
BOOST_TEST_REF( x4 );
BOOST_TEST_CREF( x4 );
return boost::report_errors();
}

View File

@@ -15,6 +15,7 @@
int main()
{
boost::reference_wrapper<int const> r( 1 ); // this should produce an ERROR
(void)r;
}
#else

View File

@@ -13,4 +13,5 @@
int main()
{
boost::reference_wrapper<int> r = boost::ref( 2 ); // this should produce an ERROR
(void)r;
}

View File

@@ -19,6 +19,7 @@ X const crv() { return X(); }
int main()
{
boost::reference_wrapper<X const> r = boost::ref( crv() ); // this should produce an ERROR
(void)r;
}
#else

View File

@@ -16,6 +16,7 @@
int main()
{
boost::reference_wrapper<int const> r = boost::cref( 2 ); // should fail
(void)r;
}
#else

View File

@@ -20,6 +20,7 @@ X const crv() { return X(); }
int main()
{
boost::reference_wrapper<X const> r = boost::cref( crv() ); // must fail
(void)r;
}
#else

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();
}

158
test/to_address_test.cpp Normal file
View File

@@ -0,0 +1,158 @@
/*
Copyright 2017-2018 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/pointer_traits.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
class P1 {
public:
explicit P1(T* p)
: p_(p) { }
T* operator->() const BOOST_NOEXCEPT {
return p_;
}
private:
T* p_;
};
template<class T>
class P2 {
public:
explicit P2(T* p)
: p_(p) { }
P1<T> operator->() const BOOST_NOEXCEPT {
return p_;
}
private:
P1<T> p_;
};
#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
template<class T>
class P3 {
public:
explicit P3(T* p)
: p_(p) { }
T* get() const BOOST_NOEXCEPT {
return p_;
}
private:
T* p_;
};
namespace boost {
template<class T>
struct pointer_traits<P3<T> > {
static T* to_address(const P3<T>& p) BOOST_NOEXCEPT {
return p.get();
}
};
} /* boost */
template<class T>
class P4 {
public:
explicit P4(T* p)
: p_(p) { }
T* operator->() const BOOST_NOEXCEPT {
return 0;
}
T* get() const BOOST_NOEXCEPT {
return p_;
}
private:
int* p_;
};
namespace boost {
template<class T>
struct pointer_traits<P4<T> > {
static T* to_address(const P4<T>& p) BOOST_NOEXCEPT {
return p.get();
}
};
} /* boost */
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
template<class T>
class P5 {
public:
explicit P5(T* p)
: p_(p) { }
T* get() const BOOST_NOEXCEPT {
return p_;
}
private:
T* p_;
};
namespace std {
template<class T>
struct pointer_traits<P5<T> > {
static T* to_address(const P5<T>& p) BOOST_NOEXCEPT {
return p.get();
}
};
} /* std */
template<class T>
class P6 {
public:
explicit P6(T* p)
: p_(p) { }
T* get() const BOOST_NOEXCEPT {
return p_;
}
private:
T* p_;
};
namespace boost {
template<class T>
struct pointer_traits<P6<T> > {
static T* to_address(const P6<T>& p) BOOST_NOEXCEPT {
return p.get();
}
};
} /* boost */
namespace std {
template<class T>
struct pointer_traits<P6<T> > {
static T* to_address(const P6<T>& p) BOOST_NOEXCEPT {
return 0;
}
};
} /* std */
#endif
#endif
int main()
{
int i = 0;
BOOST_TEST(boost::to_address(&i) == &i);
int* p = &i;
BOOST_TEST(boost::to_address(p) == &i);
P1<int> p1(&i);
BOOST_TEST(boost::to_address(p1) == &i);
P2<int> p2(&i);
BOOST_TEST(boost::to_address(p2) == &i);
#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
P3<int> p3(&i);
BOOST_TEST(boost::to_address(p3) == &i);
P4<int> p4(&i);
BOOST_TEST(boost::to_address(p4) == &i);
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
P5<int> p5(&i);
BOOST_TEST(boost::to_address(p5) == &i);
P6<int> p6(&i);
BOOST_TEST(boost::to_address(p6) == &i);
#endif
#endif
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