forked from boostorg/core
Compare commits
161 Commits
boost-1.73
...
feature/cm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ec157eb6f | ||
|
|
75fc48ad32 | ||
|
|
6985b1ae25 | ||
|
|
8ab119135c | ||
|
|
1fd2cadddd | ||
|
|
bb0c6381f6 | ||
|
|
4f6f7c3799 | ||
|
|
cd1a8fd238 | ||
|
|
b0b48c5783 | ||
|
|
ccdf5ce031 | ||
|
|
f833040d48 | ||
|
|
b93317815c | ||
|
|
01bd23df5d | ||
|
|
36cec9a5cc | ||
|
|
5e382efa84 | ||
|
|
e260bb865d | ||
|
|
f884833b42 | ||
|
|
8265fe6405 | ||
|
|
f7b04afe4d | ||
|
|
2c1eb07a68 | ||
|
|
a5cbddc466 | ||
|
|
91a64b3bcf | ||
|
|
a039f8c318 | ||
|
|
bebb7349ba | ||
|
|
dc6e3261ec | ||
|
|
15a7d84858 | ||
|
|
06023d4ffe | ||
|
|
3e0bc52c32 | ||
|
|
b83f27a9e0 | ||
|
|
578e3105b8 | ||
|
|
f34c4986c1 | ||
|
|
cfd469d858 | ||
|
|
b1e01b53f3 | ||
|
|
177c093151 | ||
|
|
cffaabead8 | ||
|
|
2715f9b5d8 | ||
|
|
8043bafb6b | ||
|
|
f6bdb17fd9 | ||
|
|
cd6847aee8 | ||
|
|
9ff312e2fb | ||
|
|
494927312d | ||
|
|
df91243a1d | ||
|
|
f4b3d5dba6 | ||
|
|
9f0b97c80b | ||
|
|
ce53cc1f8f | ||
|
|
8fad14b804 | ||
|
|
24b6d89e7f | ||
|
|
ffd79a28e1 | ||
|
|
aa97e418f2 | ||
|
|
f563d50d42 | ||
|
|
c55a20dff2 | ||
|
|
bc508f8b4c | ||
|
|
03c5481dd4 | ||
|
|
8e7ee90080 | ||
|
|
128d9314d6 | ||
|
|
012d96a72b | ||
|
|
27d700ec01 | ||
|
|
507c182f4c | ||
|
|
1a011cde56 | ||
|
|
71c3d320d5 | ||
|
|
b3fa7ca565 | ||
|
|
d3aa4a2f12 | ||
|
|
67107dbaf9 | ||
|
|
0b74f0d394 | ||
|
|
e53393357f | ||
|
|
7daee1d41b | ||
|
|
ddbaa242a9 | ||
|
|
86bff4c2d3 | ||
|
|
2e5ecbe6f6 | ||
|
|
1c43651533 | ||
|
|
afba04cf7f | ||
|
|
0ae16756eb | ||
|
|
2729beab83 | ||
|
|
71d60a3fb7 | ||
|
|
2642ad4562 | ||
|
|
f7c1f6c6ab | ||
|
|
10eb5cdf7c | ||
|
|
82a51aea40 | ||
|
|
5726534f6d | ||
|
|
a13a82f8c1 | ||
|
|
cb94f76a5e | ||
|
|
a6cab03127 | ||
|
|
fa82b680cf | ||
|
|
16e9536146 | ||
|
|
919b98d425 | ||
|
|
e8aa0c75b4 | ||
|
|
8bd2239b0b | ||
|
|
c838ebc003 | ||
|
|
aca46fae91 | ||
|
|
409c809cd8 | ||
|
|
dc8aa5eb39 | ||
|
|
26728848b4 | ||
|
|
3e41929dfb | ||
|
|
579cb8f7f3 | ||
|
|
3b14a3677d | ||
|
|
26991f0c75 | ||
|
|
cc877e6b5b | ||
|
|
123b567051 | ||
|
|
a47eebf41a | ||
|
|
045487ba96 | ||
|
|
804c5b250d | ||
|
|
bee040b8cc | ||
|
|
c307f86520 | ||
|
|
0364b64927 | ||
|
|
a04803b6cb | ||
|
|
88896d0805 | ||
|
|
bff4172486 | ||
|
|
ea0b1dc8a9 | ||
|
|
3d6683edb5 | ||
|
|
72089753f7 | ||
|
|
156a016865 | ||
|
|
0dcd164a12 | ||
|
|
54671134ae | ||
|
|
7bc2873e38 | ||
|
|
ca4893063f | ||
|
|
dcc04c5508 | ||
|
|
484487f958 | ||
|
|
503d035b7f | ||
|
|
35a025d59b | ||
|
|
c6d72da515 | ||
|
|
f96fb31850 | ||
|
|
b414be98c9 | ||
|
|
544fd495e5 | ||
|
|
e155e13084 | ||
|
|
6e36923915 | ||
|
|
b67cce85c8 | ||
|
|
376aa7aa31 | ||
|
|
65901249d5 | ||
|
|
1c16d5ed87 | ||
|
|
27715ed01a | ||
|
|
9f2dbba2fc | ||
|
|
0159b6d8e5 | ||
|
|
0dbd5aaadd | ||
|
|
34373b0127 | ||
|
|
6a33e879dd | ||
|
|
15db54983b | ||
|
|
fa6e38a9aa | ||
|
|
38f827e092 | ||
|
|
2b102e7357 | ||
|
|
9c33851420 | ||
|
|
fb593cbbc8 | ||
|
|
032ce991fb | ||
|
|
6444de7098 | ||
|
|
d3a64554f4 | ||
|
|
a57c1e0a80 | ||
|
|
e9ff763d79 | ||
|
|
6069fea76d | ||
|
|
3ca745f400 | ||
|
|
94def8a3a6 | ||
|
|
295b72cbc0 | ||
|
|
eb86df4a04 | ||
|
|
0a6b8e667b | ||
|
|
4d08e709fe | ||
|
|
12ff209bf7 | ||
|
|
bb0ef6d41e | ||
|
|
2dd51f248b | ||
|
|
8fe9805792 | ||
|
|
6624532550 | ||
|
|
c31e23b362 | ||
|
|
690514e87c | ||
|
|
080e8581d5 |
509
.github/workflows/ci.yml
vendored
Normal file
509
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,509 @@
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
#
|
||||
# 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)
|
||||
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
concurrency:
|
||||
group: ${{format('{0}:{1}', github.repository, github.ref)}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GIT_FETCH_JOBS: 8
|
||||
NET_RETRY_COUNT: 5
|
||||
DEFAULT_BUILD_VARIANT: debug,release
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Linux, gcc
|
||||
- toolset: gcc-4.4
|
||||
cxxstd: "98,0x"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.6
|
||||
cxxstd: "03,0x"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.7
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-7
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-9
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-11
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- name: UBSAN
|
||||
toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
ubsan: 1
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-11
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-7
|
||||
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-8
|
||||
- g++-7
|
||||
gcc_toolchain: 7
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
ubsan: 1
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
|
||||
- name: CMake tests
|
||||
cmake_tests: 1
|
||||
os: ubuntu-20.04
|
||||
|
||||
timeout-minutes: 120
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
steps:
|
||||
- name: Setup environment
|
||||
run: |
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
fi
|
||||
if [ -n "${{matrix.container}}" ]
|
||||
then
|
||||
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 git cmake
|
||||
fi
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
|
||||
SOURCES=(${{join(matrix.sources, ' ')}})
|
||||
for key in "${SOURCE_KEYS[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
wget -O - "$key" | sudo apt-key add - && break || sleep 2
|
||||
done
|
||||
done
|
||||
if [ ${#SOURCES[@]} -gt 0 ]
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS=("-y")
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS=0
|
||||
SOFTWARE_PROPERTIES_VERSION="$(dpkg-query --showformat='${Version}' --show software-properties-common)"
|
||||
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.96.24.20"
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS+=("-n")
|
||||
fi
|
||||
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.98.10"
|
||||
then
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS=1
|
||||
fi
|
||||
for source in "${SOURCES[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
|
||||
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
|
||||
then
|
||||
case "$source" in
|
||||
"ppa:"*)
|
||||
APT_ADD_REPO_ARGS+=("-P")
|
||||
;;
|
||||
"deb "*)
|
||||
APT_ADD_REPO_ARGS+=("-S")
|
||||
;;
|
||||
*)
|
||||
APT_ADD_REPO_ARGS+=("-U")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
APT_ADD_REPO_ARGS+=("$source")
|
||||
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
|
||||
done
|
||||
done
|
||||
fi
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
|
||||
|
||||
- name: Setup GCC Toolchain
|
||||
if: matrix.gcc_toolchain
|
||||
run: |
|
||||
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
|
||||
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
|
||||
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT"
|
||||
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
|
||||
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
|
||||
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
DEPINST_ARGS=()
|
||||
GIT_VERSION="$(git --version | sed -e 's/git version //')"
|
||||
GIT_HAS_JOBS=1
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
|
||||
then
|
||||
GIT_HAS_JOBS=0
|
||||
fi
|
||||
else
|
||||
declare -a GIT_VER=(${GIT_VERSION//./ })
|
||||
declare -a GIT_MIN_VER=(2 8 0)
|
||||
for ((i=0; i<${#GIT_VER[@]}; i++))
|
||||
do
|
||||
if [ -z "${GIT_MIN_VER[i]}" ]
|
||||
then
|
||||
GIT_MIN_VER[i]=0
|
||||
fi
|
||||
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
|
||||
then
|
||||
GIT_HAS_JOBS=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$GIT_HAS_JOBS" -ne 0 ]
|
||||
then
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
fi
|
||||
cd ..
|
||||
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
if [ -z "${{matrix.cmake_tests}}" ]
|
||||
then
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
|
||||
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
|
||||
fi
|
||||
echo " ;" >> ~/user-config.jam
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
if: matrix.cmake_tests == ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
|
||||
if [ -n "${{matrix.build_variant}}" ]
|
||||
then
|
||||
B2_ARGS+=("variant=${{matrix.build_variant}}")
|
||||
else
|
||||
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
|
||||
fi
|
||||
if [ -n "${{matrix.threading}}" ]
|
||||
then
|
||||
B2_ARGS+=("threading=${{matrix.threading}}")
|
||||
fi
|
||||
if [ -n "${{matrix.ubsan}}" ]
|
||||
then
|
||||
export UBSAN_OPTIONS="print_stacktrace=1"
|
||||
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
|
||||
fi
|
||||
if [ -n "${{matrix.cxxflags}}" ]
|
||||
then
|
||||
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
|
||||
fi
|
||||
if [ -n "${{matrix.linkflags}}" ]
|
||||
then
|
||||
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
|
||||
fi
|
||||
B2_ARGS+=("libs/$LIBRARY/test")
|
||||
./b2 "${B2_ARGS[@]}"
|
||||
|
||||
- name: Run CMake tests
|
||||
if: matrix.cmake_tests != ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build_cmake_test__ && cd __build_cmake_test__
|
||||
cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=$LIBRARY ..
|
||||
cmake --build . --target tests
|
||||
ctest --output-on-failure
|
||||
|
||||
- name: Run CMake subdir tests
|
||||
if: matrix.cmake_tests != ''
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
cmake --build . --target check
|
||||
|
||||
- name: Run CMake install tests
|
||||
if: matrix.cmake_tests != ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build . --target install
|
||||
cd ../libs/$LIBRARY/test/cmake_install_test
|
||||
mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
cmake --build . --target check
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.1
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2016
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
||||
387
.travis.yml
387
.travis.yml
@@ -1,387 +0,0 @@
|
||||
# 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
|
||||
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-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
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
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
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-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
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/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
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
|
||||
- ./b2 -j $BUILD_JOBS libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
@@ -17,13 +17,6 @@ target_link_libraries(boost_core
|
||||
Boost::config
|
||||
)
|
||||
|
||||
if(BOOST_SUPERPROJECT_VERSION)
|
||||
|
||||
include(BoostInstall)
|
||||
boost_install(TARGETS boost_core HEADER_DIRECTORY include/)
|
||||
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
10
README.md
10
README.md
@@ -8,12 +8,12 @@ The criteria for inclusion is that the utility component be:
|
||||
* used by other Boost libraries, and
|
||||
* not dependent on any other Boost modules except Core itself, Config, Assert, Static Assert, or Predef.
|
||||
|
||||
### CI Status
|
||||
### Build Status
|
||||
|
||||
Branch | Travis | Appveyor
|
||||
---------|--------|---------
|
||||
Develop | [](https://travis-ci.org/boostorg/core) | [](https://ci.appveyor.com/project/pdimov/core)
|
||||
Master | [](https://travis-ci.org/boostorg/core) | [](https://ci.appveyor.com/project/pdimov/core)
|
||||
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
|
||||
---------|----------------|--------- | ----------- | ------------ |
|
||||
Develop | [](https://github.com/boostorg/filesystem/actions?query=branch%3Adevelop) | [](https://ci.appveyor.com/project/pdimov/core) | [](http://www.boost.org/development/tests/develop/developer/core.html) | [](https://pdimov.github.io/boostdep-report/develop/core.html)
|
||||
Master | [](https://github.com/boostorg/filesystem/actions?query=branch%3Amaster) | [](https://ci.appveyor.com/project/pdimov/core) | [](http://www.boost.org/development/tests/master/developer/core.html) | [](https://pdimov.github.io/boostdep-report/master/core.html)
|
||||
|
||||
### Directories
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
@@ -36,7 +37,7 @@ environment:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
CXXSTD: 14,17,latest
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
|
||||
243
doc/allocator_access.qbk
Normal file
243
doc/allocator_access.qbk
Normal file
@@ -0,0 +1,243 @@
|
||||
[/
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section Allocator Access]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header `<boost/core/allocator_access.hpp>` provides the class and function
|
||||
templates to simplify allocator use. It provides the same functionality as the
|
||||
C++ standard library `std::allocator_traits` but with individual templates for
|
||||
each allocator feature.
|
||||
|
||||
These facilities also simplify existing libraries by avoiding having to check
|
||||
for `BOOST_NO_CXX11_ALLOCATOR` and conditionally use `std::allocator_traits`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following example shows these utilities used in the definition of
|
||||
an allocator-aware container class:
|
||||
|
||||
```
|
||||
template<class T, class A = boost::default_allocator<T> >
|
||||
class container
|
||||
: boost::empty_value<typename boost::allocator_rebind<A, T>::type> {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef A allocator_type;
|
||||
typedef typename boost::allocator_size_type<A>::type size_type;
|
||||
typedef typename boost::allocator_difference_type<A>::type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename boost::allocator_pointer<A>::type pointer;
|
||||
typedef typename boost::allocator_const_pointer<A>::type const_pointer;
|
||||
// ...
|
||||
};
|
||||
```
|
||||
|
||||
In C++11 or above, aliases such as `boost::allocator_pointer_t<A>` can be used
|
||||
instead of `typename boost::allocator_pointer<A>::type`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct allocator_value_type;
|
||||
|
||||
template<class A>
|
||||
using allocator_value_type_t = typename allocator_value_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_pointer_t = typename allocator_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_void_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_void_pointer_t =
|
||||
typename allocator_const_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_difference_type;
|
||||
|
||||
template<class A>
|
||||
using allocator_difference_type_t =
|
||||
typename allocator_difference_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_size_type;
|
||||
|
||||
template<class A>
|
||||
using allocator_size_type_t = typename allocator_size_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_copy_assignment;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_copy_assignment_t =
|
||||
typename allocator_propagate_on_container_copy_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_move_assignment_t =
|
||||
typename allocator_propagate_on_container_move_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_swap_t =
|
||||
typename allocator_propagate_on_container_swap<A>::type;
|
||||
|
||||
template<class A>
|
||||
struct allocator_is_always_equal;
|
||||
|
||||
template<class A>
|
||||
using allocator_is_always_equal_t =
|
||||
typename allocator_is_always_equal<A>::type;
|
||||
|
||||
template<class A, class T>
|
||||
struct allocator_rebind;
|
||||
|
||||
template<class A, class T>
|
||||
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
|
||||
|
||||
template<class A>
|
||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);
|
||||
|
||||
template<class A>
|
||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n,
|
||||
allocator_const_void_pointer_t<A> h);
|
||||
|
||||
template<class A>
|
||||
void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
||||
allocator_size_type_t<A> n);
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
void allocator_construct(A& a, T* p, Args&&... args);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_destroy(A& a, T* p);
|
||||
|
||||
template<class A>
|
||||
allocator_size_type_t<A> allocator_max_size(const A& a);
|
||||
|
||||
template<class A>
|
||||
A allocator_select_on_container_copy_construction(const A& a);
|
||||
|
||||
} // boost
|
||||
```
|
||||
|
||||
[section Types]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A> struct allocator_value_type;`]
|
||||
[The member `type` is `A::value_type`.]]
|
||||
[[`template<class A> struct allocator_pointer;`]
|
||||
[The member `type` is `A::pointer` if valid, otherwise `A::value_type*`.]]
|
||||
[[`template<class A> struct allocator_const_pointer;`]
|
||||
[The member `type` is `A::const_pointer` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::rebind<const
|
||||
allocator_value_type_t<A> >`.]]
|
||||
[[`template<class A> struct allocator_void_pointer;`]
|
||||
[The member `type` is `A::void_pointer` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::rebind<void>`.]]
|
||||
[[`template<class A> struct allocator_const_void_pointer;`]
|
||||
[The member `type` is `A::const_void_pointer` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::rebind<const void>`.]]
|
||||
[[`template<class A> struct allocator_difference_type;`]
|
||||
[The member `type` is `A::difference_type` if valid, otherwise
|
||||
`pointer_traits<allocator_pointer_t<A> >::difference_type`.]]
|
||||
[[`template<class A> struct allocator_size_type;`]
|
||||
[The member `type` is `A::size_type` if valid, otherwise
|
||||
`std::make_unsigned_t<allocator_difference_type_t<A> >`.]]
|
||||
[[`template<class A> struct allocator_propagate_on_container_copy_assignment;`]
|
||||
[The member `type` is `A::propagate_on_container_copy_assignment` if valid,
|
||||
otherwise `std::false_type`.]]
|
||||
[[`template<class A> struct allocator_propagate_on_container_move_assignment;`]
|
||||
[The member `type` is `A::propagate_on_container_move_assignment` if valid,
|
||||
otherwise `std::false_type`.]]
|
||||
[[`template<class A> struct allocator_propagate_on_container_swap;`]
|
||||
[The member `type` is `A::propagate_on_container_swap` if valid, otherwise
|
||||
`std::false_type`.]]
|
||||
[[`template<class A> struct allocator_is_always_equal;`]
|
||||
[The member `type` is `A::is_always_equal` if valid, otherwise
|
||||
`std::is_empty<A>::type`.]]
|
||||
[[`template<class A, class T> struct allocator_rebind;`]
|
||||
[The member `type` is `A::rebind<T>::other` if valid, otherwise `A<T, Args>`
|
||||
if this `A` is `A<U, Args>`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A>
|
||||
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);`]
|
||||
[Calls `a.allocate(n)`.]]
|
||||
[[`template<class A> allocator_pointer_t<A> allocator_allocate(A& a,
|
||||
allocator_size_type_t<A> n, allocator_const_void_pointer_t<A> hint);`]
|
||||
[Calls `a.allocate(n, hint)` if valid, otherwise calls `a.allocate(n)`.]]
|
||||
[[`template<class A> void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
||||
allocator_size_type_t<A> n);`]
|
||||
[Calls `a.deallocate(p, n)`.]]
|
||||
[[`template<class A, class T, class... Args>
|
||||
void allocator_construct(A& a, T*p, Args&&... args);`]
|
||||
[Calls `a.construct(p, std::forward<Args>(args)...)` if valid, otherwise calls
|
||||
`::new(static_cast<void*>(p)) T(std::forward<Args>(args)...)`.]]
|
||||
[[`template<class A, class T> void allocator_destroy(A& a, T* p);`]
|
||||
[Calls `a.destroy(p)` if valid, otherwise calls `p->~T()`.]]
|
||||
[[`template<class A> allocator_size_type_t<A> allocator_max_size(const A& a);`]
|
||||
[Returns `a.max_size()` if valid, otherwise returns
|
||||
`std::numeric_limits<allocator_size_type_t<A> >::max() /
|
||||
sizeof(A::value_type)`.]]
|
||||
[[`template<class A> A allocator_select_on_container_copy_construction(const
|
||||
A& a);`]
|
||||
[Returns `a.select_on_container_copy_construction()` if valid, otherwise
|
||||
returns `a`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Glen Fernandes implemented the allocator access utilities.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
203
doc/bit.qbk
Normal file
203
doc/bit.qbk
Normal file
@@ -0,0 +1,203 @@
|
||||
[/
|
||||
Copyright 2020 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:bit bit]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/bit.hpp>]
|
||||
|
||||
The header `<boost/core/bit.hpp>` implements, in a portable way,
|
||||
the C++20 `<bit>` header.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
// bit_cast
|
||||
|
||||
template<class To, class From>
|
||||
To bit_cast(From const& from) noexcept;
|
||||
|
||||
// Integral powers of 2
|
||||
|
||||
template<class T>
|
||||
constexpr bool has_single_bit(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr T bit_ceil(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr T bit_floor(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr T bit_width(T x) noexcept;
|
||||
|
||||
// Rotating
|
||||
|
||||
template<class T>
|
||||
constexpr T rotl(T x, int s) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr T rotr(T x, int s) noexcept;
|
||||
|
||||
// Counting
|
||||
|
||||
template<class T>
|
||||
constexpr int countl_zero(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr int countl_one(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr int countr_zero(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr int countr_one(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr int popcount(T x) noexcept;
|
||||
|
||||
// Endian
|
||||
|
||||
enum class endian
|
||||
{
|
||||
little = see below,
|
||||
big = see below,
|
||||
native = see below
|
||||
};
|
||||
|
||||
using endian_type = endian; // portable alias for C++03 code
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
Note: even though the functions are shown as `constexpr` in the synopsis, since they are implemented
|
||||
via compiler-specific intrinsics, portable code cannot generally rely on their being usable in a
|
||||
constant expression context.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section bit_cast]
|
||||
|
||||
`template<class To, class From> To bit_cast(From const& from) noexcept;`
|
||||
|
||||
* *Requires:* `To` and `From` must be trivially copyable and `sizeof(To)` must be the same as `sizeof(From)`.
|
||||
* *Returns:* A value of type `To` with the storage bytes copied from `from`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Integral powers of 2]
|
||||
|
||||
`template<class T> constexpr bool has_single_bit(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type (i.e. one of `unsigned char`, `unsigned short`, `unsigned int`, `unsigned long`, `unsigned long long`).
|
||||
* *Returns:* `true` if `x` is an integral power of two, `false` otherwise. (`has_single_bit(0u)` is false.)
|
||||
|
||||
`template<class T> constexpr T bit_ceil(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* The smallest integral power of 2 greater than or equal to `x`. If this value is not representable in `T`, behavior is undefined.
|
||||
|
||||
`template<class T> constexpr T bit_floor(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* If `x == 0`, 0; otherwise the maximal value `y` such that `has_single_bit(y)` is `true` and `y <= x`.
|
||||
|
||||
`template<class T> constexpr T bit_width(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* If `x == 0`, 0; otherwise one plus the base-2 logarithm of `x`, with any fractional part discarded.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Rotating]
|
||||
|
||||
In the following descriptions, `N` denotes `numeric_limits<T>::digits` and `r` denotes `s % N`.
|
||||
|
||||
`template<class T> constexpr T rotl(T x, int s) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* If `s` is negative, `rotr(x, -s)`; if `r` is 0, `x`; if `r` is positive, `(x << r) | (x >> (N - r))`.
|
||||
|
||||
`template<class T> constexpr T rotr(T x, int s) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* If `s` is negative, `rotl(x, -s)`; if `r` is 0, `x`; if `r` is positive, `(x >> r) | (x << (N - r))`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Counting]
|
||||
|
||||
`template<class T> constexpr int countl_zero(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* The number of consecutive 0 bits in the value of `x`, starting from the most significant ("left") bit.
|
||||
|
||||
`template<class T> constexpr int countl_one(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* The number of consecutive 1 bits in the value of `x`, starting from the most significant bit.
|
||||
|
||||
`template<class T> constexpr int countr_zero(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* The number of consecutive 0 bits in the value of `x`, starting from the least significant ("right") bit.
|
||||
|
||||
`template<class T> constexpr int countr_one(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* The number of consecutive 1 bits in the value of `x`, starting from the least significant bit.
|
||||
|
||||
`template<class T> constexpr int popcount(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* The number of 1 bits in the value of `x`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Endian]
|
||||
|
||||
Under C++11, `endian` is defined as `enum class endian` as shown in the synopsis. Under C++03, its definition is
|
||||
|
||||
``
|
||||
namespace endian
|
||||
{
|
||||
enum type
|
||||
{
|
||||
little = see below,
|
||||
big = see below,
|
||||
native = see below
|
||||
};
|
||||
}
|
||||
|
||||
typedef endian::type endian_type;
|
||||
``
|
||||
|
||||
The values of `endian::big` and `endian::little` are distinct. `endian::native` is equal to `endian::big` on
|
||||
big endian platforms, equal to `endian::little` on little endian platforms, and a distinct value on platforms
|
||||
that are neither.
|
||||
|
||||
Note that you should not rely on `little` and `big` having any specific values, because the C++20 standard
|
||||
leaves these unspecified.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
88
doc/changes.qbk
Normal file
88
doc/changes.qbk
Normal file
@@ -0,0 +1,88 @@
|
||||
[/
|
||||
Copyright 2021 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section Revision History]
|
||||
|
||||
[section Changes in 1.78.0]
|
||||
|
||||
* Added a generic implementation to `boost/core/cmath.hpp`, enabled when `BOOST_CORE_USE_GENERIC_CMATH`
|
||||
is defined or when the platform does not provide the necessary facilities in `<cmath>`.
|
||||
* Added `boost::core::type_name`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.77.0]
|
||||
|
||||
* `boost/core/uncaught_exceptions.hpp` has been modified for compatibility with Mac OS 10.4 and older.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.76.0]
|
||||
|
||||
* Add implicit conversion between compatible reference wrappers.
|
||||
* Add `boost/core/cmath.hpp`, a portable implementation of the floating point classification functions from `<cmath>`.
|
||||
* Add `boost/core/bit.hpp`, a portable implementation of the C++20 standard header `<bit>`.
|
||||
* Fix `BOOST_TEST_EQ`, `BOOST_TEST_NE` for character types under C++20.
|
||||
* Revise allocator access utilities (now support VS2013, and no workarounds use `allocator_traits`.)
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.74.0]
|
||||
|
||||
* Implemented the allocator access utilities which provide a replacement for `allocator_traits`
|
||||
with individual traits and functions for each facility. They support the C++11 allocator model
|
||||
when possible and provide a fallback for C++98 compatibility.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.71.0]
|
||||
|
||||
* Added functions `alloc_construct`, `alloc_construct_n`, `alloc_destroy`, and `alloc_destroy_n`
|
||||
in `<boost/core/alloc_construct.hpp>` for allocator aware and exception safe construction and
|
||||
destruction of objects and arrays.
|
||||
* Added constexpr functions `first_scalar` in `<boost/core/first_scalar.hpp>` for obtaining 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>*`.
|
||||
* Added class template `noinit_adaptor` in `<boost/core/noinit_adaptor.hpp>` which is an allocator adaptor
|
||||
that converts any allocator into one whose `construct(ptr)` performs default initialization via placement
|
||||
`new`, and whose `destroy(ptr)` invokes the `value_type` destructor directly.
|
||||
* Added class template `default_allocator` in `<boost/core/default_allocator.hpp>`, which can serve as a minimal
|
||||
default allocator that has interface similar to C++20 `std::allocator`, supports configurations with disabled
|
||||
exceptions and does not have `std` as an associated namespace. The allocator uses `operator new` and
|
||||
`operator delete` for allocation.
|
||||
* In `<boost/core/uncaught_exceptions.hpp>` header, added workarounds for better compatibility with QNX SDP 7.0
|
||||
when libc++/libc++abi libraries are used.
|
||||
* The `<boost/detail/sp_typeinfo.hpp>` header is now marked as deprecated and will be removed in a future release.
|
||||
`<boost/core/typeinfo.hpp>` should be used instead.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.69.0]
|
||||
|
||||
* Implemented `boost::empty_value`, for library authors to conveniently leverage the Empty Base Optimization to
|
||||
store objects of potentially empty types.
|
||||
* Implemented `boost::quick_exit` to provide the C++11 standard library facility `std::quick_exit` functionality.
|
||||
* Reduced the number of statics in Lightweight Test, and employ lighter abort behavior for MSVC compilers upon
|
||||
failure to call `boost::report_errors`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.67.0]
|
||||
|
||||
* Updated `to_address` and `pointer_traits` to reflect the design adopted for C++20 in
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r2.html P0653R2].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.65.0]
|
||||
|
||||
* Implemented `pointer_traits` for C++03 and higher, that implements
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r0.html P0653r0].
|
||||
* Added `BOOST_TEST_GT` and `BOOST_TEST_GE` to Lightweight Test.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
122
doc/cmath.qbk
Normal file
122
doc/cmath.qbk
Normal file
@@ -0,0 +1,122 @@
|
||||
[/
|
||||
Copyright 2018 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:cmath cmath]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/cmath.hpp>]
|
||||
|
||||
The header `<boost/core/cmath.hpp>` defines, in a portable way, the floating
|
||||
point classification and sign manipulation functions from C++11.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
// fpclassify return values
|
||||
|
||||
int const fp_zero = /*unspecified*/;
|
||||
int const fp_subnormal = /*unspecified*/;
|
||||
int const fp_normal = /*unspecified*/;
|
||||
int const fp_infinite = /*unspecified*/;
|
||||
int const fp_nan = /*unspecified*/;
|
||||
|
||||
// Classification functions
|
||||
|
||||
template<class T> bool isfinite( T x );
|
||||
template<class T> bool isnan( T x );
|
||||
template<class T> bool isinf( T x );
|
||||
template<class T> bool isnormal( T x );
|
||||
template<class T> int fpclassify( T x );
|
||||
|
||||
// Sign manipulation functions
|
||||
|
||||
template<class T> bool signbit( T x );
|
||||
template<class T> T copysign( T x, T y );
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Classification Functions]
|
||||
|
||||
[section template<class T> bool isfinite( T x );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:* `true` when `x` is finite (not infinity or NaN), `false` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section template<class T> bool isnan( T x );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:* `true` when `x` is NaN, `false` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section template<class T> bool isinf( T x );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:* `true` when `x` is infinity, `false` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section template<class T> bool isnormal( T x );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:* `true` when `x` is a normal number (not zero, subnormal, infinity, or NaN), `false` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section template<class T> int fpclassify( T x );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:*
|
||||
* `fp_zero` when `x` is zero;
|
||||
* `fp_subnormal` when `x` is subnormal;
|
||||
* `fp_infinite` when `x` is infinity;
|
||||
* `fp_nan` when `x` is NaN;
|
||||
* `fp_normal` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Sign Manipulation Functions]
|
||||
|
||||
[section template<class T> bool signbit( T x );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:* `true` when `x` is negative, `false` otherwise.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section template<class T> bool copysign( T x, T y );]
|
||||
|
||||
* *Requires:* `T` must be `float`, `double`, or `long double`.
|
||||
* *Returns:* `x` with the sign copied from `y`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -38,9 +38,14 @@ criteria for inclusion is that the utility component be:
|
||||
|
||||
[endsect]
|
||||
|
||||
[include changes.qbk]
|
||||
|
||||
[include addressof.qbk]
|
||||
[include allocator_access.qbk]
|
||||
[include alloc_construct.qbk]
|
||||
[include bit.qbk]
|
||||
[include checked_delete.qbk]
|
||||
[include cmath.qbk]
|
||||
[include default_allocator.qbk]
|
||||
[include demangle.qbk]
|
||||
[include empty_value.qbk]
|
||||
@@ -62,5 +67,6 @@ criteria for inclusion is that the utility component be:
|
||||
[include scoped_enum.qbk]
|
||||
[include swap.qbk]
|
||||
[include typeinfo.qbk]
|
||||
[include type_name.qbk]
|
||||
[include uncaught_exceptions.qbk]
|
||||
[include use_default.qbk]
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
empty_value() = default;
|
||||
|
||||
template<class... Args>
|
||||
explicit empty_value(empty_init_t, Args&&... args);
|
||||
empty_value(empty_init_t, Args&&... args);
|
||||
|
||||
const T& get() const noexcept;
|
||||
|
||||
|
||||
@@ -43,9 +43,11 @@ When using `lightweight_test.hpp`, *do not forget* to
|
||||
#define BOOST_TEST_GE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_WITH(expr1, expr2, pred) /*unspecified*/
|
||||
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */
|
||||
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) /* unspecified */
|
||||
#define BOOST_TEST_THROWS(expr, excep) /*unspecified*/
|
||||
#define BOOST_TEST_NO_THROW(expr) /*unspecified*/
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -174,6 +176,17 @@ Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointe
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_WITH]
|
||||
|
||||
``
|
||||
BOOST_TEST_WITH(expr1, expr2, pred)
|
||||
``
|
||||
|
||||
If `pred(expr1, expr2)` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_ALL_EQ]
|
||||
|
||||
``
|
||||
@@ -209,6 +222,20 @@ nothing and `expr` is not evaluated.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_NO_THROW]
|
||||
|
||||
``
|
||||
BOOST_TEST_NO_THROW(expr)
|
||||
``
|
||||
|
||||
If `BOOST_NO_EXCEPTIONS` is *not* defined and if `expr` throws an exception,
|
||||
increases the error count and outputs a message containing the expression
|
||||
and (if possible) the exception message.
|
||||
|
||||
If `BOOST_NO_EXCEPTIONS` is defined, `expr` is evaluated.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section report_errors]
|
||||
|
||||
``
|
||||
|
||||
@@ -71,8 +71,7 @@ struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
typedef noinit_adaptor<allocator_rebind_t<A, U> > other;
|
||||
};
|
||||
|
||||
noinit_adaptor() noexcept;
|
||||
@@ -86,9 +85,6 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
void construct(U* p);
|
||||
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args);
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p);
|
||||
};
|
||||
@@ -121,7 +117,7 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
[[variablelist
|
||||
[[Requires][`A` shall be constructible from `U`.]]
|
||||
[[Effects][Initializes the `A` base class with
|
||||
`static_cast<const U&>(u)`.]]]]]]
|
||||
`static_cast<const A&>(u)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -131,11 +127,6 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
[[`template<class U> void construct(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new((void*)p) U`.]]]]]
|
||||
[[`template<class U, class V, class... Args> void construct(U* p, V&& v,
|
||||
Args&&... args);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new(void*)p) U(std::forward<V>(v),
|
||||
std::forward<Args>(args)...)`.]]]]]
|
||||
[[`template<class U> void destroy(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`p->~U()`.]]]]]]
|
||||
|
||||
77
doc/type_name.qbk
Normal file
77
doc/type_name.qbk
Normal file
@@ -0,0 +1,77 @@
|
||||
[/
|
||||
Copyright 2021 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:type_name type_name]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/type_name.hpp>]
|
||||
|
||||
The header `<boost/core/type_name.hpp>` defines the function
|
||||
template `boost::core::type_name<T>()` that returns a string
|
||||
representation of the name of `T`, suitable for logging or
|
||||
diagnostic display purposes.
|
||||
|
||||
The result is similar to `boost::core::demangle( typeid(T).name() )`,
|
||||
but it's made more regular by eliminating some of the platform-specific
|
||||
differences and extra template parameters of the standard library
|
||||
container types.
|
||||
|
||||
For example, `type_name< std::map<std::string, int> >()` returns
|
||||
`"std::map<std::string, int>"` and not
|
||||
|
||||
```
|
||||
std::map<std::__cxx11::basic_string<char, std::char_traits<char>,
|
||||
std::allocator<char> >, int, std::less<std::__cxx11::basic_string<char,
|
||||
std::char_traits<char>, std::allocator<char> > >, std::allocator<
|
||||
std::pair<std::__cxx11::basic_string<char, std::char_traits<char>,
|
||||
std::allocator<char> > const, int> > >
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
class std::map<class std::basic_string<char,struct std::char_traits<char>,
|
||||
class std::allocator<char> >,int,struct std::less<class std::basic_string<
|
||||
char,struct std::char_traits<char>,class std::allocator<char> > >,class
|
||||
std::allocator<struct std::pair<class std::basic_string<char,struct
|
||||
std::char_traits<char>,class std::allocator<char> > const ,int> > >
|
||||
```
|
||||
|
||||
The return values aren't guaranteed to be stable across Boost releases.
|
||||
|
||||
Compilation with `-fno-rtti` is supported, but the returned type names aren't
|
||||
guaranteed to be particularly useful or unique.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
template<class T> std::string type_name();
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section template<class T> std::string type_name();]
|
||||
|
||||
* *Returns:* A string representation of the name of `T`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -125,7 +125,7 @@ template<class T>
|
||||
BOOST_FORCEINLINE T*
|
||||
addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) || \
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) || \
|
||||
BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
|
||||
return boost::detail::addrof<T>::get(o, 0);
|
||||
#else
|
||||
@@ -151,7 +151,7 @@ addressof(T (&o)[N]) BOOST_NOEXCEPT
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
template<class T, std::size_t N>
|
||||
BOOST_FORCEINLINE
|
||||
T (*addressof(T (&o)[N]) BOOST_NOEXCEPT)[N]
|
||||
|
||||
@@ -12,12 +12,11 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::destroy(a, p);
|
||||
boost::allocator_destroy(a, p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
@@ -25,26 +24,25 @@ inline void
|
||||
alloc_destroy_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
std::allocator_traits<A>::destroy(a, p + --n);
|
||||
boost::allocator_destroy(a, p + --n);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A&, T* p)
|
||||
alloc_destroy(noinit_adaptor<A>&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(A&, T* p, std::size_t n)
|
||||
alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
p[--n].~T();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -75,12 +73,11 @@ private:
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p);
|
||||
boost::allocator_construct(a, p);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
@@ -89,7 +86,7 @@ template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u, V&&... v)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u),
|
||||
boost::allocator_construct(a, p, std::forward<U>(u),
|
||||
std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
@@ -97,7 +94,7 @@ template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u));
|
||||
boost::allocator_construct(a, p, std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
@@ -105,14 +102,14 @@ template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, const U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
boost::allocator_construct(a, p, u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
boost::allocator_construct(a, p, u);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -122,7 +119,7 @@ alloc_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
std::allocator_traits<A>::construct(a, p + i);
|
||||
boost::allocator_construct(a, p + i);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
@@ -133,7 +130,7 @@ alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
std::allocator_traits<A>::construct(a, p + i, l[i % m]);
|
||||
boost::allocator_construct(a, p + i, l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
@@ -144,17 +141,10 @@ alloc_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
|
||||
std::allocator_traits<A>::construct(a, p + i, *b);
|
||||
boost::allocator_construct(a, p + i, *b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#else
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A&, T* p)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
@@ -163,49 +153,6 @@ alloc_construct(noinit_adaptor<A>&, T* p)
|
||||
::new(static_cast<void*>(p)) T;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, U&& u, V&&... v)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<U>(u), std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, const U& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, U& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(u);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T();
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
@@ -217,29 +164,6 @@ alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T(l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T, class I>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
|
||||
::new(static_cast<void*>(p + i)) T(*b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
||||
601
include/boost/core/allocator_access.hpp
Normal file
601
include/boost/core/allocator_access.hpp
Normal file
@@ -0,0 +1,601 @@
|
||||
/*
|
||||
Copyright 2020-2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
#endif
|
||||
#if defined(_STL_DISABLE_DEPRECATED_WARNING)
|
||||
_STL_DISABLE_DEPRECATED_WARNING
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct allocator_value_type {
|
||||
typedef typename A::value_type type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_pointer {
|
||||
typedef typename A::pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_pointer {
|
||||
typedef typename A::value_type* type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class>
|
||||
struct alloc_void {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_pointer<A,
|
||||
typename detail::alloc_void<typename A::pointer>::type> {
|
||||
typedef typename A::pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::template
|
||||
rebind_to<const typename A::value_type>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_pointer<A,
|
||||
typename detail::alloc_void<typename A::const_pointer>::type> {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename A::template rebind<void>::other::pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::template
|
||||
rebind_to<void>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_void_pointer<A,
|
||||
typename detail::alloc_void<typename A::void_pointer>::type> {
|
||||
typedef typename A::void_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename A::template rebind<void>::other::const_pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::template
|
||||
rebind_to<const void>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer<A,
|
||||
typename detail::alloc_void<typename A::const_void_pointer>::type> {
|
||||
typedef typename A::const_void_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_difference_type {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_difference_type {
|
||||
typedef typename pointer_traits<typename
|
||||
allocator_pointer<A>::type>::difference_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_difference_type<A,
|
||||
typename detail::alloc_void<typename A::difference_type>::type> {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_size_type {
|
||||
typedef typename std::make_unsigned<typename
|
||||
allocator_difference_type<A>::type>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_size_type<A,
|
||||
typename detail::alloc_void<typename A::size_type>::type> {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
namespace detail {
|
||||
|
||||
struct alloc_false {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_copy_assignment<A,
|
||||
typename detail::alloc_void<typename
|
||||
A::propagate_on_container_copy_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_copy_assignment type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment<A,
|
||||
typename detail::alloc_void<typename
|
||||
A::propagate_on_container_move_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_move_assignment type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap<A,
|
||||
typename detail::alloc_void<typename
|
||||
A::propagate_on_container_swap>::type> {
|
||||
typedef typename A::propagate_on_container_swap type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_is_always_equal {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename std::is_empty<A>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct allocator_is_always_equal<A,
|
||||
typename detail::alloc_void<typename A::is_always_equal>::type> {
|
||||
typedef typename A::is_always_equal type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
struct allocator_rebind {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class>
|
||||
struct alloc_to { };
|
||||
|
||||
template<template<class, class...> class A, class T, class U, class... V>
|
||||
struct alloc_to<A<U, V...>, T> {
|
||||
typedef A<T, V...> type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T, class = void>
|
||||
struct allocator_rebind {
|
||||
typedef typename detail::alloc_to<A, T>::type type;
|
||||
};
|
||||
|
||||
template<class A, class T>
|
||||
struct allocator_rebind<A, T,
|
||||
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n)
|
||||
{
|
||||
return a.allocate(n);
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline void
|
||||
allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
|
||||
typename allocator_size_type<A>::type n)
|
||||
{
|
||||
a.deallocate(p, n);
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
typename allocator_const_void_pointer<A>::type h)
|
||||
{
|
||||
return a.allocate(n, h);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
struct alloc_none { };
|
||||
|
||||
template<class A>
|
||||
class alloc_has_allocate {
|
||||
template<class O>
|
||||
static auto check(int) -> decltype(std::declval<O&>().allocate(
|
||||
std::declval<typename allocator_size_type<A>::type>(),
|
||||
std::declval<typename allocator_const_void_pointer<A>::type>()));
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_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 std::enable_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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_construct(A&, T* p)
|
||||
{
|
||||
::new((void*)p) T();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class V, class... Args>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V&& v, Args&&... args)
|
||||
{
|
||||
::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V&& v)
|
||||
{
|
||||
::new((void*)p) T(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, const V& v)
|
||||
{
|
||||
::new((void*)p) T(v);
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V& v)
|
||||
{
|
||||
::new((void*)p) T(v);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
class alloc_has_construct {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> decltype(std::declval<O&>().construct(std::declval<T*>(),
|
||||
std::declval<Args&&>()...));
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
inline typename std::enable_if<detail::alloc_has_construct<A, T,
|
||||
Args...>::value>::type
|
||||
allocator_construct(A& a, T* p, Args&&... args)
|
||||
{
|
||||
a.construct(p, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<class A, class T, class... Args>
|
||||
inline typename std::enable_if<!detail::alloc_has_construct<A, T,
|
||||
Args...>::value>::type
|
||||
allocator_construct(A&, T* p, Args&&... args)
|
||||
{
|
||||
::new((void*)p) T(std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class A, class T>
|
||||
class alloc_has_destroy {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> decltype(std::declval<O&>().destroy(std::declval<T*>()));
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A& a, T* p)
|
||||
{
|
||||
a.destroy(p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline typename allocator_size_type<A>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return a.max_size();
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class A>
|
||||
class alloc_has_max_size {
|
||||
template<class O>
|
||||
static auto check(int) -> decltype(std::declval<O&>().max_size());
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return a.max_size();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A&)
|
||||
{
|
||||
return (std::numeric_limits<typename
|
||||
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline A
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class A>
|
||||
class alloc_has_soccc {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> decltype(std::declval<O&>().select_on_container_copy_construction());
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a.select_on_container_copy_construction();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class A>
|
||||
using allocator_value_type_t = typename allocator_value_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_pointer_t = typename allocator_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_const_void_pointer_t =
|
||||
typename allocator_const_void_pointer<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_difference_type_t =
|
||||
typename allocator_difference_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_size_type_t = typename allocator_size_type<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_copy_assignment_t =
|
||||
typename allocator_propagate_on_container_copy_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_move_assignment_t =
|
||||
typename allocator_propagate_on_container_move_assignment<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_propagate_on_container_swap_t =
|
||||
typename allocator_propagate_on_container_swap<A>::type;
|
||||
|
||||
template<class A>
|
||||
using allocator_is_always_equal_t =
|
||||
typename allocator_is_always_equal<A>::type;
|
||||
|
||||
template<class A, class T>
|
||||
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_POP)
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
#endif
|
||||
#if defined(_STL_RESTORE_DEPRECATED_WARNING)
|
||||
_STL_RESTORE_DEPRECATED_WARNING
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
581
include/boost/core/bit.hpp
Normal file
581
include/boost/core/bit.hpp
Normal file
@@ -0,0 +1,581 @@
|
||||
#ifndef BOOST_CORE_BIT_HPP_INCLUDED
|
||||
#define BOOST_CORE_BIT_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/bit.hpp
|
||||
//
|
||||
// A portable version of the C++20 standard header <bit>
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <intrin.h>
|
||||
# pragma intrinsic(_BitScanForward)
|
||||
# pragma intrinsic(_BitScanReverse)
|
||||
# if defined(_M_X64)
|
||||
# pragma intrinsic(_BitScanForward64)
|
||||
# pragma intrinsic(_BitScanReverse64)
|
||||
# endif
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
// bit_cast
|
||||
|
||||
template<class To, class From>
|
||||
To bit_cast( From const & from ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(To) == sizeof(From) );
|
||||
|
||||
To to;
|
||||
std::memcpy( &to, &from, sizeof(To) );
|
||||
return to;
|
||||
}
|
||||
|
||||
// countl
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_CONSTEXPR inline int countl_impl( unsigned char x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_clz( x ) - ( std::numeric_limits<unsigned int>::digits - std::numeric_limits<unsigned char>::digits ): std::numeric_limits<unsigned char>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countl_impl( unsigned short x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_clz( x ) - ( std::numeric_limits<unsigned int>::digits - std::numeric_limits<unsigned short>::digits ): std::numeric_limits<unsigned short>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countl_impl( unsigned int x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_clz( x ): std::numeric_limits<unsigned int>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countl_impl( unsigned long x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_clzl( x ): std::numeric_limits<unsigned long>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countl_impl( unsigned long long x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_clzll( x ): std::numeric_limits<unsigned long long>::digits;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( x );
|
||||
}
|
||||
|
||||
#else // defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse( &r, x ) )
|
||||
{
|
||||
return 31 - static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static unsigned char const mod37[ 37 ] = { 32, 31, 6, 30, 9, 5, 0, 29, 16, 8, 2, 4, 21, 0, 19, 28, 25, 15, 0, 7, 10, 1, 17, 3, 22, 20, 26, 0, 11, 18, 23, 27, 12, 24, 13, 14, 0 };
|
||||
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
|
||||
return mod37[ x % 37 ];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse64( &r, x ) )
|
||||
{
|
||||
return 63 - static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return static_cast<boost::uint32_t>( x >> 32 ) != 0?
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ):
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 24;
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 16;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
|
||||
|
||||
if( sizeof(T) == sizeof(boost::uint8_t) )
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint8_t>( x ) );
|
||||
}
|
||||
else if( sizeof(T) == sizeof(boost::uint16_t) )
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint16_t>( x ) );
|
||||
}
|
||||
else if( sizeof(T) == sizeof(boost::uint32_t) )
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint64_t>( x ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countl_one( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::countl_zero( static_cast<T>( ~x ) );
|
||||
}
|
||||
|
||||
// countr
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_CONSTEXPR inline int countr_impl( unsigned char x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_ctz( x ): std::numeric_limits<unsigned char>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countr_impl( unsigned short x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_ctz( x ): std::numeric_limits<unsigned short>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countr_impl( unsigned int x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_ctz( x ): std::numeric_limits<unsigned int>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countr_impl( unsigned long x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_ctzl( x ): std::numeric_limits<unsigned long>::digits;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR inline int countr_impl( unsigned long long x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_ctzll( x ): std::numeric_limits<unsigned long long>::digits;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( x );
|
||||
}
|
||||
|
||||
#else // defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward( &r, x ) )
|
||||
{
|
||||
return static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static unsigned char const mod37[ 37 ] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };
|
||||
return mod37[ ( -(boost::int32_t)x & x ) % 37 ];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward64( &r, x ) )
|
||||
{
|
||||
return static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return static_cast<boost::uint32_t>( x ) != 0?
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ):
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x100 );
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x10000 );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
|
||||
|
||||
if( sizeof(T) == sizeof(boost::uint8_t) )
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint8_t>( x ) );
|
||||
}
|
||||
else if( sizeof(T) == sizeof(boost::uint16_t) )
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint16_t>( x ) );
|
||||
}
|
||||
else if( sizeof(T) == sizeof(boost::uint32_t) )
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint64_t>( x ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countr_one( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::countr_zero( static_cast<T>( ~x ) );
|
||||
}
|
||||
|
||||
// popcount
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
#if defined(__clang__) && __clang_major__ * 100 + __clang_minor__ < 304
|
||||
# define BOOST_CORE_POPCOUNT_CONSTEXPR
|
||||
#else
|
||||
# define BOOST_CORE_POPCOUNT_CONSTEXPR BOOST_CONSTEXPR
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned char x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcount( x );
|
||||
}
|
||||
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned short x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcount( x );
|
||||
}
|
||||
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned int x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcount( x );
|
||||
}
|
||||
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcountl( x );
|
||||
}
|
||||
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long long x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcountll( x );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#undef BOOST_CORE_POPCOUNT_CONSTEXPR
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::popcount_impl( x );
|
||||
}
|
||||
|
||||
#else // defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
x = x - ( ( x >> 1 ) & 0x55555555 );
|
||||
x = ( x & 0x33333333 ) + ( ( x >> 2 ) & 0x33333333 );
|
||||
x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F;
|
||||
|
||||
return static_cast<unsigned>( ( x * 0x01010101 ) >> 24 );
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
x = x - ( ( x >> 1 ) & 0x5555555555555555 );
|
||||
x = ( x & 0x3333333333333333 ) + ( ( x >> 2 ) & 0x3333333333333333 );
|
||||
x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F0F0F0F0F;
|
||||
|
||||
return static_cast<unsigned>( ( x * 0x0101010101010101 ) >> 56 );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
|
||||
|
||||
if( sizeof(T) <= sizeof(boost::uint32_t) )
|
||||
{
|
||||
return boost::core::detail::popcount_impl( static_cast<boost::uint32_t>( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return boost::core::detail::popcount_impl( static_cast<boost::uint64_t>( x ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
// rotating
|
||||
|
||||
template<class T>
|
||||
BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT
|
||||
{
|
||||
unsigned const mask = std::numeric_limits<T>::digits - 1;
|
||||
return x << (s & mask) | x >> ((-s) & mask);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT
|
||||
{
|
||||
unsigned const mask = std::numeric_limits<T>::digits - 1;
|
||||
return x >> (s & mask) | x << ((-s) & mask);
|
||||
}
|
||||
|
||||
// integral powers of 2
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x != 0 && ( x & ( x - 1 ) ) == 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return std::numeric_limits<T>::digits - boost::core::countl_zero( x );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR T bit_floor( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x == 0? 0: T(1) << ( boost::core::bit_width( x ) - 1 );
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint32_t bit_ceil_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( x == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
--x;
|
||||
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
|
||||
++x;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( x == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
--x;
|
||||
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x |= x >> 32;
|
||||
|
||||
++x;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
BOOST_CXX14_CONSTEXPR T bit_ceil( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
|
||||
|
||||
if( sizeof(T) <= sizeof(boost::uint32_t) )
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint32_t>( x ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint64_t>( x ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
// endian
|
||||
|
||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little
|
||||
|
||||
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =big
|
||||
|
||||
#elif defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER
|
||||
|
||||
#elif defined(__LITTLE_ENDIAN__)
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little
|
||||
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =big
|
||||
|
||||
#elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER =little
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_CORE_BIT_NATIVE_INITIALIZER
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
|
||||
|
||||
enum class endian
|
||||
{
|
||||
big,
|
||||
little,
|
||||
native BOOST_CORE_BIT_NATIVE_INITIALIZER
|
||||
};
|
||||
|
||||
typedef endian endian_type;
|
||||
|
||||
#else
|
||||
|
||||
namespace endian
|
||||
{
|
||||
|
||||
enum type
|
||||
{
|
||||
big,
|
||||
little,
|
||||
native BOOST_CORE_BIT_NATIVE_INITIALIZER
|
||||
};
|
||||
|
||||
} // namespace endian
|
||||
|
||||
typedef endian::type endian_type;
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_CORE_BIT_NATIVE_INITIALIZER
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_BIT_HPP_INCLUDED
|
||||
298
include/boost/core/cmath.hpp
Normal file
298
include/boost/core/cmath.hpp
Normal file
@@ -0,0 +1,298 @@
|
||||
#ifndef BOOST_CORE_CMATH_HPP_INCLUDED
|
||||
#define BOOST_CORE_CMATH_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/cmath.hpp
|
||||
//
|
||||
// Floating point classification and sign manipulation functions
|
||||
// Extracted from https://github.com/boostorg/lexical_cast/pull/37
|
||||
//
|
||||
// Copyright 2020, 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#if defined(BOOST_CORE_USE_GENERIC_CMATH) || (!defined(_MSC_VER) && !defined(FP_SUBNORMAL))
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
// fpclassify return values
|
||||
|
||||
int const fp_zero = 0;
|
||||
int const fp_subnormal = 1;
|
||||
int const fp_normal = 2;
|
||||
int const fp_infinite = 3;
|
||||
int const fp_nan = 4;
|
||||
|
||||
// Classification functions
|
||||
|
||||
template<class T> bool isfinite( T x )
|
||||
{
|
||||
return x <= (std::numeric_limits<T>::max)() && x >= -(std::numeric_limits<T>::max)();
|
||||
}
|
||||
|
||||
template<class T> bool isinf( T x )
|
||||
{
|
||||
return x > (std::numeric_limits<T>::max)() || x < -(std::numeric_limits<T>::max)();
|
||||
}
|
||||
|
||||
template<class T> bool isnan( T x )
|
||||
{
|
||||
return !isfinite( x ) && !isinf( x );
|
||||
}
|
||||
|
||||
template<class T> bool isnormal( T x )
|
||||
{
|
||||
return isfinite( x ) && ( x >= (std::numeric_limits<T>::min)() || x <= -(std::numeric_limits<T>::min)() );
|
||||
}
|
||||
|
||||
template<class T> int fpclassify( T x )
|
||||
{
|
||||
if( x == 0 ) return fp_zero;
|
||||
|
||||
if( x < 0 ) x = -x;
|
||||
|
||||
if( x > (std::numeric_limits<T>::max)() ) return fp_infinite;
|
||||
|
||||
if( x >= (std::numeric_limits<T>::min)() ) return fp_normal;
|
||||
|
||||
if( x < (std::numeric_limits<T>::min)() ) return fp_subnormal;
|
||||
|
||||
return fp_nan;
|
||||
}
|
||||
|
||||
// Sign manipulation functions
|
||||
|
||||
inline bool signbit( float x )
|
||||
{
|
||||
boost::int32_t y;
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
|
||||
|
||||
std::memcpy( &y, &x, sizeof( y ) );
|
||||
|
||||
return y < 0;
|
||||
}
|
||||
|
||||
inline bool signbit( double x )
|
||||
{
|
||||
boost::int64_t y;
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
|
||||
|
||||
std::memcpy( &y, &x, sizeof( y ) );
|
||||
|
||||
return y < 0;
|
||||
}
|
||||
|
||||
inline bool signbit( long double x )
|
||||
{
|
||||
return signbit( static_cast<double>( x ) );
|
||||
}
|
||||
|
||||
template<class T> T copysign( T x, T y )
|
||||
{
|
||||
return signbit( x ) == signbit( y )? x: -x;
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#else // defined(BOOST_CORE_USE_GENERIC_CMATH)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
# include <float.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
|
||||
template<class T> T copysign( T x, T y )
|
||||
{
|
||||
return static_cast<T>( _copysign( static_cast<double>( x ), static_cast<double>( y ) ) );
|
||||
}
|
||||
|
||||
template<class T> bool isnan( T x )
|
||||
{
|
||||
return _isnan( static_cast<double>( x ) ) != 0;
|
||||
}
|
||||
|
||||
template<class T> bool isfinite( T x )
|
||||
{
|
||||
return _finite( static_cast<double>( x ) ) != 0;
|
||||
}
|
||||
|
||||
template<class T> bool isinf( T x )
|
||||
{
|
||||
return ( _fpclass( static_cast<double>( x ) ) & ( _FPCLASS_PINF | _FPCLASS_NINF ) ) != 0;
|
||||
}
|
||||
|
||||
inline bool isnormal( float x )
|
||||
{
|
||||
// no _fpclassf in 32 bit mode
|
||||
unsigned y = reinterpret_cast< unsigned const& >( x );
|
||||
unsigned exp = ( y >> 23 ) & 0xFF;
|
||||
return exp != 0 && exp != 0xFF;
|
||||
}
|
||||
|
||||
inline bool isnormal( double x )
|
||||
{
|
||||
return ( _fpclass( x ) & ( _FPCLASS_PN | _FPCLASS_NN ) ) != 0;
|
||||
}
|
||||
|
||||
inline bool isnormal( long double x )
|
||||
{
|
||||
return boost::core::isnormal( static_cast<double>( x ) );
|
||||
}
|
||||
|
||||
template<class T> bool signbit( T x )
|
||||
{
|
||||
return _copysign( 1.0, static_cast<double>( x ) ) < 0.0;
|
||||
}
|
||||
|
||||
int const fp_zero = 0;
|
||||
int const fp_subnormal = 1;
|
||||
int const fp_normal = 2;
|
||||
int const fp_infinite = 3;
|
||||
int const fp_nan = 4;
|
||||
|
||||
inline int fpclassify( float x )
|
||||
{
|
||||
switch( _fpclass( x ) )
|
||||
{
|
||||
case _FPCLASS_SNAN:
|
||||
case _FPCLASS_QNAN:
|
||||
|
||||
return fp_nan;
|
||||
|
||||
case _FPCLASS_NINF:
|
||||
case _FPCLASS_PINF:
|
||||
|
||||
return fp_infinite;
|
||||
|
||||
case _FPCLASS_NZ:
|
||||
case _FPCLASS_PZ:
|
||||
|
||||
return fp_zero;
|
||||
|
||||
default:
|
||||
|
||||
return boost::core::isnormal( x )? fp_normal: fp_subnormal;
|
||||
}
|
||||
}
|
||||
|
||||
inline int fpclassify( double x )
|
||||
{
|
||||
switch( _fpclass( x ) )
|
||||
{
|
||||
case _FPCLASS_SNAN:
|
||||
case _FPCLASS_QNAN:
|
||||
|
||||
return fp_nan;
|
||||
|
||||
case _FPCLASS_NINF:
|
||||
case _FPCLASS_PINF:
|
||||
|
||||
return fp_infinite;
|
||||
|
||||
case _FPCLASS_NZ:
|
||||
case _FPCLASS_PZ:
|
||||
|
||||
return fp_zero;
|
||||
|
||||
case _FPCLASS_ND:
|
||||
case _FPCLASS_PD:
|
||||
|
||||
return fp_subnormal;
|
||||
|
||||
default:
|
||||
|
||||
return fp_normal;
|
||||
}
|
||||
}
|
||||
|
||||
inline int fpclassify( long double x )
|
||||
{
|
||||
return boost::core::fpclassify( static_cast<double>( x ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
using std::isfinite;
|
||||
using std::isnan;
|
||||
using std::isinf;
|
||||
using std::isnormal;
|
||||
using std::fpclassify;
|
||||
|
||||
int const fp_zero = FP_ZERO;
|
||||
int const fp_subnormal = FP_SUBNORMAL;
|
||||
int const fp_normal = FP_NORMAL;
|
||||
int const fp_infinite = FP_INFINITE;
|
||||
int const fp_nan = FP_NAN;
|
||||
|
||||
using std::signbit;
|
||||
|
||||
// std::copysign doesn't exist in libstdc++ under -std=c++03
|
||||
|
||||
#if !defined(__GNUC__)
|
||||
|
||||
template<class T> T copysign( T x, T y )
|
||||
{
|
||||
return std::copysign( x, y );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// ::copysignl is unreliable, use the built-ins
|
||||
|
||||
inline float copysign_impl( float x, float y )
|
||||
{
|
||||
return __builtin_copysignf( x, y );
|
||||
}
|
||||
|
||||
inline double copysign_impl( double x, double y )
|
||||
{
|
||||
return __builtin_copysign( x, y );
|
||||
}
|
||||
|
||||
inline long double copysign_impl( long double x, long double y )
|
||||
{
|
||||
return __builtin_copysignl( x, y );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T> T copysign( T x, T y )
|
||||
{
|
||||
return boost::core::detail::copysign_impl( x, y );
|
||||
}
|
||||
|
||||
#endif // !defined(__GNUC__)
|
||||
#endif // #if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // defined(BOOST_CORE_USE_GENERIC_CMATH)
|
||||
|
||||
#endif // #ifndef BOOST_CORE_CMATH_HPP_INCLUDED
|
||||
@@ -10,11 +10,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <new>
|
||||
#include <climits>
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
#define BOOST_CORE_NO_CXX11_ALLOCATOR
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -81,16 +76,9 @@ struct default_allocator {
|
||||
BOOST_CONSTEXPR default_allocator(const default_allocator<U>&)
|
||||
BOOST_NOEXCEPT { }
|
||||
|
||||
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
|
||||
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
|
||||
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
|
||||
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
|
||||
}
|
||||
#else
|
||||
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
T* allocate(std::size_t n) {
|
||||
@@ -120,7 +108,8 @@ struct default_allocator {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_CORE_NO_CXX11_ALLOCATOR)
|
||||
#if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \
|
||||
defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new(p) U(v);
|
||||
@@ -129,6 +118,7 @@ struct default_allocator {
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
54
include/boost/core/detail/splitmix64.hpp
Normal file
54
include/boost/core/detail/splitmix64.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
|
||||
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// An implementation of splitmix64 for testing purposes,
|
||||
// derived from Sebastiano Vigna's public domain implementation
|
||||
// http://xorshift.di.unimi.it/splitmix64.c
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class splitmix64
|
||||
{
|
||||
private:
|
||||
|
||||
boost::uint64_t x_;
|
||||
|
||||
public:
|
||||
|
||||
splitmix64(): x_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
explicit splitmix64( boost::uint64_t seed ): x_( seed )
|
||||
{
|
||||
}
|
||||
|
||||
boost::uint64_t operator()()
|
||||
{
|
||||
x_ += 0x9e3779b97f4a7c15;
|
||||
|
||||
boost::uint64_t z = x_;
|
||||
|
||||
z ^= z >> 30;
|
||||
z *= 0xbf58476d1ce4e5b9;
|
||||
z ^= z >> 27;
|
||||
z *= 0x94d049bb133111eb;
|
||||
z ^= z >> 31;
|
||||
|
||||
return z;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
|
||||
@@ -59,9 +59,9 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: value_(std::forward<Args>(args)...) { }
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: value_(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
@@ -107,9 +107,9 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: T(std::forward<Args>(args)...) { }
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: T(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
@@ -139,8 +139,7 @@ public:
|
||||
|
||||
using empty_::empty_value;
|
||||
|
||||
BOOST_INLINE_VARIABLE
|
||||
BOOST_CONSTEXPR_OR_CONST empty_init_t empty_init = empty_init_t();
|
||||
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
|
||||
|
||||
} /* boost */
|
||||
|
||||
|
||||
@@ -11,34 +11,64 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template <typename... Ts>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts&& ...)
|
||||
{}
|
||||
|
||||
#else
|
||||
|
||||
template <typename... Ts>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts const& ...)
|
||||
{}
|
||||
|
||||
#endif
|
||||
|
||||
template <typename... Ts>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
|
||||
{}
|
||||
|
||||
#else
|
||||
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename T1>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&)
|
||||
{}
|
||||
|
||||
template <typename T1>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&, T4&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&, T4&, T5&)
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&, T5 const&)
|
||||
{}
|
||||
|
||||
@@ -24,11 +24,15 @@
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
# include <crtdbg.h>
|
||||
@@ -118,14 +122,30 @@ inline void error_impl(char const * msg, char const * file, int line, char const
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
|
||||
inline void throw_failed_impl(const char* expr, char const * excep, char const * file, int line, char const * function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
|
||||
<< file << "(" << line << "): expression '" << expr << "' did not throw exception '" << excep << "' in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void no_throw_failed_impl(const char* expr, const char* file, int line, const char* function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void no_throw_failed_impl(const char* expr, const char* what, const char* file, int line, const char* function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
|
||||
<< function << "': " << what << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
|
||||
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
|
||||
// the dependency we just disable the warnings.
|
||||
@@ -156,42 +176,128 @@ template<class T> inline const void* test_output_impl(T volatile* v) { return co
|
||||
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
||||
#endif
|
||||
|
||||
struct lw_test_eq {
|
||||
// print chars as numeric
|
||||
|
||||
inline int test_output_impl( signed char const& v ) { return v; }
|
||||
inline unsigned test_output_impl( unsigned char const& v ) { return v; }
|
||||
|
||||
// Whether wchar_t is signed is implementation-defined
|
||||
|
||||
template<bool Signed> struct lwt_long_type {};
|
||||
template<> struct lwt_long_type<true> { typedef long type; };
|
||||
template<> struct lwt_long_type<false> { typedef unsigned long type; };
|
||||
|
||||
inline lwt_long_type<(static_cast<wchar_t>(-1) < static_cast<wchar_t>(0))>::type test_output_impl( wchar_t const& v ) { return v; }
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_CHAR16_T )
|
||||
inline unsigned long test_output_impl( char16_t const& v ) { return v; }
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_CHAR32_T )
|
||||
inline unsigned long test_output_impl( char32_t const& v ) { return v; }
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
inline std::string test_output_impl( char const& v )
|
||||
{
|
||||
if( std::isprint( static_cast<unsigned char>( v ) ) )
|
||||
{
|
||||
return std::string( 1, v );
|
||||
}
|
||||
else
|
||||
{
|
||||
char buffer[ 8 ];
|
||||
std::sprintf( buffer, "\\x%02X", static_cast<unsigned char>( v ) );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// predicates
|
||||
|
||||
struct lw_test_eq
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t == u; }
|
||||
static const char* op() { return "=="; }
|
||||
};
|
||||
|
||||
struct lw_test_ne {
|
||||
struct lw_test_ne
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t != u; }
|
||||
static const char* op() { return "!="; }
|
||||
};
|
||||
|
||||
struct lw_test_lt {
|
||||
struct lw_test_lt
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t < u; }
|
||||
static const char* op() { return "<"; }
|
||||
};
|
||||
|
||||
struct lw_test_le {
|
||||
struct lw_test_le
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t <= u; }
|
||||
static const char* op() { return "<="; }
|
||||
};
|
||||
|
||||
struct lw_test_gt {
|
||||
struct lw_test_gt
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t > u; }
|
||||
static const char* op() { return ">"; }
|
||||
};
|
||||
|
||||
struct lw_test_ge {
|
||||
struct lw_test_ge
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t >= u; }
|
||||
static const char* op() { return ">="; }
|
||||
};
|
||||
|
||||
// lwt_predicate_name
|
||||
|
||||
template<class T> char const * lwt_predicate_name( T const& )
|
||||
{
|
||||
return "~=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_eq const& )
|
||||
{
|
||||
return "==";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_ne const& )
|
||||
{
|
||||
return "!=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_lt const& )
|
||||
{
|
||||
return "<";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_le const& )
|
||||
{
|
||||
return "<=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_gt const& )
|
||||
{
|
||||
return ">";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_ge const& )
|
||||
{
|
||||
return ">=";
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class BinaryPredicate, class T, class U>
|
||||
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function,
|
||||
@@ -205,8 +311,8 @@ inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << pred.op() << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << lwt_predicate_name(pred) << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << lwt_predicate_name(pred) << " '" << test_output_impl(u)
|
||||
<< "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
@@ -431,6 +537,8 @@ inline int report_errors()
|
||||
|
||||
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#define BOOST_TEST_WITH(expr1,expr2,predicate) ( ::boost::detail::test_with_impl(predicate, #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
@@ -446,22 +554,38 @@ inline int report_errors()
|
||||
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) )
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
//
|
||||
#else
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP )
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
# define BOOST_TEST_NO_THROW(EXPR) \
|
||||
try { \
|
||||
EXPR; \
|
||||
} catch (const std::exception& e) { \
|
||||
::boost::detail::no_throw_failed_impl \
|
||||
(#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} catch (...) { \
|
||||
::boost::detail::no_throw_failed_impl \
|
||||
(#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
}
|
||||
//
|
||||
#else
|
||||
# define BOOST_TEST_NO_THROW(EXPR) { EXPR; }
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
|
||||
|
||||
@@ -126,6 +126,12 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
|
||||
|
||||
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// ignoring -Wvariadic-macros with #pragma doesn't work under GCC
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
# define BOOST_RETHROW throw;
|
||||
# define BOOST_CATCH_END }
|
||||
#else
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
# define BOOST_TRY { if ("")
|
||||
# define BOOST_CATCH(x) else if (!"")
|
||||
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
@@ -8,14 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <memory>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -24,12 +17,7 @@ struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
#else
|
||||
typedef noinit_adaptor<typename A::template rebind<U>::other> other;
|
||||
#endif
|
||||
typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
|
||||
};
|
||||
|
||||
noinit_adaptor()
|
||||
@@ -43,39 +31,26 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
noinit_adaptor(const U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
|
||||
: A(static_cast<const U&>(u)) { }
|
||||
: A(static_cast<const A&>(u)) { }
|
||||
|
||||
template<class U>
|
||||
void construct(U* p) {
|
||||
::new((void*)p) U;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args) {
|
||||
::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class U, class V>
|
||||
void construct(U* p, V&& v) {
|
||||
::new((void*)p) U(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
void construct(U* p, V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
//
|
||||
// ref.hpp - ref/cref, useful helper functions
|
||||
@@ -46,6 +47,26 @@ namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template< class Y, class T > struct ref_convertible
|
||||
{
|
||||
typedef char (&yes) [1];
|
||||
typedef char (&no) [2];
|
||||
|
||||
static yes f( T* );
|
||||
static no f( ... );
|
||||
|
||||
enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
|
||||
};
|
||||
|
||||
struct ref_empty
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// reference_wrapper
|
||||
|
||||
/**
|
||||
@@ -87,6 +108,21 @@ public:
|
||||
public:
|
||||
#endif
|
||||
|
||||
template<class Y> friend class reference_wrapper;
|
||||
|
||||
/**
|
||||
Constructs a `reference_wrapper` object that stores the
|
||||
reference stored in the compatible `reference_wrapper` `r`.
|
||||
|
||||
@remark Only enabled when `Y*` is convertible to `T*`.
|
||||
@remark Does not throw.
|
||||
*/
|
||||
template<class Y> reference_wrapper( reference_wrapper<Y> r,
|
||||
typename enable_if_c<boost::detail::ref_convertible<Y, T>::value,
|
||||
boost::detail::ref_empty>::type = boost::detail::ref_empty() ): t_( r.t_ )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@return The stored reference.
|
||||
@remark Does not throw.
|
||||
@@ -116,7 +152,7 @@ private:
|
||||
/**
|
||||
@cond
|
||||
*/
|
||||
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
|
||||
#if defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
|
||||
# define BOOST_REF_CONST
|
||||
#else
|
||||
# define BOOST_REF_CONST const
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#if __cplusplus >= 201103L || defined(BOOST_MSVC)
|
||||
#include <utility> //for std::swap (C++11)
|
||||
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
|
||||
#include <utility> // for std::swap (C++11)
|
||||
#else
|
||||
#include <algorithm> //for std::swap (C++98)
|
||||
#include <algorithm> // for std::swap (C++98)
|
||||
#endif
|
||||
#include <cstddef> //for std::size_t
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
namespace boost_swap_impl
|
||||
{
|
||||
|
||||
855
include/boost/core/type_name.hpp
Normal file
855
include/boost/core/type_name.hpp
Normal file
@@ -0,0 +1,855 @@
|
||||
#ifndef BOOST_CORE_TYPE_NAME_HPP_INCLUDED
|
||||
#define BOOST_CORE_TYPE_NAME_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// std::string boost::core::type_name<T>()
|
||||
//
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
#include <iosfwd>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// tn_identity
|
||||
|
||||
template<class T> struct tn_identity
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// tn_enable_if
|
||||
|
||||
template<bool C, class T> struct tn_enable_if
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct tn_enable_if<true, T>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// tn_is_reference
|
||||
|
||||
template<class T> struct tn_is_reference
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T> struct tn_is_reference<T&>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template<class T> struct tn_is_reference<T&&>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// tn_remove_const
|
||||
|
||||
template<class T> struct tn_remove_const
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct tn_remove_const<T const>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// tn_is_function (also catches references but that's OK)
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4180 4181)
|
||||
#endif
|
||||
|
||||
template<class T, class U = typename tn_remove_const<T>::type> struct tn_is_function: core::is_same<U, U const>
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_TYPEID)
|
||||
|
||||
// typeid_name
|
||||
|
||||
template<class T> std::string typeid_name()
|
||||
{
|
||||
std::string r = boost::core::demangle( typeid(T).name() );
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
if( r.substr( 0, 6 ) == "class " )
|
||||
{
|
||||
r = r.substr( 6 );
|
||||
}
|
||||
|
||||
if( r.substr( 0, 7 ) == "struct " )
|
||||
{
|
||||
r = r.substr( 7 );
|
||||
}
|
||||
|
||||
if( r.substr( 0, 5 ) == "enum " )
|
||||
{
|
||||
r = r.substr( 5 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// libc++ inline namespace
|
||||
|
||||
if( r.substr( 0, 10 ) == "std::__1::" )
|
||||
{
|
||||
r = "std::" + r.substr( 10 );
|
||||
}
|
||||
|
||||
// libstdc++ inline namespace
|
||||
|
||||
if( r.substr( 0, 14 ) == "std::__cxx11::" )
|
||||
{
|
||||
r = "std::" + r.substr( 14 );
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC == 1600
|
||||
|
||||
// msvc-10.0 puts TR1 things in std::tr1
|
||||
|
||||
if( r.substr( 0, 10 ) == "std::tr1::" )
|
||||
{
|
||||
r = "std::" + r.substr( 10 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// template names
|
||||
|
||||
template<class T> std::string class_template_name()
|
||||
{
|
||||
std::string r = typeid_name<T>();
|
||||
return r.substr( 0, r.find( '<' ) );
|
||||
}
|
||||
|
||||
template<class T> std::string sequence_template_name()
|
||||
{
|
||||
return class_template_name<T>();
|
||||
}
|
||||
|
||||
template<class T> std::string set_template_name()
|
||||
{
|
||||
return class_template_name<T>();
|
||||
}
|
||||
|
||||
template<class T> std::string map_template_name()
|
||||
{
|
||||
return class_template_name<T>();
|
||||
}
|
||||
|
||||
template<class T> std::string array_template_name()
|
||||
{
|
||||
return class_template_name<T>();
|
||||
}
|
||||
|
||||
#else // #if !defined(BOOST_NO_TYPEID)
|
||||
|
||||
template<class T> std::string typeid_name()
|
||||
{
|
||||
return "_Tp";
|
||||
}
|
||||
|
||||
template<class T> std::string class_template_name()
|
||||
{
|
||||
return "_Tm";
|
||||
}
|
||||
|
||||
template<class T> std::string sequence_template_name()
|
||||
{
|
||||
return "_Sq";
|
||||
}
|
||||
|
||||
template<class T> std::string set_template_name()
|
||||
{
|
||||
return "_St";
|
||||
}
|
||||
|
||||
template<class T> std::string map_template_name()
|
||||
{
|
||||
return "_Mp";
|
||||
}
|
||||
|
||||
template<class T> std::string array_template_name()
|
||||
{
|
||||
return "_Ar";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// tn_to_string
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4996 )
|
||||
#endif
|
||||
|
||||
inline std::string tn_to_string( std::size_t n )
|
||||
{
|
||||
char buffer[ 32 ];
|
||||
std::sprintf( buffer, "%lu", static_cast< unsigned long >( n ) );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
// tn_add_each
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<class T> int tn_add_each_impl( std::string& st )
|
||||
{
|
||||
if( !st.empty() ) st += ", ";
|
||||
st += type_name( tn_identity<T>(), "" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class... T> std::string tn_add_each()
|
||||
{
|
||||
std::string st;
|
||||
|
||||
typedef int A[ sizeof...(T) + 1 ];
|
||||
(void)A{ 0, tn_add_each_impl<T>( st )... };
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// primary
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T>, std::string const& suffix )
|
||||
{
|
||||
return typeid_name<T>() + suffix;
|
||||
}
|
||||
|
||||
// integrals
|
||||
|
||||
inline std::string type_name( tn_identity<unsigned>, std::string const& suffix )
|
||||
{
|
||||
return "unsigned" + suffix;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
inline std::string type_name( tn_identity<long long>, std::string const& suffix )
|
||||
{
|
||||
return "long long" + suffix;
|
||||
}
|
||||
|
||||
inline std::string type_name( tn_identity<unsigned long long>, std::string const& suffix )
|
||||
{
|
||||
return "unsigned long long" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
||||
|
||||
inline std::string type_name( tn_identity<char8_t>, std::string const& suffix )
|
||||
{
|
||||
return "char8_t" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// cv
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T const>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), " const" + suffix );
|
||||
}
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T volatile>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), " volatile" + suffix );
|
||||
}
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T const volatile>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), " const volatile" + suffix );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class T>
|
||||
typename tn_enable_if<!tn_is_function<T>::value, std::string>::type
|
||||
type_name( tn_identity<T const>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), " const" + suffix );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename tn_enable_if<!tn_is_function<T>::value, std::string>::type
|
||||
type_name( tn_identity<T volatile>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), " volatile" + suffix );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename tn_enable_if<!tn_is_function<T>::value, std::string>::type
|
||||
type_name( tn_identity<T const volatile>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), " const volatile" + suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// refs
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T&>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), "&" + suffix );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class T>
|
||||
typename tn_enable_if<!tn_is_reference<T>::value, std::string>::type
|
||||
type_name( tn_identity<T&>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), "&" + suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T&&>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), "&&" + suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// function types
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<class R, class... A> std::string function_type_name( tn_identity<R(A...)>, std::string const& trailer, std::string const& suffix )
|
||||
{
|
||||
std::string r = type_name( tn_identity<R>(), "" );
|
||||
|
||||
if( !suffix.empty() )
|
||||
{
|
||||
r += '(';
|
||||
|
||||
if( suffix[ 0 ] == ' ' )
|
||||
{
|
||||
r += suffix.substr( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
r += suffix;
|
||||
}
|
||||
|
||||
r += ')';
|
||||
}
|
||||
|
||||
r += '(' + tn_add_each<A...>() + ')';
|
||||
r += trailer;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...)>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), "", suffix );
|
||||
}
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile", suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) &>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " &", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const &>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const &", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile &>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile &", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile &>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile &", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) &&>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " &&", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const &&>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const &&", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile &&>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile &&", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile &&>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile &&", suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) & noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " & noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const & noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const & noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile & noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile & noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile & noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile & noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) && noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " && noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const && noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const && noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile && noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile && noexcept", suffix );
|
||||
}
|
||||
|
||||
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile && noexcept>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile && noexcept", suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
// pointers
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T*>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<T>(), "*" + suffix );
|
||||
}
|
||||
|
||||
// arrays
|
||||
|
||||
template<class T> std::pair<std::string, std::string> array_prefix_suffix( tn_identity<T> )
|
||||
{
|
||||
return std::pair<std::string, std::string>( type_name( tn_identity<T>(), "" ), "" );
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> std::pair<std::string, std::string> array_prefix_suffix( tn_identity<T[N]> )
|
||||
{
|
||||
std::pair<std::string, std::string> r = array_prefix_suffix( tn_identity<T>() );
|
||||
|
||||
r.second = '[' + tn_to_string( N ) + ']' + r.second;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class T> std::string array_type_name( tn_identity<T[]>, std::string const& suffix )
|
||||
{
|
||||
std::pair<std::string, std::string> r = array_prefix_suffix( tn_identity<T>() );
|
||||
|
||||
if( suffix.empty() )
|
||||
{
|
||||
return r.first + "[]" + r.second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return r.first + '(' + suffix + ")[]" + r.second;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T[]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T[]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T const[]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T const[]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T volatile[]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T volatile[]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T> std::string type_name( tn_identity<T const volatile[]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T const volatile[]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> std::string array_type_name( tn_identity<T[N]>, std::string const& suffix )
|
||||
{
|
||||
std::pair<std::string, std::string> r = array_prefix_suffix( tn_identity<T[N]>() );
|
||||
|
||||
if( suffix.empty() )
|
||||
{
|
||||
return r.first + r.second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return r.first + '(' + suffix + ")" + r.second;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> std::string type_name( tn_identity<T[N]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T[N]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> std::string type_name( tn_identity<T const[N]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T const[N]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> std::string type_name( tn_identity<T volatile[N]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T volatile[N]>(), suffix );
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> std::string type_name( tn_identity<T const volatile[N]>, std::string const& suffix )
|
||||
{
|
||||
return array_type_name( tn_identity<T const volatile[N]>(), suffix );
|
||||
}
|
||||
|
||||
// pointers to members
|
||||
|
||||
template<class R, class T> std::string type_name( tn_identity<R T::*>, std::string const& suffix )
|
||||
{
|
||||
return type_name( tn_identity<R>(), ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1900 && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<class R, class T, class... A> std::string type_name( tn_identity<R(T::*)(A...) const>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const", ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
|
||||
}
|
||||
|
||||
template<class R, class T, class... A> std::string type_name( tn_identity<R(T::*)(A...) volatile>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " volatile", ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
|
||||
}
|
||||
|
||||
template<class R, class T, class... A> std::string type_name( tn_identity<R(T::*)(A...) const volatile>, std::string const& suffix )
|
||||
{
|
||||
return function_type_name( tn_identity<R(A...)>(), " const volatile", ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// nullptr_t
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
|
||||
inline std::string type_name( tn_identity<std::nullptr_t>, std::string const& suffix )
|
||||
{
|
||||
return "std::nullptr_t" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// strings
|
||||
|
||||
template<template<class Ch, class Tr, class A> class L, class Ch> std::string type_name( tn_identity< L<Ch, std::char_traits<Ch>, std::allocator<Ch> > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = sequence_template_name< L<Ch, std::char_traits<Ch>, std::allocator<Ch> > >();
|
||||
return tn + '<' + type_name( tn_identity<Ch>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
inline std::string type_name( tn_identity<std::string>, std::string const& suffix )
|
||||
{
|
||||
return "std::string" + suffix;
|
||||
}
|
||||
|
||||
inline std::string type_name( tn_identity<std::wstring>, std::string const& suffix )
|
||||
{
|
||||
return "std::wstring" + suffix;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
|
||||
inline std::string type_name( tn_identity<std::u16string>, std::string const& suffix )
|
||||
{
|
||||
return "std::u16string" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T)
|
||||
|
||||
inline std::string type_name( tn_identity<std::u32string>, std::string const& suffix )
|
||||
{
|
||||
return "std::u32string" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
||||
|
||||
inline std::string type_name( tn_identity<std::basic_string<char8_t>>, std::string const& suffix )
|
||||
{
|
||||
return "std::u8string" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// string views (et al)
|
||||
|
||||
template<template<class Ch, class Tr> class L, class Ch> std::string type_name( tn_identity< L<Ch, std::char_traits<Ch> > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = sequence_template_name< L<Ch, std::char_traits<Ch> > >();
|
||||
return tn + '<' + type_name( tn_identity<Ch>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
// needed for libstdc++
|
||||
inline std::string type_name( tn_identity<std::ostream>, std::string const& suffix )
|
||||
{
|
||||
return "std::ostream" + suffix;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
inline std::string type_name( tn_identity<std::string_view>, std::string const& suffix )
|
||||
{
|
||||
return "std::string_view" + suffix;
|
||||
}
|
||||
|
||||
inline std::string type_name( tn_identity<std::wstring_view>, std::string const& suffix )
|
||||
{
|
||||
return "std::wstring_view" + suffix;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
|
||||
inline std::string type_name( tn_identity<std::u16string_view>, std::string const& suffix )
|
||||
{
|
||||
return "std::u16string_view" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T)
|
||||
|
||||
inline std::string type_name( tn_identity<std::u32string_view>, std::string const& suffix )
|
||||
{
|
||||
return "std::u32string_view" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
||||
|
||||
inline std::string type_name( tn_identity<std::basic_string_view<char8_t>>, std::string const& suffix )
|
||||
{
|
||||
return "std::u8string_view" + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// class templates
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<template<class...> class L, class... T> std::string type_name( tn_identity< L<T...> >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = class_template_name< L<T...> >();
|
||||
std::string st = tn_add_each<T...>();
|
||||
|
||||
return tn + '<' + st + '>' + suffix;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<template<class T1> class L, class T1> std::string type_name( tn_identity< L<T1> >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = class_template_name< L<T1> >();
|
||||
return tn + '<' + type_name( tn_identity<T1>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
template<template<class T1, class T2> class L, class T1, class T2> std::string type_name( tn_identity< L<T1, T2> >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = class_template_name< L<T1, T2> >();
|
||||
return tn + '<' + type_name( tn_identity<T1>(), "" ) + ", " + type_name( tn_identity<T2>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// sequence containers
|
||||
|
||||
template<template<class T, class A> class L, class T> std::string type_name( tn_identity< L<T, std::allocator<T> > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = sequence_template_name< L<T, std::allocator<T> > >();
|
||||
return tn + '<' + type_name( tn_identity<T>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
// set
|
||||
|
||||
template<template<class T, class Pr, class A> class L, class T> std::string type_name( tn_identity< L<T, std::less<T>, std::allocator<T> > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = set_template_name< L<T, std::less<T>, std::allocator<T> > >();
|
||||
return tn + '<' + type_name( tn_identity<T>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
// map
|
||||
|
||||
template<template<class T, class U, class Pr, class A> class L, class T, class U> std::string type_name( tn_identity< L<T, U, std::less<T>, std::allocator<std::pair<T const, U> > > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = map_template_name< L<T, U, std::less<T>, std::allocator<std::pair<T const, U> > > >();
|
||||
return tn + '<' + type_name( tn_identity<T>(), "" ) + ", " + type_name( tn_identity<U>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||
|
||||
// unordered_set
|
||||
|
||||
template<template<class T, class H, class Eq, class A> class L, class T> std::string type_name( tn_identity< L<T, std::hash<T>, std::equal_to<T>, std::allocator<T> > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = set_template_name< L<T, std::hash<T>, std::equal_to<T>, std::allocator<T> > >();
|
||||
return tn + '<' + type_name( tn_identity<T>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
// unordered_map
|
||||
|
||||
template<template<class T, class U, class H, class Eq, class A> class L, class T, class U> std::string type_name( tn_identity< L<T, U, std::hash<T>, std::equal_to<T>, std::allocator<std::pair<T const, U> > > >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = map_template_name< L<T, U, std::hash<T>, std::equal_to<T>, std::allocator<std::pair<T const, U> > > >();
|
||||
return tn + '<' + type_name( tn_identity<T>(), "" ) + ", " + type_name( tn_identity<U>(), "" ) + '>' + suffix;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// array
|
||||
|
||||
template<template<class T, std::size_t N> class L, class T, std::size_t N> std::string type_name( tn_identity< L<T, N> >, std::string const& suffix )
|
||||
{
|
||||
std::string tn = array_template_name< L<T, N> >();
|
||||
return tn + '<' + type_name( tn_identity<T>(), "" ) + ", " + tn_to_string( N ) + '>' + suffix;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T> std::string type_name()
|
||||
{
|
||||
return core::detail::type_name( core::detail::tn_identity<T>(), "" );
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_TYPE_NAME_HPP_INCLUDED
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2018.
|
||||
* Copyright Andrey Semashev 2018 - 2020.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* https://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -26,9 +26,24 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Visual Studio 14 supports N4152 std::uncaught_exceptions()
|
||||
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
|
||||
(defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411)
|
||||
#if defined(__APPLE__)
|
||||
#include <Availability.h>
|
||||
// Apple systems only support std::uncaught_exceptions starting with specific versions:
|
||||
// - Mac OS >= 10.12
|
||||
// - iOS >= 10.0
|
||||
// - tvOS >= 10.0
|
||||
// - watchOS >= 3.0
|
||||
// https://github.com/boostorg/core/issues/80
|
||||
#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \
|
||||
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
|
||||
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
#else
|
||||
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#endif // defined(__APPLE__)
|
||||
// Visual Studio 14.0 supports N4152 std::uncaught_exceptions() but doesn't define __cpp_lib_uncaught_exceptions
|
||||
#elif (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
@@ -46,7 +61,11 @@
|
||||
#if defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0.
|
||||
// Just disable it for now and fall back to std::uncaught_exception().
|
||||
#if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
// On AIX, xlclang++ does have cxxabi.h but doesn't have __cxa_get_globals (https://github.com/boostorg/core/issues/78).
|
||||
#if !( \
|
||||
(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405)) || \
|
||||
defined(__ibmxl__) \
|
||||
)
|
||||
#include <cxxabi.h>
|
||||
#include <cstring>
|
||||
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
|
||||
@@ -76,7 +95,7 @@ extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __att
|
||||
#endif
|
||||
} // namespace __cxxabiv1
|
||||
#endif
|
||||
#endif // !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
#endif
|
||||
#endif // defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
#ifndef ITERATOR_DWA122600_HPP_
|
||||
#define ITERATOR_DWA122600_HPP_
|
||||
|
||||
// This header is obsolete and will be deprecated.
|
||||
// This header is obsolete and deprecated.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<iterator>")
|
||||
|
||||
#include <iterator>
|
||||
#if defined(__SUNPRO_CC) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/no_exceptions_support.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/core/no_exceptions_support.hpp>")
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/scoped_enum.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/core/scoped_enum.hpp>")
|
||||
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,14 +8,15 @@
|
||||
"Andrey Semashev"
|
||||
],
|
||||
"maintainers": [
|
||||
"Peter Dimov <pdimov -at- pdimov.com>",
|
||||
"Peter Dimov <pdimov -at- gmail.com>",
|
||||
"Glen Fernandes <glenjofe -at- gmail.com>",
|
||||
"Andrey Semashev <andrey.semashev -at- gmail.com>"
|
||||
],
|
||||
"description": "A collection of simple core utilities with minimal dependencies.",
|
||||
"category": [
|
||||
"Miscellaneous"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/enable_if",
|
||||
@@ -33,7 +34,8 @@
|
||||
"maintainers": [
|
||||
"Jaakko Jarvi <jarvi -at- cs.tamu.edu>",
|
||||
"Jeremiah Willcock <jewillco -at- osl.iu.edu>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/swap",
|
||||
@@ -49,7 +51,8 @@
|
||||
],
|
||||
"maintainers": [
|
||||
"Joseph Gauterin <joseph.gauterin -at- googlemail.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "bind/ref",
|
||||
@@ -67,6 +70,7 @@
|
||||
],
|
||||
"category": [
|
||||
"Function-objects"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
]
|
||||
|
||||
102
test/Jamfile.v2
102
test/Jamfile.v2
@@ -35,7 +35,10 @@ compile-fail ref_rv_fail4.cpp ;
|
||||
compile-fail ref_rv_fail5.cpp ;
|
||||
compile-fail ref_implicit_fail.cpp ;
|
||||
compile-fail ref_implicit_fail2.cpp ;
|
||||
compile-fail ref_implicit_fail3.cpp ;
|
||||
compile-fail ref_implicit_fail4.cpp ;
|
||||
run ref_cv_test.cpp ;
|
||||
run ref_conversion_test.cpp ;
|
||||
|
||||
run eif_constructors.cpp ;
|
||||
run eif_dummy_arg_disambiguation.cpp ;
|
||||
@@ -68,22 +71,36 @@ run visit_each_test.cpp ;
|
||||
|
||||
run get_pointer_test.cpp ;
|
||||
|
||||
run lightweight_test_test.cpp ;
|
||||
run lightweight_test_test.cpp : : : <exception-handling>off : lightweight_test_test_no_except ;
|
||||
run lightweight_test_test2.cpp ;
|
||||
run lightweight_test_all_with_test.cpp ;
|
||||
run lightweight_test_lt_le_test.cpp ;
|
||||
run lightweight_test_gt_ge_test.cpp ;
|
||||
run lightweight_test_eq_nullptr.cpp ;
|
||||
run lightweight_test_test3.cpp ;
|
||||
run lightweight_test_test4.cpp ;
|
||||
run lightweight_test_test5.cpp
|
||||
: : :
|
||||
<warnings>extra
|
||||
local pedantic-errors = <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
|
||||
<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
|
||||
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare
|
||||
;
|
||||
run lightweight_test_test6.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
run-fail lightweight_test_all_eq_test.cpp ;
|
||||
run-fail lightweight_test_all_with_fail.cpp ;
|
||||
@@ -102,12 +119,20 @@ run-fail lightweight_test_fail9.cpp ;
|
||||
run-fail lightweight_test_fail10.cpp ;
|
||||
run-fail lightweight_test_fail11.cpp : ;
|
||||
run-fail lightweight_test_fail12.cpp ;
|
||||
run-fail lightweight_test_fail13.cpp ;
|
||||
run-fail lightweight_test_fail14.cpp ;
|
||||
run-fail lightweight_test_fail15.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 ;
|
||||
run lightweight_test_bool.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
run lightweight_test_with_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run-fail lightweight_test_with_fail.cpp ;
|
||||
|
||||
run is_same_test.cpp ;
|
||||
|
||||
@@ -153,7 +178,12 @@ run-fail quick_exit_fail.cpp ;
|
||||
|
||||
compile use_default_test.cpp ;
|
||||
|
||||
run default_allocator_test.cpp ;
|
||||
run default_allocator_test.cpp
|
||||
: : : <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
run noinit_adaptor_test.cpp ;
|
||||
run alloc_construct_test.cpp ;
|
||||
run alloc_construct_throws_test.cpp ;
|
||||
@@ -161,6 +191,24 @@ run alloc_construct_cxx11_test.cpp ;
|
||||
|
||||
run nvp_test.cpp ;
|
||||
|
||||
run allocator_value_type_test.cpp ;
|
||||
run allocator_pointer_test.cpp ;
|
||||
run allocator_const_pointer_test.cpp ;
|
||||
run allocator_void_pointer_test.cpp ;
|
||||
run allocator_const_void_pointer_test.cpp ;
|
||||
run allocator_difference_type_test.cpp ;
|
||||
run allocator_size_type_test.cpp ;
|
||||
run allocator_pocca_test.cpp ;
|
||||
run allocator_pocma_test.cpp ;
|
||||
run allocator_pocs_test.cpp ;
|
||||
run allocator_is_always_equal_test.cpp ;
|
||||
run allocator_rebind_test.cpp ;
|
||||
run allocator_allocate_test.cpp ;
|
||||
run allocator_allocate_hint_test.cpp ;
|
||||
run allocator_deallocate_test.cpp ;
|
||||
run allocator_max_size_test.cpp ;
|
||||
run allocator_soccc_test.cpp ;
|
||||
|
||||
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
|
||||
|
||||
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
|
||||
@@ -169,6 +217,12 @@ 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_typeid2.cpp lib_typeid : : : <link>shared : test_lib_typeid2_shared ;
|
||||
run test_lib_typeid2.cpp lib_typeid : : : <link>static : test_lib_typeid2_static ;
|
||||
|
||||
run test_lib_typeid2.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid2_shared_no_rtti ;
|
||||
run test_lib_typeid2.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid2_static_no_rtti ;
|
||||
|
||||
run uncaught_exceptions.cpp
|
||||
: : : <exception-handling>on ;
|
||||
run uncaught_exceptions_np.cpp
|
||||
@@ -177,5 +231,21 @@ run uncaught_exceptions_np.cpp
|
||||
run no_exceptions_support_test.cpp ;
|
||||
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;
|
||||
|
||||
run cmath_test.cpp ;
|
||||
run cmath_test.cpp : : : <define>BOOST_CORE_USE_GENERIC_CMATH <toolset>msvc-8.0:<build>no : cmath_test_generic ;
|
||||
|
||||
run bit_cast_test.cpp ;
|
||||
run bit_rotate_test.cpp ;
|
||||
run bit_countr_test.cpp ;
|
||||
run bit_countl_test.cpp ;
|
||||
run bit_width_test.cpp ;
|
||||
run has_single_bit_test.cpp ;
|
||||
run bit_floor_test.cpp ;
|
||||
run bit_ceil_test.cpp ;
|
||||
run bit_popcount_test.cpp ;
|
||||
run bit_endian_test.cpp ;
|
||||
|
||||
run type_name_test.cpp ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
||||
59
test/allocator_allocate_hint_test.cpp
Normal file
59
test/allocator_allocate_hint_test.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
A1()
|
||||
: value() { }
|
||||
T* allocate(std::size_t n, const void*) {
|
||||
value = n;
|
||||
return 0;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2()
|
||||
: value() { }
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return 0;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A2<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
31
test/allocator_allocate_test.cpp
Normal file
31
test/allocator_allocate_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return 0;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_const_pointer_test.cpp
Normal file
34
test/allocator_const_pointer_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* const_pointer;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_const_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
boost::allocator_const_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/allocator_const_void_pointer_test.cpp
Normal file
39
test/allocator_const_void_pointer_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* const_pointer;
|
||||
typedef int* const_void_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_const_void_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
|
||||
boost::allocator_const_void_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/allocator_construct_test.cpp
Normal file
46
test/allocator_construct_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1() { }
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2() { }
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(v + 1);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 5);
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A1<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 6);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
30
test/allocator_deallocate_test.cpp
Normal file
30
test/allocator_deallocate_test.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
void deallocate(T*, std::size_t n) {
|
||||
value = n;
|
||||
}
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A<int> a;
|
||||
boost::allocator_deallocate(a, 0, 5);
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
62
test/allocator_destroy_test.cpp
Normal file
62
test/allocator_destroy_test.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct S {
|
||||
static int count;
|
||||
S() {
|
||||
++count;
|
||||
}
|
||||
S(const S&) {
|
||||
++count;
|
||||
}
|
||||
~S() {
|
||||
--count;
|
||||
}
|
||||
};
|
||||
|
||||
int S::count = 0;
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1() { }
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2() { }
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
*p = U();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1<int> a;
|
||||
S s;
|
||||
boost::allocator_destroy(a, &s);
|
||||
BOOST_TEST_EQ(S::count, 0);
|
||||
::new((void*)&s) S();
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A1<int> a;
|
||||
int i = 5;
|
||||
boost::allocator_destroy(a, &i);
|
||||
BOOST_TEST_EQ(i, 0);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_difference_type_test.cpp
Normal file
34
test/allocator_difference_type_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef short difference_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
|
||||
boost::allocator_difference_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
boost::allocator_difference_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
47
test/allocator_is_always_equal_test.cpp
Normal file
47
test/allocator_is_always_equal_test.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct A3 {
|
||||
typedef T value_type;
|
||||
typedef std::false_type is_always_equal;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct A4 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type is_always_equal;
|
||||
int value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2<int> >::type));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A3<int> >::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A4<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/allocator_max_size_test.cpp
Normal file
39
test/allocator_max_size_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef short size_type;
|
||||
A1() { }
|
||||
short max_size() const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef short size_type;
|
||||
A2() { }
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(boost::allocator_max_size(A1<int>()), 1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_LE(boost::allocator_max_size(A2<int>()),
|
||||
(std::numeric_limits<short>::max)());
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pocca_test.cpp
Normal file
34
test/allocator_pocca_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_copy_assignment;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pocma_test.cpp
Normal file
34
test/allocator_pocma_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pocs_test.cpp
Normal file
34
test/allocator_pocs_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_swap<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_swap<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/allocator_pointer_test.cpp
Normal file
34
test/allocator_pointer_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
37
test/allocator_rebind_test.cpp
Normal file
37
test/allocator_rebind_test.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
template<class>
|
||||
struct rebind {
|
||||
typedef A1<int> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
|
||||
boost::allocator_rebind<A1<char>, bool>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
|
||||
boost::allocator_rebind<A2<char>, int>::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
35
test/allocator_size_type_test.cpp
Normal file
35
test/allocator_size_type_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/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int size_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_size_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<
|
||||
std::make_unsigned<std::ptrdiff_t>::type,
|
||||
boost::allocator_size_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
41
test/allocator_soccc_test.cpp
Normal file
41
test/allocator_soccc_test.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1(int n)
|
||||
: value(n) { }
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
A2(int n)
|
||||
: value(n) { }
|
||||
A2 select_on_container_copy_construction() const {
|
||||
return A2(value + 1);
|
||||
}
|
||||
int value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(1, boost::
|
||||
allocator_select_on_container_copy_construction(A1<int>(1)).value);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_EQ(2, boost::
|
||||
allocator_select_on_container_copy_construction(A2<int>(1)).value);
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
22
test/allocator_value_type_test.cpp
Normal file
22
test/allocator_value_type_test.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_value_type<A<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/allocator_void_pointer_test.cpp
Normal file
39
test/allocator_void_pointer_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* pointer;
|
||||
typedef int* void_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_void_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
boost::allocator_void_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
29
test/bit_cast_test.cpp
Normal file
29
test/bit_cast_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Test for boost/core/bit.hpp (bit_cast)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <cstring>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
float x = 0.89f;
|
||||
boost::uint32_t y = boost::core::bit_cast<boost::uint32_t>( x );
|
||||
|
||||
BOOST_TEST( std::memcmp( &x, &y, sizeof(x) ) == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
double x = 0.89;
|
||||
boost::uint64_t y = boost::core::bit_cast<boost::uint64_t>( x );
|
||||
|
||||
BOOST_TEST( std::memcmp( &x, &y, sizeof(x) ) == 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
65
test/bit_ceil_test.cpp
Normal file
65
test/bit_ceil_test.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
// Test for boost/core/bit.hpp (bit_ceil)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T> void test_bit_ceil( T x )
|
||||
{
|
||||
if( !boost::core::has_single_bit( x ) )
|
||||
{
|
||||
x >>= 1;
|
||||
}
|
||||
|
||||
T y = boost::core::bit_ceil( x );
|
||||
|
||||
if( x == 0 )
|
||||
{
|
||||
BOOST_TEST_EQ( y, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_TEST( boost::core::has_single_bit( y ) );
|
||||
BOOST_TEST_GE( +y, +x );
|
||||
BOOST_TEST_LT( y >> 1, +x );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_bit_ceil( static_cast<unsigned char>( 0 ) );
|
||||
test_bit_ceil( static_cast<unsigned short>( 0 ) );
|
||||
test_bit_ceil( static_cast<unsigned int>( 0 ) );
|
||||
test_bit_ceil( static_cast<unsigned long>( 0 ) );
|
||||
test_bit_ceil( static_cast<unsigned long long>( 0 ) );
|
||||
}
|
||||
|
||||
{
|
||||
test_bit_ceil( static_cast<boost::uint8_t>( 0x80 ) );
|
||||
test_bit_ceil( static_cast<boost::uint16_t>( 0x8000 ) );
|
||||
test_bit_ceil( static_cast<boost::uint32_t>( 0x80000000 ) );
|
||||
test_bit_ceil( static_cast<boost::uint64_t>( 0x8000000000000000 ) );
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_bit_ceil( static_cast<unsigned char>( x ) );
|
||||
test_bit_ceil( static_cast<unsigned short>( x ) );
|
||||
test_bit_ceil( static_cast<unsigned int>( x ) );
|
||||
test_bit_ceil( static_cast<unsigned long>( x ) );
|
||||
test_bit_ceil( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/bit_countl_test.cpp
Normal file
46
test/bit_countl_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Test for boost/core/bit.hpp (countl_zero, countl_one)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T> void test_countl( T x )
|
||||
{
|
||||
x |= static_cast<T>( 1 ) << ( std::numeric_limits<T>::digits - 1 );
|
||||
|
||||
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x >>= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::countl_zero( x ), i );
|
||||
BOOST_TEST_EQ( boost::core::countl_one( static_cast<T>( ~x ) ), i );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_countl( static_cast<unsigned char>( 0 ) );
|
||||
test_countl( static_cast<unsigned short>( 0 ) );
|
||||
test_countl( static_cast<unsigned int>( 0 ) );
|
||||
test_countl( static_cast<unsigned long>( 0 ) );
|
||||
test_countl( static_cast<unsigned long long>( 0 ) );
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_countl( static_cast<unsigned char>( x ) );
|
||||
test_countl( static_cast<unsigned short>( x ) );
|
||||
test_countl( static_cast<unsigned int>( x ) );
|
||||
test_countl( static_cast<unsigned long>( x ) );
|
||||
test_countl( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/bit_countr_test.cpp
Normal file
46
test/bit_countr_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Test for boost/core/bit.hpp (countr_zero, countr_one)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T> void test_countr( T x )
|
||||
{
|
||||
x |= 1;
|
||||
|
||||
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::countr_zero( x ), i );
|
||||
BOOST_TEST_EQ( boost::core::countr_one( static_cast<T>( ~x ) ), i );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_countr( static_cast<unsigned char>( 0 ) );
|
||||
test_countr( static_cast<unsigned short>( 0 ) );
|
||||
test_countr( static_cast<unsigned int>( 0 ) );
|
||||
test_countr( static_cast<unsigned long>( 0 ) );
|
||||
test_countr( static_cast<unsigned long long>( 0 ) );
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_countr( static_cast<unsigned char>( x ) );
|
||||
test_countr( static_cast<unsigned short>( x ) );
|
||||
test_countr( static_cast<unsigned int>( x ) );
|
||||
test_countr( static_cast<unsigned long>( x ) );
|
||||
test_countr( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
36
test/bit_endian_test.cpp
Normal file
36
test/bit_endian_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Test for boost/core/bit.hpp (bit_ceil)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <cstring>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::uint64_t v = static_cast<boost::uint64_t>( 0x0102030405060708ull );
|
||||
|
||||
if( boost::core::endian::native == boost::core::endian::little )
|
||||
{
|
||||
unsigned char w[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
|
||||
BOOST_TEST( std::memcmp( &v, w, 8 ) == 0 );
|
||||
}
|
||||
else if( boost::core::endian::native == boost::core::endian::big )
|
||||
{
|
||||
unsigned char w[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
BOOST_TEST( std::memcmp( &v, w, 8 ) == 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char w1[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
|
||||
BOOST_TEST( std::memcmp( &v, w1, 8 ) != 0 );
|
||||
|
||||
unsigned char w2[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
BOOST_TEST( std::memcmp( &v, w2, 8 ) != 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
53
test/bit_floor_test.cpp
Normal file
53
test/bit_floor_test.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// Test for boost/core/bit.hpp (bit_floor)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T> void test_bit_floor( T x )
|
||||
{
|
||||
T y = boost::core::bit_floor( x );
|
||||
|
||||
if( x == 0 )
|
||||
{
|
||||
BOOST_TEST_EQ( y, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_TEST( boost::core::has_single_bit( y ) );
|
||||
BOOST_TEST_LE( +y, +x );
|
||||
BOOST_TEST_GT( +y, x >> 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_bit_floor( static_cast<unsigned char>( 0 ) );
|
||||
test_bit_floor( static_cast<unsigned short>( 0 ) );
|
||||
test_bit_floor( static_cast<unsigned int>( 0 ) );
|
||||
test_bit_floor( static_cast<unsigned long>( 0 ) );
|
||||
test_bit_floor( static_cast<unsigned long long>( 0 ) );
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_bit_floor( static_cast<unsigned char>( x ) );
|
||||
test_bit_floor( static_cast<unsigned short>( x ) );
|
||||
test_bit_floor( static_cast<unsigned int>( x ) );
|
||||
test_bit_floor( static_cast<unsigned long>( x ) );
|
||||
test_bit_floor( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/bit_popcount_test.cpp
Normal file
46
test/bit_popcount_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Test for boost/core/bit.hpp (bit_ceil)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
||||
template<class T> void test_popcount( T x )
|
||||
{
|
||||
int k = 0;
|
||||
for( T y = x; y; y &= y - 1, ++k );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::popcount( x ), k ) || ( std::cerr << "x: " << +x << std::endl );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_popcount( static_cast<unsigned char>( 0 ) );
|
||||
test_popcount( static_cast<unsigned short>( 0 ) );
|
||||
test_popcount( static_cast<unsigned int>( 0 ) );
|
||||
test_popcount( static_cast<unsigned long>( 0 ) );
|
||||
test_popcount( static_cast<unsigned long long>( 0 ) );
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_popcount( static_cast<unsigned char>( x ) );
|
||||
test_popcount( static_cast<unsigned short>( x ) );
|
||||
test_popcount( static_cast<unsigned int>( x ) );
|
||||
test_popcount( static_cast<unsigned long>( x ) );
|
||||
test_popcount( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
175
test/bit_rotate_test.cpp
Normal file
175
test/bit_rotate_test.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
// Test for boost/core/bit.hpp (rotl, rotr)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
int const M = 256;
|
||||
|
||||
template<class T> void test_rotate( T x )
|
||||
{
|
||||
for( int i = 0; i < M; ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +boost::core::rotr( x, -i ) );
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, -i ), +boost::core::rotr( x, i ) );
|
||||
|
||||
unsigned const width = std::numeric_limits<T>::digits;
|
||||
unsigned r = i & ( width - 1 );
|
||||
|
||||
if( r == 0 )
|
||||
{
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +x );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, i ), +x );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +static_cast<T>( (x << r) | (x >> (width - r)) ) );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, i ), +static_cast<T>( (x >> r) | (x << (width - r)) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::uint8_t x = 0x11;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x22 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x88 );
|
||||
|
||||
x = 0x22;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x44 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x11 );
|
||||
|
||||
x = 0x44;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x88 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x22 );
|
||||
|
||||
x = 0x88;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x11 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x44 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint16_t x = 0x1111;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x2222 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x8888 );
|
||||
|
||||
x = 0x2222;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x4444 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x1111 );
|
||||
|
||||
x = 0x4444;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x8888 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x2222 );
|
||||
|
||||
x = 0x8888;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x1111 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x4444 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint32_t x = 0x11111111;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x22222222 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x88888888 );
|
||||
|
||||
x = 0x22222222;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x44444444 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x11111111 );
|
||||
|
||||
x = 0x44444444;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x88888888 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x22222222 );
|
||||
|
||||
x = 0x88888888;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x11111111 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x44444444 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint64_t x = 0x1111111111111111;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x2222222222222222 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x8888888888888888 );
|
||||
|
||||
x = 0x2222222222222222;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x4444444444444444 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x1111111111111111 );
|
||||
|
||||
x = 0x4444444444444444;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x8888888888888888 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x2222222222222222 );
|
||||
|
||||
x = 0x8888888888888888;
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x1111111111111111 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x4444444444444444 );
|
||||
}
|
||||
|
||||
for( int i = -M; i <= M; ++i )
|
||||
{
|
||||
{
|
||||
unsigned char x = 0;
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, i ), +x );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, i ), +x );
|
||||
}
|
||||
|
||||
{
|
||||
unsigned short x = 0;
|
||||
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
|
||||
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
|
||||
}
|
||||
|
||||
{
|
||||
unsigned int x = 0;
|
||||
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
|
||||
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long x = 0;
|
||||
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
|
||||
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long long x = 0;
|
||||
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
|
||||
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
|
||||
}
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_rotate( static_cast<unsigned char>( x ) );
|
||||
test_rotate( static_cast<unsigned short>( x ) );
|
||||
test_rotate( static_cast<unsigned int>( x ) );
|
||||
test_rotate( static_cast<unsigned long>( x ) );
|
||||
test_rotate( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
94
test/bit_width_test.cpp
Normal file
94
test/bit_width_test.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
// Test for boost/core/bit.hpp (bit_width)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T> void test_width( T x )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), std::numeric_limits<T>::digits - boost::core::countl_zero( x ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::uint8_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
|
||||
|
||||
x = 1;
|
||||
|
||||
for( int i = 0; i < 8; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint8_t>( x | ( x >> 1 ) ) ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint8_t>( x | ( x >> 2 ) ) ), i+1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint16_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
|
||||
|
||||
x = 1;
|
||||
|
||||
for( int i = 0; i < 16; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint16_t>( x | ( x >> 1 ) ) ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint16_t>( x | ( x >> 2 ) ) ), i+1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint32_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
|
||||
|
||||
x = 1;
|
||||
|
||||
for( int i = 0; i < 32; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint32_t>( x | ( x >> 1 ) ) ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint32_t>( x | ( x >> 2 ) ) ), i+1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint64_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), 0 );
|
||||
|
||||
x = 1;
|
||||
|
||||
for( int i = 0; i < 64; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint64_t>( x | ( x >> 1 ) ) ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint64_t>( x | ( x >> 2 ) ) ), i+1 );
|
||||
}
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_width( static_cast<unsigned char>( x ) );
|
||||
test_width( static_cast<unsigned short>( x ) );
|
||||
test_width( static_cast<unsigned int>( x ) );
|
||||
test_width( static_cast<unsigned long>( x ) );
|
||||
test_width( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
296
test/cmath_test.cpp
Normal file
296
test/cmath_test.cpp
Normal file
@@ -0,0 +1,296 @@
|
||||
// Test for boost/core/cmath.hpp
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <limits>
|
||||
#include <cfloat>
|
||||
|
||||
template<class T> void test_positive_normal( T x )
|
||||
{
|
||||
BOOST_TEST( boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_normal );
|
||||
|
||||
BOOST_TEST( !boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_normal( T x )
|
||||
{
|
||||
BOOST_TEST( boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_normal );
|
||||
|
||||
BOOST_TEST( boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_zero( T x )
|
||||
{
|
||||
BOOST_TEST( boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_zero );
|
||||
|
||||
BOOST_TEST( !boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_zero( T x )
|
||||
{
|
||||
BOOST_TEST( boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_zero );
|
||||
|
||||
#if defined(BOOST_CORE_USE_GENERIC_CMATH) && BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
// g++ 4.4, 4.6 fail these tests with optimizations on
|
||||
|
||||
#else
|
||||
|
||||
BOOST_TEST( boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class T> void test_positive_infinity( T x )
|
||||
{
|
||||
BOOST_TEST( !boost::core::isfinite( x ) );
|
||||
BOOST_TEST( boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_infinite );
|
||||
|
||||
BOOST_TEST( !boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_infinity( T x )
|
||||
{
|
||||
BOOST_TEST( !boost::core::isfinite( x ) );
|
||||
BOOST_TEST( boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_infinite );
|
||||
|
||||
BOOST_TEST( boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_nan( T x )
|
||||
{
|
||||
BOOST_TEST( !boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_nan );
|
||||
|
||||
BOOST_TEST( !boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_nan( T x )
|
||||
{
|
||||
BOOST_TEST( !boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_nan );
|
||||
|
||||
BOOST_TEST( boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_subnormal( T x )
|
||||
{
|
||||
BOOST_TEST( boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_subnormal );
|
||||
|
||||
BOOST_TEST( !boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(+2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(+2) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_subnormal( T x )
|
||||
{
|
||||
BOOST_TEST( boost::core::isfinite( x ) );
|
||||
BOOST_TEST( !boost::core::isinf( x ) );
|
||||
BOOST_TEST( !boost::core::isnan( x ) );
|
||||
BOOST_TEST( !boost::core::isnormal( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_subnormal );
|
||||
|
||||
BOOST_TEST( boost::core::signbit( x ) );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
|
||||
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_normal_( T x )
|
||||
{
|
||||
test_positive_normal( x );
|
||||
test_positive_normal( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_normal( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_normal_( T x )
|
||||
{
|
||||
test_negative_normal( x );
|
||||
test_positive_normal( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_normal( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_zero_( T x )
|
||||
{
|
||||
test_positive_zero( x );
|
||||
test_positive_zero( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_zero( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_zero_( T x )
|
||||
{
|
||||
test_negative_zero( x );
|
||||
test_positive_zero( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_zero( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_infinity_( T x )
|
||||
{
|
||||
test_positive_infinity( x );
|
||||
test_positive_infinity( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_infinity( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_infinity_( T x )
|
||||
{
|
||||
test_negative_infinity( x );
|
||||
test_positive_infinity( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_infinity( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_nan_( T x )
|
||||
{
|
||||
test_positive_nan( x );
|
||||
test_positive_nan( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_nan( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_nan_( T x )
|
||||
{
|
||||
test_negative_nan( x );
|
||||
test_positive_nan( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_nan( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_positive_subnormal_( T x )
|
||||
{
|
||||
test_positive_subnormal( x );
|
||||
test_positive_subnormal( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_subnormal( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
template<class T> void test_negative_subnormal_( T x )
|
||||
{
|
||||
test_negative_subnormal( x );
|
||||
test_positive_subnormal( boost::core::copysign( x, T(+1) ) );
|
||||
test_negative_subnormal( boost::core::copysign( x, T(-1) ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// float
|
||||
|
||||
test_positive_normal_( +1.0f );
|
||||
test_negative_normal_( -1.0f );
|
||||
test_positive_normal_( FLT_MIN );
|
||||
test_negative_normal_( -FLT_MIN );
|
||||
test_positive_normal_( FLT_MAX );
|
||||
test_negative_normal_( -FLT_MAX );
|
||||
test_positive_zero_( +0.0f );
|
||||
test_negative_zero_( -0.0f );
|
||||
test_positive_infinity_( std::numeric_limits<float>::infinity() );
|
||||
test_negative_infinity_( -std::numeric_limits<float>::infinity() );
|
||||
test_positive_nan_( std::numeric_limits<float>::quiet_NaN() );
|
||||
test_negative_nan_( boost::core::copysign( std::numeric_limits<float>::quiet_NaN(), -1.0f ) );
|
||||
test_positive_subnormal_( FLT_MIN / 2 );
|
||||
test_negative_subnormal_( -FLT_MIN / 2 );
|
||||
|
||||
// double
|
||||
|
||||
test_positive_normal_( +1.0 );
|
||||
test_negative_normal_( -1.0 );
|
||||
test_positive_normal_( DBL_MIN );
|
||||
test_negative_normal_( -DBL_MIN );
|
||||
test_positive_normal_( DBL_MAX );
|
||||
test_negative_normal_( -DBL_MAX );
|
||||
test_positive_zero_( +0.0 );
|
||||
test_negative_zero_( -0.0 );
|
||||
test_positive_infinity_( std::numeric_limits<double>::infinity() );
|
||||
test_negative_infinity_( -std::numeric_limits<double>::infinity() );
|
||||
test_positive_nan_( std::numeric_limits<double>::quiet_NaN() );
|
||||
test_negative_nan_( boost::core::copysign( std::numeric_limits<double>::quiet_NaN(), -1.0 ) );
|
||||
test_positive_subnormal_( DBL_MIN / 2 );
|
||||
test_negative_subnormal_( -DBL_MIN / 2 );
|
||||
|
||||
// long double
|
||||
|
||||
test_positive_normal_( +1.0l );
|
||||
test_negative_normal_( -1.0l );
|
||||
test_positive_normal_( LDBL_MIN );
|
||||
test_negative_normal_( -LDBL_MIN );
|
||||
test_positive_normal_( LDBL_MAX );
|
||||
test_negative_normal_( -LDBL_MAX );
|
||||
test_positive_zero_( +0.0l );
|
||||
test_negative_zero_( -0.0l );
|
||||
test_positive_infinity_( std::numeric_limits<long double>::infinity() );
|
||||
test_negative_infinity_( -std::numeric_limits<long double>::infinity() );
|
||||
test_positive_nan_( std::numeric_limits<long double>::quiet_NaN() );
|
||||
test_negative_nan_( boost::core::copysign( std::numeric_limits<long double>::quiet_NaN(), -1.0l ) );
|
||||
test_positive_subnormal_( LDBL_MIN / 2 );
|
||||
test_negative_subnormal_( -LDBL_MIN / 2 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -173,20 +173,11 @@ void test_construct_other()
|
||||
(void)a5;
|
||||
}
|
||||
|
||||
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
|
||||
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
|
||||
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_max_size()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_HEADERS
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
110
test/has_single_bit_test.cpp
Normal file
110
test/has_single_bit_test.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
// Test for boost/core/bit.hpp (has_single_bit)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T> void test_single_bit( T x )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), boost::core::popcount( x ) == 1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::uint8_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), false );
|
||||
|
||||
x = 1;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
|
||||
x = 2;
|
||||
|
||||
for( int i = 1; i < 8; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint8_t>( x | ( x >> 1 ) ) ), false );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint8_t>( x | ( x >> 1 ) | ( x >> 2 ) ) ), false );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint16_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), false );
|
||||
|
||||
x = 1;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
|
||||
x = 2;
|
||||
|
||||
for( int i = 1; i < 16; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint16_t>( x | ( x >> 1 ) ) ), false );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint16_t>( x | ( x >> 1 ) | ( x >> 2 ) ) ), false );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint32_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), false );
|
||||
|
||||
x = 1;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
|
||||
x = 2;
|
||||
|
||||
for( int i = 1; i < 32; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint32_t>( x | ( x >> 1 ) ) ), false );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint32_t>( x | ( x >> 1 ) | ( x >> 2 ) ) ), false );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::uint64_t x = 0;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), false );
|
||||
|
||||
x = 1;
|
||||
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
|
||||
x = 2;
|
||||
|
||||
for( int i = 1; i < 64; ++i, x <<= 1 )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint64_t>( x | ( x >> 1 ) ) ), false );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint64_t>( x | ( x >> 1 ) | ( x >> 2 ) ) ), false );
|
||||
}
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
for( int i = 0; i < 1000; ++i )
|
||||
{
|
||||
boost::uint64_t x = rng();
|
||||
|
||||
test_single_bit( static_cast<unsigned char>( x ) );
|
||||
test_single_bit( static_cast<unsigned short>( x ) );
|
||||
test_single_bit( static_cast<unsigned int>( x ) );
|
||||
test_single_bit( static_cast<unsigned long>( x ) );
|
||||
test_single_bit( static_cast<unsigned long long>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -15,3 +15,12 @@ EXPORT boost::core::typeinfo const & get_typeid_int()
|
||||
{
|
||||
return BOOST_CORE_TYPEID( int );
|
||||
}
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE X
|
||||
{
|
||||
};
|
||||
|
||||
EXPORT boost::core::typeinfo const & get_typeid_X()
|
||||
{
|
||||
return BOOST_CORE_TYPEID( X );
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
19
test/lightweight_test_fail13.cpp
Normal file
19
test/lightweight_test_fail13.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void f()
|
||||
{
|
||||
throw 5;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NO_THROW(f());
|
||||
return boost::report_errors();
|
||||
}
|
||||
26
test/lightweight_test_fail14.cpp
Normal file
26
test/lightweight_test_fail14.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct error
|
||||
: std::exception {
|
||||
const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
|
||||
return "message";
|
||||
}
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
throw error();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NO_THROW(f());
|
||||
return boost::report_errors();
|
||||
}
|
||||
37
test/lightweight_test_fail15.cpp
Normal file
37
test/lightweight_test_fail15.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Test BOOST_TEST_NE with character types
|
||||
//
|
||||
// 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 <boost/config.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NE( 'A', 'A' );
|
||||
BOOST_TEST_NE( (char)1, (char)1 );
|
||||
BOOST_TEST_NE( (unsigned char)1, (unsigned char)1 );
|
||||
BOOST_TEST_NE( (signed char)-1, (signed char)-1 );
|
||||
|
||||
BOOST_TEST_NE( L'A', L'A' );
|
||||
BOOST_TEST_NE( (wchar_t)1, (wchar_t)1 );
|
||||
|
||||
int exp = 6;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
|
||||
BOOST_TEST_NE( (char16_t)1, (char16_t)1 );
|
||||
++exp;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T)
|
||||
|
||||
BOOST_TEST_NE( (char32_t)1, (char32_t)1 );
|
||||
++exp;
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors() == exp;
|
||||
}
|
||||
@@ -8,8 +8,14 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#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>
|
||||
|
||||
struct X
|
||||
{
|
||||
@@ -33,6 +39,16 @@ void f( bool x )
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic ignored "-Waddress"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wstring-plus-int" )
|
||||
# pragma clang diagnostic ignored "-Wstring-plus-int"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 0;
|
||||
@@ -92,5 +108,9 @@ int main()
|
||||
BOOST_TEST_THROWS( f(true), X );
|
||||
BOOST_TEST_THROWS( f(false), int );
|
||||
|
||||
// BOOST_TEST_NO_THROW
|
||||
|
||||
BOOST_TEST_NO_THROW(++y);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
33
test/lightweight_test_test6.cpp
Normal file
33
test/lightweight_test_test6.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Test BOOST_TEST_EQ with character types
|
||||
//
|
||||
// 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 <boost/config.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( 'A', 'A' );
|
||||
BOOST_TEST_EQ( (char)1, (char)1 );
|
||||
BOOST_TEST_EQ( (unsigned char)1, (unsigned char)1 );
|
||||
BOOST_TEST_EQ( (signed char)-1, (signed char)-1 );
|
||||
|
||||
BOOST_TEST_EQ( L'A', L'A' );
|
||||
BOOST_TEST_EQ( (wchar_t)1, (wchar_t)1 );
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
|
||||
BOOST_TEST_EQ( (char16_t)1, (char16_t)1 );
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T)
|
||||
|
||||
BOOST_TEST_EQ( (char32_t)1, (char32_t)1 );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
39
test/lightweight_test_with_fail.cpp
Normal file
39
test/lightweight_test_with_fail.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Negative test for BOOST_TEST_WITH
|
||||
//
|
||||
// Copyright 2020 Bjorn Reese
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cmath>
|
||||
|
||||
template <typename T>
|
||||
struct with_tolerance
|
||||
{
|
||||
with_tolerance( T tolerance ): tolerance( tolerance )
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()( T lhs, T rhs ) const
|
||||
{
|
||||
return std::abs( lhs - rhs ) <= tolerance;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T tolerance;
|
||||
};
|
||||
|
||||
void test_tolerance_predicate()
|
||||
{
|
||||
BOOST_TEST_WITH( 1.0, 1.0 - 1e-6, with_tolerance<double>(1e-7) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 + 1e-6, with_tolerance<double>(1e-7) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_tolerance_predicate();
|
||||
return boost::report_errors() == 2;
|
||||
}
|
||||
39
test/lightweight_test_with_test.cpp
Normal file
39
test/lightweight_test_with_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Test for BOOST_TEST_WITH
|
||||
//
|
||||
// Copyright (c) 2020 Bjorn Reese
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cmath>
|
||||
|
||||
template <typename T>
|
||||
struct with_tolerance
|
||||
{
|
||||
with_tolerance(T tolerance) : tolerance(tolerance) {}
|
||||
bool operator()(T lhs, T rhs) const
|
||||
{
|
||||
return (std::abs(lhs - rhs) <= tolerance);
|
||||
}
|
||||
|
||||
private:
|
||||
T tolerance;
|
||||
};
|
||||
|
||||
void test_tolerance_predicate()
|
||||
{
|
||||
BOOST_TEST_WITH( 1.0, 1.0, with_tolerance<double>(1e-5) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 - 1e-6, with_tolerance<double>(1e-5) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 + 1e-6, with_tolerance<double>(1e-5) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_tolerance_predicate();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
|
||||
39
test/ref_conversion_test.cpp
Normal file
39
test/ref_conversion_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Implicit conversions between compatible reference wrappers
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
};
|
||||
|
||||
struct Y: public X
|
||||
{
|
||||
};
|
||||
|
||||
void f1( boost::reference_wrapper<X> r, Y * p )
|
||||
{
|
||||
BOOST_TEST_EQ( r.get_pointer(), p );
|
||||
}
|
||||
|
||||
void f2( boost::reference_wrapper<int const> r, int * p )
|
||||
{
|
||||
BOOST_TEST_EQ( r.get_pointer(), p );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Y y;
|
||||
f1( boost::ref(y), &y );
|
||||
|
||||
int i = 0;
|
||||
f2( boost::ref(i), &i );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
29
test/ref_implicit_fail3.cpp
Normal file
29
test/ref_implicit_fail3.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Incompatible reference_wrappers must not implicitly convert to each other
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
};
|
||||
|
||||
void f( boost::reference_wrapper<X> )
|
||||
{
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Y y;
|
||||
f( boost::ref(y) ); // should fail
|
||||
}
|
||||
21
test/ref_implicit_fail4.cpp
Normal file
21
test/ref_implicit_fail4.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Incompatible reference_wrappers must not implicitly convert to each other
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
void f( boost::reference_wrapper< int const > )
|
||||
{
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
long y = 0;
|
||||
f( boost::ref(y) ); // should fail
|
||||
}
|
||||
34
test/test_lib_typeid2.cpp
Normal file
34
test/test_lib_typeid2.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
// Copyright 2018, 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
boost::core::typeinfo const & get_typeid_X();
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE X
|
||||
{
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::core::typeinfo const & tx = BOOST_CORE_TYPEID( X );
|
||||
boost::core::typeinfo const & ty = BOOST_CORE_TYPEID( Y );
|
||||
|
||||
boost::core::typeinfo const & tx2 = get_typeid_X();
|
||||
|
||||
BOOST_TEST( tx2 == tx );
|
||||
BOOST_TEST( tx2 != ty );
|
||||
|
||||
BOOST_TEST( !tx2.before( tx ) );
|
||||
BOOST_TEST( !tx.before( tx2 ) );
|
||||
|
||||
BOOST_TEST( tx2.before( ty ) != ty.before( tx2 ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
357
test/type_name_test.cpp
Normal file
357
test/type_name_test.cpp
Normal file
@@ -0,0 +1,357 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/type_name.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
#include <iosfwd>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
|
||||
# include <unordered_set>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP)
|
||||
# include <unordered_map>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
|
||||
# include <array>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
|
||||
//
|
||||
|
||||
#define TEST(...) BOOST_TEST_EQ((boost::core::type_name<__VA_ARGS__>()), std::string(#__VA_ARGS__))
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
class B
|
||||
{
|
||||
};
|
||||
|
||||
template<class T1, class T2> struct X
|
||||
{
|
||||
};
|
||||
|
||||
enum E1
|
||||
{
|
||||
e1
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
|
||||
|
||||
enum class E2
|
||||
{
|
||||
e2
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct Ch
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST(signed char);
|
||||
TEST(unsigned char);
|
||||
TEST(short);
|
||||
TEST(unsigned short);
|
||||
TEST(int);
|
||||
TEST(unsigned);
|
||||
TEST(long);
|
||||
TEST(unsigned long);
|
||||
TEST(long long);
|
||||
TEST(unsigned long long);
|
||||
|
||||
TEST(char);
|
||||
TEST(wchar_t);
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
TEST(char16_t);
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
TEST(char32_t);
|
||||
#endif
|
||||
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
||||
TEST(char8_t);
|
||||
#endif
|
||||
#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
|
||||
TEST(std::byte);
|
||||
#endif
|
||||
|
||||
TEST(bool);
|
||||
|
||||
TEST(float);
|
||||
TEST(double);
|
||||
TEST(long double);
|
||||
|
||||
TEST(void);
|
||||
TEST(void const);
|
||||
TEST(void volatile);
|
||||
TEST(void const volatile);
|
||||
|
||||
TEST(A);
|
||||
TEST(B);
|
||||
|
||||
TEST(E1);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
|
||||
|
||||
TEST(E2);
|
||||
|
||||
#endif
|
||||
|
||||
TEST(A const);
|
||||
TEST(A volatile);
|
||||
TEST(A const volatile);
|
||||
|
||||
TEST(B&);
|
||||
TEST(B const&);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
TEST(B&&);
|
||||
TEST(B const&&);
|
||||
|
||||
#endif
|
||||
|
||||
TEST(A*);
|
||||
TEST(B const* volatile*);
|
||||
|
||||
TEST(void*);
|
||||
TEST(void const* volatile*);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
TEST(void());
|
||||
TEST(int(float, A, B*));
|
||||
|
||||
TEST(void(*)());
|
||||
TEST(void(**)());
|
||||
TEST(void(***)());
|
||||
|
||||
TEST(void(* const* const*)());
|
||||
TEST(void(* const* const&)());
|
||||
|
||||
TEST(void(&)());
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
TEST(void(&&)());
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
TEST(void() const);
|
||||
TEST(void() volatile);
|
||||
TEST(void() const volatile);
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
|
||||
|
||||
TEST(void() &);
|
||||
TEST(void() const &);
|
||||
TEST(void() volatile &);
|
||||
TEST(void() const volatile &);
|
||||
|
||||
TEST(void() &&);
|
||||
TEST(void() const &&);
|
||||
TEST(void() volatile &&);
|
||||
TEST(void() const volatile &&);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
|
||||
TEST(void() noexcept);
|
||||
TEST(void() const noexcept);
|
||||
TEST(void() volatile noexcept);
|
||||
TEST(void() const volatile noexcept);
|
||||
|
||||
TEST(void() & noexcept);
|
||||
TEST(void() const & noexcept);
|
||||
TEST(void() volatile & noexcept);
|
||||
TEST(void() const volatile & noexcept);
|
||||
|
||||
TEST(void() && noexcept);
|
||||
TEST(void() const && noexcept);
|
||||
TEST(void() volatile && noexcept);
|
||||
TEST(void() const volatile && noexcept);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
TEST(A[]);
|
||||
TEST(A const[]);
|
||||
TEST(A volatile[]);
|
||||
TEST(A const volatile[]);
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1500
|
||||
TEST(A(&)[]);
|
||||
#endif
|
||||
TEST(A const(***)[]);
|
||||
|
||||
TEST(B[1]);
|
||||
TEST(B const[1]);
|
||||
TEST(B volatile[1]);
|
||||
TEST(B const volatile[1]);
|
||||
|
||||
TEST(B(&)[1]);
|
||||
TEST(B const(***)[1]);
|
||||
|
||||
TEST(A[][2][3]);
|
||||
TEST(A const[][2][3]);
|
||||
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1500
|
||||
TEST(A(&)[][2][3]);
|
||||
#endif
|
||||
TEST(A const(***)[][2][3]);
|
||||
|
||||
TEST(B[1][2][3]);
|
||||
TEST(B const volatile[1][2][3]);
|
||||
|
||||
TEST(B(&)[1][2][3]);
|
||||
TEST(B const volatile(***)[1][2][3]);
|
||||
|
||||
TEST(int A::*);
|
||||
TEST(int const B::*);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
TEST(void(A::*)());
|
||||
TEST(void(A::*)() const);
|
||||
TEST(void(A::*)() volatile);
|
||||
TEST(void(A::*)() const volatile);
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
|
||||
|
||||
TEST(void(A::*)() &);
|
||||
TEST(void(A::*)() const &&);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
|
||||
|
||||
TEST(void(A::*)() volatile & noexcept);
|
||||
TEST(void(A::*)() const volatile && noexcept);
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
|
||||
TEST(std::nullptr_t);
|
||||
|
||||
#endif
|
||||
|
||||
TEST(std::pair<A, B>);
|
||||
TEST(std::pair<A const*, B*> volatile&);
|
||||
|
||||
TEST(std::basic_string<Ch>);
|
||||
|
||||
TEST(std::string);
|
||||
TEST(std::wstring);
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201100L
|
||||
|
||||
TEST(std::u16string);
|
||||
TEST(std::u32string);
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_CXX_VERSION >= 202000L
|
||||
|
||||
TEST(std::u8string);
|
||||
|
||||
#endif
|
||||
|
||||
TEST(X<A, B>);
|
||||
TEST(X<A const&, B&> volatile&);
|
||||
|
||||
TEST(std::vector<int>);
|
||||
TEST(std::vector<A>);
|
||||
TEST(std::vector<std::string>);
|
||||
|
||||
TEST(std::list<int>);
|
||||
TEST(std::list<B>);
|
||||
TEST(std::list<std::wstring>);
|
||||
|
||||
TEST(std::deque<int>);
|
||||
TEST(std::deque<A>);
|
||||
TEST(std::deque<std::string>);
|
||||
|
||||
TEST(std::set<int>);
|
||||
TEST(std::set<B>);
|
||||
TEST(std::set<std::string>);
|
||||
|
||||
TEST(std::map<int, A>);
|
||||
TEST(std::map<std::string, B>);
|
||||
TEST(std::map<std::wstring, std::vector<std::string> const*> const&);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
|
||||
|
||||
TEST(std::unordered_set<int>);
|
||||
TEST(std::unordered_set<std::string>);
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP)
|
||||
|
||||
TEST(std::unordered_map<int, A>);
|
||||
TEST(std::unordered_map<std::string, B>);
|
||||
TEST(std::unordered_map<std::wstring, std::set<std::string>*>);
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
|
||||
|
||||
TEST(std::array<std::string, 7>);
|
||||
TEST(std::array<std::wstring const*, 0> const&);
|
||||
|
||||
#endif
|
||||
|
||||
TEST(std::ostream);
|
||||
TEST(std::basic_ostream<wchar_t>);
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
TEST(std::basic_string_view<Ch>);
|
||||
|
||||
TEST(std::string_view);
|
||||
TEST(std::wstring_view);
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201100L
|
||||
|
||||
TEST(std::u16string_view);
|
||||
TEST(std::u32string_view);
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_CXX_VERSION >= 202000L
|
||||
|
||||
TEST(std::u8string_view);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user