forked from boostorg/core
Compare commits
119 Commits
jzmaddock-
...
feature/lw
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
295b72cbc0 | ||
|
|
0a6b8e667b | ||
|
|
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 | ||
|
|
259587da7f | ||
|
|
882a792856 | ||
|
|
130c8f2439 | ||
|
|
e38997be4d | ||
|
|
d112d23e9d | ||
|
|
e94af0d41a | ||
|
|
ac427ad64a | ||
|
|
f2644886f5 | ||
|
|
0591b1d855 | ||
|
|
7cc1047ab7 | ||
|
|
f52dec58c2 | ||
|
|
26497003f2 | ||
|
|
5fb5a3e292 | ||
|
|
7b8385afc3 | ||
|
|
106a7c0939 | ||
|
|
f2ee17fa24 | ||
|
|
eba08e936a | ||
|
|
7e1d028958 | ||
|
|
420dff80b5 | ||
|
|
4f141646b5 | ||
|
|
29f281fe7a | ||
|
|
c96dfcec4a | ||
|
|
ca832d9384 | ||
|
|
6b65cde816 | ||
|
|
b0df75ad1c | ||
|
|
5ffce48fa1 | ||
|
|
cb154c3ac2 | ||
|
|
14fb9e4433 | ||
|
|
a90dc39e06 | ||
|
|
8f5f7f9c42 | ||
|
|
612069c7e4 | ||
|
|
f3a382c017 | ||
|
|
ce05d650dc | ||
|
|
836ae6917d | ||
|
|
a0e1100421 | ||
|
|
50491408b1 | ||
|
|
62fff4d829 | ||
|
|
151f2cf645 | ||
|
|
5a549b8b22 | ||
|
|
e859d01186 | ||
|
|
08382d184d | ||
|
|
69f7b0c76b | ||
|
|
b5c178ef0b | ||
|
|
ba79489ea1 | ||
|
|
2eaed5b9e9 | ||
|
|
9c88e5cbb1 | ||
|
|
006c159dbb | ||
|
|
c7f0fa8900 | ||
|
|
fb417474ae | ||
|
|
fc83a2e3af | ||
|
|
e023e28369 | ||
|
|
b1e0735d8f | ||
|
|
a78c25e4ab | ||
|
|
02041f6c9f | ||
|
|
f14a464b29 | ||
|
|
af7e01b8c4 | ||
|
|
40424bf0b6 | ||
|
|
8d4c039f34 | ||
|
|
e6aa65a002 | ||
|
|
bb2e7e4c69 | ||
|
|
026e0aa732 | ||
|
|
0600b49827 | ||
|
|
d9b524d2e5 | ||
|
|
8702664188 | ||
|
|
0c5cff67b6 | ||
|
|
8ac5b5b00e | ||
|
|
4ea704e80a | ||
|
|
266076f83b | ||
|
|
8ea2ac50fe | ||
|
|
7f96d56eff | ||
|
|
dcbe62c6bf | ||
|
|
a8ef600c30 | ||
|
|
d8895bab46 | ||
|
|
a8c870e2e7 | ||
|
|
9db11ce554 | ||
|
|
3f3bba7869 | ||
|
|
61b4e1a45d | ||
|
|
b1949c0509 | ||
|
|
7d70451b49 | ||
|
|
bf932b4908 | ||
|
|
e3629dd1c1 | ||
|
|
dea6b04157 | ||
|
|
9f9da9dc9b | ||
|
|
cdcc50a455 | ||
|
|
6f3e6254e7 | ||
|
|
245297ab85 | ||
|
|
2574ae8a0c | ||
|
|
bbcd5b8f5c |
154
.travis.yml
154
.travis.yml
@@ -1,12 +1,10 @@
|
||||
# Copyright 2016-2018 Peter Dimov
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
@@ -99,7 +97,6 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
@@ -120,12 +117,22 @@ 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
|
||||
compiler: g++-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@@ -134,13 +141,31 @@ matrix:
|
||||
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
|
||||
|
||||
@@ -151,7 +176,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
|
||||
|
||||
@@ -162,7 +196,6 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@@ -173,7 +206,6 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@@ -186,7 +218,6 @@ matrix:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
@@ -197,7 +228,6 @@ matrix:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
@@ -208,7 +238,6 @@ matrix:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
@@ -219,42 +248,116 @@ matrix:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
- llvm-toolchain-xenial-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libstdc++-5-dev
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- llvm-toolchain-xenial-8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- 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:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
- libc++abi-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode7.3
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode8.3
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode9.4
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode10.1
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_TEST=1
|
||||
script:
|
||||
- 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 && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
@@ -263,9 +366,11 @@ install:
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule init tools/cmake
|
||||
- git submodule update --jobs 4
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/core
|
||||
- ./bootstrap.sh
|
||||
@@ -274,7 +379,8 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
|
||||
- ./b2 -j $BUILD_JOBS libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -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()
|
||||
|
||||
38
appveyor.yml
38
appveyor.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -14,37 +14,51 @@ branches:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
# 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
|
||||
CXXSTD: 14,17
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
@@ -60,11 +74,12 @@ install:
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 4
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core\
|
||||
- cmd /c bootstrap
|
||||
- b2 headers
|
||||
|
||||
@@ -73,4 +88,5 @@ build: off
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- b2 -j 3 libs/core/test toolset=%TOOLSET% %CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
|
||||
@@ -49,7 +49,7 @@ boostbook standalone
|
||||
<xsl:param>boost.root=../../../..
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
<xsl:param>toc.max.depth=1
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/core/doc/html
|
||||
<format>pdf:<xsl:param>boost.url.prefix="http://www.boost.org/doc/libs/release/libs/core/doc/html"
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
|
||||
149
doc/alloc_construct.qbk
Normal file
149
doc/alloc_construct.qbk
Normal file
@@ -0,0 +1,149 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:alloc_construct alloc_construct, alloc_destroy]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/alloc_construct.hpp> provides function templates
|
||||
`alloc_construct`, `alloc_construct_n`, `alloc_destroy`, and `alloc_destroy_n`
|
||||
for allocator aware and exception safe construction and destruction of objects
|
||||
and arrays.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
The following example allocates storage for an array of `n` elements of `T`
|
||||
using an allocator `a` and constructs `T` elements in that storage. If any
|
||||
exception was thrown during construction of an element, the constructed
|
||||
elements are destroyed in reverse order.
|
||||
|
||||
```
|
||||
template<class A>
|
||||
auto create(A& a, std::size_t n)
|
||||
{
|
||||
auto p = a.allocate(n);
|
||||
try {
|
||||
boost::alloc_construct_n(a, boost::to_address(p), n);
|
||||
} catch (...) {
|
||||
a.deallocate(p, n);
|
||||
throw;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_destroy(A& a, T* p);
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_destroy_n(A& a, T* p, std::size_t n);
|
||||
|
||||
template<class A, class T, class Args>
|
||||
void alloc_construct(A& a, T* p, Args&&... args);
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n);
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m);
|
||||
|
||||
template<class A, class T, class I>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n, I begin);
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A, class T> void alloc_destroy(A& a, T* p);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects][`std::allocator_traits<A>::destroy(a, p)`.]]]]]
|
||||
[[`template<class A, class T> void alloc_destroy_n(A& a, T* p,
|
||||
std::size_t n);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[Destroys each `i`-th element in reverse order by calling
|
||||
`std::allocator_traits<A>::destroy(a, &p[i])`.]]]]]
|
||||
[[`template<class A, class T, class Args> void alloc_construct(A& a, T* p,
|
||||
Args&&... args);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[`std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...)`.]]]]]
|
||||
[[`template<class A, class T> void alloc_construct_n(A& a, T* p,
|
||||
std::size_t n);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`std::allocator_traits<A>::construct(a, &p[i])`.]]
|
||||
[[Remarks]
|
||||
[If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
|
||||
[[`template<class A, class T> void alloc_construct_n(A& a, T* p, std::size_t n,
|
||||
const T* l, std::size_t m);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`std::allocator_traits<A>::construct(a, &p[i], l[i % m])`.]]
|
||||
[[Remarks]
|
||||
[If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
|
||||
[[`template<class A, class T, class I> void alloc_construct_n(A& a, T* p,
|
||||
std::size_t n, I begin);`]
|
||||
[[variablelist
|
||||
[[Requires]
|
||||
[[itemized_list
|
||||
[`A` is an /Allocator/][`I` is an /InputIterator/]]]]
|
||||
[[Effects]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`std::allocator_traits<A>::construct(a, &p[i], *begin++])`.]]
|
||||
[[Remarks]
|
||||
[If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Compatibility]
|
||||
|
||||
When `BOOST_NO_CXX11_ALLOCATOR` is defined, and the C++11 allocator model is
|
||||
not supported, these functions invoke constructors and destructors directly
|
||||
without going through the supplied allocator.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Glen Fernandes originally implemented this functionality in Boost.Smart_Ptr and
|
||||
later moved these functions to Boost.Core for use in other Boost libraries,
|
||||
such as Boost.Multi_Array and Boost.Histogram.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
244
doc/allocator_access.qbk
Normal file
244
doc/allocator_access.qbk
Normal file
@@ -0,0 +1,244 @@
|
||||
[/
|
||||
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.
|
||||
|
||||
This implementation supports C++03 and above. 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> hint);
|
||||
|
||||
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, otehrwise 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,18 +39,24 @@ 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]
|
||||
[include demangle.qbk]
|
||||
[include empty_value.qbk]
|
||||
[include enable_if.qbk]
|
||||
[include exchange.qbk]
|
||||
[include explicit_operator_bool.qbk]
|
||||
[include first_scalar.qbk]
|
||||
[include ignore_unused.qbk]
|
||||
[include is_same.qbk]
|
||||
[include lightweight_test.qbk]
|
||||
[include no_exceptions_support.qbk]
|
||||
[include noinit_adaptor.qbk]
|
||||
[include noncopyable.qbk]
|
||||
[include null_deleter.qbk]
|
||||
[include nvp.qbk]
|
||||
[include pointer_traits.qbk]
|
||||
[include quick_exit.qbk]
|
||||
[include ref.qbk]
|
||||
@@ -58,3 +64,4 @@ criteria for inclusion is that the utility component be:
|
||||
[include swap.qbk]
|
||||
[include typeinfo.qbk]
|
||||
[include uncaught_exceptions.qbk]
|
||||
[include use_default.qbk]
|
||||
|
||||
140
doc/default_allocator.qbk
Normal file
140
doc/default_allocator.qbk
Normal file
@@ -0,0 +1,140 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:default_allocator default_allocator]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/default_allocator.hpp> provides the class template
|
||||
`boost::default_allocator` to serve as a minimal default allocator that:
|
||||
|
||||
* Like C++2a's `std::allocator`, does not provide members such as `construct()`
|
||||
and `destroy()` to be eligible for optimizations by allocator-aware code that
|
||||
detects the absence of these members to provide more optimal construction.
|
||||
* Supports `BOOST_NO_EXCEPTIONS` in allocation.
|
||||
* Does not have `std` as an associated namespace.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following snippet shows the use of this allocator as the default allocator
|
||||
for a container.
|
||||
|
||||
```
|
||||
template<class Key, class Compare = std::less<Key>,
|
||||
class Allocator = boost::default_allocator<Key> >
|
||||
class FlatSet;
|
||||
```
|
||||
|
||||
Facilities like `make_shared` can be implemented using `allocate_shared` with
|
||||
`default_allocator`.
|
||||
|
||||
```
|
||||
template<class T, class... Args>
|
||||
enable_if_t<!is_array_v<T>, shared_ptr<T> >
|
||||
make_shared(Args&&... args)
|
||||
{
|
||||
return allocate_shared<T>(boost::default_allocator<remove_cv_t<T> >(),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
struct default_allocator {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef std::add_lvalue_reference_t<T> reference;
|
||||
typedef std::add_lvalue_reference_t<const T> const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef ``['true_type]`` propagate_on_container_move_assignment;
|
||||
typedef ``['true_type]`` is_always_equal;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef default_allocator<U> other;
|
||||
};
|
||||
|
||||
constexpr default_allocator() = default;
|
||||
|
||||
template<class U>
|
||||
constexpr default_allocator(const default_allocator<U>&) noexcept { }
|
||||
|
||||
constexpr std::size_t max_size() const noexcept;
|
||||
T* allocate(std::size_t n);
|
||||
void deallocate(T* p, std::size_t);
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
constexpr bool operator==(const default_allocator<T>&,
|
||||
const default_allocator<U>&) noexcept;
|
||||
|
||||
template<class T, class U>
|
||||
constexpr bool operator!=(const default_allocator<T>&,
|
||||
const default_allocator<U>&) noexcept;
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Members]
|
||||
|
||||
[variablelist
|
||||
[[`constexpr std::size_t max_size() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][The largest value `N` for which the call `allocate(N)` might
|
||||
succeed.]]]]]
|
||||
[[`T* allocate(std::size_t n);`]
|
||||
[[variablelist
|
||||
[[Returns]
|
||||
[A pointer to the initial element of an array of storage of size
|
||||
`n * sizeof(T)`, aligned appropriately for objects of type `T`.]]
|
||||
[[Remarks][The storage is obtained by calling `::operator new`.]]
|
||||
[[Throws][`std::bad_alloc` if the storage cannot be obtained.]]]]]
|
||||
[[`void deallocate(T* p, std::size_t n);`]
|
||||
[[variablelist
|
||||
[[Requires]
|
||||
[`p` shall be a pointer value obtained from `allocate()`. `n` shall equal the
|
||||
value passed as the first argument to the invocation of `allocate` which
|
||||
returned `p`.]]
|
||||
[[Effects][Deallocates the storage referenced by `p`.]]
|
||||
[[Remarks][Uses `::operator delete`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Operators]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T, class U> constexpr bool operator==(const
|
||||
default_allocator<T>&, const default_allocator<U>&) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`true`.]]]]]
|
||||
[[`template<class T, class U> constexpr bool operator!=(const
|
||||
default_allocator<T>&, const default_allocator<U>&) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`false`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -97,6 +97,8 @@ public:
|
||||
T& get() noexcept;
|
||||
};
|
||||
|
||||
inline constexpr empty_init_t empty_init{ };
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
@@ -111,7 +113,8 @@ public:
|
||||
|
||||
[section Member types]
|
||||
|
||||
[variablelist [[`type`][The template parameter `T`]]]
|
||||
[variablelist
|
||||
[[`type`][The template parameter `T`]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
The header <boost/core/exchange.hpp> provides the function template
|
||||
`boost::exchange` which is an implementation of the `std::exchange`
|
||||
function introduced in C++14.
|
||||
function introduced in C++14. `boost::exchange(o, v)` replaces the
|
||||
value of `o` with `v` and returns the old value of `o`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
91
doc/first_scalar.qbk
Normal file
91
doc/first_scalar.qbk
Normal file
@@ -0,0 +1,91 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:first_scalar first_scalar]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/first_scalar.hpp> provides the function templates
|
||||
`boost::first_scalar` that can be used to obtain a pointer to the first scalar
|
||||
element of an array. Given a pointer of type `T*` they return a pointer of
|
||||
type `remove_all_extents_t<T>*`. The functions are `constexpr` and can be used
|
||||
in constant expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following function uses an allocator to allocate an array of arrays and
|
||||
constructs each scalar element in it.
|
||||
|
||||
```
|
||||
#include <boost/alloc_construct.hpp>
|
||||
#include <boost/first_scalar.hpp>
|
||||
|
||||
template<class A>
|
||||
auto create(const A& allocator)
|
||||
{
|
||||
typename std::allocator_traits<A>::template
|
||||
rebind_alloc<int[2][3]> other(allocator);
|
||||
auto ptr = other.allocate(4);
|
||||
try {
|
||||
boost::alloc_construct_n(other,
|
||||
boost::first_scalar(boost::to_address(ptr)), 24);
|
||||
} catch (...) {
|
||||
other.deallocate(ptr, 4);
|
||||
throw;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
constexpr T* first_scalar(T* p) noexcept;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr auto first_scalar(T (*p)[N]) noexcept;
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T> constexpr T* first_scalar(T* p) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`p`.]]]]]
|
||||
[[`template<class T, std::size_t N> constexpr auto first_scalar(T (*p)[N])
|
||||
noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`first_scalar(&(*p)[0])`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section History]
|
||||
|
||||
Glen Fernandes implemented `first_scalar`. Peter Dimov suggested a change for
|
||||
GCC to support an additional `constexpr` use.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -1,7 +1,7 @@
|
||||
[/
|
||||
Copyright 2010, 2011 Beman Dawes
|
||||
Copyright 2013 Ion Gaztanaga
|
||||
Copyright 2014, 2017 Peter Dimov
|
||||
Copyright 2014-2019 Peter Dimov
|
||||
Copyright 2017 Kohei Takahashi
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -253,6 +253,7 @@ return a boolean value.
|
||||
``
|
||||
#define BOOST_TEST_TRAIT_TRUE((Trait)) /*unspecified*/
|
||||
#define BOOST_TEST_TRAIT_FALSE((Trait)) /*unspecified*/
|
||||
#define BOOST_TEST_TRAIT_SAME(Type1, Type2) /*unspecified*/
|
||||
``
|
||||
|
||||
[endsect]
|
||||
@@ -280,6 +281,20 @@ message containing `Trait`. Note the double set of parentheses.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_TRAIT_SAME]
|
||||
|
||||
``
|
||||
BOOST_TEST_TRAIT_SAME(Type1, Type2)
|
||||
``
|
||||
|
||||
If the two types are not the same, increases the error count and outputs a
|
||||
message containing them. This macro requires that the compiler supports
|
||||
variadic macros and `__VA_ARGS__`. (Note that unlike `BOOST_TEST_TRAIT_TRUE`
|
||||
and `BOOST_TEST_TRAIT_FALSE`, this macro only requires a single set of
|
||||
parentheses.)
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
``
|
||||
@@ -297,6 +312,8 @@ int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE(( is_same<X<int, long>::type, int> ));
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( X<int, long>::type, int );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
``
|
||||
|
||||
172
doc/noinit_adaptor.qbk
Normal file
172
doc/noinit_adaptor.qbk
Normal file
@@ -0,0 +1,172 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:noinit_adaptor noinit_adaptor]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/noinit_adaptor.hpp> provides the class
|
||||
template `boost::noinit_adaptor` that converts any allocator into
|
||||
one whose `construct(ptr)` performs default initialization via placement new,
|
||||
and whose `destroy(ptr)` invokes `value_type` destructor directly.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following example shows use of this allocator adaptor to achieve default
|
||||
initialization of elements of a trivial type, which are later assigned values.
|
||||
|
||||
```
|
||||
#include <boost/core/noinit_adaptor.hpp>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int, boost::noinit_adaptor<std::allocator<int> > > v(5);
|
||||
std::iota(v.begin(), v.end(), 1);
|
||||
}
|
||||
```
|
||||
|
||||
The `allocate_shared_noinit` function templates are now implemented simply
|
||||
using `allocate_shared` with `noinit_adaptor`.
|
||||
|
||||
```
|
||||
template<class T, class A>
|
||||
enable_if_t<is_unbounded_array_v<T>, shared_ptr<T> >
|
||||
allocate_shared_noinit(const A& a, size_t n)
|
||||
{
|
||||
return allocate_shared<T>(boost::noinit_adapt(a), n);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
enable_if_t<!is_unbounded_array_v<T>, shared_ptr<T> >
|
||||
allocate_shared_noinit(const A& a)
|
||||
{
|
||||
return allocate_shared<T>(boost::noinit_adapt(a));
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
};
|
||||
|
||||
noinit_adaptor() noexcept;
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(U&& u) noexcept;
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(const noinit_adaptor<U>& u) noexcept;
|
||||
|
||||
template<class U>
|
||||
void construct(U* p);
|
||||
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args);
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p);
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
bool operator==(const noinit_adaptor<T>& lhs,
|
||||
const noinit_adaptor<U>& rhs) noexcept;
|
||||
|
||||
template<class T, class U>
|
||||
bool operator!=(const noinit_adaptor<T>& lhs,
|
||||
const noinit_adaptor<U>& rhs) noexcept;
|
||||
|
||||
template<class A>
|
||||
noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Constructors]
|
||||
|
||||
[variablelist
|
||||
[[`noinit_adaptor() noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects][Value initializes the A base class.]]]]]
|
||||
[[`template<class U> noinit_adaptor(U&& u) noexcept;`]
|
||||
[[variablelist
|
||||
[[Requires][`A` shall be constructible from `U`.]]
|
||||
[[Effects][Initializes the `A` base class with `std::forward<U>(u)`.]]]]]
|
||||
[[`template<class U> noinit_adaptor(const noinit_adaptor<U>& u) noexcept;`]
|
||||
[[variablelist
|
||||
[[Requires][`A` shall be constructible from `U`.]]
|
||||
[[Effects][Initializes the `A` base class with
|
||||
`static_cast<const U&>(u)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class U> void construct(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new((void*)p) U`.]]]]]
|
||||
[[`template<class U, class V, class... Args> void construct(U* p, V&& v,
|
||||
Args&&... args);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new(void*)p) U(std::forward<V>(v),
|
||||
std::forward<Args>(args)...)`.]]]]]
|
||||
[[`template<class U> void destroy(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`p->~U()`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Operators]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T, class U> constexpr bool
|
||||
operator==(const noinit_adaptor<T>& lhs,
|
||||
const noinit_adaptor<U>& rhs) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`static_cast<const T&>(lhs) == static_cast<const U&>(rhs)`.]]]]]
|
||||
[[`template<class T, class U> constexpr bool
|
||||
operator!=(const noinit_adaptor<T>& lhs,
|
||||
const noinit_adaptor<U>& rhs) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`!(lhs == rhs)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Free functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A> noinit_adaptor<A> noinit_adapt(const A& a) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][`noinit_adaptor<A>(a)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
108
doc/nvp.qbk
Normal file
108
doc/nvp.qbk
Normal file
@@ -0,0 +1,108 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:nvp nvp]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/nvp.hpp> provides the class template `boost::nvp` that
|
||||
pairs a name (`const char*`) with the address of a value (`T*`). It is the new
|
||||
implementation of the NVP type previously provided by the Boost Serialization
|
||||
library. This type now lives in the Core library so that other Boost libraries
|
||||
can support named value serialization without taking a dependency on the
|
||||
Serialization library.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following snippet shows use in a member serialize function:
|
||||
|
||||
```
|
||||
template<class A>
|
||||
void serialize(A& archive, unsigned)
|
||||
{
|
||||
archive & boost::make_nvp("x", x_) & boost::make_nvp("y", y_);
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
class nvp {
|
||||
public:
|
||||
nvp(const char* name, T& value) noexcept;
|
||||
|
||||
const char* name() const noexcept;
|
||||
|
||||
T& value() const noexcept;
|
||||
|
||||
const T& const_value() const noexcept;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
const nvp<T> make_nvp(const char* name, T& value) noexcept;
|
||||
|
||||
} /* boost */
|
||||
|
||||
#define BOOST_NVP(object) ``['see below]``
|
||||
```
|
||||
|
||||
[section Constructors]
|
||||
|
||||
[variablelist
|
||||
[[`nvp(const char* name, T& value) noexcept;`]
|
||||
[Initializes the stored name pointer with `name` and the value pointer with
|
||||
`addressof(value)`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Members]
|
||||
|
||||
[variablelist
|
||||
[[`const char* name() const noexcept;`]
|
||||
[Returns a pointer to the name.]]
|
||||
[[`T& value() const noexcept;`]
|
||||
[Returns a reference to the value.]]
|
||||
[[`const T& const_value() const noexcept;`]
|
||||
[Returns a reference to the value.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T> const nvp<T> make_nvp(const char* name, T& value)
|
||||
noexcept;`]
|
||||
[Returns `nvp<T>(name, value)`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Macros]
|
||||
|
||||
[variablelist
|
||||
[[`#define BOOST_NVP(object) see below`]
|
||||
[Expands to `boost::make_nvp(BOOST_STRINGIZE(object), object)`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section History]
|
||||
|
||||
Robert Ramey originally implemented NVP in the Serialization library. Glen
|
||||
Fernandes implemented this new (but compatible) version in the Core library.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -109,7 +109,7 @@ namespace boost {
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||
it is `element_type&`.]]
|
||||
[[Returns] [`addressof(v)`.]]]]]]
|
||||
[[Returns][`addressof(v)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -131,9 +131,11 @@ namespace boost {
|
||||
|
||||
[variablelist
|
||||
[[`template<class T> constexpr T* to_address(T* v) noexcept;`]
|
||||
[[variablelist [[Returns] [`v`.]]]]]
|
||||
[[variablelist
|
||||
[[Returns][`v`.]]]]]
|
||||
[[`template<class T> auto to_address(const T& v) noexcept;`]
|
||||
[[variablelist [[Returns] [`pointer_traits<T>::to_address(v)` if that
|
||||
[[variablelist
|
||||
[[Returns][`pointer_traits<T>::to_address(v)` if that
|
||||
expression is well-formed, otherwise `to_address(v.operator->())`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -67,9 +67,9 @@ The enumeration can be forward declared:
|
||||
|
||||
BOOST_SCOPED_ENUM_FORWARD_DECLARE(future_errc);
|
||||
|
||||
There are however some limitations. First, the emulated scoped enum is not a C++ enum, so `is_enum< future_errc >` will be `false_type`.
|
||||
There are however some limitations. The emulated scoped enum is not a C++ enum, so `is_enum< future_errc >` will be `false_type`.
|
||||
|
||||
Second, the emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some helpers. Instead of
|
||||
The emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some helpers. Instead of
|
||||
|
||||
switch (ev)
|
||||
{
|
||||
@@ -99,10 +99,29 @@ use
|
||||
{
|
||||
};
|
||||
|
||||
Lastly, explicit conversion to the underlying type should be performed with `boost::underlying_cast` instead of `static_cast`:
|
||||
Explicit conversion to the underlying type should be performed with `boost::underlying_cast` instead of `static_cast`:
|
||||
|
||||
unsigned int val = boost::underlying_cast< unsigned int >(ev);
|
||||
|
||||
In C++03, scoped enums behave differently in case of calling an overloaded function when one overload takes a scoped enum as a parameter, and the other takes a parameter of an integral type. Consider the following code:
|
||||
|
||||
enum enum_regular { REGULAR_A, REGULAR_B };
|
||||
|
||||
BOOST_SCOPED_ENUM_DECLARE_BEGIN(enum_scoped)
|
||||
{
|
||||
a, b
|
||||
}
|
||||
BOOST_SCOPED_ENUM_DECLARE_END(enum_scoped)
|
||||
|
||||
void regular_or_int(enum_regular); // (1)
|
||||
void regular_or_int(int); // (2)
|
||||
void scoped_or_int(enum_scoped); // (3)
|
||||
void scoped_or_int(int); // (4)
|
||||
|
||||
regular_or_int(REGULAR_A); // calls (1) in C++03 and C++11
|
||||
scoped_or_int(enum_scoped::a); // calls (3) in C++11 but (4) in C++03!
|
||||
scoped_or_int(enum_scoped(enum_scoped::a)); // calls (3) in C++03 and C++11
|
||||
|
||||
Here is usage example:
|
||||
|
||||
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(algae, char)
|
||||
|
||||
47
doc/use_default.qbk
Normal file
47
doc/use_default.qbk
Normal file
@@ -0,0 +1,47 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:use_default use_default]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/use_default.hpp> provides the type `boost::use_default`
|
||||
which is used by other Boost libraries as a sentinel type in a templates to
|
||||
indicate defaults.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
```
|
||||
template<class Derived, class Base,
|
||||
class Value = boost::use_default,
|
||||
class CategoryOrTraversal = boost::use_default,
|
||||
class Reference = boost::use_default,
|
||||
class Difference = boost::use_default>
|
||||
class iterator_adaptor;
|
||||
|
||||
template<class Value>
|
||||
class node_iterator
|
||||
: public iterator_adaptor<node_iterator<Value>, Value*,
|
||||
boost::use_default, boost::forward_traversal_tag>;
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
struct use_default { };
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
245
include/boost/core/alloc_construct.hpp
Normal file
245
include/boost/core/alloc_construct.hpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP
|
||||
#define BOOST_CORE_ALLOC_CONSTRUCT_HPP
|
||||
|
||||
#include <boost/core/noinit_adaptor.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::destroy(a, p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
std::allocator_traits<A>::destroy(a, p + --n);
|
||||
}
|
||||
}
|
||||
#else
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(A&, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
p[--n].~T();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class T>
|
||||
class alloc_destroyer {
|
||||
public:
|
||||
alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT
|
||||
: a_(a),
|
||||
p_(p),
|
||||
n_(0) { }
|
||||
|
||||
~alloc_destroyer() {
|
||||
boost::alloc_destroy_n(a_, p_, n_);
|
||||
}
|
||||
|
||||
std::size_t& size() BOOST_NOEXCEPT {
|
||||
return n_;
|
||||
}
|
||||
|
||||
private:
|
||||
alloc_destroyer(const alloc_destroyer&);
|
||||
alloc_destroyer& operator=(const alloc_destroyer&);
|
||||
|
||||
A& a_;
|
||||
T* p_;
|
||||
std::size_t n_;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u, V&&... v)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u),
|
||||
std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, const U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
std::allocator_traits<A>::construct(a, p + i);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
std::allocator_traits<A>::construct(a, p + i, l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T, class I>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
|
||||
std::allocator_traits<A>::construct(a, p + i, *b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#else
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A&, T* p)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(noinit_adaptor<A>&, T* p)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, U&& u, V&&... v)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<U>(u), std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, const U& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, U& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(u);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T();
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<noinit_adaptor<A>, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T;
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T(l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T, class I>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
|
||||
::new(static_cast<void*>(p + i)) T(*b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
545
include/boost/core/allocator_access.hpp
Normal file
545
include/boost/core/allocator_access.hpp
Normal file
@@ -0,0 +1,545 @@
|
||||
/*
|
||||
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/core/pointer_traits.hpp>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <type_traits>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && \
|
||||
!defined(BOOST_NO_SFINAE_EXPR) && \
|
||||
(!defined(BOOST_MSVC) || BOOST_MSVC >= 1910)
|
||||
#define BOOST_CORE_ALLOCATOR_DETECTION
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct allocator_value_type {
|
||||
typedef typename A::value_type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class>
|
||||
struct alloc_void {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
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;
|
||||
};
|
||||
#else
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
typedef std::false_type alloc_false_type;
|
||||
#else
|
||||
struct alloc_false_type {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef detail::alloc_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;
|
||||
};
|
||||
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef detail::alloc_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;
|
||||
};
|
||||
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef detail::alloc_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;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
template<class A, class = void>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename std::is_empty<A>::type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename detail::alloc_false_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class, class>
|
||||
struct alloc_to { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class A, class T, class U, class... V>
|
||||
struct alloc_to<A<U, V...>, T> {
|
||||
typedef A<T, V...> type;
|
||||
};
|
||||
#else
|
||||
template<template<class> class A, class T, class U>
|
||||
struct alloc_to<A<U>, T> {
|
||||
typedef A<T> type;
|
||||
};
|
||||
|
||||
template<template<class, class> class A, class T, class U1, class U2>
|
||||
struct alloc_to<A<U1, U2>, T> {
|
||||
typedef A<T, U2> type;
|
||||
};
|
||||
|
||||
template<template<class, class, class> class A, class T, class U1, class U2,
|
||||
class U3>
|
||||
struct alloc_to<A<U1, U2, U3>, T> {
|
||||
typedef A<T, U2, U3> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* 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;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n)
|
||||
{
|
||||
return a.allocate(n);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<bool, class = void>
|
||||
struct alloc_if { };
|
||||
|
||||
template<class R>
|
||||
struct alloc_if<true, R> {
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
template<class T>
|
||||
T alloc_declval() BOOST_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
template<class, class = void>
|
||||
struct alloc_has_allocate {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
template<class A>
|
||||
struct alloc_has_allocate<A, typename
|
||||
alloc_void<decltype(alloc_declval<A&>().allocate(alloc_declval<typename
|
||||
boost::allocator_size_type<A>::type>(), alloc_declval<typename
|
||||
boost::allocator_const_void_pointer<A>::type>()))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename detail::alloc_if<detail::alloc_has_allocate<A>::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 detail::alloc_if<!detail::alloc_has_allocate<A>::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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class...>
|
||||
struct alloc_types { };
|
||||
#else
|
||||
template<class>
|
||||
struct alloc_types { };
|
||||
#endif
|
||||
|
||||
template<class, class, class, class = void>
|
||||
struct alloc_has_construct {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class... U>
|
||||
struct alloc_has_construct<A, T, alloc_types<U...>, typename
|
||||
alloc_void<decltype(alloc_declval<A&>().construct(alloc_declval<T*>(),
|
||||
alloc_declval<U>()...))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
struct alloc_has_construct<A, T, alloc_types<U>, typename
|
||||
alloc_void<decltype(alloc_declval<A&>().construct(alloc_declval<T*>(),
|
||||
alloc_declval<U>()))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class... Args>
|
||||
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<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 detail::alloc_if<!detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<Args...> >::value>::type
|
||||
allocator_construct(A&, T* p, Args&&... args)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<V> >::value>::type
|
||||
allocator_construct(A& a, T*p, V&& v)
|
||||
{
|
||||
a.construct(p, std::forward<V>(v));
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<V> >::value>::type
|
||||
allocator_construct(A&, T* p, V&& v)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<V> >::value>::type
|
||||
allocator_construct(A& a, T*p, const V& v)
|
||||
{
|
||||
a.construct(p, v);
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<V> >::value>::type
|
||||
allocator_construct(A&, T* p, const V& v)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(v);
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<V> >::value>::type
|
||||
allocator_construct(A& a, T*p, V& v)
|
||||
{
|
||||
a.construct(p, v);
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
|
||||
detail::alloc_types<V> >::value>::type
|
||||
allocator_construct(A&, T* p, V& v)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class = void>
|
||||
struct alloc_has_destroy {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
template<class A, class T>
|
||||
struct alloc_has_destroy<A, T, typename
|
||||
alloc_void<decltype(alloc_declval<A&>().
|
||||
destroy(alloc_declval<T*>()))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
inline typename detail::alloc_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 detail::alloc_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class, class = void>
|
||||
struct alloc_has_max_size {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
template<class A>
|
||||
struct alloc_has_max_size<A,
|
||||
typename alloc_void<decltype(alloc_declval<const
|
||||
A&>().max_size())>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename detail::alloc_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 detail::alloc_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);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class, class = void>
|
||||
struct alloc_has_soccc {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
template<class A>
|
||||
struct alloc_has_soccc<A,
|
||||
typename alloc_void<decltype(alloc_declval<const
|
||||
A&>().select_on_container_copy_construction())>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename detail::alloc_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 detail::alloc_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
#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
|
||||
@@ -7,6 +7,8 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// boost/checked_delete.hpp
|
||||
//
|
||||
@@ -26,7 +28,7 @@ namespace boost
|
||||
|
||||
// verify that types are complete for increased safety
|
||||
|
||||
template<class T> inline void checked_delete(T * x)
|
||||
template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
|
||||
{
|
||||
// intentionally complex - simplification causes regressions
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
@@ -34,7 +36,7 @@ template<class T> inline void checked_delete(T * x)
|
||||
delete x;
|
||||
}
|
||||
|
||||
template<class T> inline void checked_array_delete(T * x)
|
||||
template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
|
||||
{
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
@@ -46,7 +48,7 @@ template<class T> struct checked_deleter
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
void operator()(T * x) const
|
||||
void operator()(T * x) const BOOST_NOEXCEPT
|
||||
{
|
||||
// boost:: disables ADL
|
||||
boost::checked_delete(x);
|
||||
@@ -58,7 +60,7 @@ template<class T> struct checked_array_deleter
|
||||
typedef void result_type;
|
||||
typedef T * argument_type;
|
||||
|
||||
void operator()(T * x) const
|
||||
void operator()(T * x) const BOOST_NOEXCEPT
|
||||
{
|
||||
boost::checked_array_delete(x);
|
||||
}
|
||||
|
||||
154
include/boost/core/default_allocator.hpp
Normal file
154
include/boost/core/default_allocator.hpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_DEFAULT_ALLOCATOR_HPP
|
||||
#define BOOST_CORE_DEFAULT_ALLOCATOR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
#define BOOST_CORE_NO_CXX11_ALLOCATOR
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
BOOST_NORETURN void throw_exception(const std::exception&);
|
||||
#endif
|
||||
|
||||
namespace default_ {
|
||||
|
||||
struct true_type {
|
||||
typedef bool value_type;
|
||||
typedef true_type type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
|
||||
BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT {
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR bool operator()() const BOOST_NOEXCEPT {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct add_reference {
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct add_reference<void> {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct add_reference<const void> {
|
||||
typedef const void type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct default_allocator {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef typename add_reference<T>::type reference;
|
||||
typedef typename add_reference<const T>::type const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
typedef true_type is_always_equal;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef default_allocator<U> other;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
default_allocator() = default;
|
||||
#else
|
||||
BOOST_CONSTEXPR default_allocator() BOOST_NOEXCEPT { }
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
BOOST_CONSTEXPR default_allocator(const default_allocator<U>&)
|
||||
BOOST_NOEXCEPT { }
|
||||
|
||||
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
return std::numeric_limits<std::ptrdiff_t>::max()
|
||||
< std::numeric_limits<std::size_t>::max() / sizeof(T)
|
||||
? std::numeric_limits<std::ptrdiff_t>::max()
|
||||
: std::numeric_limits<std::size_t>::max() / sizeof(T);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
T* allocate(std::size_t n) {
|
||||
if (n > max_size()) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
return static_cast<T*>(::operator new(sizeof(T) * n));
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t) {
|
||||
::operator delete(p);
|
||||
}
|
||||
#else
|
||||
T* allocate(std::size_t n) {
|
||||
if (n > max_size()) {
|
||||
boost::throw_exception(std::bad_alloc());
|
||||
}
|
||||
void* p = ::operator new(sizeof(T) * n, std::nothrow);
|
||||
if (!p) {
|
||||
boost::throw_exception(std::bad_alloc());
|
||||
}
|
||||
return static_cast<T*>(p);
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t) {
|
||||
::operator delete(p, std::nothrow);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_CORE_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new(p) U(v);
|
||||
}
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
BOOST_CONSTEXPR inline bool
|
||||
operator==(const default_allocator<T>&,
|
||||
const default_allocator<U>&) BOOST_NOEXCEPT
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
BOOST_CONSTEXPR inline bool
|
||||
operator!=(const default_allocator<T>&,
|
||||
const default_allocator<U>&) BOOST_NOEXCEPT
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* default_ */
|
||||
|
||||
using default_::default_allocator;
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -71,6 +71,10 @@ public:
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, const U& value)
|
||||
: value_(value) { }
|
||||
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U& value)
|
||||
: value_(value) { }
|
||||
#endif
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT {
|
||||
@@ -115,6 +119,10 @@ public:
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, const U& value)
|
||||
: T(value) { }
|
||||
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U& value)
|
||||
: T(value) { }
|
||||
#endif
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT {
|
||||
@@ -131,6 +139,8 @@ public:
|
||||
|
||||
using empty_::empty_value;
|
||||
|
||||
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
||||
45
include/boost/core/first_scalar.hpp
Normal file
45
include/boost/core/first_scalar.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_FIRST_SCALAR_HPP
|
||||
#define BOOST_CORE_FIRST_SCALAR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct make_scalar {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T, std::size_t N>
|
||||
struct make_scalar<T[N]> {
|
||||
typedef typename make_scalar<T>::type type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR inline T*
|
||||
first_scalar(T* p) BOOST_NOEXCEPT
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_CONSTEXPR inline typename detail::make_scalar<T>::type*
|
||||
first_scalar(T (*p)[N]) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::first_scalar(&(*p)[0]);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -22,14 +22,18 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cstdlib>
|
||||
#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 +52,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 +93,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)
|
||||
@@ -110,14 +129,14 @@ inline void throw_failed_impl(char const * excep, char const * file, int line, c
|
||||
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
|
||||
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
|
||||
// the dependency we just disable the warnings.
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4389)
|
||||
#elif defined(__clang__) && defined(__has_warning)
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning("-Wsign-compare")
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wsign-compare"
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4389)
|
||||
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
@@ -174,13 +193,14 @@ struct lw_test_ge {
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
@@ -189,15 +209,17 @@ inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const
|
||||
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << 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 +227,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 +245,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 +309,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,20 +380,22 @@ void test_all_with_impl(FormattedOutputFunction& output,
|
||||
if (error_count == 0)
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#elif defined(__clang__) && defined(__has_warning)
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning("-Wsign-compare")
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
@@ -379,23 +408,25 @@ inline int report_errors()
|
||||
result.done();
|
||||
|
||||
int errors = result.errors();
|
||||
|
||||
if( errors == 0 )
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< "No errors detected." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// `return report_errors();` from main only supports 8 bit exit codes
|
||||
return errors < 256? errors: 255;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#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) )
|
||||
|
||||
@@ -9,16 +9,21 @@
|
||||
|
||||
// boost/core/lightweight_test_trait.hpp
|
||||
//
|
||||
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE
|
||||
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
//
|
||||
// Copyright 2019 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -26,6 +31,50 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class, int = 0> struct test_print { };
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>)
|
||||
{
|
||||
return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T));
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>();
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " const";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " volatile";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " const volatile";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>)
|
||||
{
|
||||
return o << test_print<T, 1>();
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>)
|
||||
{
|
||||
return o << test_print<T, 1>() << " &";
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>)
|
||||
{
|
||||
return o << test_print<T, 1>() << " &&";
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ),
|
||||
bool expected, char const * file, int line, char const * function )
|
||||
{
|
||||
@@ -46,6 +95,31 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> inline bool test_trait_same_impl_( T )
|
||||
{
|
||||
return T::value;
|
||||
}
|
||||
|
||||
template<class T1, class T2> inline void test_trait_same_impl( char const * types,
|
||||
boost::core::is_same<T1, T2> same, char const * file, int line, char const * function )
|
||||
{
|
||||
if( test_trait_same_impl_( same ) )
|
||||
{
|
||||
test_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test 'is_same<" << types << ">'"
|
||||
<< " failed in function '" << function
|
||||
<< "' ('" << test_print<T1>()
|
||||
<< "' != '" << test_print<T2>() << "')"
|
||||
<< std::endl;
|
||||
|
||||
++test_results().errors();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
@@ -53,4 +127,11 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
|
||||
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#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
|
||||
|
||||
@@ -32,9 +32,21 @@
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# define BOOST_TRY { if ("")
|
||||
# define BOOST_CATCH(x) else if (!"")
|
||||
# else
|
||||
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
# define BOOST_TRY { if (true)
|
||||
# define BOOST_CATCH(x) else if (false)
|
||||
# else
|
||||
// warning C4127: conditional expression is constant
|
||||
# define BOOST_TRY { \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: 4127)) \
|
||||
if (true) \
|
||||
__pragma(warning(pop))
|
||||
# define BOOST_CATCH(x) else \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: 4127)) \
|
||||
if (false) \
|
||||
__pragma(warning(pop))
|
||||
# endif
|
||||
# define BOOST_RETHROW
|
||||
# define BOOST_CATCH_END }
|
||||
|
||||
112
include/boost/core/noinit_adaptor.hpp
Normal file
112
include/boost/core/noinit_adaptor.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <memory>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
#else
|
||||
typedef noinit_adaptor<typename A::template rebind<U>::other> other;
|
||||
#endif
|
||||
};
|
||||
|
||||
noinit_adaptor()
|
||||
: A() { }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class U>
|
||||
noinit_adaptor(U&& u) BOOST_NOEXCEPT
|
||||
: A(std::forward<U>(u)) { }
|
||||
#else
|
||||
template<class U>
|
||||
noinit_adaptor(const U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
|
||||
: A(static_cast<const U&>(u)) { }
|
||||
|
||||
template<class U>
|
||||
void construct(U* p) {
|
||||
::new((void*)p) U;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args) {
|
||||
::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class U, class V>
|
||||
void construct(U* p, V&& v) {
|
||||
::new((void*)p) U(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
void construct(U* p, V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const noinit_adaptor<T>& lhs,
|
||||
const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<const T&>(lhs) == static_cast<const U&>(rhs);
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const noinit_adaptor<T>& lhs,
|
||||
const noinit_adaptor<U>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline noinit_adaptor<A>
|
||||
noinit_adapt(const A& a) BOOST_NOEXCEPT
|
||||
{
|
||||
return noinit_adaptor<A>(a);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
57
include/boost/core/nvp.hpp
Normal file
57
include/boost/core/nvp.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_NVP_HPP
|
||||
#define BOOST_CORE_NVP_HPP
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class T>
|
||||
class nvp {
|
||||
public:
|
||||
nvp(const char* n, T& v) BOOST_NOEXCEPT
|
||||
: n_(n)
|
||||
, v_(boost::addressof(v)) { }
|
||||
|
||||
const char* name() const BOOST_NOEXCEPT {
|
||||
return n_;
|
||||
}
|
||||
|
||||
T& value() const BOOST_NOEXCEPT {
|
||||
return *v_;
|
||||
}
|
||||
|
||||
const T& const_value() const BOOST_NOEXCEPT {
|
||||
return *v_;
|
||||
}
|
||||
|
||||
private:
|
||||
const char* n_;
|
||||
T* v_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline const nvp<T>
|
||||
make_nvp(const char* n, T& v) BOOST_NOEXCEPT
|
||||
{
|
||||
return nvp<T>(n, v);
|
||||
}
|
||||
|
||||
} /* serialization */
|
||||
|
||||
using serialization::nvp;
|
||||
using serialization::make_nvp;
|
||||
|
||||
} /* boost */
|
||||
|
||||
#define BOOST_NVP(v) boost::make_nvp(BOOST_STRINGIZE(v), v)
|
||||
|
||||
#endif
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#if __cplusplus >= 201103L || defined(BOOST_MSVC)
|
||||
#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
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
bool operator==( typeinfo const& rhs ) const
|
||||
{
|
||||
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
|
||||
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
|
||||
|
||||
return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0;
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
bool before( typeinfo const& rhs ) const
|
||||
{
|
||||
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && defined(__GNUC__) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
|
||||
#if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
|
||||
|
||||
return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* \author Andrey Semashev
|
||||
* \date 2018-11-10
|
||||
*
|
||||
* \brief This header provides an `uncaught_exception` function implementation, which was introduced in C++17.
|
||||
* \brief This header provides an `uncaught_exceptions` function implementation, which was introduced in C++17.
|
||||
*
|
||||
* The code in this file is based on the implementation by Evgeny Panasyuk:
|
||||
*
|
||||
@@ -46,20 +46,41 @@
|
||||
#if defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0.
|
||||
// Just disable it for now and fall back to std::uncaught_exception().
|
||||
#if !defined(__MINGW32__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
|
||||
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
|
||||
#if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
#include <cxxabi.h>
|
||||
// Only GCC 4.7 declares __cxa_get_globals() in cxxabi.h, older compilers do not expose this function but it's there
|
||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407
|
||||
#include <cstring>
|
||||
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
|
||||
// At least on MinGW and Linux, only GCC since 4.7 declares __cxa_get_globals() in cxxabi.h. Older versions of GCC do not expose this function but it's there.
|
||||
// On OpenBSD, it seems, the declaration is also missing.
|
||||
// Note that at least on FreeBSD 11, cxxabi.h declares __cxa_get_globals with a different exception specification, so we can't declare the function unconditionally.
|
||||
// On Linux with clang and libc++ and on OS X, there is a version of cxxabi.h from libc++abi that doesn't declare __cxa_get_globals, but provides __cxa_uncaught_exceptions.
|
||||
// The function only appeared in version _LIBCPPABI_VERSION >= 1002 of the library. Unfortunately, there are linking errors about undefined reference to __cxa_uncaught_exceptions
|
||||
// on Ubuntu Trusty and OS X, so we avoid using it and forward-declare __cxa_get_globals instead.
|
||||
// On QNX SDP 7.0 (QCC 5.4.0), there are multiple cxxabi.h, one from glibcxx from gcc and another from libc++abi from LLVM. Which one is included will be determined by the qcc
|
||||
// command line arguments (-V and/or -Y; http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.utilities/topic/q/qcc.html). The LLVM libc++abi is missing the declaration
|
||||
// of __cxa_get_globals but it is also patched by QNX developers to not define _LIBCPPABI_VERSION. Older QNX SDP versions, up to and including 6.6, don't provide LLVM and libc++abi.
|
||||
// See https://github.com/boostorg/core/issues/59.
|
||||
#if !defined(__FreeBSD__) && \
|
||||
( \
|
||||
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \
|
||||
defined(__OpenBSD__) || \
|
||||
(defined(__QNXNTO__) && !defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || \
|
||||
defined(_LIBCPPABI_VERSION) \
|
||||
)
|
||||
namespace __cxxabiv1 {
|
||||
struct __cxa_eh_globals;
|
||||
#if defined(__OpenBSD__)
|
||||
extern "C" __cxa_eh_globals* __cxa_get_globals();
|
||||
#else
|
||||
extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __attribute__((__const__));
|
||||
} // namespace __cxxabiv1
|
||||
#endif // defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407
|
||||
#endif
|
||||
} // namespace __cxxabiv1
|
||||
#endif
|
||||
#endif // !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
#endif // defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
#include <cstring>
|
||||
#define BOOST_CORE_HAS_GETPTD
|
||||
namespace boost {
|
||||
namespace core {
|
||||
@@ -89,10 +110,14 @@ inline unsigned int uncaught_exceptions() BOOST_NOEXCEPT
|
||||
return static_cast< unsigned int >(std::uncaught_exceptions());
|
||||
#elif defined(BOOST_CORE_HAS_CXA_GET_GLOBALS)
|
||||
// Tested on {clang 3.2,GCC 3.5.6,GCC 4.1.2,GCC 4.4.6,GCC 4.4.7}x{x32,x64}
|
||||
return *(reinterpret_cast< const unsigned int* >(reinterpret_cast< const char* >(::abi::__cxa_get_globals()) + sizeof(void*))); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8
|
||||
unsigned int count;
|
||||
std::memcpy(&count, reinterpret_cast< const unsigned char* >(::abi::__cxa_get_globals()) + sizeof(void*), sizeof(count)); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8
|
||||
return count;
|
||||
#elif defined(BOOST_CORE_HAS_GETPTD)
|
||||
// MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}.
|
||||
return *(reinterpret_cast< const unsigned int* >(static_cast< const char* >(boost::core::detail::_getptd()) + (sizeof(void*) == 8 ? 0x100 : 0x90))); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
|
||||
unsigned int count;
|
||||
std::memcpy(&count, static_cast< const unsigned char* >(boost::core::detail::_getptd()) + (sizeof(void*) == 8u ? 0x100 : 0x90), sizeof(count)); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
|
||||
return count;
|
||||
#else
|
||||
// Portable C++03 implementation. Does not allow to detect multiple nested exceptions.
|
||||
return static_cast< unsigned int >(std::uncaught_exception());
|
||||
|
||||
17
include/boost/core/use_default.hpp
Normal file
17
include/boost/core/use_default.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_USE_DEFAULT_HPP
|
||||
#define BOOST_CORE_USE_DEFAULT_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct use_default { };
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,9 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED( "<boost/core/typeinfo.hpp>" )
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
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)
|
||||
105
test/Jamfile.v2
105
test/Jamfile.v2
@@ -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,16 +68,35 @@ 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_eq_test.cpp ;
|
||||
run lightweight_test_all_with_test.cpp ;
|
||||
run lightweight_test_all_with_fail.cpp ;
|
||||
run lightweight_test_lt_le_test.cpp ;
|
||||
run lightweight_test_gt_ge_test.cpp ;
|
||||
run lightweight_test_eq_nullptr.cpp ;
|
||||
run lightweight_test_test3.cpp ;
|
||||
local pedantic-errors = <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<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 ;
|
||||
run-fail lightweight_test_all_with_fail.cpp ;
|
||||
|
||||
run-fail lightweight_test_fail.cpp ;
|
||||
run-fail lightweight_test_fail2.cpp ;
|
||||
@@ -89,12 +110,16 @@ 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_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 is_same_test.cpp ;
|
||||
|
||||
run typeinfo_test.cpp ;
|
||||
@@ -103,9 +128,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 ;
|
||||
@@ -124,22 +152,59 @@ run to_address_test.cpp ;
|
||||
run exchange_test.cpp ;
|
||||
run exchange_move_test.cpp ;
|
||||
|
||||
run first_scalar_test.cpp ;
|
||||
compile first_scalar_constexpr_test.cpp ;
|
||||
|
||||
run empty_value_test.cpp ;
|
||||
run empty_value_size_test.cpp ;
|
||||
run empty_value_final_test.cpp ;
|
||||
|
||||
run quick_exit_test.cpp ;
|
||||
run-fail quick_exit_fail.cpp ;
|
||||
|
||||
compile use_default_test.cpp ;
|
||||
|
||||
run default_allocator_test.cpp ;
|
||||
run noinit_adaptor_test.cpp ;
|
||||
run alloc_construct_test.cpp ;
|
||||
run alloc_construct_throws_test.cpp ;
|
||||
run alloc_construct_cxx11_test.cpp ;
|
||||
|
||||
run nvp_test.cpp ;
|
||||
|
||||
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 ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
|
||||
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
|
||||
|
||||
run uncaught_exceptions.cpp : : : <exception-handling>on ;
|
||||
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
|
||||
run uncaught_exceptions.cpp
|
||||
: : : <exception-handling>on ;
|
||||
run uncaught_exceptions_np.cpp
|
||||
: : : <exception-handling>on ;
|
||||
|
||||
run no_exceptions_support_test.cpp ;
|
||||
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
78
test/alloc_construct_cxx11_test.cpp
Normal file
78
test/alloc_construct_cxx11_test.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/core/alloc_construct.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
explicit type(int x)
|
||||
: value_(x) { }
|
||||
|
||||
int value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
static int count;
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
|
||||
int value_;
|
||||
};
|
||||
|
||||
int type::count = 0;
|
||||
|
||||
template<class T>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
template<class V>
|
||||
void construct(type* ptr, const V& value) {
|
||||
::new(static_cast<void*>(ptr)) type(value + 1);
|
||||
++type::count;
|
||||
}
|
||||
|
||||
void destroy(type* ptr) {
|
||||
ptr->~type();
|
||||
--type::count;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
creator<type> a;
|
||||
type* p = a.allocate(1);
|
||||
boost::alloc_construct(a, p, 1);
|
||||
BOOST_TEST_EQ(type::count, 1);
|
||||
BOOST_TEST_EQ(p->value(), 2);
|
||||
boost::alloc_destroy(a, p);
|
||||
BOOST_TEST_EQ(type::count, 0);
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
135
test/alloc_construct_test.cpp
Normal file
135
test/alloc_construct_test.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/alloc_construct.hpp>
|
||||
#include <boost/core/default_allocator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
explicit type(int x = 0, int y = 0)
|
||||
: value_(x + y) {
|
||||
++count;
|
||||
}
|
||||
|
||||
type(const type& other)
|
||||
: value_(other.value_) {
|
||||
++count;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--count;
|
||||
}
|
||||
|
||||
int value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
static int count;
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
int type::count = 0;
|
||||
|
||||
void test_construct()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(1);
|
||||
boost::alloc_construct(a, p);
|
||||
BOOST_TEST_EQ(type::count, 1);
|
||||
BOOST_TEST_EQ(p->value(), 0);
|
||||
boost::alloc_destroy(a, p);
|
||||
BOOST_TEST_EQ(type::count, 0);
|
||||
a.deallocate(p, 1);
|
||||
}
|
||||
|
||||
void test_construct_value()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(1);
|
||||
boost::alloc_construct(a, p, 1);
|
||||
BOOST_TEST_EQ(type::count, 1);
|
||||
BOOST_TEST_EQ(p->value(), 1);
|
||||
boost::alloc_destroy(a, p);
|
||||
BOOST_TEST_EQ(type::count, 0);
|
||||
a.deallocate(p, 1);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
void test_construct_args()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(1);
|
||||
boost::alloc_construct(a, p, 1, 2);
|
||||
BOOST_TEST_EQ(type::count, 1);
|
||||
BOOST_TEST_EQ(p->value(), 3);
|
||||
boost::alloc_destroy(a, p);
|
||||
BOOST_TEST_EQ(type::count, 0);
|
||||
a.deallocate(p, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_construct_n()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(3);
|
||||
boost::alloc_construct_n(a, p, 3);
|
||||
BOOST_TEST_EQ(type::count, 3);
|
||||
BOOST_TEST_EQ(p[0].value(), 0);
|
||||
BOOST_TEST_EQ(p[1].value(), 0);
|
||||
BOOST_TEST_EQ(p[2].value(), 0);
|
||||
boost::alloc_destroy_n(a, p, 3);
|
||||
BOOST_TEST_EQ(type::count, 0);
|
||||
a.deallocate(p, 3);
|
||||
}
|
||||
|
||||
void test_construct_n_list()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(3);
|
||||
type q(1);
|
||||
boost::alloc_construct_n(a, p, 3, &q, 1);
|
||||
BOOST_TEST_EQ(type::count, 4);
|
||||
BOOST_TEST_EQ(p[0].value(), 1);
|
||||
BOOST_TEST_EQ(p[1].value(), 1);
|
||||
BOOST_TEST_EQ(p[2].value(), 1);
|
||||
boost::alloc_destroy_n(a, p, 3);
|
||||
BOOST_TEST_EQ(type::count, 1);
|
||||
a.deallocate(p, 3);
|
||||
}
|
||||
|
||||
void test_construct_n_iterator()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(3);
|
||||
type l[] = { type(1), type(2), type(3) };
|
||||
boost::alloc_construct_n(a, p, 3, &l[0]);
|
||||
BOOST_TEST_EQ(type::count, 6);
|
||||
BOOST_TEST_EQ(p[0].value(), 1);
|
||||
BOOST_TEST_EQ(p[1].value(), 2);
|
||||
BOOST_TEST_EQ(p[2].value(), 3);
|
||||
boost::alloc_destroy_n(a, p, 3);
|
||||
BOOST_TEST_EQ(type::count, 3);
|
||||
a.deallocate(p, 3);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_construct();
|
||||
test_construct_value();
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
test_construct_args();
|
||||
#endif
|
||||
test_construct_n();
|
||||
test_construct_n_list();
|
||||
test_construct_n_iterator();
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/alloc_construct_throws_test.cpp
Normal file
46
test/alloc_construct_throws_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/alloc_construct.hpp>
|
||||
#include <boost/core/default_allocator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
type() {
|
||||
if (count == 4) {
|
||||
throw true;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--count;
|
||||
}
|
||||
|
||||
static int count;
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
};
|
||||
|
||||
int type::count = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::default_allocator<type> a;
|
||||
type* p = a.allocate(5);
|
||||
try {
|
||||
boost::alloc_construct_n(a, p, 5);
|
||||
BOOST_ERROR("construct_n did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST_EQ(type::count, 0);
|
||||
}
|
||||
a.deallocate(p, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
61
test/allocator_allocate_hint_test.cpp
Normal file
61
test/allocator_allocate_hint_test.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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 A1 {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
A1()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
value = n;
|
||||
return &value;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
struct A2 {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
A2()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
value = n;
|
||||
return &value;
|
||||
}
|
||||
|
||||
pointer allocate(size_type n, const void*) {
|
||||
value = n + 1;
|
||||
return &value;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1 a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 1);
|
||||
}
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
{
|
||||
A2 a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 2);
|
||||
}
|
||||
#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>
|
||||
|
||||
struct A {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
A()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
value = n;
|
||||
return &value;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 5), 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
30
test/allocator_const_pointer_test.cpp
Normal file
30
test/allocator_const_pointer_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/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct A1 {
|
||||
typedef char value_type;
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
typedef char value_type;
|
||||
typedef int* pointer;
|
||||
typedef const bool* const_pointer;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const char*,
|
||||
boost::allocator_const_pointer<A1>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const bool*,
|
||||
boost::allocator_const_pointer<A2>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
28
test/allocator_const_void_pointer_test.cpp
Normal file
28
test/allocator_const_void_pointer_test.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 {
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
typedef int* pointer;
|
||||
typedef const bool* const_void_pointer;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
|
||||
boost::allocator_const_void_pointer<A1>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const bool*,
|
||||
boost::allocator_const_void_pointer<A2>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
49
test/allocator_construct_test.cpp
Normal file
49
test/allocator_construct_test.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
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/default_allocator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct S {
|
||||
S(int v)
|
||||
: value(v) { }
|
||||
|
||||
int value;
|
||||
};
|
||||
|
||||
struct A1 { };
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
struct A2 {
|
||||
void construct(S* p, int v) {
|
||||
new(p) S(v + 1);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::default_allocator<S> d;
|
||||
{
|
||||
S* p = d.allocate(1);
|
||||
A1 a;
|
||||
boost::allocator_construct(a, p, 1);
|
||||
BOOST_TEST_EQ(p->value, 1);
|
||||
d.deallocate(p, 1);
|
||||
}
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
{
|
||||
S* p = d.allocate(1);
|
||||
A2 a;
|
||||
boost::allocator_construct(a, p, 1);
|
||||
BOOST_TEST_EQ(p->value, 2);
|
||||
d.deallocate(p, 1);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
31
test/allocator_deallocate_test.cpp
Normal file
31
test/allocator_deallocate_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>
|
||||
|
||||
struct A {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
A()
|
||||
: value() { }
|
||||
|
||||
void deallocate(pointer, size_type n) {
|
||||
value = n;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A 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/default_allocator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct S {
|
||||
static int count;
|
||||
|
||||
S() {
|
||||
++count;
|
||||
}
|
||||
|
||||
S(const S&) {
|
||||
++count;
|
||||
}
|
||||
|
||||
~S() {
|
||||
--count;
|
||||
}
|
||||
};
|
||||
|
||||
int S::count = 0;
|
||||
|
||||
struct A1 { };
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
struct A2 {
|
||||
void destroy(S*) {
|
||||
++S::count;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::default_allocator<S> d;
|
||||
{
|
||||
S* p = d.allocate(1);
|
||||
new(p) S;
|
||||
A1 a;
|
||||
boost::allocator_destroy(a, p);
|
||||
BOOST_TEST_EQ(S::count, 0);
|
||||
d.deallocate(p, 1);
|
||||
}
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
{
|
||||
S* p = d.allocate(1);
|
||||
new(p) S;
|
||||
A2 a;
|
||||
boost::allocator_destroy(a, p);
|
||||
BOOST_TEST_EQ(S::count, 2);
|
||||
d.deallocate(p, 1);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
28
test/allocator_difference_type_test.cpp
Normal file
28
test/allocator_difference_type_test.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 {
|
||||
typedef char* pointer;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
typedef char* pointer;
|
||||
typedef int difference_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::allocator_difference_type<A1>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_difference_type<A2>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
36
test/allocator_is_always_equal_test.cpp
Normal file
36
test/allocator_is_always_equal_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 {
|
||||
int value;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
struct is_always_equal {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
struct A3 { };
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1>::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2>::type));
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A3>::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
35
test/allocator_max_size_test.cpp
Normal file
35
test/allocator_max_size_test.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
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 A1 {
|
||||
typedef long value_type;
|
||||
typedef short size_type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
struct A2 {
|
||||
typedef long value_type;
|
||||
typedef short size_type;
|
||||
|
||||
size_type max_size() const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(boost::allocator_max_size(A1()),
|
||||
std::numeric_limits<A1::size_type>::max() / sizeof(A1::value_type));
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
BOOST_TEST_EQ(boost::allocator_max_size(A2()), 1);
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
27
test/allocator_pocca_test.cpp
Normal file
27
test/allocator_pocca_test.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 { };
|
||||
|
||||
struct A2 {
|
||||
struct propagate_on_container_copy_assignment {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A1>::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A2>::type));
|
||||
return boost::report_errors();
|
||||
}
|
||||
27
test/allocator_pocma_test.cpp
Normal file
27
test/allocator_pocma_test.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 { };
|
||||
|
||||
struct A2 {
|
||||
struct propagate_on_container_move_assignment {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A1>::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A2>::type));
|
||||
return boost::report_errors();
|
||||
}
|
||||
27
test/allocator_pocs_test.cpp
Normal file
27
test/allocator_pocs_test.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 { };
|
||||
|
||||
struct A2 {
|
||||
struct propagate_on_container_swap {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_swap<A1>::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_swap<A2>::type));
|
||||
return boost::report_errors();
|
||||
}
|
||||
28
test/allocator_pointer_test.cpp
Normal file
28
test/allocator_pointer_test.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 {
|
||||
typedef char value_type;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
typedef char value_type;
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
|
||||
boost::allocator_pointer<A1>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_pointer<A2>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
30
test/allocator_rebind_test.cpp
Normal file
30
test/allocator_rebind_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/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class, class, class>
|
||||
struct A1 { };
|
||||
|
||||
template<class, class U, class V>
|
||||
struct A2 {
|
||||
template<class T>
|
||||
struct rebind {
|
||||
typedef A1<T, U, V> other;
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<bool, int, float>,
|
||||
boost::allocator_rebind<A1<char, int, float>, bool>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<bool, int, float>,
|
||||
boost::allocator_rebind<A2<char, int, float>, bool>::type>));
|
||||
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>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
struct A1 {
|
||||
typedef long difference_type;
|
||||
};
|
||||
#else
|
||||
struct A1 {
|
||||
typedef unsigned long size_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct A2 {
|
||||
typedef long difference_type;
|
||||
typedef unsigned short size_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<unsigned long,
|
||||
boost::allocator_size_type<A1>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<unsigned short,
|
||||
boost::allocator_size_type<A2>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
40
test/allocator_soccc_test.cpp
Normal file
40
test/allocator_soccc_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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 A1 {
|
||||
A1(int v)
|
||||
: value(v) { }
|
||||
|
||||
int value;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
struct A2 {
|
||||
A2(int v)
|
||||
: value(v) { }
|
||||
|
||||
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(1)).value);
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
BOOST_TEST_EQ(2,
|
||||
boost::allocator_select_on_container_copy_construction(A2(1)).value);
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
21
test/allocator_value_type_test.cpp
Normal file
21
test/allocator_value_type_test.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A {
|
||||
typedef int value_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_value_type<A>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
28
test/allocator_void_pointer_test.cpp
Normal file
28
test/allocator_void_pointer_test.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
struct A1 {
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
typedef int* pointer;
|
||||
typedef bool* void_pointer;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
boost::allocator_void_pointer<A1>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool*,
|
||||
boost::allocator_void_pointer<A2>::type>));
|
||||
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>)
|
||||
19
test/cmake_subdir_test/CMakeLists.txt
Normal file
19
test/cmake_subdir_test/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../.. boostorg/core)
|
||||
add_subdirectory(../../../assert boostorg/assert)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::core)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
277
test/default_allocator_test.cpp
Normal file
277
test/default_allocator_test.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/default_allocator.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
class type {
|
||||
public:
|
||||
explicit type(double value)
|
||||
: value_(value) { }
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
|
||||
double value_;
|
||||
};
|
||||
|
||||
void test_value_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::default_allocator<int>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(type,
|
||||
boost::default_allocator<type>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(int[5],
|
||||
boost::default_allocator<int[5]>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(void,
|
||||
boost::default_allocator<void>::value_type);
|
||||
}
|
||||
|
||||
void test_pointer()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(int*,
|
||||
boost::default_allocator<int>::pointer);
|
||||
BOOST_TEST_TRAIT_SAME(type*,
|
||||
boost::default_allocator<type>::pointer);
|
||||
BOOST_TEST_TRAIT_SAME(int(*)[5],
|
||||
boost::default_allocator<int[5]>::pointer);
|
||||
BOOST_TEST_TRAIT_SAME(void*,
|
||||
boost::default_allocator<void>::pointer);
|
||||
}
|
||||
|
||||
void test_const_pointer()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(const int*,
|
||||
boost::default_allocator<int>::const_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(const type*,
|
||||
boost::default_allocator<type>::const_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(const int(*)[5],
|
||||
boost::default_allocator<int[5]>::const_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(const void*,
|
||||
boost::default_allocator<void>::const_pointer);
|
||||
}
|
||||
|
||||
void test_reference()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(int&,
|
||||
boost::default_allocator<int>::reference);
|
||||
BOOST_TEST_TRAIT_SAME(type&,
|
||||
boost::default_allocator<type>::reference);
|
||||
BOOST_TEST_TRAIT_SAME(int(&)[5],
|
||||
boost::default_allocator<int[5]>::reference);
|
||||
BOOST_TEST_TRAIT_SAME(void,
|
||||
boost::default_allocator<void>::reference);
|
||||
}
|
||||
|
||||
void test_const_reference()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(const int&,
|
||||
boost::default_allocator<int>::const_reference);
|
||||
BOOST_TEST_TRAIT_SAME(const type&,
|
||||
boost::default_allocator<type>::const_reference);
|
||||
BOOST_TEST_TRAIT_SAME(const int(&)[5],
|
||||
boost::default_allocator<int[5]>::const_reference);
|
||||
BOOST_TEST_TRAIT_SAME(const void,
|
||||
boost::default_allocator<void>::const_reference);
|
||||
}
|
||||
|
||||
void test_size_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::default_allocator<int>::size_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::default_allocator<type>::size_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::default_allocator<int[5]>::size_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::default_allocator<void>::size_type);
|
||||
}
|
||||
|
||||
void test_difference_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::default_allocator<int>::difference_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::default_allocator<type>::difference_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::default_allocator<int[5]>::difference_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::default_allocator<void>::difference_type);
|
||||
}
|
||||
|
||||
void test_propagate_on_container_move_assignment()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int>::
|
||||
propagate_on_container_move_assignment));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<type>::
|
||||
propagate_on_container_move_assignment));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int[5]>::
|
||||
propagate_on_container_move_assignment));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<void>::
|
||||
propagate_on_container_move_assignment));
|
||||
}
|
||||
|
||||
void test_is_always_equal()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int>::is_always_equal));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<type>::is_always_equal));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<int[5]>::is_always_equal));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::default_allocator<void>::is_always_equal));
|
||||
}
|
||||
|
||||
void test_rebind()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(boost::default_allocator<type>,
|
||||
boost::default_allocator<int>::rebind<type>::other);
|
||||
BOOST_TEST_TRAIT_SAME(boost::default_allocator<int[5]>,
|
||||
boost::default_allocator<type>::rebind<int[5]>::other);
|
||||
BOOST_TEST_TRAIT_SAME(boost::default_allocator<void>,
|
||||
boost::default_allocator<int[5]>::rebind<void>::other);
|
||||
BOOST_TEST_TRAIT_SAME(boost::default_allocator<int>,
|
||||
boost::default_allocator<void>::rebind<int>::other);
|
||||
}
|
||||
|
||||
void test_default_construct()
|
||||
{
|
||||
boost::default_allocator<int> a1;
|
||||
(void)a1;
|
||||
boost::default_allocator<type> a2;
|
||||
(void)a2;
|
||||
boost::default_allocator<int[5]> a3;
|
||||
(void)a3;
|
||||
boost::default_allocator<void> a4;
|
||||
(void)a4;
|
||||
}
|
||||
|
||||
void test_copy()
|
||||
{
|
||||
boost::default_allocator<int> a1;
|
||||
boost::default_allocator<int> a2(a1);
|
||||
(void)a2;
|
||||
boost::default_allocator<int[5]> a3;
|
||||
boost::default_allocator<int[5]> a4(a3);
|
||||
(void)a4;
|
||||
boost::default_allocator<void> a5;
|
||||
boost::default_allocator<void> a6(a5);
|
||||
(void)a6;
|
||||
}
|
||||
|
||||
void test_construct_other()
|
||||
{
|
||||
boost::default_allocator<int> a1;
|
||||
boost::default_allocator<type> a2(a1);
|
||||
boost::default_allocator<int[5]> a3(a2);
|
||||
boost::default_allocator<void> a4(a3);
|
||||
boost::default_allocator<int> a5(a4);
|
||||
(void)a5;
|
||||
}
|
||||
|
||||
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
|
||||
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_max_size()
|
||||
{
|
||||
BOOST_TEST_EQ(max_size<int>(),
|
||||
boost::default_allocator<int>().max_size());
|
||||
BOOST_TEST_EQ(max_size<type>(),
|
||||
boost::default_allocator<type>().max_size());
|
||||
BOOST_TEST_EQ(max_size<int[5]>(),
|
||||
boost::default_allocator<int[5]>().max_size());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void test_allocate()
|
||||
{
|
||||
boost::default_allocator<T> a;
|
||||
T* p = a.allocate(1);
|
||||
BOOST_TEST(p != 0);
|
||||
a.deallocate(p, 1);
|
||||
p = a.allocate(0);
|
||||
a.deallocate(p, 0);
|
||||
BOOST_TEST_THROWS(a.allocate(a.max_size() + 1), std::bad_alloc);
|
||||
}
|
||||
|
||||
void test_allocate_deallocate()
|
||||
{
|
||||
test_allocate<int>();
|
||||
test_allocate<type>();
|
||||
test_allocate<int[5]>();
|
||||
}
|
||||
|
||||
void test_equals()
|
||||
{
|
||||
BOOST_TEST(boost::default_allocator<int>() ==
|
||||
boost::default_allocator<type>());
|
||||
BOOST_TEST(boost::default_allocator<type>() ==
|
||||
boost::default_allocator<int[5]>());
|
||||
BOOST_TEST(boost::default_allocator<int[5]>() ==
|
||||
boost::default_allocator<void>());
|
||||
BOOST_TEST(boost::default_allocator<void>() ==
|
||||
boost::default_allocator<int>());
|
||||
}
|
||||
|
||||
void test_not_equals()
|
||||
{
|
||||
BOOST_TEST(!(boost::default_allocator<int>() !=
|
||||
boost::default_allocator<type>()));
|
||||
BOOST_TEST(!(boost::default_allocator<type>() !=
|
||||
boost::default_allocator<int[5]>()));
|
||||
BOOST_TEST(!(boost::default_allocator<int[5]>() !=
|
||||
boost::default_allocator<void>()));
|
||||
BOOST_TEST(!(boost::default_allocator<void>() !=
|
||||
boost::default_allocator<int>()));
|
||||
}
|
||||
|
||||
void test_container()
|
||||
{
|
||||
std::vector<int, boost::default_allocator<int> > v;
|
||||
v.push_back(1);
|
||||
BOOST_TEST(v.size() == 1);
|
||||
BOOST_TEST(v.front() == 1);
|
||||
std::list<int, boost::default_allocator<int> > l;
|
||||
l.push_back(1);
|
||||
BOOST_TEST(l.size() == 1);
|
||||
BOOST_TEST(l.front() == 1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_value_type();
|
||||
test_pointer();
|
||||
test_const_pointer();
|
||||
test_reference();
|
||||
test_const_reference();
|
||||
test_size_type();
|
||||
test_difference_type();
|
||||
test_propagate_on_container_move_assignment();
|
||||
test_is_always_equal();
|
||||
test_rebind();
|
||||
test_default_construct();
|
||||
test_copy();
|
||||
test_construct_other();
|
||||
test_max_size();
|
||||
test_allocate_deallocate();
|
||||
test_equals();
|
||||
test_not_equals();
|
||||
test_container();
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
62
test/empty_value_final_test.cpp
Normal file
62
test/empty_value_final_test.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/empty_value.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_FINAL)
|
||||
class type final {
|
||||
public:
|
||||
explicit type(int count)
|
||||
: value_(count) { }
|
||||
int value() const {
|
||||
return value_ + 1;
|
||||
}
|
||||
int value() {
|
||||
return value_ + 2;
|
||||
}
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
struct empty final {
|
||||
int value() const {
|
||||
return 1;
|
||||
}
|
||||
int value() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
void test_type()
|
||||
{
|
||||
const boost::empty_value<type> v1(boost::empty_init_t(), 3);
|
||||
BOOST_TEST(v1.get().value() == 4);
|
||||
boost::empty_value<type> v2(boost::empty_init_t(), 3);
|
||||
BOOST_TEST(v2.get().value() == 5);
|
||||
}
|
||||
|
||||
void test_empty()
|
||||
{
|
||||
const boost::empty_value<empty> v1 = boost::empty_init_t();
|
||||
BOOST_TEST(v1.get().value() == 1);
|
||||
boost::empty_value<empty> v2;
|
||||
BOOST_TEST(v2.get().value() == 2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_type();
|
||||
test_empty();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -9,67 +9,63 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct empty {
|
||||
operator bool() const {
|
||||
return false;
|
||||
int value() const {
|
||||
return 1;
|
||||
}
|
||||
operator bool() {
|
||||
return true;
|
||||
int value() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
class type {
|
||||
public:
|
||||
type()
|
||||
: value_(false) { }
|
||||
explicit type(bool value)
|
||||
: value_(value) { }
|
||||
operator bool() const {
|
||||
return value_;
|
||||
explicit type(int count)
|
||||
: value_(count) { }
|
||||
int value() const {
|
||||
return value_ + 1;
|
||||
}
|
||||
int value() {
|
||||
return value_ + 2;
|
||||
}
|
||||
private:
|
||||
bool value_;
|
||||
int value_;
|
||||
};
|
||||
|
||||
void test_bool()
|
||||
void test_int()
|
||||
{
|
||||
const boost::empty_value<bool> v1(boost::empty_init_t(), true);
|
||||
BOOST_TEST(v1.get());
|
||||
boost::empty_value<bool> v2 = boost::empty_init_t();
|
||||
BOOST_TEST(!v2.get());
|
||||
const boost::empty_value<int> v1(boost::empty_init_t(), 7);
|
||||
BOOST_TEST(v1.get() == 7);
|
||||
boost::empty_value<int> v2 = boost::empty_init_t();
|
||||
BOOST_TEST(v2.get() == 0);
|
||||
v2 = v1;
|
||||
BOOST_TEST(v2.get());
|
||||
v2.get() = false;
|
||||
BOOST_TEST(!v2.get());
|
||||
BOOST_TEST(v2.get() == 7);
|
||||
v2.get() = 8;
|
||||
BOOST_TEST(v2.get() == 8);
|
||||
}
|
||||
|
||||
void test_empty()
|
||||
{
|
||||
empty e;
|
||||
const boost::empty_value<empty> v1(boost::empty_init_t(), e);
|
||||
BOOST_TEST(!v1.get());
|
||||
const boost::empty_value<empty> v1 = boost::empty_init_t();
|
||||
BOOST_TEST(v1.get().value() == 1);
|
||||
boost::empty_value<empty> v2;
|
||||
BOOST_TEST(v2.get());
|
||||
v2 = v1;
|
||||
BOOST_TEST(v2.get());
|
||||
v2.get() = empty();
|
||||
BOOST_TEST(v2.get());
|
||||
BOOST_TEST(v2.get().value() == 2);
|
||||
}
|
||||
|
||||
void test_type()
|
||||
{
|
||||
const boost::empty_value<type> v1(boost::empty_init_t(), true);
|
||||
BOOST_TEST(v1.get());
|
||||
boost::empty_value<type> v2;
|
||||
BOOST_TEST(!v2.get());
|
||||
const boost::empty_value<type> v1(boost::empty_init_t(), 2);
|
||||
BOOST_TEST(v1.get().value() == 3);
|
||||
boost::empty_value<type> v2(boost::empty_init_t(), 3);
|
||||
BOOST_TEST(v2.get().value() == 5);
|
||||
v2 = v1;
|
||||
BOOST_TEST(v2.get());
|
||||
v2.get() = type();
|
||||
BOOST_TEST(!v2.get());
|
||||
BOOST_TEST(v2.get().value() == 4);
|
||||
v2.get() = type(4);
|
||||
BOOST_TEST(v2.get().value() == 6);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_bool();
|
||||
test_int();
|
||||
test_empty();
|
||||
test_type();
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
19
test/first_scalar_constexpr_test.cpp
Normal file
19
test/first_scalar_constexpr_test.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
#include <boost/core/first_scalar.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
static int i1 = 0;
|
||||
BOOST_STATIC_ASSERT(boost::first_scalar(&i1) == &i1);
|
||||
static int i2[4] = { };
|
||||
BOOST_STATIC_ASSERT(boost::first_scalar(i2) == &i2[0]);
|
||||
static int i3[2][4][6] = { };
|
||||
BOOST_STATIC_ASSERT(boost::first_scalar(i3) == &i3[0][0][0]);
|
||||
#endif
|
||||
20
test/first_scalar_test.cpp
Normal file
20
test/first_scalar_test.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/first_scalar.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i1 = 0;
|
||||
BOOST_TEST_EQ(boost::first_scalar(&i1), &i1);
|
||||
int i2[4] = { };
|
||||
BOOST_TEST_EQ(boost::first_scalar(i2), &i2[0]);
|
||||
int i3[2][4][6] = { };
|
||||
BOOST_TEST_EQ(boost::first_scalar(i3), &i3[0][0][0]);
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -120,5 +120,5 @@ int main()
|
||||
++test_cases;
|
||||
}
|
||||
|
||||
return !boost::report_errors();
|
||||
return boost::report_errors() == test_cases;
|
||||
}
|
||||
|
||||
@@ -101,5 +101,5 @@ int main()
|
||||
test_cases += fail_vector();
|
||||
test_cases += fail_tolerance_predicate();
|
||||
|
||||
return !boost::report_errors();
|
||||
return boost::report_errors() == test_cases;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
68
test/lightweight_test_fail12.cpp
Normal file
68
test/lightweight_test_fail12.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// Negative test for BOOST_TEST_TRAIT_SAME
|
||||
//
|
||||
// Copyright 2014, 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<class T1, class T2> struct Y
|
||||
{
|
||||
typedef T1 type;
|
||||
};
|
||||
|
||||
typedef int I1;
|
||||
typedef const int I2;
|
||||
typedef volatile int I3;
|
||||
typedef const volatile int I4;
|
||||
typedef int& I5;
|
||||
typedef const int& I6;
|
||||
typedef volatile int& I7;
|
||||
typedef const volatile int& I8;
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
typedef int&& I9;
|
||||
typedef const int&& I10;
|
||||
typedef volatile int&& I11;
|
||||
typedef const volatile int&& I12;
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char[2]);
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char[]);
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char*);
|
||||
BOOST_TEST_TRAIT_SAME(void(), void(int));
|
||||
BOOST_TEST_TRAIT_SAME(void(), void(*)());
|
||||
BOOST_TEST_TRAIT_SAME(X, void);
|
||||
BOOST_TEST_TRAIT_SAME(X::type, void);
|
||||
BOOST_TEST_TRAIT_SAME(X, Y<void, void>);
|
||||
BOOST_TEST_TRAIT_SAME(X::type, Y<float, int>::type);
|
||||
BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, double>);
|
||||
BOOST_TEST_TRAIT_SAME(I1, I2);
|
||||
BOOST_TEST_TRAIT_SAME(I3, I4);
|
||||
BOOST_TEST_TRAIT_SAME(I5, I6);
|
||||
BOOST_TEST_TRAIT_SAME(I7, I8);
|
||||
|
||||
int expected = 14;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(I9, I10);
|
||||
BOOST_TEST_TRAIT_SAME(I11, I12);
|
||||
|
||||
expected += 2;
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors() == expected;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
36
test/lightweight_test_test4.cpp
Normal file
36
test/lightweight_test_test4.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Test for BOOST_TEST_TRAIT_SAME
|
||||
//
|
||||
// Copyright 2014, 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<class T1, class T2> struct Y
|
||||
{
|
||||
typedef T1 type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(X, X);
|
||||
BOOST_TEST_TRAIT_SAME(void, void);
|
||||
BOOST_TEST_TRAIT_SAME(char[1], char[1]);
|
||||
BOOST_TEST_TRAIT_SAME(char[], char[]);
|
||||
BOOST_TEST_TRAIT_SAME(void(), void());
|
||||
BOOST_TEST_TRAIT_SAME(X::type, X::type);
|
||||
BOOST_TEST_TRAIT_SAME(X::type, Y<int, float>::type);
|
||||
BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, float>);
|
||||
BOOST_TEST_TRAIT_SAME(Y<void, float>::type, void);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
19
test/lightweight_test_test5.cpp
Normal file
19
test/lightweight_test_test5.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Test that BOOST_TEST_EQ doesn't emit sign compare warnings
|
||||
//
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(1, 1u);
|
||||
BOOST_TEST_EQ(~0u, -1);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
52
test/no_exceptions_support_test.cpp
Normal file
52
test/no_exceptions_support_test.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Test for no_exceptions_support.hpp
|
||||
//
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/quick_exit.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <exception>
|
||||
|
||||
void f()
|
||||
{
|
||||
boost::throw_exception( std::exception() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TRY
|
||||
{
|
||||
f();
|
||||
}
|
||||
BOOST_CATCH( std::exception const& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
BOOST_CATCH( ... )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void throw_exception( std::exception const& )
|
||||
{
|
||||
boost::quick_exit( 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
100
test/noinit_adaptor_test.cpp
Normal file
100
test/noinit_adaptor_test.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/noinit_adaptor.hpp>
|
||||
#include <boost/core/default_allocator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <vector>
|
||||
|
||||
template<class T>
|
||||
class creator
|
||||
: public boost::default_allocator<T> {
|
||||
public:
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator(int state)
|
||||
: state_(state) { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>& other)
|
||||
: state_(other.state()) { }
|
||||
|
||||
template<class U, class V>
|
||||
void construct(U*, const V&) {
|
||||
BOOST_ERROR("construct");
|
||||
}
|
||||
|
||||
template<class U>
|
||||
void destroy(U*) {
|
||||
BOOST_ERROR("destroy");
|
||||
}
|
||||
|
||||
int state() const {
|
||||
return state_;
|
||||
}
|
||||
|
||||
private:
|
||||
int state_;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>& lhs, const creator<U>& rhs)
|
||||
{
|
||||
return lhs.state() == rhs.state();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>& lhs, const creator<U>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
class type {
|
||||
public:
|
||||
type() { }
|
||||
|
||||
type(int value)
|
||||
: value_(value) { }
|
||||
|
||||
int value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
inline bool
|
||||
operator==(const type& lhs, const type& rhs)
|
||||
{
|
||||
return lhs.value() == rhs.value();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
void test(const A& allocator)
|
||||
{
|
||||
std::vector<typename A::value_type, A> v(allocator);
|
||||
v.push_back(1);
|
||||
BOOST_TEST(v.front() == 1);
|
||||
v.clear();
|
||||
v.resize(5);
|
||||
v.front() = 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(boost::noinit_adaptor<creator<int> >(1));
|
||||
test(boost::noinit_adaptor<creator<type> >(2));
|
||||
test(boost::noinit_adapt(creator<int>(3)));
|
||||
test(boost::noinit_adapt(creator<type>(4)));
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/nvp_test.cpp
Normal file
46
test/nvp_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/nvp.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void test()
|
||||
{
|
||||
const char* n = "name";
|
||||
int v = 1;
|
||||
boost::nvp<int> p(n, v);
|
||||
BOOST_TEST_EQ(p.name(), n);
|
||||
BOOST_TEST_EQ(p.value(), 1);
|
||||
BOOST_TEST_EQ(&p.value(), &v);
|
||||
}
|
||||
|
||||
void test_factory()
|
||||
{
|
||||
const char* n = "name";
|
||||
int v = 1;
|
||||
boost::nvp<int> p = boost::make_nvp(n, v);
|
||||
BOOST_TEST_EQ(p.name(), n);
|
||||
BOOST_TEST_EQ(p.value(), 1);
|
||||
BOOST_TEST_EQ(&p.value(), &v);
|
||||
}
|
||||
|
||||
void test_macro()
|
||||
{
|
||||
int v = 1;
|
||||
boost::nvp<int> p = BOOST_NVP(v);
|
||||
BOOST_TEST_CSTR_EQ(p.name(), "v");
|
||||
BOOST_TEST_EQ(p.value(), 1);
|
||||
BOOST_TEST_EQ(&p.value(), &v);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
test_factory();
|
||||
test_macro();
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/underlying_type.hpp>
|
||||
#include <boost/visit_each.hpp>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user