1
0
forked from boostorg/core

Compare commits

...

88 Commits

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

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

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

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

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

Lastly, changed __cxa_get_globals and _getptd-based implementations
to avoid violating strict aliasing rules. This is still formally UB
to access structure fields like we do, but this is one less reason to
cause miscompilation or compiler warnings.
2019-01-08 00:23:09 +03:00
Andrey Semashev
9f9da9dc9b Limit __cxa_uncaught_exceptions to only since libc++abi 1002 and later. 2019-01-07 13:34:52 +03:00
Andrey Semashev
cdcc50a455 Added an implementation for uncaught_exceptions for libc++abi.
This should fix compilation errors due to missing declaration of
__cxa_get_globals when compiled against libc++ on Linux.
2019-01-07 02:14:31 +03:00
Andrey Semashev
6f3e6254e7 Only declare __cxa_get_globals on MinGW gcc < 4.7, where it's needed.
This should work around differences between the function signatures on other
platforms, like FreeBSD, for example.
2019-01-06 21:29:15 +03:00
Peter Dimov
245297ab85 Add test/cmake_subdir_test 2019-01-06 04:43:47 +02:00
Andrey Semashev
2574ae8a0c Made git branch selection less obscure and more POSIX shell conforming. 2019-01-03 23:47:43 +03:00
Andrey Semashev
bbcd5b8f5c Use the actual number of logical CPUs for the number of CI build/test jobs. 2019-01-03 23:05:17 +03:00
50 changed files with 2696 additions and 95 deletions

View File

@@ -1,4 +1,4 @@
# Copyright 2016-2018 Peter Dimov
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@@ -6,7 +6,7 @@ language: cpp
sudo: false
python: "2.7"
dist: trusty
branches:
only:
@@ -99,7 +99,6 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
@@ -119,6 +118,16 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
@@ -221,6 +230,30 @@ matrix:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
- os: linux
dist: xenial
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
@@ -240,6 +273,7 @@ matrix:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: linux
compiler: clang++-libc++
@@ -248,13 +282,40 @@ matrix:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode7.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode8.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode9.4
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode10.1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
script:
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
@@ -263,6 +324,7 @@ install:
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
@@ -274,7 +336,8 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j 3 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}
- 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:

View File

@@ -1,4 +1,4 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@@ -14,37 +14,44 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
TOOLSET: msvc-14.1,clang-win
ADDRMD: 32,64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
@@ -60,11 +67,12 @@ install:
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule update --jobs 4
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core\
- cmd /c bootstrap
- b2 headers
@@ -73,4 +81,5 @@ build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j 3 libs/core/test toolset=%TOOLSET% %CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release

View File

@@ -49,7 +49,7 @@ boostbook standalone
<xsl:param>boost.root=../../../..
<xsl:param>generate.section.toc.level=1
<xsl:param>toc.max.depth=1
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/core/doc/html
<format>pdf:<xsl:param>boost.url.prefix="http://www.boost.org/doc/libs/release/libs/core/doc/html"
;
###############################################################################

149
doc/alloc_construct.qbk Normal file
View File

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

View File

@@ -39,18 +39,23 @@ criteria for inclusion is that the utility component be:
[endsect]
[include addressof.qbk]
[include alloc_construct.qbk]
[include checked_delete.qbk]
[include default_allocator.qbk]
[include demangle.qbk]
[include empty_value.qbk]
[include enable_if.qbk]
[include exchange.qbk]
[include explicit_operator_bool.qbk]
[include first_scalar.qbk]
[include ignore_unused.qbk]
[include is_same.qbk]
[include lightweight_test.qbk]
[include no_exceptions_support.qbk]
[include noinit_adaptor.qbk]
[include noncopyable.qbk]
[include null_deleter.qbk]
[include nvp.qbk]
[include pointer_traits.qbk]
[include quick_exit.qbk]
[include ref.qbk]
@@ -58,3 +63,4 @@ criteria for inclusion is that the utility component be:
[include swap.qbk]
[include typeinfo.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]

140
doc/default_allocator.qbk Normal file
View File

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

View File

@@ -111,7 +111,8 @@ public:
[section Member types]
[variablelist [[`type`][The template parameter `T`]]]
[variablelist
[[`type`][The template parameter `T`]]]
[endsect]

View File

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

91
doc/first_scalar.qbk Normal file
View File

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

View File

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

172
doc/noinit_adaptor.qbk Normal file
View File

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

108
doc/nvp.qbk Normal file
View File

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

View File

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

View File

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

47
doc/use_default.qbk Normal file
View File

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

View File

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

View File

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

View File

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

View File

@@ -71,6 +71,10 @@ public:
template<class U>
empty_value(boost::empty_init_t, const U& value)
: value_(value) { }
template<class U>
empty_value(boost::empty_init_t, U& value)
: value_(value) { }
#endif
const T& get() const BOOST_NOEXCEPT {
@@ -115,6 +119,10 @@ public:
template<class U>
empty_value(boost::empty_init_t, const U& value)
: T(value) { }
template<class U>
empty_value(boost::empty_init_t, U& value)
: T(value) { }
#endif
const T& get() const BOOST_NOEXCEPT {

View File

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

View File

@@ -22,8 +22,8 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/core/no_exceptions_support.hpp>
#include <boost/current_function.hpp>
#include <boost/config.hpp>
#include <iostream>
#include <iterator>
#include <cstdlib>
@@ -110,14 +110,14 @@ inline void throw_failed_impl(char const * excep, char const * file, int line, c
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
// the dependency we just disable the warnings.
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__clang__) && defined(__has_warning)
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-compare"
# endif
#elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
@@ -361,12 +361,12 @@ void test_all_with_impl(FormattedOutputFunction& output,
}
}
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__) && defined(__has_warning)
#if defined(__clang__) && defined(__has_warning)
# if __has_warning("-Wsign-compare")
# pragma clang diagnostic pop
# endif
#elif defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
# pragma GCC diagnostic pop
#endif
@@ -379,18 +379,20 @@ inline int report_errors()
result.done();
int errors = result.errors();
if( errors == 0 )
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< "No errors detected." << std::endl;
return 0;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
return 1;
}
// `return report_errors();` from main only supports 8 bit exit codes
return errors < 256? errors: 255;
}
} // namespace boost

View File

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

View File

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

View File

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

View File

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

View File

@@ -47,7 +47,7 @@ public:
bool operator==( typeinfo const& rhs ) const
{
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0;
@@ -65,7 +65,7 @@ public:
bool before( typeinfo const& rhs ) const
{
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0;

View File

@@ -9,7 +9,7 @@
* \author Andrey Semashev
* \date 2018-11-10
*
* \brief This header provides an `uncaught_exception` function implementation, which was introduced in C++17.
* \brief This header provides an `uncaught_exceptions` function implementation, which was introduced in C++17.
*
* The code in this file is based on the implementation by Evgeny Panasyuk:
*
@@ -46,20 +46,41 @@
#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__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
#if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
#include <cxxabi.h>
// Only GCC 4.7 declares __cxa_get_globals() in cxxabi.h, older compilers do not expose this function but it's there
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407
#include <cstring>
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
// At least on MinGW and Linux, only GCC since 4.7 declares __cxa_get_globals() in cxxabi.h. Older versions of GCC do not expose this function but it's there.
// On OpenBSD, it seems, the declaration is also missing.
// Note that at least on FreeBSD 11, cxxabi.h declares __cxa_get_globals with a different exception specification, so we can't declare the function unconditionally.
// On Linux with clang and libc++ and on OS X, there is a version of cxxabi.h from libc++abi that doesn't declare __cxa_get_globals, but provides __cxa_uncaught_exceptions.
// The function only appeared in version _LIBCPPABI_VERSION >= 1002 of the library. Unfortunately, there are linking errors about undefined reference to __cxa_uncaught_exceptions
// on Ubuntu Trusty and OS X, so we avoid using it and forward-declare __cxa_get_globals instead.
// On QNX SDP 7.0 (QCC 5.4.0), there are multiple cxxabi.h, one from glibcxx from gcc and another from libc++abi from LLVM. Which one is included will be determined by the qcc
// command line arguments (-V and/or -Y; http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.utilities/topic/q/qcc.html). The LLVM libc++abi is missing the declaration
// of __cxa_get_globals but it is also patched by QNX developers to not define _LIBCPPABI_VERSION. Older QNX SDP versions, up to and including 6.6, don't provide LLVM and libc++abi.
// See https://github.com/boostorg/core/issues/59.
#if !defined(__FreeBSD__) && \
( \
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \
defined(__OpenBSD__) || \
(defined(__QNXNTO__) && !defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || \
defined(_LIBCPPABI_VERSION) \
)
namespace __cxxabiv1 {
struct __cxa_eh_globals;
#if defined(__OpenBSD__)
extern "C" __cxa_eh_globals* __cxa_get_globals();
#else
extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __attribute__((__const__));
} // namespace __cxxabiv1
#endif // defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407
#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 {
@@ -89,10 +110,14 @@ inline unsigned int uncaught_exceptions() BOOST_NOEXCEPT
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}
return *(reinterpret_cast< const unsigned int* >(reinterpret_cast< const char* >(::abi::__cxa_get_globals()) + sizeof(void*))); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8
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}.
return *(reinterpret_cast< const unsigned int* >(static_cast< const char* >(boost::core::detail::_getptd()) + (sizeof(void*) == 8 ? 0x100 : 0x90))); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
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());

View File

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

View File

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

View File

@@ -69,13 +69,21 @@ run get_pointer_test.cpp ;
run lightweight_test_test.cpp ;
run lightweight_test_test.cpp : : : <exception-handling>off : lightweight_test_test_no_except ;
run lightweight_test_test2.cpp ;
run lightweight_test_all_eq_test.cpp ;
run lightweight_test_all_with_test.cpp ;
run lightweight_test_all_with_fail.cpp ;
run lightweight_test_lt_le_test.cpp ;
run lightweight_test_gt_ge_test.cpp ;
run lightweight_test_eq_nullptr.cpp ;
run lightweight_test_test3.cpp ;
run lightweight_test_test4.cpp ;
run lightweight_test_test5.cpp : : :
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
run-fail lightweight_test_all_eq_test.cpp ;
run-fail lightweight_test_all_with_fail.cpp ;
run-fail lightweight_test_fail.cpp ;
run-fail lightweight_test_fail2.cpp ;
@@ -90,6 +98,7 @@ run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp ;
run-fail lightweight_test_fail12.cpp ;
run-fail lightweight_test_lt_fail.cpp ;
run-fail lightweight_test_le_fail.cpp ;
run-fail lightweight_test_gt_fail.cpp ;
@@ -124,22 +133,39 @@ run to_address_test.cpp ;
run exchange_test.cpp ;
run exchange_move_test.cpp ;
run first_scalar_test.cpp ;
compile first_scalar_constexpr_test.cpp ;
run empty_value_test.cpp ;
run empty_value_size_test.cpp ;
run empty_value_final_test.cpp ;
run quick_exit_test.cpp ;
run-fail quick_exit_fail.cpp ;
compile use_default_test.cpp ;
run default_allocator_test.cpp ;
run noinit_adaptor_test.cpp ;
run alloc_construct_test.cpp ;
run alloc_construct_throws_test.cpp ;
run alloc_construct_cxx11_test.cpp ;
run nvp_test.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run uncaught_exceptions.cpp : : : <exception-handling>on ;
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
run no_exceptions_support_test.cpp ;
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,19 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/core)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

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

View File

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

View File

@@ -9,67 +9,63 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
struct empty {
operator bool() const {
return false;
int value() const {
return 1;
}
operator bool() {
return true;
int value() {
return 2;
}
};
class type {
public:
type()
: value_(false) { }
explicit type(bool value)
: value_(value) { }
operator bool() const {
return value_;
explicit type(int count)
: value_(count) { }
int value() const {
return value_ + 1;
}
int value() {
return value_ + 2;
}
private:
bool value_;
int value_;
};
void test_bool()
void test_int()
{
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());
const boost::empty_value<int> v1(boost::empty_init_t(), 7);
BOOST_TEST(v1.get() == 7);
boost::empty_value<int> v2 = boost::empty_init_t();
BOOST_TEST(v2.get() == 0);
v2 = v1;
BOOST_TEST(v2.get());
v2.get() = false;
BOOST_TEST(!v2.get());
BOOST_TEST(v2.get() == 7);
v2.get() = 8;
BOOST_TEST(v2.get() == 8);
}
void test_empty()
{
empty e;
const boost::empty_value<empty> v1(boost::empty_init_t(), e);
BOOST_TEST(!v1.get());
const boost::empty_value<empty> v1 = boost::empty_init_t();
BOOST_TEST(v1.get().value() == 1);
boost::empty_value<empty> v2;
BOOST_TEST(v2.get());
v2 = v1;
BOOST_TEST(v2.get());
v2.get() = empty();
BOOST_TEST(v2.get());
BOOST_TEST(v2.get().value() == 2);
}
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());
const boost::empty_value<type> v1(boost::empty_init_t(), 2);
BOOST_TEST(v1.get().value() == 3);
boost::empty_value<type> v2(boost::empty_init_t(), 3);
BOOST_TEST(v2.get().value() == 5);
v2 = v1;
BOOST_TEST(v2.get());
v2.get() = type();
BOOST_TEST(!v2.get());
BOOST_TEST(v2.get().value() == 4);
v2.get() = type(4);
BOOST_TEST(v2.get().value() == 6);
}
int main()
{
test_bool();
test_int();
test_empty();
test_type();
return boost::report_errors();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

46
test/nvp_test.cpp Normal file
View File

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

View File

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

View File

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

15
test/use_default_test.cpp Normal file
View File

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