forked from boostorg/core
Compare commits
65 Commits
feature/us
...
feature/te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6d72da515 | ||
|
|
f96fb31850 | ||
|
|
b414be98c9 | ||
|
|
544fd495e5 | ||
|
|
e155e13084 | ||
|
|
6e36923915 | ||
|
|
b67cce85c8 | ||
|
|
376aa7aa31 | ||
|
|
65901249d5 | ||
|
|
1c16d5ed87 | ||
|
|
27715ed01a | ||
|
|
9f2dbba2fc | ||
|
|
0159b6d8e5 | ||
|
|
0dbd5aaadd | ||
|
|
34373b0127 | ||
|
|
6a33e879dd | ||
|
|
15db54983b | ||
|
|
fa6e38a9aa | ||
|
|
38f827e092 | ||
|
|
2b102e7357 | ||
|
|
9c33851420 | ||
|
|
fb593cbbc8 | ||
|
|
032ce991fb | ||
|
|
6444de7098 | ||
|
|
d3a64554f4 | ||
|
|
a57c1e0a80 | ||
|
|
e9ff763d79 | ||
|
|
6069fea76d | ||
|
|
3ca745f400 | ||
|
|
94def8a3a6 | ||
|
|
295b72cbc0 | ||
|
|
eb86df4a04 | ||
|
|
0a6b8e667b | ||
|
|
4d08e709fe | ||
|
|
12ff209bf7 | ||
|
|
bb0ef6d41e | ||
|
|
2dd51f248b | ||
|
|
8fe9805792 | ||
|
|
6624532550 | ||
|
|
c31e23b362 | ||
|
|
690514e87c | ||
|
|
5a5d2adda0 | ||
|
|
10c01d0d56 | ||
|
|
27d8ef1286 | ||
|
|
b5c2726d1b | ||
|
|
0eecbda0b1 | ||
|
|
2a471c3417 | ||
|
|
5ca752323f | ||
|
|
13e9d3d4d9 | ||
|
|
f3cd812ccb | ||
|
|
8f2841de83 | ||
|
|
bf5778403e | ||
|
|
fc285464aa | ||
|
|
750625272f | ||
|
|
bda2b9b4b1 | ||
|
|
ac4c781cac | ||
|
|
72ca0d8664 | ||
|
|
253b07f630 | ||
|
|
e59271fdc2 | ||
|
|
bc82adcd0b | ||
|
|
868cb07578 | ||
|
|
38f71361fb | ||
|
|
6d62fb5f5e | ||
|
|
0d71f42365 | ||
|
|
080e8581d5 |
120
.travis.yml
120
.travis.yml
@@ -4,9 +4,7 @@
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
dist: trusty
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
@@ -129,27 +127,57 @@ matrix:
|
||||
- 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
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
- g++-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-10
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@@ -160,7 +188,16 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- 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
|
||||
|
||||
@@ -171,7 +208,6 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@@ -182,7 +218,6 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@@ -195,7 +230,6 @@ matrix:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
@@ -206,7 +240,6 @@ matrix:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
@@ -217,7 +250,6 @@ matrix:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
@@ -228,7 +260,7 @@ matrix:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
- llvm-toolchain-xenial-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
@@ -239,10 +271,9 @@ matrix:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-8
|
||||
- llvm-toolchain-xenial-8
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
@@ -255,18 +286,31 @@ matrix:
|
||||
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
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libstdc++-5-dev
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-10
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
@@ -276,6 +320,7 @@ matrix:
|
||||
- libc++abi-dev
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
@@ -305,14 +350,36 @@ matrix:
|
||||
osx_image: xcode10.1
|
||||
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
env: CMAKE_TEST=1
|
||||
script:
|
||||
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=core ..
|
||||
- ctest --output-on-failure -R boost_core
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
install:
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
|
||||
script:
|
||||
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- cmake ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_INSTALL_TEST=1
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="assert;config;core" -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build . --target install
|
||||
- cd ../libs/core/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
@@ -328,6 +395,7 @@ install:
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule init tools/cmake
|
||||
- git submodule update --jobs 4
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/core
|
||||
- ./bootstrap.sh
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# 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
|
||||
|
||||
# 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...3.16)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(BoostCore LANGUAGES CXX)
|
||||
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_core INTERFACE)
|
||||
add_library(Boost::core ALIAS boost_core)
|
||||
@@ -15,7 +12,20 @@ add_library(Boost::core ALIAS boost_core)
|
||||
target_include_directories(boost_core INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_core
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
)
|
||||
|
||||
if(BOOST_SUPERPROJECT_VERSION)
|
||||
|
||||
include(BoostInstall)
|
||||
boost_install(TARGETS boost_core HEADER_DIRECTORY include/)
|
||||
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -22,10 +22,17 @@ environment:
|
||||
ADDRMD: 32,64
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1,clang-win
|
||||
TOOLSET: msvc-14.1
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
|
||||
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
|
||||
243
doc/allocator_access.qbk
Normal file
243
doc/allocator_access.qbk
Normal file
@@ -0,0 +1,243 @@
|
||||
[/
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section Allocator Access]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header `<boost/core/allocator_access.hpp>` provides the class and function
|
||||
templates to simplify allocator use. It provides the same functionality as the
|
||||
C++ standard library `std::allocator_traits` but with individual templates for
|
||||
each allocator feature.
|
||||
|
||||
These facilities also simplify existing libraries by avoiding having to check
|
||||
for `BOOST_NO_CXX11_ALLOCATOR` and conditionally use `std::allocator_traits`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following example shows these utilities used in the definition of
|
||||
an allocator-aware container class:
|
||||
|
||||
```
|
||||
template<class T, class A = boost::default_allocator<T> >
|
||||
class container
|
||||
: boost::empty_value<typename boost::allocator_rebind<A, T>::type> {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef A allocator_type;
|
||||
typedef typename boost::allocator_size_type<A>::type size_type;
|
||||
typedef typename boost::allocator_difference_type<A>::type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename boost::allocator_pointer<A>::type pointer;
|
||||
typedef typename boost::allocator_const_pointer<A>::type const_pointer;
|
||||
// ...
|
||||
};
|
||||
```
|
||||
|
||||
In C++11 or above, aliases such as `boost::allocator_pointer_t<A>` can be used
|
||||
instead of `typename boost::allocator_pointer<A>::type`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct allocator_value_type;
|
||||
|
||||
template<class A>
|
||||
using allocator_value_type_t = typename allocator_value_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_pointer_t = typename allocator_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_void_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_void_pointer_t =
|
||||
typename allocator_const_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_difference_type;
|
||||
|
||||
template<class A>
|
||||
using allocator_difference_type_t =
|
||||
typename allocator_difference_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_size_type;
|
||||
|
||||
template<class A>
|
||||
using allocator_size_type_t = typename allocator_size_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_copy_assignment;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_copy_assignment_t =
|
||||
typename allocator_propagate_on_container_copy_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_move_assignment_t =
|
||||
typename allocator_propagate_on_container_move_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_swap_t =
|
||||
typename allocator_propagate_on_container_swap<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_is_always_equal;
|
||||
|
||||
template<class A>
|
||||
using allocator_is_always_equal_t =
|
||||
typename allocator_is_always_equal<A>::type;
|
||||
|
||||
template<class A, class T>
|
||||
struct allocator_rebind;
|
||||
|
||||
template<class A, class T>
|
||||
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
|
||||
|
||||
template<class A>
|
||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);
|
||||
|
||||
template<class A>
|
||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n,
|
||||
allocator_const_void_pointer_t<A> h);
|
||||
|
||||
template<class A>
|
||||
void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
||||
allocator_size_type_t<A> n);
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
void allocator_construct(A& a, T* p, Args&&... args);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_destroy(A& a, T* p);
|
||||
|
||||
template<class A>
|
||||
allocator_size_type_t<A> allocator_max_size(const A& a);
|
||||
|
||||
template<class A>
|
||||
A allocator_select_on_container_copy_construction(const A& a);
|
||||
|
||||
} // boost
|
||||
```
|
||||
|
||||
[section Types]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A> struct allocator_value_type;`]
|
||||
[The member `type` is `A::value_type`.]]
|
||||
[[`template<class A> struct allocator_pointer;`]
|
||||
[The member `type` is `A::pointer` if valid, otherwise `A::value_type*`.]]
|
||||
[[`template<class A> struct allocator_const_pointer;`]
|
||||
[The member `type` is `A::const_pointer` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::rebind<const
|
||||
allocator_value_type_t<A> >`.]]
|
||||
[[`template<class A> struct allocator_void_pointer;`]
|
||||
[The member `type` is `A::void_pointer` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::rebind<void>`.]]
|
||||
[[`template<class A> struct allocator_const_void_pointer;`]
|
||||
[The member `type` is `A::const_void_pointer` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::rebind<const void>`.]]
|
||||
[[`template<class A> struct allocator_difference_type;`]
|
||||
[The member `type` is `A::difference_type` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::difference_type`.]]
|
||||
[[`template<class A> struct allocator_size_type;`]
|
||||
[The member `type` is `A::size_type` if valid, otherwise
|
||||
`std::make_unsigned_t<allocator_difference_type_t<A> >`.]]
|
||||
[[`template<class A> struct allocator_propagate_on_container_copy_assignment;`]
|
||||
[The member `type` is `A::propagate_on_container_copy_assignment` if valid,
|
||||
otherwise `std::false_type`.]]
|
||||
[[`template<class A> struct allocator_propagate_on_container_move_assignment;`]
|
||||
[The member `type` is `A::propagate_on_container_move_assignment` if valid,
|
||||
otherwise `std::false_type`.]]
|
||||
[[`template<class A> struct allocator_propagate_on_container_swap;`]
|
||||
[The member `type` is `A::propagate_on_container_swap` if valid, otherwise
|
||||
`std::false_type`.]]
|
||||
[[`template<class A> struct allocator_is_always_equal;`]
|
||||
[The member `type` is `A::is_always_equal` if valid, otherwise
|
||||
`std::is_empty<A>::type`.]]
|
||||
[[`template<class A, class T> struct allocator_rebind;`]
|
||||
[The member `type` is `A::rebind<T>::other` if valid, otherwise `A<T, Args>`
|
||||
if this `A` is `A<U, Args>`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A>
|
||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);`]
|
||||
[Calls `a.allocate(n)`.]]
|
||||
[[`template<class A> allocator_pointer_t<A> allocator_allocate(A& a,
|
||||
allocator_size_type_t<A> n, allocator_const_void_pointer_t<A> hint);`]
|
||||
[Calls `a.allocate(n, hint)` if valid, otherwise calls `a.allocate(n)`.]]
|
||||
[[`template<class A> void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
||||
allocator_size_type_t<A> n);`]
|
||||
[Calls `a.deallocate(p, n)`.]]
|
||||
[[`template<class A, class T, class... Args>
|
||||
void allocator_construct(A& a, T*p, Args&&... args);`]
|
||||
[Calls `a.construct(p, std::forward<Args>(args)...)` if valid, otherwise calls
|
||||
`::new(static_cast<void*>(p)) T(std::forward<Args>(args)...)`.]]
|
||||
[[`template<class A, class T> void allocator_destroy(A& a, T* p);`]
|
||||
[Calls `a.destroy(p)` if valid, otherwise calls `p->~T()`.]]
|
||||
[[`template<class A> allocator_size_type_t<A> allocator_max_size(const A& a);`]
|
||||
[Returns `a.max_size()` if valid, otherwise returns
|
||||
`std::numeric_limits<allocator_size_type_t<A> >::max() /
|
||||
sizeof(A::value_type)`.]]
|
||||
[[`template<class A> A allocator_select_on_container_copy_construction(const
|
||||
A& a);`]
|
||||
[Returns `a.select_on_container_copy_construction()` if valid, otherwise
|
||||
returns `a`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Glen Fernandes implemented the allocator access utilities.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -39,6 +39,7 @@ criteria for inclusion is that the utility component be:
|
||||
[endsect]
|
||||
|
||||
[include addressof.qbk]
|
||||
[include allocator_access.qbk]
|
||||
[include alloc_construct.qbk]
|
||||
[include checked_delete.qbk]
|
||||
[include default_allocator.qbk]
|
||||
|
||||
@@ -90,13 +90,15 @@ public:
|
||||
empty_value() = default;
|
||||
|
||||
template<class... Args>
|
||||
explicit empty_value(empty_init_t, Args&&... args);
|
||||
empty_value(empty_init_t, Args&&... args);
|
||||
|
||||
const T& get() const noexcept;
|
||||
|
||||
T& get() noexcept;
|
||||
};
|
||||
|
||||
inline constexpr empty_init_t empty_init{ };
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
|
||||
@@ -43,9 +43,11 @@ When using `lightweight_test.hpp`, *do not forget* to
|
||||
#define BOOST_TEST_GE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_WITH(expr1, expr2, pred) /*unspecified*/
|
||||
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */
|
||||
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) /* unspecified */
|
||||
#define BOOST_TEST_THROWS(expr, excep) /*unspecified*/
|
||||
#define BOOST_TEST_NO_THROW(expr) /*unspecified*/
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -174,6 +176,17 @@ Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointe
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_WITH]
|
||||
|
||||
``
|
||||
BOOST_TEST_WITH(expr1, expr2, pred)
|
||||
``
|
||||
|
||||
If `pred(expr1, expr2)` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_ALL_EQ]
|
||||
|
||||
``
|
||||
@@ -209,6 +222,20 @@ nothing and `expr` is not evaluated.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_NO_THROW]
|
||||
|
||||
``
|
||||
BOOST_TEST_NO_THROW(expr)
|
||||
``
|
||||
|
||||
If `BOOST_NO_EXCEPTIONS` is *not* defined and if `expr` throws an exception,
|
||||
increases the error count and outputs a message containing the expression
|
||||
and (if possible) the exception message.
|
||||
|
||||
If `BOOST_NO_EXCEPTIONS` is defined, `expr` is evaluated.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section report_errors]
|
||||
|
||||
``
|
||||
|
||||
@@ -71,8 +71,7 @@ struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
typedef noinit_adaptor<allocator_rebind_t<A, U> > other;
|
||||
};
|
||||
|
||||
noinit_adaptor() noexcept;
|
||||
@@ -86,9 +85,6 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
void construct(U* p);
|
||||
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args);
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p);
|
||||
};
|
||||
@@ -121,7 +117,7 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
[[variablelist
|
||||
[[Requires][`A` shall be constructible from `U`.]]
|
||||
[[Effects][Initializes the `A` base class with
|
||||
`static_cast<const U&>(u)`.]]]]]]
|
||||
`static_cast<const A&>(u)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -131,11 +127,6 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
[[`template<class U> void construct(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new((void*)p) U`.]]]]]
|
||||
[[`template<class U, class V, class... Args> void construct(U* p, V&& v,
|
||||
Args&&... args);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new(void*)p) U(std::forward<V>(v),
|
||||
std::forward<Args>(args)...)`.]]]]]
|
||||
[[`template<class U> void destroy(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`p->~U()`.]]]]]]
|
||||
|
||||
@@ -125,7 +125,7 @@ template<class T>
|
||||
BOOST_FORCEINLINE T*
|
||||
addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) || \
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) || \
|
||||
BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
|
||||
return boost::detail::addrof<T>::get(o, 0);
|
||||
#else
|
||||
@@ -151,7 +151,7 @@ addressof(T (&o)[N]) BOOST_NOEXCEPT
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
template<class T, std::size_t N>
|
||||
BOOST_FORCEINLINE
|
||||
T (*addressof(T (&o)[N]) BOOST_NOEXCEPT)[N]
|
||||
|
||||
@@ -12,12 +12,11 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::destroy(a, p);
|
||||
boost::allocator_destroy(a, p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
@@ -25,26 +24,25 @@ inline void
|
||||
alloc_destroy_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
std::allocator_traits<A>::destroy(a, p + --n);
|
||||
boost::allocator_destroy(a, p + --n);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A&, T* p)
|
||||
alloc_destroy(noinit_adaptor<A>&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(A&, T* p, std::size_t n)
|
||||
alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
p[--n].~T();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -75,12 +73,11 @@ private:
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p);
|
||||
boost::allocator_construct(a, p);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
@@ -89,7 +86,7 @@ template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u, V&&... v)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u),
|
||||
boost::allocator_construct(a, p, std::forward<U>(u),
|
||||
std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
@@ -97,7 +94,7 @@ template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u));
|
||||
boost::allocator_construct(a, p, std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
@@ -105,14 +102,14 @@ template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, const U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
boost::allocator_construct(a, p, u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
boost::allocator_construct(a, p, u);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -122,7 +119,7 @@ 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);
|
||||
boost::allocator_construct(a, p + i);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
@@ -133,7 +130,7 @@ 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]);
|
||||
boost::allocator_construct(a, p + i, l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
@@ -144,17 +141,10 @@ 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);
|
||||
boost::allocator_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
|
||||
@@ -163,49 +153,6 @@ 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)
|
||||
@@ -217,29 +164,6 @@ alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
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
|
||||
|
||||
623
include/boost/core/allocator_access.hpp
Normal file
623
include/boost/core/allocator_access.hpp
Normal file
@@ -0,0 +1,623 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#if !defined(BOOST_MSVC)
|
||||
#include <limits>
|
||||
#else
|
||||
#include <memory>
|
||||
#endif
|
||||
#include <type_traits>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
struct alloc_false {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
#else
|
||||
template<class>
|
||||
struct alloc_void {
|
||||
typedef void type;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_value_type {
|
||||
typedef typename A::value_type type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_pointer {
|
||||
typedef typename A::pointer type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
struct allocator_pointer {
|
||||
typedef typename std::allocator_traits<A>::pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_pointer {
|
||||
typedef typename A::value_type* type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_pointer<A,
|
||||
typename detail::alloc_void<typename A::pointer>::type> {
|
||||
typedef typename A::pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename std::allocator_traits<A>::const_pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::template
|
||||
rebind_to<const typename A::value_type>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_pointer<A,
|
||||
typename detail::alloc_void<typename A::const_pointer>::type> {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename A::template rebind<void>::other::pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::template
|
||||
rebind_to<void>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_void_pointer<A,
|
||||
typename detail::alloc_void<typename A::void_pointer>::type> {
|
||||
typedef typename A::void_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename A::template rebind<void>::other::const_pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::template
|
||||
rebind_to<const void>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer<A,
|
||||
typename detail::alloc_void<typename A::const_void_pointer>::type> {
|
||||
typedef typename A::const_void_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_difference_type {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_difference_type {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::difference_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_difference_type<A,
|
||||
typename detail::alloc_void<typename A::difference_type>::type> {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_size_type {
|
||||
typedef typename std::make_unsigned<typename
|
||||
allocator_difference_type<A>::type>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_size_type<A,
|
||||
typename detail::alloc_void<typename A::size_type>::type> {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_copy_assignment<A,
|
||||
typename detail::alloc_void<typename
|
||||
A::propagate_on_container_copy_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_copy_assignment type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment<A,
|
||||
typename detail::alloc_void<typename
|
||||
A::propagate_on_container_move_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_move_assignment type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap<A,
|
||||
typename detail::alloc_void<typename
|
||||
A::propagate_on_container_swap>::type> {
|
||||
typedef typename A::propagate_on_container_swap type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_is_always_equal {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename std::is_empty<A>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_is_always_equal<A,
|
||||
typename detail::alloc_void<typename A::is_always_equal>::type> {
|
||||
typedef typename A::is_always_equal type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
struct allocator_rebind {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A, class T>
|
||||
struct allocator_rebind {
|
||||
typedef typename std::allocator_traits<A>::template rebind_alloc<T> type;
|
||||
};
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class>
|
||||
struct alloc_to { };
|
||||
|
||||
template<template<class, class...> class A, class T, class U, class... V>
|
||||
struct alloc_to<A<U, V...>, T> {
|
||||
typedef A<T, V...> type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T, class = void>
|
||||
struct allocator_rebind {
|
||||
typedef typename detail::alloc_to<A, T>::type type;
|
||||
};
|
||||
|
||||
template<class A, class T>
|
||||
struct allocator_rebind<A, T,
|
||||
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n)
|
||||
{
|
||||
return a.allocate(n);
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline void
|
||||
allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
|
||||
typename allocator_size_type<A>::type n)
|
||||
{
|
||||
a.deallocate(p, n);
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
typename allocator_const_void_pointer<A>::type h)
|
||||
{
|
||||
return a.allocate(n, h);
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
typename allocator_const_void_pointer<A>::type h)
|
||||
{
|
||||
return std::allocator_traits<A>::allocate(a, n, h);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class, class = void>
|
||||
struct alloc_has_allocate {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A, class N, class H>
|
||||
struct alloc_has_allocate<A, N, H,
|
||||
typename alloc_void<decltype(std::declval<A&>().allocate(std::declval<N>(),
|
||||
std::declval<H>()))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_allocate<A,
|
||||
typename allocator_size_type<A>::type,
|
||||
typename allocator_const_void_pointer<A>::type>::value,
|
||||
typename allocator_pointer<A>::type>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
typename allocator_const_void_pointer<A>::type h)
|
||||
{
|
||||
return a.allocate(n, h);
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_allocate<A,
|
||||
typename allocator_size_type<A>::type,
|
||||
typename allocator_const_void_pointer<A>::type>::value,
|
||||
typename allocator_pointer<A>::type>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
typename allocator_const_void_pointer<A>::type)
|
||||
{
|
||||
return a.allocate(n);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_construct(A&, T* p)
|
||||
{
|
||||
::new((void*)p) T();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class V, class... Args>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V&& v, Args&&... args)
|
||||
{
|
||||
::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V&& v)
|
||||
{
|
||||
::new((void*)p) T(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, const V& v)
|
||||
{
|
||||
::new((void*)p) T(v);
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V& v)
|
||||
{
|
||||
::new((void*)p) T(v);
|
||||
}
|
||||
#endif
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A, class T, class... Args>
|
||||
inline void
|
||||
allocator_construct(A& a, T* p, Args&&... args)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class, class...>
|
||||
struct alloc_has_construct {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
struct alloc_has_construct<typename alloc_void<decltype(std::declval<A
|
||||
&>().construct(std::declval<T*>(), std::declval<Args&&>()...))>::type,
|
||||
A, T, Args...> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
inline typename std::enable_if<detail::alloc_has_construct<void, A, T,
|
||||
Args...>::value>::type
|
||||
allocator_construct(A& a, T* p, Args&&... args)
|
||||
{
|
||||
a.construct(p, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
inline typename std::enable_if<!detail::alloc_has_construct<void, A, T,
|
||||
Args...>::value>::type
|
||||
allocator_construct(A&, T* p, Args&&... args)
|
||||
{
|
||||
::new((void*)p) T(std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_destroy(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::destroy(a, p);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class = void>
|
||||
struct alloc_has_destroy {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A, class T>
|
||||
struct alloc_has_destroy<A, T,
|
||||
typename alloc_void<decltype(std::declval<A
|
||||
&>().destroy(std::declval<T*>()))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A& a, T* p)
|
||||
{
|
||||
a.destroy(p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline typename allocator_size_type<A>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return a.max_size();
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
inline typename allocator_size_type<A>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return std::allocator_traits<A>::max_size(a);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class = void>
|
||||
struct alloc_has_max_size {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_has_max_size<A,
|
||||
typename alloc_void<decltype(std::declval<const
|
||||
A&>().max_size())>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return a.max_size();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A&)
|
||||
{
|
||||
return (std::numeric_limits<typename
|
||||
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline A
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
inline A
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return std::allocator_traits<A>::select_on_container_copy_construction(a);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class = void>
|
||||
struct alloc_has_soccc {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_has_soccc<A,
|
||||
typename alloc_void<decltype(std::declval<const
|
||||
A&>().select_on_container_copy_construction())>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a.select_on_container_copy_construction();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class A>
|
||||
using allocator_value_type_t = typename allocator_value_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_pointer_t = typename allocator_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_void_pointer_t =
|
||||
typename allocator_const_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_difference_type_t =
|
||||
typename allocator_difference_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_size_type_t = typename allocator_size_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_copy_assignment_t =
|
||||
typename allocator_propagate_on_container_copy_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_move_assignment_t =
|
||||
typename allocator_propagate_on_container_move_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_swap_t =
|
||||
typename allocator_propagate_on_container_swap<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_is_always_equal_t =
|
||||
typename allocator_is_always_equal<A>::type;
|
||||
|
||||
template<class A, class T>
|
||||
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -10,11 +10,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <new>
|
||||
#include <climits>
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
#define BOOST_CORE_NO_CXX11_ALLOCATOR
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -81,16 +76,9 @@ struct default_allocator {
|
||||
BOOST_CONSTEXPR default_allocator(const default_allocator<U>&)
|
||||
BOOST_NOEXCEPT { }
|
||||
|
||||
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
|
||||
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
|
||||
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
|
||||
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
|
||||
}
|
||||
#else
|
||||
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
T* allocate(std::size_t n) {
|
||||
@@ -120,7 +108,8 @@ struct default_allocator {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_CORE_NO_CXX11_ALLOCATOR)
|
||||
#if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \
|
||||
defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new(p) U(v);
|
||||
@@ -129,6 +118,7 @@ struct default_allocator {
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -59,9 +59,9 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: value_(std::forward<Args>(args)...) { }
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: value_(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
@@ -107,9 +107,9 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: T(std::forward<Args>(args)...) { }
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: T(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
@@ -139,6 +139,8 @@ public:
|
||||
|
||||
using empty_::empty_value;
|
||||
|
||||
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,12 +24,17 @@
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
# include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||
// some other stream, so allow user to configure output stream:
|
||||
#ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
@@ -48,7 +53,13 @@ public:
|
||||
: report_(false)
|
||||
, errors_(0) {
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1310)
|
||||
// disable message boxes on assert(), abort()
|
||||
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
#endif
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
// disable message boxes on iterator debugging violations
|
||||
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -83,12 +94,21 @@ inline int& test_errors()
|
||||
return test_results().errors();
|
||||
}
|
||||
|
||||
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
|
||||
inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr << "' failed in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
if( v )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr << "' failed in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void error_impl(char const * msg, char const * file, int line, char const * function)
|
||||
@@ -99,14 +119,30 @@ inline void error_impl(char const * msg, char const * file, int line, char const
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
|
||||
inline void throw_failed_impl(const char* expr, char const * excep, char const * file, int line, char const * function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
|
||||
<< file << "(" << line << "): expression '" << expr << "' did not throw exception '" << excep << "' in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void no_throw_failed_impl(const char* expr, const char* file, int line, const char* function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void no_throw_failed_impl(const char* expr, const char* what, const char* file, int line, const char* function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
|
||||
<< function << "': " << what << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
|
||||
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
|
||||
// the dependency we just disable the warnings.
|
||||
@@ -137,67 +173,111 @@ template<class T> inline const void* test_output_impl(T volatile* v) { return co
|
||||
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
||||
#endif
|
||||
|
||||
struct lw_test_eq {
|
||||
// predicates
|
||||
|
||||
struct lw_test_eq
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t == u; }
|
||||
static const char* op() { return "=="; }
|
||||
};
|
||||
|
||||
struct lw_test_ne {
|
||||
struct lw_test_ne
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t != u; }
|
||||
static const char* op() { return "!="; }
|
||||
};
|
||||
|
||||
struct lw_test_lt {
|
||||
struct lw_test_lt
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t < u; }
|
||||
static const char* op() { return "<"; }
|
||||
};
|
||||
|
||||
struct lw_test_le {
|
||||
struct lw_test_le
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t <= u; }
|
||||
static const char* op() { return "<="; }
|
||||
};
|
||||
|
||||
struct lw_test_gt {
|
||||
struct lw_test_gt
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t > u; }
|
||||
static const char* op() { return ">"; }
|
||||
};
|
||||
|
||||
struct lw_test_ge {
|
||||
struct lw_test_ge
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t >= u; }
|
||||
static const char* op() { return ">="; }
|
||||
};
|
||||
|
||||
// lwt_predicate_name
|
||||
|
||||
template<class T> char const * lwt_predicate_name( T const& )
|
||||
{
|
||||
return "~=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_eq const& )
|
||||
{
|
||||
return "==";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_ne const& )
|
||||
{
|
||||
return "!=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_lt const& )
|
||||
{
|
||||
return "<";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_le const& )
|
||||
{
|
||||
return "<=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_gt const& )
|
||||
{
|
||||
return ">";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_ge const& )
|
||||
{
|
||||
return ">=";
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class BinaryPredicate, class T, class U>
|
||||
inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function,
|
||||
T const & t, U const & u)
|
||||
{
|
||||
if( pred(t, u) )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << pred.op() << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << lwt_predicate_name(pred) << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << lwt_predicate_name(pred) << " '" << test_output_impl(u)
|
||||
<< "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
inline bool test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, char const * const t, char const * const u )
|
||||
{
|
||||
if( std::strcmp(t, u) == 0 )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -205,15 +285,17 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
|
||||
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
inline bool test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, char const * const t, char const * const u )
|
||||
{
|
||||
if( std::strcmp(t, u) != 0 )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -221,11 +303,12 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
|
||||
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2>
|
||||
void test_all_eq_impl(FormattedOutputFunction& output,
|
||||
bool test_all_eq_impl(FormattedOutputFunction& output,
|
||||
char const * file, int line, char const * function,
|
||||
InputIterator1 first_begin, InputIterator1 first_end,
|
||||
InputIterator2 second_begin, InputIterator2 second_end)
|
||||
@@ -284,16 +367,18 @@ void test_all_eq_impl(FormattedOutputFunction& output,
|
||||
if (error_count == 0)
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate>
|
||||
void test_all_with_impl(FormattedOutputFunction& output,
|
||||
bool test_all_with_impl(FormattedOutputFunction& output,
|
||||
char const * file, int line, char const * function,
|
||||
InputIterator1 first_begin, InputIterator1 first_end,
|
||||
InputIterator2 second_begin, InputIterator2 second_end,
|
||||
@@ -353,11 +438,13 @@ void test_all_with_impl(FormattedOutputFunction& output,
|
||||
if (error_count == 0)
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,11 +484,13 @@ inline int report_errors()
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
|
||||
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
|
||||
|
||||
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#define BOOST_TEST_WITH(expr1,expr2,predicate) ( ::boost::detail::test_with_impl(predicate, #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
@@ -417,22 +506,38 @@ inline int report_errors()
|
||||
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) )
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
//
|
||||
#else
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP )
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
# define BOOST_TEST_NO_THROW(EXPR) \
|
||||
try { \
|
||||
EXPR; \
|
||||
} catch (const std::exception& e) { \
|
||||
::boost::detail::no_throw_failed_impl \
|
||||
(#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} catch (...) { \
|
||||
::boost::detail::no_throw_failed_impl \
|
||||
(#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
}
|
||||
//
|
||||
#else
|
||||
# define BOOST_TEST_NO_THROW(EXPR) { EXPR; }
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
|
||||
|
||||
@@ -126,6 +126,12 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
|
||||
|
||||
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// ignoring -Wvariadic-macros with #pragma doesn't work under GCC
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
# define BOOST_RETHROW throw;
|
||||
# define BOOST_CATCH_END }
|
||||
#else
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
# define BOOST_TRY { if ("")
|
||||
# define BOOST_CATCH(x) else if (!"")
|
||||
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
@@ -8,14 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <memory>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -24,12 +17,7 @@ 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
|
||||
typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
|
||||
};
|
||||
|
||||
noinit_adaptor()
|
||||
@@ -43,39 +31,26 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
noinit_adaptor(const U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
|
||||
: A(static_cast<const U&>(u)) { }
|
||||
: A(static_cast<const A&>(u)) { }
|
||||
|
||||
template<class U>
|
||||
void construct(U* p) {
|
||||
::new((void*)p) U;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args) {
|
||||
::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class U, class V>
|
||||
void construct(U* p, V&& v) {
|
||||
::new((void*)p) U(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
void construct(U* p, V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
|
||||
@@ -13,6 +13,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <memory>
|
||||
#else
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ private:
|
||||
/**
|
||||
@cond
|
||||
*/
|
||||
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
|
||||
#if defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
|
||||
# define BOOST_REF_CONST
|
||||
#else
|
||||
# define BOOST_REF_CONST const
|
||||
|
||||
@@ -23,9 +23,12 @@
|
||||
|
||||
#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
|
||||
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
|
||||
#include <utility> // for std::swap (C++11)
|
||||
#else
|
||||
#include <algorithm> // for std::swap (C++98)
|
||||
#endif
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
namespace boost_swap_impl
|
||||
{
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
#ifndef ITERATOR_DWA122600_HPP_
|
||||
#define ITERATOR_DWA122600_HPP_
|
||||
|
||||
// This header is obsolete and will be deprecated.
|
||||
// This header is obsolete and deprecated.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<iterator>")
|
||||
|
||||
#include <iterator>
|
||||
#if defined(__SUNPRO_CC) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/no_exceptions_support.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/core/no_exceptions_support.hpp>")
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/scoped_enum.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/core/scoped_enum.hpp>")
|
||||
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
13
test/CMakeLists.txt
Normal file
13
test/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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
|
||||
|
||||
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits Boost::throw_exception)
|
||||
|
||||
endif()
|
||||
|
||||
add_subdirectory(swap)
|
||||
@@ -55,10 +55,12 @@ compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_delete.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_shift.cpp ;
|
||||
|
||||
compile ignore_unused_test.cpp : <toolset>gcc-4.8:<cxxflags>"-Wunused-variable -Wunused-local-typedefs -Werror"
|
||||
<toolset>gcc:<cxxflags>"-Wunused-variable -Werror"
|
||||
<toolset>clang:<cxxflags>"-Wunused-variable -Werror"
|
||||
<toolset>msvc:<cxxflags>"/we4100 /we4101" ;
|
||||
compile ignore_unused_test.cpp
|
||||
: <warnings>extra
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>msvc:<warnings-as-errors>on ;
|
||||
|
||||
run sp_typeinfo_test.cpp ;
|
||||
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
|
||||
|
||||
@@ -66,20 +68,31 @@ run visit_each_test.cpp ;
|
||||
|
||||
run get_pointer_test.cpp ;
|
||||
|
||||
run lightweight_test_test.cpp ;
|
||||
run lightweight_test_test.cpp : : : <exception-handling>off : lightweight_test_test_no_except ;
|
||||
run lightweight_test_test2.cpp ;
|
||||
run lightweight_test_all_with_test.cpp ;
|
||||
run lightweight_test_lt_le_test.cpp ;
|
||||
run lightweight_test_gt_ge_test.cpp ;
|
||||
run lightweight_test_eq_nullptr.cpp ;
|
||||
run lightweight_test_test3.cpp ;
|
||||
run lightweight_test_test4.cpp ;
|
||||
run lightweight_test_test5.cpp : : :
|
||||
<warnings>extra
|
||||
local pedantic-errors = <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
run lightweight_test_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_test.cpp : : :
|
||||
<exception-handling>off $(pedantic-errors) : lightweight_test_test_no_except ;
|
||||
run lightweight_test_test2.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_all_with_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_lt_le_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_gt_ge_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_eq_nullptr.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_test3.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_test4.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_test5.cpp
|
||||
: : : $(pedantic-errors)
|
||||
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
|
||||
|
||||
run-fail lightweight_test_all_eq_test.cpp ;
|
||||
@@ -97,13 +110,22 @@ 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_fail11.cpp : ;
|
||||
run-fail lightweight_test_fail12.cpp ;
|
||||
run-fail lightweight_test_fail13.cpp ;
|
||||
run-fail lightweight_test_fail14.cpp ;
|
||||
run-fail lightweight_test_lt_fail.cpp ;
|
||||
run-fail lightweight_test_le_fail.cpp ;
|
||||
run-fail lightweight_test_gt_fail.cpp ;
|
||||
run-fail lightweight_test_ge_fail.cpp ;
|
||||
|
||||
run lightweight_test_bool.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
run lightweight_test_with_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run-fail lightweight_test_with_fail.cpp ;
|
||||
|
||||
run is_same_test.cpp ;
|
||||
|
||||
run typeinfo_test.cpp ;
|
||||
@@ -112,9 +134,12 @@ run typeinfo_test.cpp : : : <rtti>off : typeinfo_test_no_rtti ;
|
||||
run iterator_test.cpp ;
|
||||
run detail_iterator_test.cpp ;
|
||||
|
||||
run demangle_test.cpp : : : <test-info>always_show_run_output ;
|
||||
run demangle_test.cpp
|
||||
: : : <test-info>always_show_run_output ;
|
||||
|
||||
run demangled_name_test.cpp
|
||||
: : : <test-info>always_show_run_output ;
|
||||
|
||||
run demangled_name_test.cpp : : : <test-info>always_show_run_output ;
|
||||
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
|
||||
|
||||
run scoped_enum.cpp ;
|
||||
@@ -145,7 +170,12 @@ run-fail quick_exit_fail.cpp ;
|
||||
|
||||
compile use_default_test.cpp ;
|
||||
|
||||
run default_allocator_test.cpp ;
|
||||
run default_allocator_test.cpp
|
||||
: : : <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
run noinit_adaptor_test.cpp ;
|
||||
run alloc_construct_test.cpp ;
|
||||
run alloc_construct_throws_test.cpp ;
|
||||
@@ -153,6 +183,24 @@ run alloc_construct_cxx11_test.cpp ;
|
||||
|
||||
run nvp_test.cpp ;
|
||||
|
||||
run allocator_value_type_test.cpp ;
|
||||
run allocator_pointer_test.cpp ;
|
||||
run allocator_const_pointer_test.cpp ;
|
||||
run allocator_void_pointer_test.cpp ;
|
||||
run allocator_const_void_pointer_test.cpp ;
|
||||
run allocator_difference_type_test.cpp ;
|
||||
run allocator_size_type_test.cpp ;
|
||||
run allocator_pocca_test.cpp ;
|
||||
run allocator_pocma_test.cpp ;
|
||||
run allocator_pocs_test.cpp ;
|
||||
run allocator_is_always_equal_test.cpp ;
|
||||
run allocator_rebind_test.cpp ;
|
||||
run allocator_allocate_test.cpp ;
|
||||
run allocator_allocate_hint_test.cpp ;
|
||||
run allocator_deallocate_test.cpp ;
|
||||
run allocator_max_size_test.cpp ;
|
||||
run allocator_soccc_test.cpp ;
|
||||
|
||||
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
|
||||
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
|
||||
@@ -161,8 +209,10 @@ run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
|
||||
|
||||
run uncaught_exceptions.cpp : : : <exception-handling>on ;
|
||||
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
|
||||
run 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 ;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
|
||||
void f0()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined( BOOST_NO_CXX11_NULLPTR )
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T> void scalar_test( T * = 0 )
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T> void scalar_test( T * = 0 )
|
||||
{
|
||||
|
||||
59
test/allocator_allocate_hint_test.cpp
Normal file
59
test/allocator_allocate_hint_test.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
A1()
|
||||
: value() { }
|
||||
T* allocate(std::size_t n, const void*) {
|
||||
value = n;
|
||||
return 0;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2()
|
||||
: value() { }
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return 0;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A2<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
31
test/allocator_allocate_test.cpp
Normal file
31
test/allocator_allocate_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return 0;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_const_pointer_test.cpp
Normal file
34
test/allocator_const_pointer_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* const_pointer;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_const_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
boost::allocator_const_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/allocator_const_void_pointer_test.cpp
Normal file
39
test/allocator_const_void_pointer_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* const_pointer;
|
||||
typedef int* const_void_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_const_void_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
|
||||
boost::allocator_const_void_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/allocator_construct_test.cpp
Normal file
46
test/allocator_construct_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1() { }
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2() { }
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(v + 1);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 5);
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A1<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 6);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
30
test/allocator_deallocate_test.cpp
Normal file
30
test/allocator_deallocate_test.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
void deallocate(T*, std::size_t n) {
|
||||
value = n;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A<int> a;
|
||||
boost::allocator_deallocate(a, 0, 5);
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
62
test/allocator_destroy_test.cpp
Normal file
62
test/allocator_destroy_test.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct S {
|
||||
static int count;
|
||||
S() {
|
||||
++count;
|
||||
}
|
||||
S(const S&) {
|
||||
++count;
|
||||
}
|
||||
~S() {
|
||||
--count;
|
||||
}
|
||||
};
|
||||
|
||||
int S::count = 0;
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1() { }
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2() { }
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
*p = U();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1<int> a;
|
||||
S s;
|
||||
boost::allocator_destroy(a, &s);
|
||||
BOOST_TEST_EQ(S::count, 0);
|
||||
::new((void*)&s) S();
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A1<int> a;
|
||||
int i = 5;
|
||||
boost::allocator_destroy(a, &i);
|
||||
BOOST_TEST_EQ(i, 0);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_difference_type_test.cpp
Normal file
34
test/allocator_difference_type_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef short difference_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
|
||||
boost::allocator_difference_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::allocator_difference_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
47
test/allocator_is_always_equal_test.cpp
Normal file
47
test/allocator_is_always_equal_test.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct A3 {
|
||||
typedef T value_type;
|
||||
typedef std::false_type is_always_equal;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct A4 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type is_always_equal;
|
||||
int value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2<int> >::type));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A3<int> >::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A4<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/allocator_max_size_test.cpp
Normal file
39
test/allocator_max_size_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef short size_type;
|
||||
A1() { }
|
||||
short max_size() const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef short size_type;
|
||||
A2() { }
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(boost::allocator_max_size(A1<int>()), 1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_LE(boost::allocator_max_size(A2<int>()),
|
||||
(std::numeric_limits<short>::max)());
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pocca_test.cpp
Normal file
34
test/allocator_pocca_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_copy_assignment;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pocma_test.cpp
Normal file
34
test/allocator_pocma_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pocs_test.cpp
Normal file
34
test/allocator_pocs_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_swap<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_swap<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pointer_test.cpp
Normal file
34
test/allocator_pointer_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
37
test/allocator_rebind_test.cpp
Normal file
37
test/allocator_rebind_test.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
template<class>
|
||||
struct rebind {
|
||||
typedef A1<int> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
|
||||
boost::allocator_rebind<A1<char>, bool>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
|
||||
boost::allocator_rebind<A2<char>, int>::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_size_type_test.cpp
Normal file
34
test/allocator_size_type_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int size_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_size_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::size_t,
|
||||
boost::allocator_size_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
41
test/allocator_soccc_test.cpp
Normal file
41
test/allocator_soccc_test.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1(int n)
|
||||
: value(n) { }
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2(int n)
|
||||
: value(n) { }
|
||||
A2 select_on_container_copy_construction() const {
|
||||
return A2(value + 1);
|
||||
}
|
||||
int value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(1, boost::
|
||||
allocator_select_on_container_copy_construction(A1<int>(1)).value);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_EQ(2, boost::
|
||||
allocator_select_on_container_copy_construction(A2<int>(1)).value);
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
22
test/allocator_value_type_test.cpp
Normal file
22
test/allocator_value_type_test.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_value_type<A<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/allocator_void_pointer_test.cpp
Normal file
39
test/allocator_void_pointer_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* pointer;
|
||||
typedef int* void_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_void_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
boost::allocator_void_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
17
test/cmake_install_test/CMakeLists.txt
Normal file
17
test/cmake_install_test/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(boost_core REQUIRED)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::core)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
@@ -2,7 +2,7 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
|
||||
@@ -173,20 +173,11 @@ void test_construct_other()
|
||||
(void)a5;
|
||||
}
|
||||
|
||||
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
|
||||
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
|
||||
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_max_size()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_HEADERS
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if_c;
|
||||
using boost::lazy_enable_if_c;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::lazy_enable_if;
|
||||
using boost::lazy_disable_if;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::is_arithmetic;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using boost::enable_if_has_type;
|
||||
using boost::enable_if_c;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/utility/explicit_operator_bool.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
63
test/lightweight_test_bool.cpp
Normal file
63
test/lightweight_test_bool.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST( BOOST_TEST( true ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST( false ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_NOT( false ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_NOT( true ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_EQ( 1, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_EQ( 1, 2 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_NE( 1, 2 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_NE( 1, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_LT( 1, 2 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_LT( 1, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_LE( 1, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_LE( 2, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_GT( 2, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_GT( 1, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_GE( 1, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_GE( 1, 2 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_CSTR_EQ( "1", "1" ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_CSTR_EQ( "1", "2" ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_CSTR_NE( "1", "2" ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_CSTR_NE( "1", "1" ) );
|
||||
|
||||
std::vector<int> v1;
|
||||
v1.push_back( 1 );
|
||||
|
||||
std::vector<int> v2;
|
||||
|
||||
BOOST_TEST( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v1.begin(), v1.end()) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v2.begin(), v2.end()) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v1.begin(), v1.end(), boost::detail::lw_test_eq()) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v2.begin(), v2.end(), boost::detail::lw_test_eq()) );
|
||||
|
||||
int const * p = 0;
|
||||
|
||||
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
|
||||
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
|
||||
|
||||
int x = 0;
|
||||
p = &x;
|
||||
|
||||
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
|
||||
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
|
||||
|
||||
return boost::report_errors() == 14? 0: 1;
|
||||
}
|
||||
@@ -8,8 +8,12 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4100 ) // nullptr_t parameter unrereferenced
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
19
test/lightweight_test_fail13.cpp
Normal file
19
test/lightweight_test_fail13.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void f()
|
||||
{
|
||||
throw 5;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NO_THROW(f());
|
||||
return boost::report_errors();
|
||||
}
|
||||
26
test/lightweight_test_fail14.cpp
Normal file
26
test/lightweight_test_fail14.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct error
|
||||
: std::exception {
|
||||
const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
|
||||
return "message";
|
||||
}
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
throw error();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NO_THROW(f());
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
|
||||
@@ -8,8 +8,14 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4702 ) // unreachable code
|
||||
# pragma warning( disable: 4530 ) // unwind without /EHsc from <ostream>
|
||||
# pragma warning( disable: 4577 ) // noexcept without /EHsc from <exception>
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <vector>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
@@ -33,6 +39,16 @@ void f( bool x )
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Waddress"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wstring-plus-int" )
|
||||
# pragma clang diagnostic ignored "-Wstring-plus-int"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 0;
|
||||
@@ -92,5 +108,9 @@ int main()
|
||||
BOOST_TEST_THROWS( f(true), X );
|
||||
BOOST_TEST_THROWS( f(false), int );
|
||||
|
||||
// BOOST_TEST_NO_THROW
|
||||
|
||||
BOOST_TEST_NO_THROW(++y);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
39
test/lightweight_test_with_fail.cpp
Normal file
39
test/lightweight_test_with_fail.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Negative test for BOOST_TEST_WITH
|
||||
//
|
||||
// Copyright 2020 Bjorn Reese
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cmath>
|
||||
|
||||
template <typename T>
|
||||
struct with_tolerance
|
||||
{
|
||||
with_tolerance( T tolerance ): tolerance( tolerance )
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()( T lhs, T rhs ) const
|
||||
{
|
||||
return std::abs( lhs - rhs ) <= tolerance;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T tolerance;
|
||||
};
|
||||
|
||||
void test_tolerance_predicate()
|
||||
{
|
||||
BOOST_TEST_WITH( 1.0, 1.0 - 1e-6, with_tolerance<double>(1e-7) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 + 1e-6, with_tolerance<double>(1e-7) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_tolerance_predicate();
|
||||
return boost::report_errors() == 2;
|
||||
}
|
||||
39
test/lightweight_test_with_test.cpp
Normal file
39
test/lightweight_test_with_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Test for BOOST_TEST_WITH
|
||||
//
|
||||
// Copyright (c) 2020 Bjorn Reese
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cmath>
|
||||
|
||||
template <typename T>
|
||||
struct with_tolerance
|
||||
{
|
||||
with_tolerance(T tolerance) : tolerance(tolerance) {}
|
||||
bool operator()(T lhs, T rhs) const
|
||||
{
|
||||
return (std::abs(lhs - rhs) <= tolerance);
|
||||
}
|
||||
|
||||
private:
|
||||
T tolerance;
|
||||
};
|
||||
|
||||
void test_tolerance_predicate()
|
||||
{
|
||||
BOOST_TEST_WITH( 1.0, 1.0, with_tolerance<double>(1e-5) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 - 1e-6, with_tolerance<double>(1e-5) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 + 1e-6, with_tolerance<double>(1e-5) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_tolerance_predicate();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
|
||||
void f0()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// see 'ref_ct_test.cpp' for compile-time part
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
namespace {
|
||||
using namespace boost;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define BOOST_ALLOW_DEPRECATED_HEADERS
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
|
||||
11
test/swap/CMakeLists.txt
Normal file
11
test/swap/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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
|
||||
|
||||
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core)
|
||||
|
||||
endif()
|
||||
@@ -7,65 +7,31 @@
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
local compile_tests =
|
||||
root_header_1.cpp
|
||||
root_header_2.cpp
|
||||
lib_header_1.cpp
|
||||
lib_header_2.cpp
|
||||
mixed_headers_1.cpp
|
||||
mixed_headers_2.cpp
|
||||
;
|
||||
compile swap_root_header_1.cpp ;
|
||||
compile swap_root_header_2.cpp ;
|
||||
compile swap_lib_header_1.cpp ;
|
||||
compile swap_lib_header_2.cpp ;
|
||||
compile swap_mixed_headers_1.cpp ;
|
||||
compile swap_mixed_headers_2.cpp ;
|
||||
|
||||
local compile_fail_tests =
|
||||
const_wrapper_fail.cpp ;
|
||||
compile-fail swap_const_wrapper_fail.cpp ;
|
||||
|
||||
local run_tests =
|
||||
primitive.cpp
|
||||
specialized_in_boost.cpp
|
||||
specialized_in_global.cpp
|
||||
specialized_in_other.cpp
|
||||
specialized_in_std.cpp
|
||||
specialized_in_boost_and_other.cpp
|
||||
std_bitset.cpp
|
||||
std_dateorder.cpp
|
||||
std_string.cpp
|
||||
std_typeinfo_ptr.cpp
|
||||
std_vector_of_boost.cpp
|
||||
std_vector_of_global.cpp
|
||||
std_vector_of_other.cpp
|
||||
no_ambiguity_in_boost.cpp
|
||||
array_of_array_of_class.cpp
|
||||
array_of_array_of_int.cpp
|
||||
array_of_class.cpp
|
||||
array_of_int.cpp
|
||||
array_of_template.cpp
|
||||
;
|
||||
|
||||
rule test_all
|
||||
{
|
||||
local all_rules ;
|
||||
local file ;
|
||||
|
||||
for file in $(compile_tests)
|
||||
{
|
||||
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
|
||||
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) ] ;
|
||||
all_rules += [ run $(file) : : : : "swap-$(test_name)" ] ;
|
||||
}
|
||||
|
||||
#ECHO All rules: $(all_rules) ;
|
||||
return $(all_rules) ;
|
||||
}
|
||||
|
||||
test-suite core/swap : [ test_all r ] ;
|
||||
run swap_primitive.cpp ;
|
||||
run swap_specialized_in_boost.cpp ;
|
||||
run swap_specialized_in_global.cpp ;
|
||||
run swap_specialized_in_other.cpp ;
|
||||
run swap_specialized_in_std.cpp ;
|
||||
run swap_specialized_in_boost_and_other.cpp ;
|
||||
run swap_std_bitset.cpp ;
|
||||
run swap_std_dateorder.cpp ;
|
||||
run swap_std_string.cpp ;
|
||||
run swap_std_typeinfo_ptr.cpp ;
|
||||
run swap_std_vector_of_boost.cpp ;
|
||||
run swap_std_vector_of_global.cpp ;
|
||||
run swap_std_vector_of_other.cpp ;
|
||||
run swap_no_ambiguity_in_boost.cpp ;
|
||||
run swap_array_of_array_of_class.cpp ;
|
||||
run swap_array_of_array_of_int.cpp ;
|
||||
run swap_array_of_class.cpp ;
|
||||
run swap_array_of_int.cpp ;
|
||||
run swap_array_of_template.cpp ;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user