mirror of
https://github.com/boostorg/core.git
synced 2025-07-29 12:27:42 +02:00
Compare commits
86 Commits
boost-1.68
...
boost-1.70
Author | SHA1 | Date | |
---|---|---|---|
4ea704e80a | |||
266076f83b | |||
8ea2ac50fe | |||
7f96d56eff | |||
dcbe62c6bf | |||
a8ef600c30 | |||
d8895bab46 | |||
a8c870e2e7 | |||
9db11ce554 | |||
3f3bba7869 | |||
61b4e1a45d | |||
b1949c0509 | |||
7d70451b49 | |||
bf932b4908 | |||
e3629dd1c1 | |||
dea6b04157 | |||
9f9da9dc9b | |||
cdcc50a455 | |||
6f3e6254e7 | |||
245297ab85 | |||
2574ae8a0c | |||
bbcd5b8f5c | |||
83ea633d09 | |||
2b60d044ac | |||
3cd1885209 | |||
9d123dc9a3 | |||
82957de970 | |||
d60775659b | |||
bade4d23e8 | |||
a5c891441c | |||
e9f986d11e | |||
5a55d9572f | |||
e98a546e89 | |||
4dc12c59bd | |||
3c9c9603ad | |||
026be7659c | |||
ada6b9e447 | |||
79e3bf7175 | |||
1d9d6f579e | |||
5ed58ee20f | |||
9dfa265b49 | |||
3aa817e8d0 | |||
4ae42efdae | |||
32ac6c5b36 | |||
13c09e805b | |||
81df44e80b | |||
944f27853b | |||
0bc795de4a | |||
d2b20486a0 | |||
88acbce1e9 | |||
0c605bf32f | |||
53772c8c73 | |||
6dd97ee415 | |||
8d4f1bb4af | |||
d56c31d688 | |||
5e08874182 | |||
56bd3784bf | |||
cf66842419 | |||
861eb5cf4c | |||
205b319b57 | |||
6f1d88d153 | |||
7f7c4c5b83 | |||
dfd5a0b8db | |||
d8c0768788 | |||
d0a9206d6a | |||
76c3538315 | |||
f2638b6d64 | |||
30c006ac82 | |||
c71eb0e479 | |||
3f7d36445d | |||
a08dda22b2 | |||
2d99acd7ec | |||
65b98db868 | |||
edcd9e2cf5 | |||
2eaba7d6d1 | |||
a05906fd44 | |||
f3782a946f | |||
f504872d89 | |||
e1f070b7b4 | |||
740f2142c5 | |||
5c10ee4517 | |||
b7ad896707 | |||
70413b0568 | |||
b8a9b2c234 | |||
e11fa9ac03 | |||
e1d50a1de2 |
145
.travis.yml
145
.travis.yml
@ -1,4 +1,4 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2016-2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@ -28,6 +28,26 @@ matrix:
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
@ -89,6 +109,26 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
@ -103,7 +143,6 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
@ -112,20 +151,9 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
@ -137,7 +165,6 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
@ -149,7 +176,6 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
@ -173,22 +199,102 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- libc++abi-dev
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- libc++abi-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode7.3
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode8.3
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode9.4
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode10.1
|
||||
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
script:
|
||||
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- cmake ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 4
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/core
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
@ -196,7 +302,8 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
|
||||
- ./b2 -j $BUILD_JOBS libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
21
CMakeLists.txt
Normal file
21
CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
# Partial (add_subdirectory only) and experimental CMake support
|
||||
# Subject to change; please do not rely on the contents of this file yet
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(BoostCore LANGUAGES CXX)
|
||||
|
||||
add_library(boost_core INTERFACE)
|
||||
add_library(Boost::core ALIAS boost_core)
|
||||
|
||||
target_include_directories(boost_core INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_core
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
)
|
@ -1,7 +1,7 @@
|
||||
Boost.Core
|
||||
==========
|
||||
|
||||
Boost.Core, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
|
||||
Boost.Core, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), is a collection of core utilities used by other Boost libraries.
|
||||
The criteria for inclusion is that the utility component be:
|
||||
|
||||
* simple,
|
||||
@ -23,10 +23,10 @@ Master | [
|
||||
* [Documentation](https://boost.org/libs/core)
|
||||
* [Report bugs](https://svn.boost.org/trac/boost/newticket?component=core;version=Boost%20Release%20Branch). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
|
||||
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
||||
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
|
||||
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).
|
||||
|
46
appveyor.yml
46
appveyor.yml
@ -17,21 +17,6 @@ environment:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
|
||||
@ -39,19 +24,46 @@ environment:
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 4
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core
|
||||
- cmd /c bootstrap
|
||||
- b2 headers
|
||||
@ -61,4 +73,4 @@ build: off
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- b2 -j 3 libs/core/test toolset=%TOOLSET% %CXXSTD%
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD%
|
||||
|
3
doc/.gitignore
vendored
Normal file
3
doc/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/html/
|
||||
/pdf/
|
||||
ref_reference.xml
|
@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2014 Glen Joseph Fernandes
|
||||
# glenfe at live dot com
|
||||
# Copyright 2014 Glen Joseph Fernandes
|
||||
# (glenjofe@gmail.com)
|
||||
#
|
||||
# Distributed under the Boost Software License,
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
|
14
doc/core.qbk
14
doc/core.qbk
@ -1,10 +1,10 @@
|
||||
[/
|
||||
Copyright (c) 2014 Glen Joseph Fernandes
|
||||
glenfe at live dot com
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[library Boost.Core
|
||||
@ -41,6 +41,7 @@ criteria for inclusion is that the utility component be:
|
||||
[include addressof.qbk]
|
||||
[include checked_delete.qbk]
|
||||
[include demangle.qbk]
|
||||
[include empty_value.qbk]
|
||||
[include enable_if.qbk]
|
||||
[include exchange.qbk]
|
||||
[include explicit_operator_bool.qbk]
|
||||
@ -51,7 +52,10 @@ criteria for inclusion is that the utility component be:
|
||||
[include noncopyable.qbk]
|
||||
[include null_deleter.qbk]
|
||||
[include pointer_traits.qbk]
|
||||
[include quick_exit.qbk]
|
||||
[include ref.qbk]
|
||||
[include scoped_enum.qbk]
|
||||
[include swap.qbk]
|
||||
[include typeinfo.qbk]
|
||||
[include uncaught_exceptions.qbk]
|
||||
[include use_default.qbk]
|
||||
|
137
doc/empty_value.qbk
Normal file
137
doc/empty_value.qbk
Normal file
@ -0,0 +1,137 @@
|
||||
[/
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:empty_value empty_value]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/empty_value.hpp> provides the class template
|
||||
`boost::empty_value` for library authors to conveniently leverage the Empty
|
||||
Base Optimization to store objects of potentially empty types.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following example shows `boost::empty_value` used to create a type that
|
||||
stores a pointer, comparer, and allocator, where the comparer and allocator
|
||||
could be empty types.
|
||||
|
||||
```
|
||||
template<class Ptr, class Compare, class Allocator>
|
||||
class storage
|
||||
: empty_value<Compare, 0>
|
||||
, empty_value<Allocator, 1> {
|
||||
public:
|
||||
storage()
|
||||
: empty_value<Compare, 0>(empty_init_t())
|
||||
, empty_value<Allocator, 1>(empty_init_t())
|
||||
, ptr_() { }
|
||||
|
||||
storage(const Compare& c, const Allocator& a)
|
||||
: empty_value<Compare, 0>(empty_init_t(), c)
|
||||
, empty_value<Allocator, 1>(empty_init_t(), a)
|
||||
, ptr_() { }
|
||||
|
||||
const Ptr& pointer() const {
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
Ptr& pointer() {
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
const Compare& compare() const {
|
||||
return empty_value<Compare, 0>::get();
|
||||
}
|
||||
|
||||
Compare& compare() {
|
||||
return empty_value<Compare, 0>::get();
|
||||
}
|
||||
|
||||
const Allocator& allocator() const {
|
||||
return empty_value<Allocator, 1>::get();
|
||||
}
|
||||
|
||||
Allocator& allocator() {
|
||||
return empty_value<Allocator, 1>::get();
|
||||
}
|
||||
|
||||
private:
|
||||
Ptr ptr_;
|
||||
};
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
struct empty_init_t { };
|
||||
|
||||
template<class T, unsigned Index = 0, bool Empty = ``/see below/``>
|
||||
class empty_value {
|
||||
public:
|
||||
typedef T type;
|
||||
|
||||
empty_value() = default;
|
||||
|
||||
template<class... Args>
|
||||
explicit empty_value(empty_init_t, Args&&... args);
|
||||
|
||||
const T& get() const noexcept;
|
||||
|
||||
T& get() noexcept;
|
||||
};
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Template parameters]
|
||||
|
||||
[variablelist
|
||||
[[`T`][The type of value to store]]
|
||||
[[`Index`][Optional: Specify to create a distinct base type]]
|
||||
[[`Empty`][Optional: Specify to force inheritance from type]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member types]
|
||||
|
||||
[variablelist [[`type`][The template parameter `T`]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Constructors]
|
||||
|
||||
[variablelist
|
||||
[[`empty_value() = default;`][Default initialize the value]]
|
||||
[[`template<class... Args> empty_value(empty_init_t, Args&&... args);`]
|
||||
[Initialize the value with `std::forward<Args>(args)...`]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member functions]
|
||||
|
||||
[variablelist
|
||||
[[`const T& get() const noexcept;`][Returns the value]]
|
||||
[[`T& get() noexcept;`][Returns the value]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
@ -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();
|
||||
}
|
||||
``
|
||||
|
40
doc/quick_exit.qbk
Normal file
40
doc/quick_exit.qbk
Normal file
@ -0,0 +1,40 @@
|
||||
[/
|
||||
Copyright 2018 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:quick_exit quick_exit]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/quick_exit.hpp>]
|
||||
|
||||
The header `<boost/core/quick_exit.hpp>` defines the function
|
||||
`void boost::quick_exit(int code)`. It calls the standard C++11 function
|
||||
[@https://en.cppreference.com/w/cpp/utility/program/quick_exit
|
||||
`std::quick_exit(code)`], if that is available, and otherwise exits the
|
||||
process via [@https://en.cppreference.com/w/cpp/utility/program/_Exit
|
||||
`std::_Exit(code)`] or equivalent.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
[[noreturn]] void quick_exit(int code) noexcept;
|
||||
}
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
52
doc/uncaught_exceptions.qbk
Normal file
52
doc/uncaught_exceptions.qbk
Normal file
@ -0,0 +1,52 @@
|
||||
[/
|
||||
/ Copyright (c) 2018 Andrey Semashev
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:uncaught_exceptions uncaught_exceptions]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Andrey Semashev
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/uncaught_exceptions.hpp>]
|
||||
|
||||
The header `<boost/core/uncaught_exceptions.hpp>` defines the `boost::core::uncaught_exceptions` function,
|
||||
which is a more portable implementation of the same named function introduced in C++17. The function
|
||||
returns the number of the currently pending exceptions. When that function returns a value greater than 0,
|
||||
throwing an exception from a destructor can terminate the program.
|
||||
|
||||
Unfortunately, the function cannot be implemented on every pre-C++17 compiler, although the most commonly
|
||||
used compilers are supported. When the compiler does not provide the necessary functionality,
|
||||
`boost::core::uncaught_exceptions` returns a non-zero value if at least one exception is pending (i.e. not
|
||||
necessarily the number of pending exceptions), and `BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED` macro
|
||||
is defined.
|
||||
|
||||
[section Example]
|
||||
``
|
||||
class my_class
|
||||
{
|
||||
private:
|
||||
const unsigned int m_exception_count;
|
||||
|
||||
public:
|
||||
my_class() : m_exception_count(boost::core::uncaught_exceptions())
|
||||
{
|
||||
}
|
||||
|
||||
~my_class() noexcept(false)
|
||||
{
|
||||
if (m_exception_count == boost::core::uncaught_exceptions())
|
||||
do_something_potentially_throwing();
|
||||
}
|
||||
};
|
||||
``
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
47
doc/use_default.qbk
Normal file
47
doc/use_default.qbk
Normal 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]
|
@ -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);
|
||||
}
|
||||
|
136
include/boost/core/empty_value.hpp
Normal file
136
include/boost/core/empty_value.hpp
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_EMPTY_VALUE_HPP
|
||||
#define BOOST_CORE_EMPTY_VALUE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700)
|
||||
#define BOOST_DETAIL_EMPTY_VALUE_BASE
|
||||
#elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1800)
|
||||
#define BOOST_DETAIL_EMPTY_VALUE_BASE
|
||||
#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1800)
|
||||
#define BOOST_DETAIL_EMPTY_VALUE_BASE
|
||||
#elif defined(BOOST_CLANG) && !defined(__CUDACC__)
|
||||
#if __has_feature(is_empty) && __has_feature(is_final)
|
||||
#define BOOST_DETAIL_EMPTY_VALUE_BASE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
struct use_empty_value_base {
|
||||
enum {
|
||||
#if defined(BOOST_DETAIL_EMPTY_VALUE_BASE)
|
||||
value = __is_empty(T) && !__is_final(T)
|
||||
#else
|
||||
value = false
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
struct empty_init_t { };
|
||||
|
||||
namespace empty_ {
|
||||
|
||||
template<class T, unsigned N = 0,
|
||||
bool E = boost::use_empty_value_base<T>::value>
|
||||
class empty_value {
|
||||
public:
|
||||
typedef T type;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
empty_value() = default;
|
||||
#else
|
||||
empty_value() { }
|
||||
#endif
|
||||
|
||||
empty_value(boost::empty_init_t)
|
||||
: value_() { }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: value_(std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
: value_(std::forward<U>(value)) { }
|
||||
#endif
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, const U& value)
|
||||
: value_(value) { }
|
||||
#endif
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
|
||||
T& get() BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
T value_;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
template<class T, unsigned N>
|
||||
class empty_value<T, N, true>
|
||||
: T {
|
||||
public:
|
||||
typedef T type;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
empty_value() = default;
|
||||
#else
|
||||
empty_value() { }
|
||||
#endif
|
||||
|
||||
empty_value(boost::empty_init_t)
|
||||
: T() { }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: T(std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
: T(std::forward<U>(value)) { }
|
||||
#endif
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, const U& value)
|
||||
: T(value) { }
|
||||
#endif
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& get() BOOST_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* empty_ */
|
||||
|
||||
using empty_::empty_value;
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
@ -19,6 +19,7 @@
|
||||
#define BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
@ -52,6 +53,8 @@
|
||||
return !this->operator! ();\
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
/*!
|
||||
* \brief The macro defines a constexpr explicit operator of conversion to \c bool
|
||||
*
|
||||
@ -65,6 +68,12 @@
|
||||
return !this->operator! ();\
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL() BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
|
||||
|
||||
#endif
|
||||
|
||||
#else // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
#if (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG)
|
||||
|
@ -14,16 +14,19 @@
|
||||
// Copyright (2) Beman Dawes 2010, 2011
|
||||
// Copyright (3) Ion Gaztanaga 2013
|
||||
//
|
||||
// Copyright 2018 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
|
||||
@ -39,29 +42,45 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct report_errors_reminder
|
||||
{
|
||||
bool called_report_errors_function;
|
||||
|
||||
report_errors_reminder() : called_report_errors_function(false) {}
|
||||
|
||||
~report_errors_reminder()
|
||||
{
|
||||
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
|
||||
class test_result {
|
||||
public:
|
||||
test_result()
|
||||
: report_(false)
|
||||
, errors_(0) {
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1310)
|
||||
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
#endif
|
||||
}
|
||||
|
||||
~test_result() {
|
||||
if (!report_) {
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "main() should return report_errors()" << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
int& errors() {
|
||||
return errors_;
|
||||
}
|
||||
|
||||
void done() {
|
||||
report_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool report_;
|
||||
int errors_;
|
||||
};
|
||||
|
||||
inline report_errors_reminder& report_errors_remind()
|
||||
inline test_result& test_results()
|
||||
{
|
||||
static report_errors_reminder r;
|
||||
return r;
|
||||
static test_result instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
inline int & test_errors()
|
||||
inline int& test_errors()
|
||||
{
|
||||
static int x = 0;
|
||||
report_errors_remind();
|
||||
return x;
|
||||
return test_results().errors();
|
||||
}
|
||||
|
||||
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
|
||||
@ -69,7 +88,7 @@ inline void test_failed_impl(char const * expr, char const * file, int line, cha
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr << "' failed in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_errors();
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void error_impl(char const * msg, char const * file, int line, char const * function)
|
||||
@ -77,7 +96,7 @@ inline void error_impl(char const * msg, char const * file, int line, char const
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): " << msg << " in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_errors();
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
|
||||
@ -85,7 +104,7 @@ inline void throw_failed_impl(char const * excep, char const * file, int line, c
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_errors();
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
|
||||
@ -118,105 +137,58 @@ template<class T> inline const void* test_output_impl(T volatile* v) { return co
|
||||
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
||||
#endif
|
||||
|
||||
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t == u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' != '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
struct lw_test_eq {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t == u; }
|
||||
static const char* op() { return "=="; }
|
||||
};
|
||||
|
||||
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t != u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " != " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' == '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
struct lw_test_ne {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t != u; }
|
||||
static const char* op() { return "!="; }
|
||||
};
|
||||
|
||||
template<class T, class U> inline void test_lt_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t < u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " < " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' >= '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
struct lw_test_lt {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t < u; }
|
||||
static const char* op() { return "<"; }
|
||||
};
|
||||
|
||||
template<class T, class U> inline void test_le_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t <= u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " <= " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' > '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
struct lw_test_le {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t <= u; }
|
||||
static const char* op() { return "<="; }
|
||||
};
|
||||
|
||||
template<class T, class U> inline void test_gt_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t > u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " > " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' <= '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
struct lw_test_gt {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t > u; }
|
||||
static const char* op() { return ">"; }
|
||||
};
|
||||
|
||||
template<class T, class U> inline void test_ge_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
struct lw_test_ge {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t >= u; }
|
||||
static const char* op() { return ">="; }
|
||||
};
|
||||
|
||||
template<class BinaryPredicate, class T, class U>
|
||||
inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function,
|
||||
T const & t, U const & u)
|
||||
{
|
||||
if( t >= u )
|
||||
if( pred(t, u) )
|
||||
{
|
||||
report_errors_remind();
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " >= " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << test_output_impl(t) << "' < '" << test_output_impl(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << pred.op() << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
|
||||
<< "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,15 +197,14 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
{
|
||||
if( std::strcmp(t, u) == 0 )
|
||||
{
|
||||
report_errors_remind();
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << t << "' != '" << u << "'" << std::endl;
|
||||
++test_errors();
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
|
||||
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,15 +213,14 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
{
|
||||
if( std::strcmp(t, u) != 0 )
|
||||
{
|
||||
report_errors_remind();
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << t << "' == '" << u << "'" << std::endl;
|
||||
++test_errors();
|
||||
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
|
||||
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,12 +283,12 @@ void test_all_eq_impl(FormattedOutputFunction& output,
|
||||
|
||||
if (error_count == 0)
|
||||
{
|
||||
boost::detail::report_errors_remind();
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++boost::detail::test_errors();
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,12 +352,12 @@ void test_all_with_impl(FormattedOutputFunction& output,
|
||||
|
||||
if (error_count == 0)
|
||||
{
|
||||
report_errors_remind();
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++test_errors();
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,10 +375,10 @@ void test_all_with_impl(FormattedOutputFunction& output,
|
||||
|
||||
inline int report_errors()
|
||||
{
|
||||
boost::detail::report_errors_remind().called_report_errors_function = true;
|
||||
|
||||
int errors = boost::detail::test_errors();
|
||||
boost::detail::test_result& result = boost::detail::test_results();
|
||||
result.done();
|
||||
|
||||
int errors = result.errors();
|
||||
if( errors == 0 )
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
@ -425,18 +395,18 @@ inline int report_errors()
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
|
||||
|
||||
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_lt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_le_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_gt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_ge_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_lt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_le(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_gt(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ge(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
@ -452,6 +422,7 @@ inline int report_errors()
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
// boost/core/lightweight_test_trait.hpp
|
||||
//
|
||||
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE
|
||||
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
//
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -31,7 +32,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
|
||||
{
|
||||
if( T::value == expected )
|
||||
{
|
||||
report_errors_remind();
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -42,7 +43,32 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
|
||||
<< "' (should have been " << ( expected? "true": "false" ) << ")"
|
||||
<< std::endl;
|
||||
|
||||
++test_errors();
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> inline bool test_trait_same_impl_( T )
|
||||
{
|
||||
return T::value;
|
||||
}
|
||||
|
||||
template<class T1, class T2> inline void test_trait_same_impl( char const * types,
|
||||
boost::core::is_same<T1, T2> same, char const * file, int line, char const * function )
|
||||
{
|
||||
if( test_trait_same_impl_( same ) )
|
||||
{
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test 'is_same<" << types << ">'"
|
||||
<< " failed in function '" << function
|
||||
<< "' ('" << boost::core::demangled_name( BOOST_CORE_TYPEID(T1) )
|
||||
<< "' != '" << boost::core::demangled_name( BOOST_CORE_TYPEID(T2) ) << "')"
|
||||
<< std::endl;
|
||||
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,5 +78,6 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
|
||||
|
||||
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP
|
||||
|
@ -20,7 +20,22 @@ namespace boost {
|
||||
|
||||
namespace noncopyable_ // protection from unintended ADL
|
||||
{
|
||||
class noncopyable
|
||||
#ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
|
||||
#define BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
|
||||
|
||||
// noncopyable derives from base_token to enable Type Traits to detect
|
||||
// whether a type derives from noncopyable without needing the definition
|
||||
// of noncopyable itself.
|
||||
//
|
||||
// The definition of base_token is macro-guarded so that Type Trais can
|
||||
// define it locally without including this header, to avoid a dependency
|
||||
// on Core.
|
||||
|
||||
struct base_token {};
|
||||
|
||||
#endif // #ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
|
||||
|
||||
class noncopyable: base_token
|
||||
{
|
||||
protected:
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
||||
|
59
include/boost/core/quick_exit.hpp
Normal file
59
include/boost/core/quick_exit.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
|
||||
#define BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/quick_exit.hpp
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
|
||||
|
||||
extern "C" _CRTIMP __cdecl __MINGW_NOTHROW void _exit (int) __MINGW_ATTRIB_NORETURN;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) && __cplusplus < 201103L
|
||||
|
||||
extern "C" _Noreturn void quick_exit(int);
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
BOOST_NORETURN void quick_exit( int code ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
::_exit( code );
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
|
||||
::_exit( code );
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
::_Exit( code );
|
||||
|
||||
#else
|
||||
|
||||
::quick_exit( code );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_QUICK_EXIT_HPP_INCLUDED
|
@ -19,7 +19,8 @@
|
||||
// Copyright (C) 2002 David Abrahams
|
||||
//
|
||||
// Copyright (C) 2014 Glen Joseph Fernandes
|
||||
// glenfe at live dot com
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2014 Agustin Berge
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
|
@ -21,13 +21,19 @@
|
||||
// avoid ambiguity when swapping objects of a Boost type that does
|
||||
// not have its own boost::swap overload.
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <utility> //for std::swap (C++11)
|
||||
#include <algorithm> //for std::swap (C++98)
|
||||
#include <cstddef> //for std::size_t
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost_swap_impl
|
||||
{
|
||||
// we can't use type_traits here
|
||||
|
||||
template<class T> struct is_const { enum _vt { value = 0 }; };
|
||||
template<class T> struct is_const<T const> { enum _vt { value = 1 }; };
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
void swap_impl(T& left, T& right)
|
||||
@ -51,7 +57,8 @@ namespace boost
|
||||
{
|
||||
template<class T1, class T2>
|
||||
BOOST_GPU_ENABLED
|
||||
void swap(T1& left, T2& right)
|
||||
typename enable_if_c< !boost_swap_impl::is_const<T1>::value && !boost_swap_impl::is_const<T2>::value >::type
|
||||
swap(T1& left, T2& right)
|
||||
{
|
||||
::boost_swap_impl::swap_impl(left, right);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <functional>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -36,26 +37,43 @@ private:
|
||||
typeinfo& operator=( typeinfo const& );
|
||||
|
||||
char const * name_;
|
||||
void (*lib_id_)();
|
||||
|
||||
public:
|
||||
|
||||
explicit typeinfo( char const * name ): name_( name )
|
||||
typeinfo( char const * name, void (*lib_id)() ): name_( name ), lib_id_( lib_id )
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==( typeinfo const& rhs ) const
|
||||
{
|
||||
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
|
||||
|
||||
return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0;
|
||||
|
||||
#else
|
||||
|
||||
return this == &rhs;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator!=( typeinfo const& rhs ) const
|
||||
{
|
||||
return this != &rhs;
|
||||
return !( *this == rhs );
|
||||
}
|
||||
|
||||
bool before( typeinfo const& rhs ) const
|
||||
{
|
||||
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
|
||||
|
||||
return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0;
|
||||
|
||||
#else
|
||||
|
||||
return std::less< typeinfo const* >()( this, &rhs );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
char const* name() const
|
||||
@ -74,7 +92,7 @@ inline char const * demangled_name( core::typeinfo const & ti )
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct core_typeid_
|
||||
template<class T> struct BOOST_SYMBOL_VISIBLE core_typeid_
|
||||
{
|
||||
static boost::core::typeinfo ti_;
|
||||
|
||||
@ -84,13 +102,11 @@ template<class T> struct core_typeid_
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(__SUNPRO_CC)
|
||||
// see #4199, the Sun Studio compiler gets confused about static initialization
|
||||
// constructor arguments. But an assignment works just fine.
|
||||
template<class T> boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name();
|
||||
#else
|
||||
template<class T> boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name());
|
||||
#endif
|
||||
BOOST_SYMBOL_VISIBLE inline void core_typeid_lib_id()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T> boost::core::typeinfo core_typeid_< T >::ti_( core_typeid_< T >::name(), &core_typeid_lib_id );
|
||||
|
||||
template<class T> struct core_typeid_< T & >: core_typeid_< T >
|
||||
{
|
||||
|
131
include/boost/core/uncaught_exceptions.hpp
Normal file
131
include/boost/core/uncaught_exceptions.hpp
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2018.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* https://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file uncaught_exceptions.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 2018-11-10
|
||||
*
|
||||
* \brief This header provides an `uncaught_exception` function implementation, which was introduced in C++17.
|
||||
*
|
||||
* The code in this file is based on the implementation by Evgeny Panasyuk:
|
||||
*
|
||||
* https://github.com/panaseleus/stack_unwinding/blob/master/boost/exception/uncaught_exception_count.hpp
|
||||
*/
|
||||
|
||||
#ifndef BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_
|
||||
#define BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_
|
||||
|
||||
#include <exception>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Visual Studio 14 supports N4152 std::uncaught_exceptions()
|
||||
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
|
||||
(defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS)
|
||||
|
||||
// cxxabi.h availability macro
|
||||
#if defined(__has_include) && (!defined(BOOST_GCC) || (__GNUC__ >= 5))
|
||||
# if __has_include(<cxxabi.h>)
|
||||
# define BOOST_CORE_HAS_CXXABI_H
|
||||
# endif
|
||||
#elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
|
||||
# define BOOST_CORE_HAS_CXXABI_H
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0.
|
||||
// Just disable it for now and fall back to std::uncaught_exception().
|
||||
#if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
#include <cxxabi.h>
|
||||
#include <cstring>
|
||||
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
|
||||
// At least on MinGW and Linux, only GCC since 4.7 declares __cxa_get_globals() in cxxabi.h. Older versions of GCC do not expose this function but it's there.
|
||||
// On OpenBSD, it seems, the declaration is also missing.
|
||||
// Note that at least on FreeBSD 11, cxxabi.h declares __cxa_get_globals with a different exception specification, so we can't declare the function unconditionally.
|
||||
// On Linux with clang and libc++ and on OS X, there is a version of cxxabi.h from libc++abi that doesn't declare __cxa_get_globals, but provides __cxa_uncaught_exceptions.
|
||||
// The function only appeared in version _LIBCPPABI_VERSION >= 1002 of the library. Unfortunately, there are linking errors about undefined reference to __cxa_uncaught_exceptions
|
||||
// on Ubuntu Trusty and OS X, so we avoid using it and forward-declare __cxa_get_globals instead.
|
||||
#if !defined(__FreeBSD__) && \
|
||||
( \
|
||||
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(_LIBCPPABI_VERSION) \
|
||||
)
|
||||
namespace __cxxabiv1 {
|
||||
struct __cxa_eh_globals;
|
||||
#if defined(__OpenBSD__)
|
||||
extern "C" __cxa_eh_globals* __cxa_get_globals();
|
||||
#else
|
||||
extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __attribute__((__const__));
|
||||
#endif
|
||||
} // namespace __cxxabiv1
|
||||
#endif
|
||||
#endif // !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
#endif // defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
#include <cstring>
|
||||
#define BOOST_CORE_HAS_GETPTD
|
||||
namespace boost {
|
||||
namespace core {
|
||||
namespace detail {
|
||||
extern "C" void* _getptd();
|
||||
} // namespace detail
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
#endif // defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
|
||||
#endif // !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS)
|
||||
|
||||
#if !defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS) && !defined(BOOST_CORE_HAS_CXA_GET_GLOBALS) && !defined(BOOST_CORE_HAS_GETPTD)
|
||||
//! This macro is defined when `uncaught_exceptions` is not guaranteed to return values greater than 1 if multiple exceptions are pending
|
||||
#define BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace core {
|
||||
|
||||
//! Returns the number of currently pending exceptions
|
||||
inline unsigned int uncaught_exceptions() BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS)
|
||||
// C++17 implementation
|
||||
return static_cast< unsigned int >(std::uncaught_exceptions());
|
||||
#elif defined(BOOST_CORE_HAS_CXA_GET_GLOBALS)
|
||||
// Tested on {clang 3.2,GCC 3.5.6,GCC 4.1.2,GCC 4.4.6,GCC 4.4.7}x{x32,x64}
|
||||
unsigned int count;
|
||||
std::memcpy(&count, reinterpret_cast< const unsigned char* >(::abi::__cxa_get_globals()) + sizeof(void*), sizeof(count)); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8
|
||||
return count;
|
||||
#elif defined(BOOST_CORE_HAS_GETPTD)
|
||||
// MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}.
|
||||
unsigned int count;
|
||||
std::memcpy(&count, static_cast< const unsigned char* >(boost::core::detail::_getptd()) + (sizeof(void*) == 8u ? 0x100 : 0x90), sizeof(count)); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
|
||||
return count;
|
||||
#else
|
||||
// Portable C++03 implementation. Does not allow to detect multiple nested exceptions.
|
||||
return static_cast< unsigned int >(std::uncaught_exception());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_CORE_HAS_CXXABI_H
|
||||
#undef BOOST_CORE_HAS_CXA_GET_GLOBALS
|
||||
#undef BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#undef BOOST_CORE_HAS_GETPTD
|
||||
|
||||
#endif // BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_
|
17
include/boost/core/use_default.hpp
Normal file
17
include/boost/core/use_default.hpp
Normal 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
|
@ -9,7 +9,7 @@
|
||||
],
|
||||
"maintainers": [
|
||||
"Peter Dimov <pdimov -at- pdimov.com>",
|
||||
"Glen Fernandes <glenfe -at- live.com>",
|
||||
"Glen Fernandes <glenjofe -at- gmail.com>",
|
||||
"Andrey Semashev <andrey.semashev -at- gmail.com>"
|
||||
],
|
||||
"description": "A collection of simple core utilities with minimal dependencies.",
|
||||
|
@ -68,15 +68,16 @@ run get_pointer_test.cpp ;
|
||||
|
||||
run lightweight_test_test.cpp ;
|
||||
run lightweight_test_test.cpp : : : <exception-handling>off : lightweight_test_test_no_except ;
|
||||
|
||||
run lightweight_test_test2.cpp ;
|
||||
run lightweight_test_all_eq_test.cpp ;
|
||||
run lightweight_test_all_with_test.cpp ;
|
||||
run lightweight_test_all_with_fail.cpp ;
|
||||
run lightweight_test_lt_le_test.cpp ;
|
||||
run lightweight_test_gt_ge_test.cpp ;
|
||||
|
||||
run lightweight_test_eq_nullptr.cpp ;
|
||||
run lightweight_test_test3.cpp ;
|
||||
run lightweight_test_test4.cpp ;
|
||||
run lightweight_test_test5.cpp ;
|
||||
|
||||
run-fail lightweight_test_fail.cpp ;
|
||||
run-fail lightweight_test_fail2.cpp ;
|
||||
@ -90,6 +91,7 @@ run-fail lightweight_test_fail8.cpp ;
|
||||
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
|
||||
run-fail lightweight_test_fail9.cpp ;
|
||||
run-fail lightweight_test_fail10.cpp ;
|
||||
run-fail lightweight_test_fail11.cpp ;
|
||||
run-fail lightweight_test_lt_fail.cpp ;
|
||||
run-fail lightweight_test_le_fail.cpp ;
|
||||
run-fail lightweight_test_gt_fail.cpp ;
|
||||
@ -124,5 +126,25 @@ run to_address_test.cpp ;
|
||||
run exchange_test.cpp ;
|
||||
run exchange_move_test.cpp ;
|
||||
|
||||
run empty_value_test.cpp ;
|
||||
run empty_value_size_test.cpp ;
|
||||
run empty_value_final_test.cpp ;
|
||||
|
||||
run quick_exit_test.cpp ;
|
||||
run-fail quick_exit_fail.cpp ;
|
||||
|
||||
compile use_default_test.cpp ;
|
||||
|
||||
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
|
||||
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
|
||||
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
|
||||
|
||||
run uncaught_exceptions.cpp : : : <exception-handling>on ;
|
||||
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
19
test/cmake_subdir_test/CMakeLists.txt
Normal file
19
test/cmake_subdir_test/CMakeLists.txt
Normal 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>)
|
62
test/empty_value_final_test.cpp
Normal file
62
test/empty_value_final_test.cpp
Normal 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
|
60
test/empty_value_size_test.cpp
Normal file
60
test/empty_value_size_test.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
#include <boost/core/empty_value.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct T1 { };
|
||||
|
||||
struct S1
|
||||
: boost::empty_value<T1, 0, true> { };
|
||||
|
||||
struct T2 {
|
||||
int value;
|
||||
};
|
||||
|
||||
struct S2
|
||||
: boost::empty_value<T1, 0, true>
|
||||
, boost::empty_value<T2, 1, true> { };
|
||||
|
||||
struct S3
|
||||
: boost::empty_value<T1, 0, false>
|
||||
, boost::empty_value<T2, 1, true> { };
|
||||
|
||||
struct T3 { };
|
||||
|
||||
struct S4
|
||||
: boost::empty_value<T1, 0, true>
|
||||
, boost::empty_value<T3, 1, true> { };
|
||||
|
||||
struct S5
|
||||
: boost::empty_value<T1, 0, false>
|
||||
, boost::empty_value<T3, 1, false> { };
|
||||
|
||||
struct S6
|
||||
: boost::empty_value<T1, 0, true>
|
||||
, boost::empty_value<T2, 1, true>
|
||||
, boost::empty_value<T3, 2, true> { };
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(sizeof(S1) == sizeof(T1));
|
||||
BOOST_TEST(sizeof(S2) == sizeof(T2));
|
||||
BOOST_TEST(sizeof(S3) > sizeof(T2));
|
||||
BOOST_TEST(sizeof(S4) == sizeof(T1));
|
||||
BOOST_TEST(sizeof(S5) > sizeof(T1));
|
||||
BOOST_TEST(sizeof(S6) == sizeof(T2));
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
72
test/empty_value_test.cpp
Normal file
72
test/empty_value_test.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/empty_value.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct empty {
|
||||
int value() const {
|
||||
return 1;
|
||||
}
|
||||
int value() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
class type {
|
||||
public:
|
||||
explicit type(int count)
|
||||
: value_(count) { }
|
||||
int value() const {
|
||||
return value_ + 1;
|
||||
}
|
||||
int value() {
|
||||
return value_ + 2;
|
||||
}
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
void test_int()
|
||||
{
|
||||
const boost::empty_value<int> v1(boost::empty_init_t(), 7);
|
||||
BOOST_TEST(v1.get() == 7);
|
||||
boost::empty_value<int> v2 = boost::empty_init_t();
|
||||
BOOST_TEST(v2.get() == 0);
|
||||
v2 = v1;
|
||||
BOOST_TEST(v2.get() == 7);
|
||||
v2.get() = 8;
|
||||
BOOST_TEST(v2.get() == 8);
|
||||
}
|
||||
|
||||
void test_empty()
|
||||
{
|
||||
const boost::empty_value<empty> v1 = boost::empty_init_t();
|
||||
BOOST_TEST(v1.get().value() == 1);
|
||||
boost::empty_value<empty> v2;
|
||||
BOOST_TEST(v2.get().value() == 2);
|
||||
}
|
||||
|
||||
void test_type()
|
||||
{
|
||||
const boost::empty_value<type> v1(boost::empty_init_t(), 2);
|
||||
BOOST_TEST(v1.get().value() == 3);
|
||||
boost::empty_value<type> v2(boost::empty_init_t(), 3);
|
||||
BOOST_TEST(v2.get().value() == 5);
|
||||
v2 = v1;
|
||||
BOOST_TEST(v2.get().value() == 4);
|
||||
v2.get() = type(4);
|
||||
BOOST_TEST(v2.get().value() == 6);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_int();
|
||||
test_empty();
|
||||
test_type();
|
||||
return boost::report_errors();
|
||||
}
|
17
test/lib_typeid.cpp
Normal file
17
test/lib_typeid.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
// Copyright 2018 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(LIB_TYPEID_DYN_LINK)
|
||||
# define EXPORT BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
# define EXPORT
|
||||
#endif
|
||||
|
||||
EXPORT boost::core::typeinfo const & get_typeid_int()
|
||||
{
|
||||
return BOOST_CORE_TYPEID( int );
|
||||
}
|
@ -120,7 +120,5 @@ int main()
|
||||
++test_cases;
|
||||
}
|
||||
|
||||
boost::report_errors();
|
||||
|
||||
return boost::detail::test_errors() != test_cases;
|
||||
return !boost::report_errors();
|
||||
}
|
||||
|
@ -101,7 +101,5 @@ int main()
|
||||
test_cases += fail_vector();
|
||||
test_cases += fail_tolerance_predicate();
|
||||
|
||||
boost::report_errors();
|
||||
|
||||
return boost::detail::test_errors() != test_cases;
|
||||
return !boost::report_errors();
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ int main()
|
||||
BOOST_TEST_EQ( p1, nullptr );
|
||||
BOOST_TEST_NE( p2, nullptr );
|
||||
|
||||
BOOST_TEST_EQ( nullptr, p1 );
|
||||
BOOST_TEST_NE( nullptr, p2 );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
14
test/lightweight_test_fail11.cpp
Normal file
14
test/lightweight_test_fail11.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(true);
|
||||
return 0;
|
||||
}
|
147
test/lightweight_test_test3.cpp
Normal file
147
test/lightweight_test_test3.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
//
|
||||
// Test for lightweight_test.hpp
|
||||
//
|
||||
// Copyright (c) 2014, 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <ostream>
|
||||
|
||||
// EQ
|
||||
|
||||
struct eq1: private boost::noncopyable {};
|
||||
struct eq2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, eq1 const& )
|
||||
{
|
||||
return os << "eq1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, eq2 const& )
|
||||
{
|
||||
return os << "eq2()";
|
||||
}
|
||||
|
||||
bool operator==( eq1 const&, eq2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// NE
|
||||
|
||||
struct ne1: private boost::noncopyable {};
|
||||
struct ne2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ne1 const& )
|
||||
{
|
||||
return os << "ne1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ne2 const& )
|
||||
{
|
||||
return os << "ne2()";
|
||||
}
|
||||
|
||||
bool operator!=( ne1 const&, ne2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// LT
|
||||
|
||||
struct lt1: private boost::noncopyable {};
|
||||
struct lt2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, lt1 const& )
|
||||
{
|
||||
return os << "lt1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, lt2 const& )
|
||||
{
|
||||
return os << "lt2()";
|
||||
}
|
||||
|
||||
bool operator<( lt1 const&, lt2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// LE
|
||||
|
||||
struct le1: private boost::noncopyable {};
|
||||
struct le2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, le1 const& )
|
||||
{
|
||||
return os << "le1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, le2 const& )
|
||||
{
|
||||
return os << "le2()";
|
||||
}
|
||||
|
||||
bool operator<=( le1 const&, le2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// GT
|
||||
|
||||
struct gt1: private boost::noncopyable {};
|
||||
struct gt2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, gt1 const& )
|
||||
{
|
||||
return os << "gt1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, gt2 const& )
|
||||
{
|
||||
return os << "gt2()";
|
||||
}
|
||||
|
||||
bool operator>( gt1 const&, gt2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// GE
|
||||
|
||||
struct ge1: private boost::noncopyable {};
|
||||
struct ge2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ge1 const& )
|
||||
{
|
||||
return os << "ge1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ge2 const& )
|
||||
{
|
||||
return os << "ge2()";
|
||||
}
|
||||
|
||||
bool operator>=( ge1 const&, ge2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( eq1(), eq2() );
|
||||
BOOST_TEST_NE( ne1(), ne2() );
|
||||
BOOST_TEST_LT( lt1(), lt2() );
|
||||
BOOST_TEST_LE( le1(), le2() );
|
||||
BOOST_TEST_GT( gt1(), gt2() );
|
||||
BOOST_TEST_GE( ge1(), ge2() );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
36
test/lightweight_test_test4.cpp
Normal file
36
test/lightweight_test_test4.cpp
Normal 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();
|
||||
}
|
37
test/lightweight_test_test5.cpp
Normal file
37
test/lightweight_test_test5.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Negative test for BOOST_TEST_TRAIT_SAME
|
||||
//
|
||||
// Copyright 2014, 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<class T1, class T2> struct Y
|
||||
{
|
||||
typedef T1 type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char[2]);
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char[]);
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char*);
|
||||
BOOST_TEST_TRAIT_SAME(void(), void(int));
|
||||
BOOST_TEST_TRAIT_SAME(void(), void(*)());
|
||||
BOOST_TEST_TRAIT_SAME(X, void);
|
||||
BOOST_TEST_TRAIT_SAME(X::type, void);
|
||||
BOOST_TEST_TRAIT_SAME(X, Y<void, void>);
|
||||
BOOST_TEST_TRAIT_SAME(X::type, Y<float, int>::type);
|
||||
BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, double>);
|
||||
|
||||
return boost::report_errors() == 10;
|
||||
}
|
17
test/quick_exit_fail.cpp
Normal file
17
test/quick_exit_fail.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
// Test for quick_exit.hpp
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
#include <boost/core/quick_exit.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::quick_exit( 1 );
|
||||
return 0;
|
||||
}
|
17
test/quick_exit_test.cpp
Normal file
17
test/quick_exit_test.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
// Test for quick_exit.hpp
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
#include <boost/core/quick_exit.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::quick_exit( 0 );
|
||||
return 1;
|
||||
}
|
@ -16,6 +16,9 @@ local compile_tests =
|
||||
mixed_headers_2.cpp
|
||||
;
|
||||
|
||||
local compile_fail_tests =
|
||||
const_wrapper_fail.cpp ;
|
||||
|
||||
local run_tests =
|
||||
primitive.cpp
|
||||
specialized_in_boost.cpp
|
||||
@ -49,6 +52,12 @@ rule test_all
|
||||
all_rules += [ compile $(file) : : "swap-$(test_name)" ] ;
|
||||
}
|
||||
|
||||
for file in $(compile_fail_tests)
|
||||
{
|
||||
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
|
||||
all_rules += [ compile-fail $(file) : : "swap-$(test_name)" ] ;
|
||||
}
|
||||
|
||||
for file in $(run_tests)
|
||||
{
|
||||
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
|
||||
|
28
test/swap/const_wrapper_fail.cpp
Normal file
28
test/swap/const_wrapper_fail.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2018 Andrzej Krzemieński
|
||||
// Copyright 2018 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/core/swap.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class T> struct Wrapper
|
||||
{
|
||||
T value;
|
||||
};
|
||||
|
||||
template<class T> inline void swap( Wrapper<T> & w, Wrapper<T> & v )
|
||||
{
|
||||
boost::swap( w, v );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::Wrapper<int> const w = { 2 };
|
||||
boost::Wrapper<int> const v = { 3 };
|
||||
|
||||
swap( w, v );
|
||||
}
|
26
test/test_lib_typeid.cpp
Normal file
26
test/test_lib_typeid.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
// Copyright 2018 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
boost::core::typeinfo const & get_typeid_int();
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::core::typeinfo const & ti = BOOST_CORE_TYPEID( int );
|
||||
boost::core::typeinfo const & tf = BOOST_CORE_TYPEID( float );
|
||||
|
||||
boost::core::typeinfo const & ti2 = get_typeid_int();
|
||||
|
||||
BOOST_TEST( ti2 == ti );
|
||||
BOOST_TEST( ti2 != tf );
|
||||
|
||||
BOOST_TEST( !ti2.before( ti ) );
|
||||
BOOST_TEST( !ti.before( ti2 ) );
|
||||
|
||||
BOOST_TEST( ti2.before( tf ) != tf.before( ti2 ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
55
test/uncaught_exceptions.cpp
Normal file
55
test/uncaught_exceptions.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2018.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* https://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file uncaught_exceptions.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 2018-11-10
|
||||
*
|
||||
* \brief This file contains tests for the uncaught_exceptions function.
|
||||
*
|
||||
* This file only contains the very basic checks of functionality that can be portably achieved
|
||||
* through C++03 std::uncaught_exception.
|
||||
*/
|
||||
|
||||
#include <boost/core/uncaught_exceptions.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct my_exception {};
|
||||
|
||||
class exception_watcher
|
||||
{
|
||||
unsigned int& m_count;
|
||||
|
||||
public:
|
||||
explicit exception_watcher(unsigned int& count) : m_count(count) {}
|
||||
~exception_watcher() { m_count = boost::core::uncaught_exceptions(); }
|
||||
};
|
||||
|
||||
// Tests for uncaught_exceptions when used in a destructor while an exception propagates
|
||||
void test_in_destructor()
|
||||
{
|
||||
const unsigned int root_count = boost::core::uncaught_exceptions();
|
||||
|
||||
unsigned int level1_count = root_count;
|
||||
try
|
||||
{
|
||||
exception_watcher watcher(level1_count);
|
||||
throw my_exception();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_TEST_NE(root_count, level1_count);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_in_destructor();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
90
test/uncaught_exceptions_np.cpp
Normal file
90
test/uncaught_exceptions_np.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2018.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* https://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file uncaught_exceptions_np.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 2018-11-10
|
||||
*
|
||||
* \brief This file contains tests for the uncaught_exceptions function.
|
||||
*
|
||||
* This file contains checks that are compiler specific and not quite portable or require C++17.
|
||||
*/
|
||||
|
||||
#include <boost/core/uncaught_exceptions.hpp>
|
||||
|
||||
#if !defined(BOOST_CORE_UNCAUGHT_EXCEPTIONS_EMULATED)
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct my_exception1 {};
|
||||
struct my_exception2 {};
|
||||
|
||||
class exception_watcher2
|
||||
{
|
||||
unsigned int& m_count;
|
||||
|
||||
public:
|
||||
explicit exception_watcher2(unsigned int& count) : m_count(count) {}
|
||||
~exception_watcher2() { m_count = boost::core::uncaught_exceptions(); }
|
||||
};
|
||||
|
||||
class exception_watcher1
|
||||
{
|
||||
unsigned int& m_count1;
|
||||
unsigned int& m_count2;
|
||||
|
||||
public:
|
||||
exception_watcher1(unsigned int& count1, unsigned int& count2) : m_count1(count1), m_count2(count2) {}
|
||||
~exception_watcher1()
|
||||
{
|
||||
m_count1 = boost::core::uncaught_exceptions();
|
||||
try
|
||||
{
|
||||
exception_watcher2 watcher2(m_count2);
|
||||
throw my_exception2();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Tests for uncaught_exceptions when used in nested destructors while an exception propagates
|
||||
void test_in_nested_destructors()
|
||||
{
|
||||
const unsigned int root_count = boost::core::uncaught_exceptions();
|
||||
|
||||
unsigned int level1_count = root_count, level2_count = root_count;
|
||||
try
|
||||
{
|
||||
exception_watcher1 watcher1(level1_count, level2_count);
|
||||
throw my_exception1();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_TEST_NE(root_count, level1_count);
|
||||
BOOST_TEST_NE(root_count, level2_count);
|
||||
BOOST_TEST_NE(level1_count, level2_count);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_in_nested_destructors();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
15
test/use_default_test.cpp
Normal file
15
test/use_default_test.cpp
Normal 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>;
|
Reference in New Issue
Block a user