forked from boostorg/core
Compare commits
214 Commits
feature/cm
...
esp-idf-co
| Author | SHA1 | Date | |
|---|---|---|---|
| 47dab0d545 | |||
| 17513d123b | |||
|
|
ac9d79992e | ||
|
|
b6c3190468 | ||
|
|
f941d2e1f7 | ||
|
|
c0e2211c2b | ||
|
|
eec8689d58 | ||
|
|
45e5b1ebcf | ||
|
|
8645bcb06e | ||
|
|
ebff02a932 | ||
|
|
42ed795866 | ||
|
|
0212774324 | ||
|
|
43d0da03f3 | ||
|
|
0011697492 | ||
|
|
d74140983d | ||
|
|
1e5c86eb9d | ||
|
|
00cc660f28 | ||
|
|
44610b65ba | ||
|
|
5e0ff1680f | ||
|
|
4defdfd233 | ||
|
|
c4deb479fd | ||
|
|
f326683d42 | ||
|
|
dbefea9631 | ||
|
|
a32c1ee7ac | ||
|
|
230dd83002 | ||
|
|
ec91f29d56 | ||
|
|
188ca25bf3 | ||
|
|
ed84fc4e23 | ||
|
|
622b7a398a | ||
|
|
35a4e09854 | ||
|
|
b7c987f83c | ||
|
|
89d8efb7ff | ||
|
|
f12eeb6b9f | ||
|
|
ad63dcda9f | ||
|
|
6a5f726602 | ||
|
|
cf619432a7 | ||
|
|
b38c148969 | ||
|
|
bae7c049b0 | ||
|
|
ea7b623b7d | ||
|
|
6ae6ff79f1 | ||
|
|
06976ccad7 | ||
|
|
65723e0e1f | ||
|
|
df3b9827cf | ||
|
|
392cc988dd | ||
|
|
0ef1c06fd8 | ||
|
|
0b9624d047 | ||
|
|
574c7cf86e | ||
|
|
6e6af5fc90 | ||
|
|
95f2a76c90 | ||
|
|
28d26d13f1 | ||
|
|
ac71c55b4e | ||
|
|
c83e682b7e | ||
|
|
7a79d17da2 | ||
|
|
02b3f91fc3 | ||
|
|
a2b37091eb | ||
|
|
78dd0cce2f | ||
|
|
a121ab0278 | ||
|
|
0e62373aa2 | ||
|
|
6da7958281 | ||
|
|
c8479b4eca | ||
|
|
f5ab83efe8 | ||
|
|
eb7bc1ff53 | ||
|
|
d038633f98 | ||
|
|
ac4bdcc4c5 | ||
|
|
85a3183c01 | ||
|
|
0c9675cf56 | ||
|
|
5abadf4472 | ||
|
|
6b3fb219cc | ||
|
|
febc195093 | ||
|
|
8985ce604e | ||
|
|
15c884438c | ||
|
|
15f7fb7eaa | ||
|
|
46f37b2f16 | ||
|
|
c1be2097d7 | ||
|
|
c8b989d80b | ||
|
|
74c770206a | ||
|
|
a1ad1784bf | ||
|
|
213e4695bf | ||
|
|
a4172b4319 | ||
|
|
e4fb94b73c | ||
|
|
ef3505db59 | ||
|
|
f94db671f6 | ||
|
|
7b45315af1 | ||
|
|
bdd4bf7d9a | ||
|
|
9f2cdfa7d2 | ||
|
|
964ef98eee | ||
|
|
f09ab90243 | ||
|
|
d2e897fd60 | ||
|
|
66f6ea594a | ||
|
|
6a91536da6 | ||
|
|
c3a398b9a0 | ||
|
|
e73e8bfc83 | ||
|
|
633a47f85b | ||
|
|
eae98e909e | ||
|
|
a581a42c4f | ||
|
|
e44781e290 | ||
|
|
11958e9568 | ||
|
|
56566d9abc | ||
|
|
9efeed68cb | ||
|
|
da3c89dc5b | ||
|
|
ba208ad7fc | ||
|
|
bbfa6344fa | ||
|
|
bf4354a3a4 | ||
|
|
a4b661068d | ||
|
|
8299d25eb2 | ||
|
|
847f9d43fe | ||
|
|
44e294fff1 | ||
|
|
b5f59858b9 | ||
|
|
bed07e7d5b | ||
|
|
971cda2e4c | ||
|
|
d81c61abb4 | ||
|
|
370a74c249 | ||
|
|
62d1b1bb59 | ||
|
|
bb99544852 | ||
|
|
9b5bf05fae | ||
|
|
309a6bb797 | ||
|
|
9d1b59ec6c | ||
|
|
12f5f51427 | ||
|
|
0565456622 | ||
|
|
fda0f87576 | ||
|
|
e9718374ac | ||
|
|
79b7c49fb3 | ||
|
|
585ac9ace1 | ||
|
|
493832a570 | ||
|
|
8942e8ecc9 | ||
|
|
cbf03c4b9c | ||
|
|
5cf3569218 | ||
|
|
d5bd40e528 | ||
|
|
0e57df5aab | ||
|
|
62b23df9ef | ||
|
|
fdf1ed78a7 | ||
|
|
e02c333706 | ||
|
|
b677d1eeae | ||
|
|
0f7d02de01 | ||
|
|
773499db5e | ||
|
|
ce912859aa | ||
|
|
bfeee019dd | ||
|
|
220d4ae0a9 | ||
|
|
5d7b469e29 | ||
|
|
3cec508460 | ||
|
|
a47fac1449 | ||
|
|
7340f123fe | ||
|
|
038064e824 | ||
|
|
52c58efc36 | ||
|
|
15fdc0ab39 | ||
|
|
b520289660 | ||
|
|
9b22937647 | ||
|
|
903d44c0c5 | ||
|
|
88eee0c628 | ||
|
|
54965f567d | ||
|
|
c43a172ded | ||
|
|
ddf9b5087b | ||
|
|
d17313d407 | ||
|
|
c8b860704e | ||
|
|
e9ffc4336c | ||
|
|
a121d5a000 | ||
|
|
5c82e38c93 | ||
|
|
db15c7419d | ||
|
|
62e9d9b868 | ||
|
|
b01f2fe4d2 | ||
|
|
408cd96595 | ||
|
|
9f2ec3bfca | ||
|
|
63f3a97a15 | ||
|
|
b70bbf14db | ||
|
|
b251310a8f | ||
|
|
969a201c75 | ||
|
|
b9f1b9f39a | ||
|
|
3d4eb536cd | ||
|
|
a51364c5d3 | ||
|
|
ab3950fdfb | ||
|
|
fe9c0164c0 | ||
|
|
8ec0e7f68a | ||
|
|
85e24f0483 | ||
|
|
be820fea2e | ||
|
|
af3e6a667b | ||
|
|
c3cfe7a861 | ||
|
|
d87766a768 | ||
|
|
706747ab08 | ||
|
|
41c3b6a7dd | ||
|
|
8223ff03e4 | ||
|
|
18334b1614 | ||
|
|
df65ea6600 | ||
|
|
d1ad50cefb | ||
|
|
09870f0739 | ||
|
|
95e64ef71f | ||
|
|
673e3c302c | ||
|
|
a8e7a3395e | ||
|
|
09044f58d6 | ||
|
|
f9fa1772f2 | ||
|
|
c7dfa29f29 | ||
|
|
93c18fb937 | ||
|
|
c005ad5e55 | ||
|
|
8cf4d16297 | ||
|
|
0deaa2d502 | ||
|
|
22de922125 | ||
|
|
531726eb09 | ||
|
|
31a9336778 | ||
|
|
87c21a23bb | ||
|
|
3e9cc2153b | ||
|
|
98630095f3 | ||
|
|
b3906601f7 | ||
|
|
3b5595e940 | ||
|
|
290340fd27 | ||
|
|
31e2caef12 | ||
|
|
042bb98142 | ||
|
|
c65c05c006 | ||
|
|
1aa8341bd7 | ||
|
|
e206cddc6f | ||
|
|
c8b55f1bde | ||
|
|
62ba7ca18b | ||
|
|
964dfe2b74 | ||
|
|
016ae92ecf | ||
|
|
7d05dfa87d | ||
|
|
95924b1329 |
337
.github/workflows/ci.yml
vendored
337
.github/workflows/ci.yml
vendored
@@ -14,10 +14,6 @@ on:
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
concurrency:
|
||||
group: ${{format('{0}:{1}', github.repository, github.ref)}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GIT_FETCH_JOBS: 8
|
||||
NET_RETRY_COUNT: 5
|
||||
@@ -103,17 +99,18 @@ jobs:
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-11
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12
|
||||
- name: UBSAN
|
||||
toolset: gcc-11
|
||||
toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
ubsan: 1
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-11
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- g++-12
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
@@ -217,6 +214,32 @@ jobs:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-14
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-13
|
||||
- libc++-13-dev
|
||||
- libc++abi-13-dev
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-12
|
||||
@@ -234,10 +257,6 @@ jobs:
|
||||
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}}
|
||||
@@ -256,7 +275,7 @@ jobs:
|
||||
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
|
||||
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 perl git cmake
|
||||
fi
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
@@ -266,28 +285,32 @@ jobs:
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
|
||||
SOURCES=(${{join(matrix.sources, ' ')}})
|
||||
declare -a SOURCE_KEYS SOURCES
|
||||
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
|
||||
then
|
||||
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
|
||||
fi
|
||||
if [ -n "${{join(matrix.sources, ' ')}}" ]
|
||||
then
|
||||
SOURCES=("${{join(matrix.sources, '" "')}}")
|
||||
fi
|
||||
for key in "${SOURCE_KEYS[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
echo "Adding key: $key"
|
||||
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"
|
||||
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
|
||||
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
|
||||
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
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
|
||||
for source in "${SOURCES[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
@@ -308,6 +331,7 @@ jobs:
|
||||
esac
|
||||
fi
|
||||
APT_ADD_REPO_ARGS+=("$source")
|
||||
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
|
||||
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
|
||||
done
|
||||
done
|
||||
@@ -338,12 +362,11 @@ jobs:
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
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" ]
|
||||
@@ -370,29 +393,35 @@ jobs:
|
||||
fi
|
||||
if [ "$GIT_HAS_JOBS" -ne 0 ]
|
||||
then
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
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}}" ]
|
||||
git submodule init tools/boost_install
|
||||
git submodule init libs/headers
|
||||
git submodule init tools/build
|
||||
git submodule init tools/cmake
|
||||
git submodule init libs/assert
|
||||
git submodule init libs/config
|
||||
git submodule init libs/static_assert
|
||||
git submodule init libs/throw_exception
|
||||
git submodule init libs/type_traits
|
||||
git submodule init libs/utility
|
||||
git submodule init libs/io
|
||||
git submodule update $GIT_ARGS
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
|
||||
if [ -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
|
||||
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
|
||||
fi
|
||||
echo " ;" >> ~/user-config.jam
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
@@ -426,50 +455,27 @@ jobs:
|
||||
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"
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
@@ -497,8 +503,18 @@ jobs:
|
||||
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%
|
||||
git submodule init tools/boost_install
|
||||
git submodule init libs/headers
|
||||
git submodule init tools/build
|
||||
git submodule init tools/cmake
|
||||
git submodule init libs/assert
|
||||
git submodule init libs/config
|
||||
git submodule init libs/static_assert
|
||||
git submodule init libs/throw_exception
|
||||
git submodule init libs/type_traits
|
||||
git submodule init libs/utility
|
||||
git submodule init libs/io
|
||||
git submodule update --jobs %GIT_FETCH_JOBS%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
@@ -506,4 +522,163 @@ jobs:
|
||||
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
|
||||
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
posix-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- 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
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- 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
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- 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
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Generated by `boostdep --cmake core`
|
||||
# Copyright 2020, 2021 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
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
if(NOT DEFINED IDF_TARGET)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
|
||||
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
@@ -15,10 +18,31 @@ target_link_libraries(boost_core
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
|
||||
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${headers}
|
||||
INCLUDE_DIRS
|
||||
include
|
||||
REQUIRES
|
||||
boost_assert
|
||||
boost_config
|
||||
boost_static_assert
|
||||
boost_throw_exception
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
13
appveyor.yml
13
appveyor.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Copyright 2016-2021 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)
|
||||
|
||||
@@ -29,14 +29,9 @@ environment:
|
||||
|
||||
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17,latest
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
@@ -77,6 +72,8 @@ install:
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/utility
|
||||
- git submodule init libs/io
|
||||
- git submodule init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 4
|
||||
@@ -90,4 +87,4 @@ test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
# or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import project ;
|
||||
import doxygen ;
|
||||
import quickbook ;
|
||||
|
||||
path-constant INCLUDES : ../../.. ;
|
||||
|
||||
doxygen ref_reference
|
||||
:
|
||||
[ glob ../../../boost/core/ref.hpp ]
|
||||
$(INCLUDES)/boost/core/ref.hpp
|
||||
:
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
<doxygen:param>EXPAND_ONLY_PREDEF=YES
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:alloc_construct alloc_construct, alloc_destroy]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/alloc_construct.hpp> provides function templates
|
||||
`alloc_construct`, `alloc_construct_n`, `alloc_destroy`, and `alloc_destroy_n`
|
||||
for allocator aware and exception safe construction and destruction of objects
|
||||
and arrays.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
The following example allocates storage for an array of `n` elements of `T`
|
||||
using an allocator `a` and constructs `T` elements in that storage. If any
|
||||
exception was thrown during construction of an element, the constructed
|
||||
elements are destroyed in reverse order.
|
||||
|
||||
```
|
||||
template<class A>
|
||||
auto create(A& a, std::size_t n)
|
||||
{
|
||||
auto p = a.allocate(n);
|
||||
try {
|
||||
boost::alloc_construct_n(a, boost::to_address(p), n);
|
||||
} catch (...) {
|
||||
a.deallocate(p, n);
|
||||
throw;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_destroy(A& a, T* p);
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_destroy_n(A& a, T* p, std::size_t n);
|
||||
|
||||
template<class A, class T, class Args>
|
||||
void alloc_construct(A& a, T* p, Args&&... args);
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n);
|
||||
|
||||
template<class A, class T>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m);
|
||||
|
||||
template<class A, class T, class I>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n, I begin);
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class A, class T> void alloc_destroy(A& a, T* p);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects][`std::allocator_traits<A>::destroy(a, p)`.]]]]]
|
||||
[[`template<class A, class T> void alloc_destroy_n(A& a, T* p,
|
||||
std::size_t n);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[Destroys each `i`-th element in reverse order by calling
|
||||
`std::allocator_traits<A>::destroy(a, &p[i])`.]]]]]
|
||||
[[`template<class A, class T, class Args> void alloc_construct(A& a, T* p,
|
||||
Args&&... args);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[`std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...)`.]]]]]
|
||||
[[`template<class A, class T> void alloc_construct_n(A& a, T* p,
|
||||
std::size_t n);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`std::allocator_traits<A>::construct(a, &p[i])`.]]
|
||||
[[Remarks]
|
||||
[If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
|
||||
[[`template<class A, class T> void alloc_construct_n(A& a, T* p, std::size_t n,
|
||||
const T* l, std::size_t m);`]
|
||||
[[variablelist
|
||||
[[Requires][`A` is an /Allocator/]]
|
||||
[[Effects]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`std::allocator_traits<A>::construct(a, &p[i], l[i % m])`.]]
|
||||
[[Remarks]
|
||||
[If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
|
||||
[[`template<class A, class T, class I> void alloc_construct_n(A& a, T* p,
|
||||
std::size_t n, I begin);`]
|
||||
[[variablelist
|
||||
[[Requires]
|
||||
[[itemized_list
|
||||
[`A` is an /Allocator/][`I` is an /InputIterator/]]]]
|
||||
[[Effects]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`std::allocator_traits<A>::construct(a, &p[i], *begin++])`.]]
|
||||
[[Remarks]
|
||||
[If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Compatibility]
|
||||
|
||||
When `BOOST_NO_CXX11_ALLOCATOR` is defined, and the C++11 allocator model is
|
||||
not supported, these functions invoke constructors and destructors directly
|
||||
without going through the supplied allocator.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Glen Fernandes originally implemented this functionality in Boost.Smart_Ptr and
|
||||
later moved these functions to Boost.Core for use in other Boost libraries,
|
||||
such as Boost.Multi_Array and Boost.Histogram.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -1,12 +1,12 @@
|
||||
[/
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
Copyright 2020-2022 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]
|
||||
[section allocator_access]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
@@ -21,6 +21,9 @@ 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.
|
||||
|
||||
It also adds additional functionality for allocator aware exception safe
|
||||
construction and destruction of arrays.
|
||||
|
||||
These facilities also simplify existing libraries by avoiding having to check
|
||||
for `BOOST_NO_CXX11_ALLOCATOR` and conditionally use `std::allocator_traits`.
|
||||
|
||||
@@ -51,6 +54,26 @@ public:
|
||||
In C++11 or above, aliases such as `boost::allocator_pointer_t<A>` can be used
|
||||
instead of `typename boost::allocator_pointer<A>::type`.
|
||||
|
||||
The following example allocates storage for an array of `n` elements of `T`
|
||||
using an allocator `a` and constructs `T` elements in that storage. If any
|
||||
exception was thrown during construction of an element, the constructed
|
||||
elements are destroyed in reverse order.
|
||||
|
||||
```
|
||||
template<class A>
|
||||
auto create(A& a, std::size_t n)
|
||||
{
|
||||
auto p = a.allocate(n);
|
||||
try {
|
||||
boost::allocator_construct_n(a, boost::to_address(p), n);
|
||||
} catch (...) {
|
||||
a.deallocate(p, n);
|
||||
throw;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
@@ -150,9 +173,22 @@ void allocator_deallocate(A& a, allocator_pointer_t<A> p,
|
||||
template<class A, class T, class... Args>
|
||||
void allocator_construct(A& a, T* p, Args&&... args);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_construct_n(A& a, T* p, std::size_t n);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_construct_n(A& a, T* p, std::size_t n, const T* l,
|
||||
std::size_t m);
|
||||
|
||||
template<class A, class T, class I>
|
||||
void allocator_construct_n(A& a, T* p, std::size_t n, I begin);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_destroy(A& a, T* p);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_destroy_n(A& a, T* p, std::size_t n);
|
||||
|
||||
template<class A>
|
||||
allocator_size_type_t<A> allocator_max_size(const A& a);
|
||||
|
||||
@@ -168,7 +204,8 @@ A allocator_select_on_container_copy_construction(const A& a);
|
||||
[[`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*`.]]
|
||||
[The member `type` is `A::pointer` if valid, otherwise
|
||||
`allocator_value_type_t<A>*`.]]
|
||||
[[`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
|
||||
@@ -219,12 +256,34 @@ allocator_size_type_t<A> n);`]
|
||||
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 alloc_construct_n(A& a, T* p, std::size_t n);`]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`boost::allocator_construct(a, &p[i])`.
|
||||
If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `boost::allocator_destroy(a, &p[j])`.]]
|
||||
[[`template<class A, class T>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m);`]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`boost::allocator_construct(a, &p[i], l[i % m])`.
|
||||
If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `boost::allocator_destroy(a, &p[j])`.]]
|
||||
[[`template<class A, class T, class I>
|
||||
void alloc_construct_n(A& a, T* p, std::size_t n, I begin);`]
|
||||
[Constructs each `i`-th element in order by calling
|
||||
`boost::allocator_construct(a, &p[i], *begin++)`.
|
||||
If an exception is thrown destroys each already constructed `j`-th element in
|
||||
reverse order by calling `boost::allocator_destroy(a, &p[j])`.]]
|
||||
[[`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, class T>
|
||||
void allocator_destroy_n(A& a, T* p, std::size_t n);`]
|
||||
[Destroys each `i`-th element in reverse order by calling
|
||||
`boost::allocator_destroy(a, &p[i])`.]]
|
||||
[[`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)`.]]
|
||||
sizeof(allocator_value_type_t<A>)`.]]
|
||||
[[`template<class A> A allocator_select_on_container_copy_construction(const
|
||||
A& a);`]
|
||||
[Returns `a.select_on_container_copy_construction()` if valid, otherwise
|
||||
|
||||
116
doc/allocator_traits.qbk
Normal file
116
doc/allocator_traits.qbk
Normal file
@@ -0,0 +1,116 @@
|
||||
[/
|
||||
Copyright 2021 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_traits allocator_traits]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
This header <boost/core/allocator_traits.hpp> provides an implementation of the
|
||||
C++ standard library class template `allocator_traits` based on the facilities
|
||||
in [link core.allocator_access Allocator Access]. Users should still prefer the
|
||||
individual traits, but this utility exists to simplify migration.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct allocator_traits {
|
||||
using allocator_type = A;
|
||||
|
||||
using value_type = allocator_value_type_t<A>;
|
||||
|
||||
using pointer = allocator_pointer_t<A>;
|
||||
|
||||
using const_pointer = allocator_const_pointer_t<A>;
|
||||
|
||||
using void_pointer = allocator_void_pointer_t<A>;
|
||||
|
||||
using const_pointer = allocator_const_void_pointer_t<A>;
|
||||
|
||||
using difference_type = allocator_difference_type_t<A>;
|
||||
|
||||
using size_type = allocator_size_type_t<A>;
|
||||
|
||||
using propagate_on_container_copy_assignment =
|
||||
allocator_propagate_on_container_copy_assignment_t<A>;
|
||||
|
||||
using propagate_on_container_move_assignment =
|
||||
allocator_propagate_on_container_move_assignment_t<A>;
|
||||
|
||||
using propagate_on_container_swap =
|
||||
allocator_propagate_on_container_swap_t<A>;
|
||||
|
||||
using is_always_equal = allocator_is_always_equal_t<A>;
|
||||
|
||||
template<class T>
|
||||
using rebind_traits = allocator_traits<allocator_rebind_t<A, T> >;
|
||||
|
||||
static pointer allocate(A& a, size_type n);
|
||||
|
||||
static pointer allocate(A& a, size_type n, const_void_pointer h);
|
||||
|
||||
static void deallocate(A& a, pointer p, size_type n);
|
||||
|
||||
template<class T, class... Args>
|
||||
static void construct(A& a, T* p, Args&&... args);
|
||||
|
||||
static void destroy(A& a, T* p);
|
||||
|
||||
static size_type max_size(const A& a) noexcept;
|
||||
|
||||
static A select_on_container_copy_construction(const A& a);
|
||||
};
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Static member functions]
|
||||
|
||||
[variablelist
|
||||
[[`static pointer allocate(A& a, size_type n);`]
|
||||
[Equivalent to: `return boost::allocator_allocate(a, n);`]]
|
||||
[[`static pointer allocate(A& a, size_type n, const_void_pointer h);`]
|
||||
[Equivalent to: `return boost::allocator_allocate(a, n, h);`]]
|
||||
[[`static void deallocate(A& a, pointer p, size_type n);`]
|
||||
[Equivalent to: `boost::allocator_deallocate(a, n, h);`]]
|
||||
[[`template<class T, class... Args>
|
||||
static void construct(A& a, T* p, Args&&... args);`]
|
||||
[Equivalent to:
|
||||
`boost::allocator_construct(a, p, std::forward<Args>(args)...);`]]
|
||||
[[`static void destroy(A& a, T* p);`]
|
||||
[Equivalent to: `boost::allocator_destroy(a, p);`]]
|
||||
[[`static size_type max_size(const A& a) noexcept;`]
|
||||
[Equivalent to: `return boost::allocator_max_size(a);`]]
|
||||
[[`static A select_on_container_copy_construction(const A& a);`]
|
||||
[Equivalent to:
|
||||
`return boost::allocator_select_on_container_copy_construction(a);`]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Notes]
|
||||
|
||||
# The member `rebind_alloc` is not provided for parity with C++03 where it is
|
||||
unimplementable. Instead of `allocator_traits<A>::rebind_alloc<U>` you can
|
||||
express the same with `allocator_traits<A>::rebind_traits<U>::allocator_type`
|
||||
or more simply with `allocator_rebind_t<A, U>`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -6,11 +6,23 @@
|
||||
|
||||
[section Revision History]
|
||||
|
||||
[section Changes in 1.79.0]
|
||||
|
||||
* Added `boost::allocator_traits`, an implementation of `std::allocator_traits`.
|
||||
* Made `boost::pointer_traits` SFINAE friendly.
|
||||
* `boost/iterator.hpp` is deprecated and will be removed in a future release. The header defines `boost::iterator` template, which is equivalent to `std::iterator` in `<iterator>` header. However, since `std::iterator` is itself deprecated in C++17, users are advised to remove `boost::iterator` or `std::iterator` use from their code.
|
||||
* Added `boost::core::verbose_terminate_handler`, a utility function intended
|
||||
to be passed to `std::set_terminate` that prints information about the
|
||||
uncaught exception to `stderr`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[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`.
|
||||
* Added `boost::core::type_name`, a utility function that returns the name of a type as a string.
|
||||
* Added `boost::span`, a C++11 implementation of C++20's `std::span`.
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -22,11 +34,11 @@
|
||||
|
||||
[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`.)
|
||||
* Added implicit conversion between compatible reference wrappers.
|
||||
* Added `boost/core/cmath.hpp`, a portable implementation of the floating point classification functions from `<cmath>`.
|
||||
* Added `boost/core/bit.hpp`, a portable implementation of the C++20 standard header `<bit>`.
|
||||
* Fixed `BOOST_TEST_EQ`, `BOOST_TEST_NE` for character types under C++20.
|
||||
* Revised allocator access utilities (now support VS2013, and no workarounds use `allocator_traits`.)
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -35,6 +47,7 @@
|
||||
* 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.
|
||||
* Added `BOOST_TEST_WITH` to Lightweight Test.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ criteria for inclusion is that the utility component be:
|
||||
* simple,
|
||||
* used by other Boost libraries, and
|
||||
* not dependent on any other Boost modules except Core
|
||||
itself, Config, Assert, Static Assert, or Predef.
|
||||
itself, Config, Assert, StaticAssert, or ThrowException.
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -42,7 +42,7 @@ criteria for inclusion is that the utility component be:
|
||||
|
||||
[include addressof.qbk]
|
||||
[include allocator_access.qbk]
|
||||
[include alloc_construct.qbk]
|
||||
[include allocator_traits.qbk]
|
||||
[include bit.qbk]
|
||||
[include checked_delete.qbk]
|
||||
[include cmath.qbk]
|
||||
@@ -65,8 +65,10 @@ criteria for inclusion is that the utility component be:
|
||||
[include quick_exit.qbk]
|
||||
[include ref.qbk]
|
||||
[include scoped_enum.qbk]
|
||||
[include span.qbk]
|
||||
[include swap.qbk]
|
||||
[include typeinfo.qbk]
|
||||
[include type_name.qbk]
|
||||
[include uncaught_exceptions.qbk]
|
||||
[include use_default.qbk]
|
||||
[include verbose_terminate_handler.qbk]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[/
|
||||
Copyright 2017-2018 Glen Joseph Fernandes
|
||||
Copyright 2017-2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -47,68 +47,88 @@ void function(Allocator& a)
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
template<class T> struct pointer_traits {
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits {
|
||||
typedef T pointer;
|
||||
typedef ``['see below]`` element_type;
|
||||
typedef ``['see below]`` difference_type;
|
||||
|
||||
template<class U> struct rebind_to { typedef ``['see below]`` type; };
|
||||
template<class U> using rebind = typename rebind_to<U>::type;
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef ``['see below]`` type;
|
||||
};
|
||||
|
||||
static pointer pointer_to(``['see below]`` v);
|
||||
};
|
||||
template<class U>
|
||||
using rebind = typename rebind_to<U>::type;
|
||||
|
||||
template<class T> struct pointer_traits<T*> {
|
||||
static pointer pointer_to(element_type& v);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits<T*> {
|
||||
typedef T* pointer;
|
||||
typedef T element_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
template<class U> struct rebind_to { typedef U* type; };
|
||||
template<class U> using rebind = typename rebind_to<U>::type;
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef U* type;
|
||||
};
|
||||
|
||||
template<class U>
|
||||
using rebind = typename rebind_to<U>::type;
|
||||
|
||||
static pointer pointer_to(``['see below]`` v) noexcept;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
constexpr T* to_address(T* v) noexcept;
|
||||
template<class T>
|
||||
constexpr T* to_address(T* v) noexcept;
|
||||
|
||||
template<class T>
|
||||
auto to_address(const T& v) noexcept;
|
||||
}
|
||||
template<class T>
|
||||
auto to_address(const T& v) noexcept;
|
||||
|
||||
} // boost
|
||||
```
|
||||
|
||||
[section Overview]
|
||||
|
||||
If the member type `element_type` is not defined, then all other members are
|
||||
also not defined (`pointer_traits` is SFINAE-friendly).
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member types]
|
||||
|
||||
[variablelist
|
||||
[[`typedef` ['see below] `element_type;`]
|
||||
[`T::element_type` if such a type exists; otherwise `U` if `T` is a class
|
||||
template instantiation of the form `Pointer<U, Args>`, where `Args` is zero
|
||||
or more type arguments; otherwise the specialization is ill-formed.]]
|
||||
or more type arguments; otherwise the member is not defined.]]
|
||||
[[`typedef` ['see below] `difference_type;`]
|
||||
[`T::difference_type` if such a type exists; otherwise `std::ptrdiff_t`.]]
|
||||
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
|
||||
[`type` is `T::rebind<U>` if such a type exists; otherwise, `Pointer<V, Args>`
|
||||
if `T` is a class template instantiation of the form `Pointer<T, Args>`,
|
||||
where `Args` is zero or more type arguments; otherwise, the instantiation of
|
||||
`rebind_to` is ill-formed.]]]
|
||||
where `Args` is zero or more type arguments; otherwise, the member is not
|
||||
defined.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member functions]
|
||||
|
||||
[variablelist
|
||||
[[`static pointer pointer_traits::pointer_to(`['see below] `v);`]
|
||||
[[`static pointer pointer_traits::pointer_to(element_type& v);`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||
it is `element_type&`.]]
|
||||
[If `element_type` is a void type, or if `T::pointer_to(v)` is not well formed,
|
||||
this member is not defined.]]
|
||||
[[Returns]
|
||||
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
||||
[[`static pointer pointer_traits<T*>::pointer_to(`['see below] `v) noexcept;`]
|
||||
[[`static pointer pointer_traits<T*>::pointer_to(element_type& v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||
it is `element_type&`.]]
|
||||
[If `element_type` is a void type, this member is not defined.]]
|
||||
[[Returns][`addressof(v)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
396
doc/span.qbk
Normal file
396
doc/span.qbk
Normal file
@@ -0,0 +1,396 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:span span]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
This header <boost/core/span.hpp> provides class template `span`, which is a
|
||||
view over a sequence of objects. It implements the C++20 standard library
|
||||
`std::span` facility. This implementation supports C++11 and higher.
|
||||
|
||||
In addition to referencing the sequence of objects, the span knows the count of
|
||||
objects. There are two kinds of spans:
|
||||
|
||||
* Dynamic size (`span<T>` or `span<T, dynamic_extent>`)
|
||||
* Static size (`span<T, N>`)
|
||||
|
||||
Dynamic size spans have a count that can be a value known at run time. Static
|
||||
size spans have a count that must be known at compile time.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following snippet shows a function to compute a SHA1 hash whose parameters
|
||||
and return type use spans.
|
||||
|
||||
```
|
||||
auto sha1(boost::span<const unsigned char> input,
|
||||
boost::span<unsigned char, SHA_DIGEST_LENGTH> ouput)
|
||||
{
|
||||
SHA_CTX context;
|
||||
SHA1_Init(&context);
|
||||
SHA1_Update(&context, input.data(), input.size());
|
||||
SHA1_Final(output.data(), &context);
|
||||
return output;
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
constexpr std::size_t dynamic_extent = -1;
|
||||
|
||||
template<class T, std::size_t E = dynamic_extent>
|
||||
class span {
|
||||
public:
|
||||
typedef T element_type;
|
||||
typedef std::remove_cv_t<T> value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef std::reverse_iterator<T*> reverse_iterator;
|
||||
typedef std::reverse_iterator<const T*> const_reverse_iterator;
|
||||
|
||||
static constexpr std::size_t extent = E;
|
||||
|
||||
constexpr span() noexcept;
|
||||
|
||||
explicit(E != dynamic_extent)
|
||||
template<class I>
|
||||
constexpr span(I* f, size_type c);
|
||||
|
||||
explicit(E != dynamic_extent)
|
||||
template<class I, class L>
|
||||
constexpr span(I* f, L* l);
|
||||
|
||||
template<std::size_t N>
|
||||
constexpr span(type_identity_t<T> (&a)[N]);
|
||||
|
||||
template<class U, std::size_t N>
|
||||
constexpr span(std::array<U, N>& a) noexcept;
|
||||
|
||||
template<class U, std::size_t N>
|
||||
constexpr span(const std::array<U, N>& a) noexcept;
|
||||
|
||||
explicit(E != dynamic_extent)
|
||||
template<class R>
|
||||
constexpr span(R&& r);
|
||||
|
||||
explicit(E != dynamic_extent && N == dynamic_extent)
|
||||
template<class U, std::size_t N>
|
||||
constexpr span(const span<U, N>& s) noexcept;
|
||||
|
||||
template<std::size_t C>
|
||||
constexpr span<T, C> first() const;
|
||||
|
||||
template<std::size_t C>
|
||||
constexpr span<T, C> last() const;
|
||||
|
||||
template<std::size_t O, std::size_t C = dynamic_extent>
|
||||
constexpr span<T, see below> subspan() const;
|
||||
|
||||
constexpr span<T, dynamic_extent> first(size_type c) const;
|
||||
constexpr span<T, dynamic_extent> last(size_type c) const;
|
||||
|
||||
constexpr span<T, dynamic_extent> subspan(size_type o,
|
||||
size_type c = dynamic_extent) const;
|
||||
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type size_bytes() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
constexpr reference operator[](size_type i) const;
|
||||
constexpr reference front() const;
|
||||
constexpr reference back() const;
|
||||
constexpr pointer data() const noexcept;
|
||||
|
||||
constexpr iterator begin() const noexcept;
|
||||
constexpr iterator end() const noexcept;
|
||||
constexpr reverse_iterator rbegin() const noexcept;
|
||||
constexpr reverse_iterator rend() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
constexpr const_reverse_iterator crbegin() const noexcept;
|
||||
constexpr const_reverse_iterator crend() const noexcept;
|
||||
};
|
||||
|
||||
template<class I, class L>
|
||||
span(I*, L) -> span<I>;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
span(T(&)[N]) -> span<T, N>;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
span(std::array<T, N>&) -> span<T, N>;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
span(const std::array<T, N>&) -> span<const T, N>;
|
||||
|
||||
template<class R>
|
||||
span(R&&) -> span<std::remove_pointer_t<decltype(std::declval<R&>().data())> >;
|
||||
|
||||
template<class T, std::size_t E>
|
||||
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
|
||||
as_bytes(span<T, E> s) noexcept;
|
||||
|
||||
template<class T, std::size_t E>
|
||||
span<std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
|
||||
as_writable_bytes(span<T, E> s) noexcept;
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Constructors]
|
||||
|
||||
[variablelist
|
||||
[[`constexpr span() noexcept;`]
|
||||
[[variablelist
|
||||
[[Constraints][`E == dynamic_extent || E == 0` is `true`.]]
|
||||
[[Postconditions][`size() == 0 && data() == nullptr`.]]]]]
|
||||
[[`explicit(E != dynamic_extent)
|
||||
template<class I>
|
||||
constexpr span(I* f, size_type c);`]
|
||||
[[variablelist
|
||||
[[Constraints]
|
||||
[`is_convertible_v<I(*)[], T(*)[]>` is `true`.]]
|
||||
[[Preconditions]
|
||||
[[itemized_list
|
||||
[`[f, f + c)` is a valid range.]
|
||||
[If `E` is not equal to `dynamic_extent`, then `c` is equal to `E`.]]]]
|
||||
[[Effects][Constructs a `span` with data `f` and size `c`.]]
|
||||
[[Throws][Nothing.]]]]]
|
||||
[[`explicit(E != dynamic_extent)
|
||||
template<class I, class L>
|
||||
constexpr span(I* f, L* l);`]
|
||||
[[variablelist
|
||||
[[Constraints]
|
||||
[`is_convertible_v<I(*)[], T(*)[]>` is `true`.]]
|
||||
[[Preconditions]
|
||||
[[itemized_list
|
||||
[If `E` is not equal to `dynamic_extent`, then `l - f` is equal to `E`.]
|
||||
[`[f, l)` is a valid range.]]]]
|
||||
[[Effects][Constructs a `span` with data `f` and size `l - f`.]]
|
||||
[[Throws][Nothing.]]]]]
|
||||
[[`template<std::size_t N>
|
||||
constexpr span(type_identity_t<T> (&a)[N]);`]
|
||||
[[variablelist
|
||||
[[Constraints][`E == dynamic_extent || E == N` is `true`.]]
|
||||
[[Effects][Constructs a `span` that is a view over the supplied array.]]
|
||||
[[Postconditions][`size() == N && data() == &a[0]` is `true`.]]]]]
|
||||
[[`template<class U, std::size_t N>
|
||||
constexpr span(std::array<U, N>& a) noexcept;`]
|
||||
[[variablelist
|
||||
[[Constraints]
|
||||
[[itemized_list
|
||||
[`E == dynamic_extent || E == N` is `true`, and]
|
||||
[`U(*)[]` is convertible to `T(*)[]`.]]]]
|
||||
[[Effects][Constructs a `span` that is a view over the supplied array.]]
|
||||
[[Postconditions][`size() == N && data() == a.data()` is `true`.]]]]]
|
||||
[[`template<class U, std::size_t N>
|
||||
constexpr span(const std::array<U, N>& a) noexcept;`]
|
||||
[[variablelist
|
||||
[[Constraints]
|
||||
[[itemized_list
|
||||
[`E == dynamic_extent || E == N` is `true`, and]
|
||||
[`U(*)[]` is convertible to `T(*)[]`.]]]]
|
||||
[[Effects][Constructs a `span` that is a view over the supplied array.]]
|
||||
[[Postconditions][`size() == N && data() == a.data()` is `true`.]]]]]
|
||||
[[`explicit(E != dynamic_extent)
|
||||
template<class R>
|
||||
constexpr span(R&& r);`]
|
||||
[[variablelist
|
||||
[[Constraints]
|
||||
[[itemized_list
|
||||
[`is_lvalue_reference_v<R> || is_const_v<T>` is `true`]
|
||||
[`remove_cvref_t<R>` is not a specialization of `span`,]
|
||||
[`remove_cvref_t<R>` is not a specialization of `array`,]
|
||||
[`is_array_v<remove_cvref_t<R>>` is `false`,]
|
||||
[`r.data()` is well-formed and
|
||||
`is_convertible_v<remove_pointer_t<decltype(declval<R&>().data())>(*)[],
|
||||
T(*)[]>` is `true`, and]
|
||||
[`r.size()` is well-formed and
|
||||
`is_convertible_v<decltype(declval<R&>().size()), size_t>` is `true`.]]]]
|
||||
[[Effects][Constructs a `span` with data `r.data()` and size `r.size()`.]]
|
||||
[[Throws][What and when r.data() and r.size() throw.]]]]]
|
||||
[[`explicit(E != dynamic_extent && N == dynamic_extent)
|
||||
template<class U, std::size_t N>
|
||||
constexpr span(const span<U, N>& s) noexcept;`]
|
||||
[[variablelist
|
||||
[[Constraints]
|
||||
[[itemized_list
|
||||
[`E == dynamic_extent || N == dynamic_extent || E == N` is `true`, and]
|
||||
[`is_convertible_v<U(*)[], T(*)[]>` is `true`.]]]]
|
||||
[[Preconditions]
|
||||
[If `E` is not equal to `dynamic_extent`, then `s.size()` is equal to `E`.]]
|
||||
[[Effects]
|
||||
[Constructs a `span` that is a view over the range
|
||||
`[s.data(), s.data() + s.size())`.]]
|
||||
[[Postconditions][`size() == s.size() && data() == s.data()`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Subviews]
|
||||
|
||||
[variablelist
|
||||
[[`template<std::size_t C> constexpr span<T, C> first() const;`]
|
||||
[[variablelist
|
||||
[[Mandates][`C <= E` is `true`.]]
|
||||
[[Preconditions][`C <= size()` is `true`.]]
|
||||
[[Effects]
|
||||
[Equivalent to `return R{data(), C};` where `R` is the return type.]]]]]
|
||||
[[`template<std::size_t C> constexpr span<T, C> last() const;`]
|
||||
[[variablelist
|
||||
[[Mandates][`C <= E` is `true`.]]
|
||||
[[Preconditions][`C <= size()` is `true`.]]
|
||||
[[Effects]
|
||||
[Equivalent to `return R{data() + (size() - C), C};` where `R` is the return
|
||||
type.]]]]]
|
||||
[[`template<std::size_t O, std::size_t C = dynamic_extent>
|
||||
constexpr span<T, see below> subspan() const;`]
|
||||
[[variablelist
|
||||
[[Mandates][`O <= E && (C == dynamic_extent || C <= E - O)` is `true`.]]
|
||||
[[Preconditions]
|
||||
[`O <= size() && (C == dynamic_extent || C <= size() - O)` is `true`.]]
|
||||
[[Effects]
|
||||
[Equivalent to
|
||||
`return span<T, see below>(data() + O,
|
||||
C != dynamic_extent ? C : size() - O);`.]]
|
||||
[[Remarks]
|
||||
[The second template argument of the returned span type is:
|
||||
`C != dynamic_extent ? C : (E != dynamic_extent ? E - O :
|
||||
dynamic_extent)`]]]]]
|
||||
[[`constexpr span<T, dynamic_extent> first(size_type c) const;`]
|
||||
[[variablelist
|
||||
[[Preconditions][`c <= size()` is `true`.]]
|
||||
[[Effects][Equivalent to: `return {data(), c};`]]]]]
|
||||
[[`constexpr span<T, dynamic_extent> last(size_type c) const;`]
|
||||
[[variablelist
|
||||
[[Preconditions][`c <= size()` is `true`.]]
|
||||
[[Effects][Equivalent to: `return {data() + (size() - c), c};`]]]]]
|
||||
[[`constexpr span<T, dynamic_extent> subspan(size_type o,
|
||||
size_type c = dynamic_extent) const;`]
|
||||
[[variablelist
|
||||
[[Preconditions]
|
||||
[`o <= size() && (c == dynamic_extent || o + c <= size())` is `true`.]]
|
||||
[[Effects]
|
||||
[Equivalent to:
|
||||
`return {data() + o, c == dynamic_extent ? size() - o : c};`]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Observers]
|
||||
|
||||
[variablelist
|
||||
[[`constexpr size_type size() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][The number of elements in the span.]]]]]
|
||||
[[`constexpr size_type size_bytes() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects][Equivalent to: `return size() * sizeof(T);`]]]]]
|
||||
[[`constexpr bool empty() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects][Equivalent to: `return size() == 0;`]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Element access]
|
||||
|
||||
[variablelist
|
||||
[[`constexpr reference operator[](size_type i) const;`]
|
||||
[[variablelist
|
||||
[[Preconditions][`i < size()` is `true`.]]
|
||||
[[Effects][Equivalent to: `return *(data() + i);`]]]]]
|
||||
[[`constexpr reference front() const;`]
|
||||
[[variablelist
|
||||
[[Preconditions][`empty()` is `false`.]]
|
||||
[[Effects][Equivalent to: `return *data();`]]]]]
|
||||
[[`constexpr reference back() const;`]
|
||||
[[variablelist
|
||||
[[Preconditions][`empty()` is `false`.]]
|
||||
[[Effects][Equivalent to: `return *(data() + (size() - 1);`]]]]]
|
||||
[[`constexpr pointer data() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][A pointer to the first element in the span.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Iterator support]
|
||||
|
||||
[variablelist
|
||||
[[`constexpr iterator begin() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][A constant iterator referring to the first element in the span. If `empty()`,
|
||||
then it returns the same value as `cend()`.]]]]]
|
||||
[[`constexpr iterator end() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][A constant iterator which is the past-the-end value.]]]]]
|
||||
[[`constexpr reverse_iterator rbegin() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects][Equivalent to: `return reverse_iterator(end());`]]]]]
|
||||
[[`constexpr reverse_iterator rend() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects][Equivalent to: `return reverse_iterator(begin());`]]]]]
|
||||
[[`constexpr const_iterator cbegin() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns]
|
||||
[A constant iterator referring to the first element in the span. If `empty()`,
|
||||
then it returns the same value as `cend()`.]]]]]
|
||||
[[`constexpr const_iterator cend() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns][A constant iterator which is the past-the-end value.]]]]]
|
||||
[[`constexpr const_reverse_iterator crbegin() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects][Equivalent to: `return const_reverse_iterator(cend());`]]]]]
|
||||
[[`constexpr const_reverse_iterator crend() const noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects]
|
||||
[Equivalent to: `return const_reverse_iterator(cbegin());`]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Views of object representation]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T, std::size_t E>
|
||||
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
|
||||
as_bytes(span<T, E> s) noexcept;`]
|
||||
[[variablelist
|
||||
[[Effects]
|
||||
[Equivalent to:
|
||||
`return {reinterpret_cast<const byte*>(s.data()), s.size_bytes()};`.]]]]]
|
||||
[[`template<class T, std::size_t E>
|
||||
span<std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
|
||||
as_writable_bytes(span<T, E> s) noexcept;`]
|
||||
[[variablelist
|
||||
[[Constraints][`is_const_v<T>` is `false`.]]
|
||||
[[Effects]
|
||||
[Equivalent to: `return R{reinterpret_cast<byte*>(s.data()), s.size_bytes()};`
|
||||
where `R` is the return type.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
768
doc/string_view.qbk
Normal file
768
doc/string_view.qbk
Normal file
@@ -0,0 +1,768 @@
|
||||
[/
|
||||
Copyright 2021 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:string_view string_view]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/string_view.hpp>]
|
||||
|
||||
The header `<boost/core/string_view.hpp>` defines `boost::core::string_view`,
|
||||
a portable and interoperable implementation of `std::string_view`.
|
||||
|
||||
Unlike `boost::string_view`, `boost::core::string_view` has implicit
|
||||
conversions from and to `std::string_view`, which allows Boost libraries that
|
||||
support C++11/C++14 to use it in interfaces without forcing users to forgo the
|
||||
use of `std::string_view` in their code.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
template<class Ch> class basic_string_view
|
||||
{
|
||||
public:
|
||||
|
||||
// types
|
||||
|
||||
typedef std::char_traits<Ch> traits_type;
|
||||
typedef Ch value_type;
|
||||
typedef Ch* pointer;
|
||||
typedef Ch const* const_pointer;
|
||||
typedef Ch& reference;
|
||||
typedef Ch const& const_reference;
|
||||
typedef Ch const* const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// npos
|
||||
|
||||
static constexpr size_type npos = static_cast<size_type>( -1 );
|
||||
|
||||
public:
|
||||
|
||||
// construction and assignment
|
||||
|
||||
constexpr basic_string_view() noexcept;
|
||||
constexpr basic_string_view( basic_string_view const& ) noexcept = default;
|
||||
constexpr basic_string_view& operator=( basic_string_view const& ) noexcept & = default;
|
||||
constexpr basic_string_view( Ch const* str ) noexcept;
|
||||
constexpr basic_string_view( Ch const* str, size_type len ) noexcept;
|
||||
constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;
|
||||
template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;
|
||||
basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;
|
||||
|
||||
// conversions
|
||||
|
||||
template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;
|
||||
template<class Ch2> operator std::basic_string_view<Ch2>() const noexcept;
|
||||
|
||||
// iterator support
|
||||
|
||||
constexpr const_iterator begin() const noexcept;
|
||||
constexpr const_iterator end() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
constexpr const_reverse_iterator rbegin() const noexcept;
|
||||
constexpr const_reverse_iterator rend() const noexcept;
|
||||
constexpr const_reverse_iterator crbegin() const noexcept;
|
||||
constexpr const_reverse_iterator crend() const noexcept;
|
||||
|
||||
// capacity
|
||||
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type length() const noexcept;
|
||||
constexpr size_type max_size() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// element access
|
||||
|
||||
constexpr const_reference operator[]( size_type pos ) const noexcept;
|
||||
constexpr const_reference at( size_type pos ) const;
|
||||
constexpr const_reference front() const noexcept;
|
||||
constexpr const_reference back() const noexcept;
|
||||
constexpr const_pointer data() const noexcept;
|
||||
|
||||
// modifiers
|
||||
|
||||
constexpr void remove_prefix( size_type n ) noexcept;
|
||||
constexpr void remove_suffix( size_type n ) noexcept;
|
||||
constexpr void swap( basic_string_view& s ) noexcept;
|
||||
|
||||
// string operations
|
||||
|
||||
constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const;
|
||||
constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const;
|
||||
|
||||
// compare
|
||||
|
||||
constexpr int compare( basic_string_view str ) const noexcept;
|
||||
constexpr int compare( size_type pos1, size_type n1, basic_string_view str ) const;
|
||||
constexpr int compare( size_type pos1, size_type n1, basic_string_view str, size_type pos2, size_type n2 ) const;
|
||||
constexpr int compare( Ch const* s ) const;
|
||||
constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const;
|
||||
constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const;
|
||||
|
||||
// starts_with
|
||||
|
||||
constexpr bool starts_with( basic_string_view x ) const noexcept;
|
||||
constexpr bool starts_with( Ch x ) const noexcept;
|
||||
constexpr bool starts_with( Ch const* x ) const noexcept;
|
||||
|
||||
// ends_with
|
||||
|
||||
constexpr bool ends_with( basic_string_view x ) const noexcept;
|
||||
constexpr bool ends_with( Ch x ) const noexcept;
|
||||
constexpr bool ends_with( Ch const* x ) const noexcept;
|
||||
|
||||
// find
|
||||
|
||||
constexpr size_type find( basic_string_view str, size_type pos = 0 ) const noexcept;
|
||||
constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept;
|
||||
constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept;
|
||||
constexpr size_type find( Ch const* s, size_type pos = 0 ) const noexcept;
|
||||
|
||||
// rfind
|
||||
|
||||
constexpr size_type rfind( basic_string_view str, size_type pos = npos ) const noexcept;
|
||||
constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept;
|
||||
constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept;
|
||||
constexpr size_type rfind( Ch const* s, size_type pos = npos ) const noexcept;
|
||||
|
||||
// find_first_of
|
||||
|
||||
constexpr size_type find_first_of( basic_string_view str, size_type pos = 0 ) const noexcept;
|
||||
constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept;
|
||||
constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept;
|
||||
constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const noexcept;
|
||||
|
||||
// find_last_of
|
||||
|
||||
constexpr size_type find_last_of( basic_string_view str, size_type pos = npos ) const noexcept;
|
||||
constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept;
|
||||
constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept;
|
||||
constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const noexcept;
|
||||
|
||||
// find_first_not_of
|
||||
|
||||
constexpr size_type find_first_not_of( basic_string_view str, size_type pos = 0 ) const noexcept;
|
||||
constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept;
|
||||
constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;
|
||||
constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const noexcept;
|
||||
|
||||
// find_last_not_of
|
||||
|
||||
constexpr size_type find_last_not_of( basic_string_view str, size_type pos = npos ) const noexcept;
|
||||
constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept;
|
||||
constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;
|
||||
constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const noexcept;
|
||||
|
||||
// contains
|
||||
|
||||
constexpr bool contains( basic_string_view sv ) const noexcept;
|
||||
constexpr bool contains( Ch c ) const noexcept;
|
||||
constexpr bool contains( Ch const* s ) const noexcept;
|
||||
|
||||
// relational operators
|
||||
|
||||
constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept;
|
||||
constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
|
||||
constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept;
|
||||
constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
|
||||
constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept;
|
||||
constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
|
||||
};
|
||||
|
||||
// stream inserter
|
||||
|
||||
template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str );
|
||||
|
||||
// typedef names
|
||||
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<char8_t> u8string_view;
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Construction]
|
||||
|
||||
[section `constexpr basic_string_view() noexcept;`]
|
||||
|
||||
* *Ensures:* `data() == 0`; `size() == 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr basic_string_view( Ch const* str ) noexcept;`]
|
||||
|
||||
* *Ensures:* `data() == str`; `size() == traits_type::length( str )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr basic_string_view( Ch const* str, size_type len ) noexcept;`]
|
||||
|
||||
* *Ensures:* `data() == str`; `size() == len`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;`]
|
||||
|
||||
* *Requires:* `end >= begin`.
|
||||
* *Ensures:* `data() == begin`; `size() == end - begin`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;`]
|
||||
|
||||
* *Ensures:* `data() == str.data()`; `size() == str.size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;`]
|
||||
|
||||
* *Ensures:* `data() == str.data()`; `size() == str.size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Conversions]
|
||||
|
||||
[section `template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;`]
|
||||
|
||||
* *Returns:* `std::basic_string<Ch, std::char_traits<Ch>, A>( data(), size() )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `template<class Ch2> operator std::basic_string_view<Ch2>() const noexcept;`]
|
||||
|
||||
* *Constraints:* `Ch2` is the same type as `Ch`.
|
||||
* *Returns:* `std::basic_string_view<Ch2>( data(), size() )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Iterator Support]
|
||||
|
||||
[section `constexpr const_iterator begin() const noexcept;`]
|
||||
|
||||
* *Returns:* `data()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_iterator end() const noexcept;`]
|
||||
|
||||
* *Returns:* `data() + size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_iterator cbegin() const noexcept;`]
|
||||
|
||||
* *Returns:* `begin()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_iterator cend() const noexcept;`]
|
||||
|
||||
* *Returns:* `end()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reverse_iterator rbegin() const noexcept;`]
|
||||
|
||||
* *Returns:* `const_reverse_iterator( end() )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reverse_iterator rend() const noexcept;`]
|
||||
|
||||
* *Returns:* `const_reverse_iterator( begin() )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reverse_iterator crbegin() const noexcept;`]
|
||||
|
||||
* *Returns:* `rbegin()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reverse_iterator crend() const noexcept;`]
|
||||
|
||||
* *Returns:* `rend()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Capacity]
|
||||
|
||||
[section `constexpr size_type size() const noexcept;`]
|
||||
|
||||
* *Returns:* the length of the referenced character sequence.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type length() const noexcept;`]
|
||||
|
||||
* *Returns:* `size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type max_size() const noexcept;`]
|
||||
|
||||
* *Returns:* `std::numeric_limits<size_type>::max() / sizeof(Ch)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool empty() const noexcept;`]
|
||||
|
||||
* *Returns:* `size() == 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Element Access]
|
||||
|
||||
[section `constexpr const_reference operator[]( size_type pos ) const noexcept;`]
|
||||
|
||||
* *Requires:* `pos < size()`.
|
||||
* *Returns:* `data()[ pos ]`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reference at( size_type pos ) const;`]
|
||||
|
||||
* *Returns:* `data()[ pos ]`.
|
||||
* *Throws:* `std::out_of_range` when `pos >= size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reference front() const noexcept;`]
|
||||
|
||||
* *Requires:* `!empty()`.
|
||||
* *Returns:* `data()[ 0 ]`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_reference back() const noexcept;`]
|
||||
|
||||
* *Requires:* `!empty()`.
|
||||
* *Returns:* `data()[ size() - 1 ]`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr const_pointer data() const noexcept;`]
|
||||
|
||||
* *Returns:* a pointer to the beginning of the referenced character sequence.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Modifiers]
|
||||
|
||||
[section `constexpr void remove_prefix( size_type n ) noexcept;`]
|
||||
|
||||
* *Requires:* `n <= size()`.
|
||||
* *Effects:* advances `data()` by `n` and decreases `size()` by `n`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr void remove_suffix( size_type n ) noexcept;`]
|
||||
|
||||
* *Requires:* `n <= size()`.
|
||||
* *Effects:* decreases `size()` by `n`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr void swap( basic_string_view& s ) noexcept;`]
|
||||
|
||||
* *Effects:* exchanges the contents of `*this` and `s`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section String Operations]
|
||||
|
||||
[section copy]
|
||||
|
||||
[section `constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const;`]
|
||||
|
||||
* *Effects:* copies to `s` the contents of `substr( pos, n )`.
|
||||
* *Throws:* `std::out_of_range` when `pos >= size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section substr]
|
||||
|
||||
[section `constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const;`]
|
||||
|
||||
* *Returns:* `basic_string_view( data() + pos, std::min( size() - pos, n ) )`.
|
||||
* *Throws:* `std::out_of_range` when `pos >= size()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section compare]
|
||||
|
||||
[section `constexpr int compare( basic_string_view str ) const noexcept;`]
|
||||
|
||||
* *Returns:*
|
||||
* if `traits_type::compare( data(), str.data(), std::min( size(), str.size() ) )` is not zero, returns it. Otherwise,
|
||||
* if `size() < str.size()`, returns a negative number. Otherwise,
|
||||
* if `size() > str.size()`, returns a positive number. Otherwise,
|
||||
* returns 0.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr int compare( size_type pos1, size_type n1, basic_string_view str ) const;`]
|
||||
|
||||
* *Returns:* `substr( pos1, n1 ).compare( str )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr int compare( size_type pos1, size_type n1, basic_string_view str, size_type pos2, size_type n2 ) const;`]
|
||||
|
||||
* *Returns:* `substr( pos1, n1 ).compare( str.substr( pos2, n2 ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr int compare( Ch const* s ) const noexcept;`]
|
||||
|
||||
* *Returns:* `compare( basic_string_view( s ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const;`]
|
||||
|
||||
* *Returns:* `substr( pos1, n1 ).compare( basic_string_view( s ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const;`]
|
||||
|
||||
* *Returns:* `substr( pos1, n1 ).compare( basic_string_view( s, n2 ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section starts_with]
|
||||
|
||||
[section `constexpr bool starts_with( basic_string_view x ) const noexcept;`]
|
||||
|
||||
* *Returns:* `substr( 0, x.size() ) == x`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool starts_with( Ch x ) const noexcept;`]
|
||||
|
||||
* *Returns:* `starts_with( basic_string_view( &x, 1 ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool starts_with( Ch const* x ) const noexcept;`]
|
||||
|
||||
* *Returns:* `starts_with( basic_string_view( x ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section ends_with]
|
||||
|
||||
[section `constexpr bool ends_with( basic_string_view x ) const noexcept;`]
|
||||
|
||||
* *Returns:* `size() >= x.size() && substr( size() - x.size(), x.size() ) == x`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool ends_with( Ch x ) const noexcept;`]
|
||||
|
||||
* *Returns:* `ends_with( basic_string_view( &x, 1 ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool ends_with( Ch const* x ) const noexcept;`]
|
||||
|
||||
* *Returns:* `ends_with( basic_string_view( x ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Searching]
|
||||
|
||||
[section find]
|
||||
|
||||
[section `constexpr size_type find( basic_string_view str, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* The lowest position `i` such that `i >= pos` and `substr( i, str.size() ) == str`, or `npos` if such a position doesn't exist.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find( basic_string_view( &c, 1 ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find( basic_string_view( s, n ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find( Ch const* s, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find( basic_string_view( s ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section rfind]
|
||||
|
||||
[section `constexpr size_type rfind( basic_string_view str, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* The highest position `i` such that `i <= pos` and `substr( i, str.size() ) == str`, or `npos` if such a position doesn't exist.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* `rfind( basic_string_view( &c, 1 ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept;`]
|
||||
|
||||
* *Returns:* `rfind( basic_string_view( s, n ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type rfind( Ch const* s, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* `rfind( basic_string_view( s ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section find_first_of]
|
||||
|
||||
[section `constexpr size_type find_first_of( basic_string_view str, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* The lowest position `i` such that `i >= pos` and the character at position `i` is equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_first_of( basic_string_view( &c, 1 ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_first_of( basic_string_view( s, n ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_first_of( basic_string_view( s ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section find_last_of]
|
||||
|
||||
[section `constexpr size_type find_last_of( basic_string_view str, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* The highest position `i` such that `i <= pos` and the character at position `i` is equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_last_of( basic_string_view( &c, 1 ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_last_of( basic_string_view( s, n ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_last_of( basic_string_view( s ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section find_first_not_of]
|
||||
|
||||
[section `constexpr size_type find_first_not_of( basic_string_view str, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* The lowest position `i` such that `i >= pos` and the character at position `i` is not equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_first_not_of( basic_string_view( &c, 1 ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_first_not_of( basic_string_view( s, n ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_first_not_of( basic_string_view( s ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section find_last_not_of]
|
||||
|
||||
[section `constexpr size_type find_last_not_of( basic_string_view str, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* The highest position `i` such that `i <= pos` and the character at position `i` is not equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_last_not_of( basic_string_view( &c, 1 ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_last_not_of( basic_string_view( s, n ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find_last_not_of( basic_string_view( s ), pos )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section contains]
|
||||
|
||||
[section `constexpr bool contains( basic_string_view sv ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find( sv ) != npos`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool contains( Ch c ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find( c ) != npos`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr bool contains( Ch const* s ) const noexcept;`]
|
||||
|
||||
* *Returns:* `find( s ) != npos`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Relational Operators]
|
||||
|
||||
[section `constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
|
||||
|
||||
* *Returns:* `sv1.compare( sv2 ) == 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
|
||||
|
||||
* *Returns:* `sv1.compare( sv2 ) != 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
|
||||
|
||||
* *Returns:* `sv1.compare( sv2 ) < 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
|
||||
|
||||
* *Returns:* `sv1.compare( sv2 ) <= 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
|
||||
|
||||
* *Returns:* `sv1.compare( sv2 ) > 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
|
||||
|
||||
* *Returns:* `sv1.compare( sv2 ) >= 0`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Stream Inserter]
|
||||
|
||||
[section `template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str );`]
|
||||
|
||||
* *Effects:* equivalent to `os << x`, where `x` is a pointer to a null-terminated character sequence with the same contents as `str`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
70
doc/verbose_terminate_handler.qbk
Normal file
70
doc/verbose_terminate_handler.qbk
Normal file
@@ -0,0 +1,70 @@
|
||||
[/
|
||||
Copyright 2022 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:verbose_terminate_handler verbose_terminate_handler]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/verbose_terminate_handler.hpp>]
|
||||
|
||||
The header `<boost/core/verbose_terminate_handler.hpp>` defines
|
||||
the function `void boost::core::verbose_terminate_handler()`. Its
|
||||
purpose is to be set as a terminate handler as in
|
||||
```
|
||||
std::set_terminate( boost::core::verbose_terminate_handler );
|
||||
```
|
||||
|
||||
When invoked, the function prints information about the current
|
||||
uncaught exception to `stderr` and then calls `std::abort`.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
[[noreturn]] void verbose_terminate_handler();
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
```
|
||||
#include <boost/core/verbose_terminate_handler.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <exception>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::set_terminate( boost::core::verbose_terminate_handler );
|
||||
boost::throw_with_location( std::exception() );
|
||||
}
|
||||
```
|
||||
|
||||
Sample output:
|
||||
```
|
||||
std::terminate called after throwing an exception:
|
||||
|
||||
type: class boost::detail::with_throw_location<class std::exception>
|
||||
what(): Unknown exception
|
||||
location: example.cpp:8:12 in function 'main'
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -8,6 +8,9 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP
|
||||
#define BOOST_CORE_ALLOC_CONSTRUCT_HPP
|
||||
|
||||
/*
|
||||
This functionality is now in <boost/core/allocator_access.hpp>.
|
||||
*/
|
||||
#include <boost/core/noinit_adaptor.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -23,56 +26,9 @@ template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
boost::allocator_destroy(a, p + --n);
|
||||
}
|
||||
boost::allocator_destroy_n(a, p, n);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(noinit_adaptor<A>&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
p[--n].~T();
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class T>
|
||||
class alloc_destroyer {
|
||||
public:
|
||||
alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT
|
||||
: a_(a),
|
||||
p_(p),
|
||||
n_(0) { }
|
||||
|
||||
~alloc_destroyer() {
|
||||
boost::alloc_destroy_n(a_, p_, n_);
|
||||
}
|
||||
|
||||
std::size_t& size() BOOST_NOEXCEPT {
|
||||
return n_;
|
||||
}
|
||||
|
||||
private:
|
||||
alloc_destroyer(const alloc_destroyer&);
|
||||
alloc_destroyer& operator=(const alloc_destroyer&);
|
||||
|
||||
A& a_;
|
||||
T* p_;
|
||||
std::size_t n_;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p)
|
||||
@@ -117,51 +73,21 @@ 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) {
|
||||
boost::allocator_construct(a, p + i);
|
||||
}
|
||||
hold.size() = 0;
|
||||
boost::allocator_construct_n(a, p, n);
|
||||
}
|
||||
|
||||
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) {
|
||||
boost::allocator_construct(a, p + i, l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
boost::allocator_construct_n(a, p, n, l, m);
|
||||
}
|
||||
|
||||
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)) {
|
||||
boost::allocator_construct(a, p + i, *b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(noinit_adaptor<A>&, T* p)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<noinit_adaptor<A>, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T;
|
||||
}
|
||||
hold.size() = 0;
|
||||
boost::allocator_construct_n(a, p, n, b);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2020-2021 Glen Joseph Fernandes
|
||||
Copyright 2020-2022 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -9,16 +9,34 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#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 <new>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <type_traits>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40300)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
|
||||
#elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
|
||||
#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
|
||||
#elif defined(BOOST_CLANG) && !defined(__CUDACC__)
|
||||
#if __has_feature(is_empty)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
|
||||
#endif
|
||||
#elif defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __oracle_is_empty(T)
|
||||
#elif defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
|
||||
#elif defined(BOOST_CODEGEARC)
|
||||
#define BOOST_DETAIL_ALLOC_EMPTY(T) __is_empty(T)
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
#endif
|
||||
@@ -37,244 +55,311 @@ 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 A, class = void>
|
||||
struct alloc_ptr {
|
||||
typedef typename boost::allocator_value_type<A>::type* type;
|
||||
};
|
||||
|
||||
template<class>
|
||||
struct alloc_void {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_pointer<A,
|
||||
typename detail::alloc_void<typename A::pointer>::type> {
|
||||
struct alloc_ptr<A,
|
||||
typename 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;
|
||||
};
|
||||
} /* detail */
|
||||
|
||||
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;
|
||||
struct allocator_pointer {
|
||||
typedef typename detail::alloc_ptr<A>::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;
|
||||
template<class A, class = void>
|
||||
struct alloc_const_ptr {
|
||||
typedef typename boost::pointer_traits<typename
|
||||
boost::allocator_pointer<A>::type>::template rebind_to<const typename
|
||||
boost::allocator_value_type<A>::type>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_const_ptr<A,
|
||||
typename alloc_void<typename A::const_pointer>::type> {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
|
||||
} /* 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;
|
||||
struct allocator_const_pointer {
|
||||
typedef typename detail::alloc_const_ptr<A>::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 { };
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class> class A, class T, class U>
|
||||
struct alloc_to<A<U>, T> {
|
||||
typedef A<T> type;
|
||||
};
|
||||
|
||||
template<template<class, class> class A, class T, class U, class V>
|
||||
struct alloc_to<A<U, V>, T> {
|
||||
typedef A<T, V> type;
|
||||
};
|
||||
|
||||
template<template<class, class, class> class A, class T, class U, class V1,
|
||||
class V2>
|
||||
struct alloc_to<A<U, V1, V2>, T> {
|
||||
typedef A<T, V1, V2> type;
|
||||
};
|
||||
#else
|
||||
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 */
|
||||
#endif
|
||||
|
||||
template<class A, class T, class = void>
|
||||
struct allocator_rebind {
|
||||
typedef typename detail::alloc_to<A, T>::type type;
|
||||
struct alloc_rebind {
|
||||
typedef typename 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> {
|
||||
struct alloc_rebind<A, T,
|
||||
typename alloc_void<typename A::template rebind<T>::other>::type> {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
struct allocator_rebind {
|
||||
typedef typename detail::alloc_rebind<A, T>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class = void>
|
||||
struct alloc_void_ptr {
|
||||
typedef typename boost::pointer_traits<typename
|
||||
boost::allocator_pointer<A>::type>::template
|
||||
rebind_to<void>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_void_ptr<A,
|
||||
typename alloc_void<typename A::void_pointer>::type> {
|
||||
typedef typename A::void_pointer type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename detail::alloc_void_ptr<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class = void>
|
||||
struct alloc_const_void_ptr {
|
||||
typedef typename boost::pointer_traits<typename
|
||||
boost::allocator_pointer<A>::type>::template
|
||||
rebind_to<const void>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_const_void_ptr<A,
|
||||
typename alloc_void<typename A::const_void_pointer>::type> {
|
||||
typedef typename A::const_void_pointer type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename detail::alloc_const_void_ptr<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class = void>
|
||||
struct alloc_diff_type {
|
||||
typedef typename boost::pointer_traits<typename
|
||||
boost::allocator_pointer<A>::type>::difference_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_diff_type<A,
|
||||
typename alloc_void<typename A::difference_type>::type> {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_difference_type {
|
||||
typedef typename detail::alloc_diff_type<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class = void>
|
||||
struct alloc_size_type {
|
||||
typedef std::size_t type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct alloc_size_type {
|
||||
typedef typename std::make_unsigned<typename
|
||||
boost::allocator_difference_type<A>::type>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class A>
|
||||
struct alloc_size_type<A,
|
||||
typename alloc_void<typename A::size_type>::type> {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename detail::alloc_size_type<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<bool V>
|
||||
struct alloc_bool {
|
||||
typedef bool value_type;
|
||||
typedef alloc_bool type;
|
||||
|
||||
static const bool value = V;
|
||||
|
||||
operator bool() const BOOST_NOEXCEPT {
|
||||
return V;
|
||||
}
|
||||
|
||||
bool operator()() const BOOST_NOEXCEPT {
|
||||
return V;
|
||||
}
|
||||
};
|
||||
|
||||
template<bool V>
|
||||
const bool alloc_bool<V>::value;
|
||||
|
||||
typedef alloc_bool<false> alloc_false;
|
||||
#else
|
||||
typedef std::false_type alloc_false;
|
||||
#endif
|
||||
|
||||
template<class A, class = void>
|
||||
struct alloc_pocca {
|
||||
typedef alloc_false type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_pocca<A,
|
||||
typename alloc_void<typename
|
||||
A::propagate_on_container_copy_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_copy_assignment type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef typename detail::alloc_pocca<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class = void>
|
||||
struct alloc_pocma {
|
||||
typedef alloc_false type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_pocma<A,
|
||||
typename alloc_void<typename
|
||||
A::propagate_on_container_move_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_move_assignment type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef typename detail::alloc_pocma<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class = void>
|
||||
struct alloc_pocs {
|
||||
typedef alloc_false type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_pocs<A,
|
||||
typename alloc_void<typename A::propagate_on_container_swap>::type> {
|
||||
typedef typename A::propagate_on_container_swap type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef typename detail::alloc_pocs<A>::type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class = void>
|
||||
struct alloc_equal {
|
||||
typedef typename std::is_empty<A>::type type;
|
||||
};
|
||||
#elif defined(BOOST_DETAIL_ALLOC_EMPTY)
|
||||
template<class A, class = void>
|
||||
struct alloc_equal {
|
||||
typedef alloc_bool<BOOST_DETAIL_ALLOC_EMPTY(A)> type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct alloc_equal {
|
||||
typedef alloc_false type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class A>
|
||||
struct alloc_equal<A,
|
||||
typename alloc_void<typename A::is_always_equal>::type> {
|
||||
typedef typename A::is_always_equal type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename detail::alloc_equal<A>::type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n)
|
||||
@@ -301,21 +386,24 @@ allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
struct alloc_none { };
|
||||
template<class>
|
||||
struct alloc_no {
|
||||
char x, y;
|
||||
};
|
||||
|
||||
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>()));
|
||||
static auto check(int)
|
||||
-> alloc_no<decltype(std::declval<O&>().allocate(std::declval<typename
|
||||
boost::allocator_size_type<A>::type>(), std::declval<typename
|
||||
boost::allocator_const_void_pointer<A>::type>()))>;
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
@@ -339,9 +427,55 @@ allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class = void>
|
||||
struct alloc_has_construct {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
struct alloc_has_construct<A,
|
||||
typename alloc_void<typename A::_default_construct_destroy>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#else
|
||||
template<class A, class T, class... Args>
|
||||
class alloc_has_construct {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> alloc_no<decltype(std::declval<O&>().construct(std::declval<T*>(),
|
||||
std::declval<Args&&>()...))>;
|
||||
|
||||
template<class>
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<bool, class = void>
|
||||
struct alloc_if { };
|
||||
|
||||
template<class T>
|
||||
struct alloc_if<true, T> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
inline typename detail::alloc_if<detail::alloc_has_construct<A>::value>::type
|
||||
allocator_construct(A& a, T* p)
|
||||
{
|
||||
a.construct(p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline typename detail::alloc_if<!detail::alloc_has_construct<A>::value>::type
|
||||
allocator_construct(A&, T* p)
|
||||
{
|
||||
::new((void*)p) T();
|
||||
@@ -379,25 +513,6 @@ allocator_construct(A&, T* p, V& 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
|
||||
@@ -415,132 +530,236 @@ allocator_construct(A&, T* p, 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 {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class, class = void>
|
||||
struct alloc_has_destroy {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A, class T>
|
||||
struct alloc_has_destroy<A, T,
|
||||
typename alloc_void<typename A::_default_construct_destroy>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#else
|
||||
template<class A, class T>
|
||||
class alloc_has_destroy {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> decltype(std::declval<O&>().destroy(std::declval<T*>()));
|
||||
-> alloc_no<decltype(std::declval<O&>().destroy(std::declval<T*>()))>;
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type
|
||||
inline typename detail::alloc_if<detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A& a, T* p)
|
||||
{
|
||||
a.destroy(p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||
inline typename detail::alloc_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
#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 T, T>
|
||||
struct alloc_no {
|
||||
char x, y;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
class alloc_has_max_size {
|
||||
template<class O>
|
||||
static auto check(int) -> decltype(std::declval<O&>().max_size());
|
||||
static alloc_no<typename boost::allocator_size_type<O>::type(O::*)(),
|
||||
&O::max_size> check(int);
|
||||
|
||||
template<class O>
|
||||
static alloc_no<typename boost::allocator_size_type<O>::type(O::*)() const,
|
||||
&O::max_size> check(int);
|
||||
|
||||
template<class O>
|
||||
static alloc_no<typename boost::allocator_size_type<O>::type(*)(),
|
||||
&O::max_size> check(int);
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
#else
|
||||
template<class A>
|
||||
class alloc_has_max_size {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> alloc_no<decltype(std::declval<const O&>().max_size())>;
|
||||
|
||||
template<class>
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_max_size<A>::value,
|
||||
inline typename detail::alloc_if<detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A& a)
|
||||
allocator_max_size(const A& a) BOOST_NOEXCEPT
|
||||
{
|
||||
return a.max_size();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_max_size<A>::value,
|
||||
inline typename detail::alloc_if<!detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A&)
|
||||
allocator_max_size(const A&) BOOST_NOEXCEPT
|
||||
{
|
||||
return (std::numeric_limits<typename
|
||||
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
|
||||
allocator_size_type<A>::type>::max)() /
|
||||
sizeof(typename allocator_value_type<A>::type);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
#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 {
|
||||
class alloc_has_soccc {
|
||||
template<class O>
|
||||
static alloc_no<O(O::*)(), &O::select_on_container_copy_construction>
|
||||
check(int);
|
||||
|
||||
template<class O>
|
||||
static alloc_no<O(O::*)() const, &O::select_on_container_copy_construction>
|
||||
check(int);
|
||||
|
||||
template<class O>
|
||||
static alloc_no<O(*)(), &O::select_on_container_copy_construction>
|
||||
check(int);
|
||||
|
||||
template<class>
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
#else
|
||||
template<class A>
|
||||
class alloc_has_soccc {
|
||||
template<class O>
|
||||
static auto check(int)
|
||||
-> decltype(std::declval<O&>().select_on_container_copy_construction());
|
||||
static auto check(int) -> alloc_no<decltype(std::declval<const
|
||||
O&>().select_on_container_copy_construction())>;
|
||||
|
||||
template<class>
|
||||
static alloc_none check(long);
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value =
|
||||
!std::is_same<decltype(check<A>(0)), alloc_none>::value;
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1;
|
||||
};
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_soccc<A>::value, A>::type
|
||||
inline typename detail::alloc_if<detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a.select_on_container_copy_construction();
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||
inline typename detail::alloc_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_destroy_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
boost::allocator_destroy(a, p + --n);
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class A, class T>
|
||||
class alloc_destroyer {
|
||||
public:
|
||||
alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT
|
||||
: a_(a), p_(p), n_(0) { }
|
||||
|
||||
~alloc_destroyer() {
|
||||
boost::allocator_destroy_n(a_, p_, n_);
|
||||
}
|
||||
|
||||
std::size_t& size() BOOST_NOEXCEPT {
|
||||
return n_;
|
||||
}
|
||||
|
||||
private:
|
||||
alloc_destroyer(const alloc_destroyer&);
|
||||
alloc_destroyer& operator=(const alloc_destroyer&);
|
||||
|
||||
A& a_;
|
||||
T* p_;
|
||||
std::size_t n_;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> d(a, p);
|
||||
for (std::size_t& i = d.size(); i < n; ++i) {
|
||||
boost::allocator_construct(a, p + i);
|
||||
}
|
||||
d.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> d(a, p);
|
||||
for (std::size_t& i = d.size(); i < n; ++i) {
|
||||
boost::allocator_construct(a, p + i, l[i % m]);
|
||||
}
|
||||
d.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T, class I>
|
||||
inline void
|
||||
allocator_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> d(a, p);
|
||||
for (std::size_t& i = d.size(); i < n; void(++i), void(++b)) {
|
||||
boost::allocator_construct(a, p + i, *b);
|
||||
}
|
||||
d.size() = 0;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class A>
|
||||
|
||||
112
include/boost/core/allocator_traits.hpp
Normal file
112
include/boost/core/allocator_traits.hpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
Copyright 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_TRAITS_HPP
|
||||
#define BOOST_CORE_ALLOCATOR_TRAITS_HPP
|
||||
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class A>
|
||||
struct allocator_traits {
|
||||
typedef A allocator_type;
|
||||
|
||||
typedef typename allocator_value_type<A>::type value_type;
|
||||
|
||||
typedef typename allocator_pointer<A>::type pointer;
|
||||
|
||||
typedef typename allocator_const_pointer<A>::type const_pointer;
|
||||
|
||||
typedef typename allocator_void_pointer<A>::type void_pointer;
|
||||
|
||||
typedef typename allocator_const_void_pointer<A>::type const_void_pointer;
|
||||
|
||||
typedef typename allocator_difference_type<A>::type difference_type;
|
||||
|
||||
typedef typename allocator_size_type<A>::type size_type;
|
||||
|
||||
typedef typename allocator_propagate_on_container_copy_assignment<A>::type
|
||||
propagate_on_container_copy_assignment;
|
||||
|
||||
typedef typename allocator_propagate_on_container_move_assignment<A>::type
|
||||
propagate_on_container_move_assignment;
|
||||
|
||||
typedef typename allocator_propagate_on_container_swap<A>::type
|
||||
propagate_on_container_swap;
|
||||
|
||||
typedef typename allocator_is_always_equal<A>::type is_always_equal;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T>
|
||||
using rebind_traits = allocator_traits<typename
|
||||
allocator_rebind<A, T>::type>;
|
||||
#else
|
||||
template<class T>
|
||||
struct rebind_traits
|
||||
: allocator_traits<typename allocator_rebind<A, T>::type> { };
|
||||
#endif
|
||||
|
||||
static pointer allocate(A& a, size_type n) {
|
||||
return boost::allocator_allocate(a, n);
|
||||
}
|
||||
|
||||
static pointer allocate(A& a, size_type n, const_void_pointer h) {
|
||||
return boost::allocator_allocate(a, n, h);
|
||||
}
|
||||
|
||||
static void deallocate(A& a, pointer p, size_type n) {
|
||||
return boost::allocator_deallocate(a, p, n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void construct(A& a, T* p) {
|
||||
boost::allocator_construct(a, p);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class T, class V, class... Args>
|
||||
static void construct(A& a, T* p, V&& v, Args&&... args) {
|
||||
boost::allocator_construct(a, p, std::forward<V>(v),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class T, class V>
|
||||
static void construct(A& a, T* p, V&& v) {
|
||||
boost::allocator_construct(a, p, std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class T, class V>
|
||||
static void construct(A& a, T* p, const V& v) {
|
||||
boost::allocator_construct(a, p, v);
|
||||
}
|
||||
|
||||
template<class T, class V>
|
||||
static void construct(A& a, T* p, V& v) {
|
||||
boost::allocator_construct(a, p, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
static void destroy(A& a, T* p) {
|
||||
boost::allocator_destroy(a, p);
|
||||
}
|
||||
|
||||
static size_type max_size(const A& a) BOOST_NOEXCEPT {
|
||||
return boost::allocator_max_size(a);
|
||||
}
|
||||
|
||||
static A select_on_container_copy_construction(const A& a) {
|
||||
return boost::allocator_select_on_container_copy_construction(a);
|
||||
}
|
||||
};
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -22,13 +22,20 @@
|
||||
#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
|
||||
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
# pragma warning(disable: 4244) // conversion from int to T
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
namespace boost
|
||||
@@ -75,9 +82,9 @@ 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
|
||||
BOOST_CONSTEXPR inline int countl_impl( boost::ulong_long_type x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_clzll( x ): std::numeric_limits<unsigned long long>::digits;
|
||||
return x? __builtin_clzll( x ): std::numeric_limits<boost::ulong_long_type>::digits;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@@ -164,15 +171,15 @@ 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) )
|
||||
BOOST_IF_CONSTEXPR ( 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) )
|
||||
else BOOST_IF_CONSTEXPR ( 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) )
|
||||
else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint32_t) )
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) );
|
||||
}
|
||||
@@ -217,9 +224,9 @@ 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
|
||||
BOOST_CONSTEXPR inline int countr_impl( boost::ulong_long_type x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x? __builtin_ctzll( x ): std::numeric_limits<unsigned long long>::digits;
|
||||
return x? __builtin_ctzll( x ): std::numeric_limits<boost::ulong_long_type>::digits;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@@ -299,15 +306,15 @@ 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) )
|
||||
BOOST_IF_CONSTEXPR ( 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) )
|
||||
else BOOST_IF_CONSTEXPR ( 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) )
|
||||
else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint32_t) )
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) );
|
||||
}
|
||||
@@ -358,7 +365,7 @@ BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long x ) BOOST_
|
||||
return __builtin_popcountl( x );
|
||||
}
|
||||
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( unsigned long long x ) BOOST_NOEXCEPT
|
||||
BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( boost::ulong_long_type x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_popcountll( x );
|
||||
}
|
||||
@@ -403,7 +410,7 @@ 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) )
|
||||
BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) )
|
||||
{
|
||||
return boost::core::detail::popcount_impl( static_cast<boost::uint32_t>( x ) );
|
||||
}
|
||||
@@ -439,10 +446,13 @@ BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
|
||||
return x != 0 && ( x & ( x - 1 ) ) == 0;
|
||||
}
|
||||
|
||||
// bit_width should return int, https://cplusplus.github.io/LWG/issue3656
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return std::numeric_limits<T>::digits - boost::core::countl_zero( x );
|
||||
return static_cast<T>(
|
||||
std::numeric_limits<T>::digits - boost::core::countl_zero( x ) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -502,7 +512,7 @@ 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) )
|
||||
BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) )
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint32_t>( x ) ) );
|
||||
}
|
||||
@@ -578,4 +588,8 @@ typedef endian::type endian_type;
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_BIT_HPP_INCLUDED
|
||||
|
||||
@@ -19,21 +19,25 @@ BOOST_NORETURN void throw_exception(const std::exception&);
|
||||
|
||||
namespace default_ {
|
||||
|
||||
struct true_type {
|
||||
template<bool V>
|
||||
struct bool_constant {
|
||||
typedef bool value_type;
|
||||
typedef true_type type;
|
||||
typedef bool_constant type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
static const bool value = V;
|
||||
|
||||
BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT {
|
||||
return true;
|
||||
operator bool() const BOOST_NOEXCEPT {
|
||||
return V;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR bool operator()() const BOOST_NOEXCEPT {
|
||||
return true;
|
||||
bool operator()() const BOOST_NOEXCEPT {
|
||||
return V;
|
||||
}
|
||||
};
|
||||
|
||||
template<bool V>
|
||||
const bool bool_constant<V>::value;
|
||||
|
||||
template<class T>
|
||||
struct add_reference {
|
||||
typedef T& type;
|
||||
@@ -58,8 +62,8 @@ struct default_allocator {
|
||||
typedef typename add_reference<const T>::type const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
typedef true_type is_always_equal;
|
||||
typedef bool_constant<true> propagate_on_container_move_assignment;
|
||||
typedef bool_constant<true> is_always_equal;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
@@ -108,6 +112,12 @@ struct default_allocator {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
T* allocate(std::size_t n, const void*) {
|
||||
return allocate(n);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \
|
||||
defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
|
||||
@@ -34,14 +34,14 @@ public:
|
||||
|
||||
boost::uint64_t operator()()
|
||||
{
|
||||
x_ += 0x9e3779b97f4a7c15;
|
||||
x_ += ( boost::uint64_t(0x9e3779b9u) << 32 ) + 0x7f4a7c15u;
|
||||
|
||||
boost::uint64_t z = x_;
|
||||
|
||||
z ^= z >> 30;
|
||||
z *= 0xbf58476d1ce4e5b9;
|
||||
z *= ( boost::uint64_t(0xbf58476du) << 32 ) + 0x1ce4e5b9u;
|
||||
z ^= z >> 27;
|
||||
z *= 0x94d049bb133111eb;
|
||||
z *= ( boost::uint64_t(0x94d049bbu) << 32 ) + 0x133111ebu;
|
||||
z ^= z >> 31;
|
||||
|
||||
return z;
|
||||
|
||||
1256
include/boost/core/detail/string_view.hpp
Normal file
1256
include/boost/core/detail/string_view.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,11 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4510)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
@@ -143,4 +148,8 @@ BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
|
||||
|
||||
} /* boost */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//
|
||||
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
// Copyright 2014, 2021 Peter Dimov
|
||||
//
|
||||
// Copyright 2019 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
@@ -21,60 +21,15 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/type_name.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class, int = 0> struct test_print { };
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>)
|
||||
{
|
||||
return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T));
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>();
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " const";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " volatile";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>)
|
||||
{
|
||||
return o << test_print<T, 2>() << " const volatile";
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>)
|
||||
{
|
||||
return o << test_print<T, 1>();
|
||||
}
|
||||
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>)
|
||||
{
|
||||
return o << test_print<T, 1>() << " &";
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>)
|
||||
{
|
||||
return o << test_print<T, 1>() << " &&";
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ),
|
||||
bool expected, char const * file, int line, char const * function )
|
||||
{
|
||||
@@ -86,7 +41,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): predicate '" << trait << "' ["
|
||||
<< boost::core::demangled_name( BOOST_CORE_TYPEID(T) ) << "]"
|
||||
<< boost::core::type_name<T>() << "]"
|
||||
<< " test failed in function '" << function
|
||||
<< "' (should have been " << ( expected? "true": "false" ) << ")"
|
||||
<< std::endl;
|
||||
@@ -112,8 +67,8 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test 'is_same<" << types << ">'"
|
||||
<< " failed in function '" << function
|
||||
<< "' ('" << test_print<T1>()
|
||||
<< "' != '" << test_print<T2>() << "')"
|
||||
<< "' ('" << boost::core::type_name<T1>()
|
||||
<< "' != '" << boost::core::type_name<T2>() << "')"
|
||||
<< std::endl;
|
||||
|
||||
++test_results().errors();
|
||||
@@ -121,7 +76,6 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace boost {
|
||||
template<class A>
|
||||
struct noinit_adaptor
|
||||
: A {
|
||||
typedef void _default_construct_destroy;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
|
||||
@@ -56,6 +58,7 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
(void)p;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace noncopyable_ // protection from unintended ADL
|
||||
// whether a type derives from noncopyable without needing the definition
|
||||
// of noncopyable itself.
|
||||
//
|
||||
// The definition of base_token is macro-guarded so that Type Trais can
|
||||
// The definition of base_token is macro-guarded so that Type Traits can
|
||||
// define it locally without including this header, to avoid a dependency
|
||||
// on Core.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017-2018 Glen Joseph Fernandes
|
||||
Copyright 2017-2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -9,43 +9,23 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#define BOOST_CORE_POINTER_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
#include <memory>
|
||||
#else
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
template<class T>
|
||||
struct pointer_traits
|
||||
: std::pointer_traits<T> {
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef typename std::pointer_traits<T>::template rebind<U> type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits<T*>
|
||||
: std::pointer_traits<T*> {
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef U* type;
|
||||
};
|
||||
};
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
struct ptr_none { };
|
||||
|
||||
template<class>
|
||||
struct ptr_void {
|
||||
struct ptr_valid {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_first;
|
||||
template<class>
|
||||
struct ptr_first {
|
||||
typedef ptr_none type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class T, class U, class... Args>
|
||||
@@ -75,7 +55,7 @@ struct ptr_element {
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_element<T, typename ptr_void<typename T::element_type>::type> {
|
||||
struct ptr_element<T, typename ptr_valid<typename T::element_type>::type> {
|
||||
typedef typename T::element_type type;
|
||||
};
|
||||
|
||||
@@ -86,12 +66,12 @@ struct ptr_difference {
|
||||
|
||||
template<class T>
|
||||
struct ptr_difference<T,
|
||||
typename ptr_void<typename T::difference_type>::type> {
|
||||
typename ptr_valid<typename T::difference_type>::type> {
|
||||
typedef typename T::difference_type type;
|
||||
};
|
||||
|
||||
template<class T, class V>
|
||||
struct ptr_transform;
|
||||
template<class, class>
|
||||
struct ptr_transform { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class T, class U, class... Args, class V>
|
||||
@@ -117,68 +97,131 @@ struct ptr_transform<T<U1, U2, U3>, V> {
|
||||
#endif
|
||||
|
||||
template<class T, class U, class = void>
|
||||
struct ptr_rebind {
|
||||
typedef typename ptr_transform<T, U>::type type;
|
||||
};
|
||||
struct ptr_rebind
|
||||
: ptr_transform<T, U> { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T, class U>
|
||||
struct ptr_rebind<T, U,
|
||||
typename ptr_void<typename T::template rebind<U> >::type> {
|
||||
typename ptr_valid<typename T::template rebind<U> >::type> {
|
||||
typedef typename T::template rebind<U> type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
template<class T, class E>
|
||||
class ptr_to_expr {
|
||||
template<class>
|
||||
struct result {
|
||||
char x, y;
|
||||
};
|
||||
|
||||
static E& source();
|
||||
|
||||
template<class O>
|
||||
static auto check(int) -> result<decltype(O::pointer_to(source()))>;
|
||||
|
||||
template<class>
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTEXPR bool value = sizeof(check<T>(0)) > 1;
|
||||
};
|
||||
|
||||
template<class T, class E>
|
||||
struct ptr_to_expr<T*, E> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
template<class T, class E>
|
||||
struct ptr_has_to {
|
||||
BOOST_STATIC_CONSTEXPR bool value = ptr_to_expr<T, E>::value;
|
||||
};
|
||||
#else
|
||||
template<class, class>
|
||||
struct ptr_has_to {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct ptr_value {
|
||||
typedef T type;
|
||||
struct ptr_has_to<T, void> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ptr_value<void> {
|
||||
typedef struct { } type;
|
||||
template<class T>
|
||||
struct ptr_has_to<T, const void> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_has_to<T, volatile void> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_has_to<T, const volatile void> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class T, class E, bool = ptr_has_to<T, E>::value>
|
||||
struct ptr_to { };
|
||||
|
||||
template<class T, class E>
|
||||
struct ptr_to<T, E, true> {
|
||||
static T pointer_to(E& v) {
|
||||
return T::pointer_to(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_to<T*, T, true> {
|
||||
static T* pointer_to(T& v) BOOST_NOEXCEPT {
|
||||
return boost::addressof(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class E>
|
||||
struct ptr_traits
|
||||
: ptr_to<T, E> {
|
||||
typedef T pointer;
|
||||
typedef E element_type;
|
||||
typedef typename ptr_difference<T>::type difference_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind_to
|
||||
: ptr_rebind<T, U> { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class U>
|
||||
using rebind = typename rebind_to<U>::type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits<T, ptr_none> { };
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits {
|
||||
typedef T pointer;
|
||||
typedef typename detail::ptr_element<T>::type element_type;
|
||||
typedef typename detail::ptr_difference<T>::type difference_type;
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef typename detail::ptr_rebind<T, U>::type type;
|
||||
};
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class U>
|
||||
using rebind = typename detail::ptr_rebind<T, U>::type;
|
||||
#endif
|
||||
static pointer
|
||||
pointer_to(typename detail::ptr_value<element_type>::type& v) {
|
||||
return pointer::pointer_to(v);
|
||||
}
|
||||
};
|
||||
struct pointer_traits
|
||||
: detail::ptr_traits<T, typename detail::ptr_element<T>::type> { };
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits<T*> {
|
||||
struct pointer_traits<T*>
|
||||
: detail::ptr_to<T*, T> {
|
||||
typedef T* pointer;
|
||||
typedef T element_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef U* type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class U>
|
||||
using rebind = U*;
|
||||
using rebind = typename rebind_to<U>::type;
|
||||
#endif
|
||||
static T*
|
||||
pointer_to(typename detail::ptr_value<T>::type& v) BOOST_NOEXCEPT {
|
||||
return boost::addressof(v);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR inline T*
|
||||
|
||||
@@ -33,7 +33,7 @@ extern "C" _Noreturn void quick_exit(int);
|
||||
namespace boost
|
||||
{
|
||||
|
||||
BOOST_NORETURN void quick_exit( int code ) BOOST_NOEXCEPT
|
||||
BOOST_NORETURN inline void quick_exit( int code ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
|
||||
399
include/boost/core/span.hpp
Normal file
399
include/boost/core/span.hpp
Normal file
@@ -0,0 +1,399 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_CORE_SPAN_HPP
|
||||
#define BOOST_CORE_SPAN_HPP
|
||||
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
|
||||
constexpr std::size_t dynamic_extent = static_cast<std::size_t>(-1);
|
||||
|
||||
template<class T, std::size_t E = dynamic_extent>
|
||||
class span;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class U, class T>
|
||||
struct span_convertible {
|
||||
static constexpr bool value = std::is_convertible<U(*)[], T(*)[]>::value;
|
||||
};
|
||||
|
||||
template<std::size_t E, std::size_t N>
|
||||
struct span_capacity {
|
||||
static constexpr bool value = E == boost::dynamic_extent || E == N;
|
||||
};
|
||||
|
||||
template<class T, std::size_t E, class U, std::size_t N>
|
||||
struct span_compatible {
|
||||
static constexpr bool value = span_capacity<E, N>::value &&
|
||||
span_convertible<U, T>::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct span_uncvref {
|
||||
typedef typename std::remove_cv<typename
|
||||
std::remove_reference<T>::type>::type type;
|
||||
};
|
||||
|
||||
template<class>
|
||||
struct span_is_span {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class T, std::size_t E>
|
||||
struct span_is_span<boost::span<T, E> > {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct span_is_array {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class T, std::size_t N>
|
||||
struct span_is_array<std::array<T, N> > {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class, class = void>
|
||||
struct span_data { };
|
||||
|
||||
template<class T>
|
||||
struct span_data<T,
|
||||
typename std::enable_if<std::is_pointer<decltype(std::declval<T
|
||||
&>().data())>::value>::type> {
|
||||
typedef typename std::remove_pointer<decltype(std::declval<T
|
||||
&>().data())>::type type;
|
||||
};
|
||||
|
||||
template<class, class, class = void>
|
||||
struct span_has_data {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class R, class T>
|
||||
struct span_has_data<R, T, typename std::enable_if<span_convertible<typename
|
||||
span_data<R>::type, T>::value>::type> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class, class = void>
|
||||
struct span_has_size {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class R>
|
||||
struct span_has_size<R, typename
|
||||
std::enable_if<std::is_convertible<decltype(std::declval<R&>().size()),
|
||||
std::size_t>::value>::type> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class R, class T>
|
||||
struct span_is_range {
|
||||
static constexpr bool value = (std::is_const<T>::value ||
|
||||
std::is_lvalue_reference<R>::value) &&
|
||||
!span_is_span<typename span_uncvref<R>::type>::value &&
|
||||
!span_is_array<typename span_uncvref<R>::type>::value &&
|
||||
!std::is_array<typename span_uncvref<R>::type>::value &&
|
||||
span_has_data<R, T>::value &&
|
||||
span_has_size<R>::value;
|
||||
};
|
||||
|
||||
template<std::size_t E, std::size_t N>
|
||||
struct span_implicit {
|
||||
static constexpr bool value = E == boost::dynamic_extent ||
|
||||
N != boost::dynamic_extent;
|
||||
};
|
||||
|
||||
template<class T, std::size_t E, class U, std::size_t N>
|
||||
struct span_copyable {
|
||||
static constexpr bool value = (N == boost::dynamic_extent ||
|
||||
span_capacity<E, N>::value) && span_convertible<U, T>::value;
|
||||
};
|
||||
|
||||
template<std::size_t E, std::size_t O>
|
||||
struct span_sub {
|
||||
static constexpr std::size_t value = E == boost::dynamic_extent ?
|
||||
boost::dynamic_extent : E - O;
|
||||
};
|
||||
|
||||
template<class T, std::size_t E>
|
||||
struct span_store {
|
||||
constexpr span_store(T* p_, std::size_t) noexcept
|
||||
: p(p_) { }
|
||||
static constexpr std::size_t n = E;
|
||||
T* p;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct span_store<T, boost::dynamic_extent> {
|
||||
constexpr span_store(T* p_, std::size_t n_) noexcept
|
||||
: p(p_)
|
||||
, n(n_) { }
|
||||
T* p;
|
||||
std::size_t n;
|
||||
};
|
||||
|
||||
template<class T, std::size_t E>
|
||||
struct span_bytes {
|
||||
static constexpr std::size_t value = sizeof(T) * E;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct span_bytes<T, boost::dynamic_extent> {
|
||||
static constexpr std::size_t value = boost::dynamic_extent;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T, std::size_t E>
|
||||
class span {
|
||||
public:
|
||||
typedef T element_type;
|
||||
typedef typename std::remove_cv<T>::type value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef std::reverse_iterator<T*> reverse_iterator;
|
||||
typedef std::reverse_iterator<const T*> const_reverse_iterator;
|
||||
|
||||
static constexpr std::size_t extent = E;
|
||||
|
||||
template<std::size_t N = E,
|
||||
typename std::enable_if<N == dynamic_extent || N == 0, int>::type = 0>
|
||||
constexpr span() noexcept
|
||||
: s_(0, 0) { }
|
||||
|
||||
template<class I,
|
||||
typename std::enable_if<E == dynamic_extent &&
|
||||
detail::span_convertible<I, T>::value, int>::type = 0>
|
||||
constexpr span(I* f, size_type c)
|
||||
: s_(f, c) { }
|
||||
|
||||
template<class I,
|
||||
typename std::enable_if<E != dynamic_extent &&
|
||||
detail::span_convertible<I, T>::value, int>::type = 0>
|
||||
explicit constexpr span(I* f, size_type c)
|
||||
: s_(f, c) { }
|
||||
|
||||
template<class I, class L,
|
||||
typename std::enable_if<E == dynamic_extent &&
|
||||
detail::span_convertible<I, T>::value, int>::type = 0>
|
||||
constexpr span(I* f, L* l)
|
||||
: s_(f, l - f) { }
|
||||
|
||||
template<class I, class L,
|
||||
typename std::enable_if<E != dynamic_extent &&
|
||||
detail::span_convertible<I, T>::value, int>::type = 0>
|
||||
explicit constexpr span(I* f, L* l)
|
||||
: s_(f, l - f) { }
|
||||
|
||||
template<std::size_t N,
|
||||
typename std::enable_if<detail::span_capacity<E, N>::value,
|
||||
int>::type = 0>
|
||||
constexpr span(typename std::enable_if<true, T>::type (&a)[N]) noexcept
|
||||
: s_(a, N) { }
|
||||
|
||||
template<class U, std::size_t N,
|
||||
typename std::enable_if<detail::span_compatible<T, E, U, N>::value,
|
||||
int>::type = 0>
|
||||
constexpr span(std::array<U, N>& a) noexcept
|
||||
: s_(a.data(), N) { }
|
||||
|
||||
template<class U, std::size_t N,
|
||||
typename std::enable_if<detail::span_compatible<T, E, const U,
|
||||
N>::value, int>::type = 0>
|
||||
constexpr span(const std::array<U, N>& a) noexcept
|
||||
: s_(a.data(), N) { }
|
||||
|
||||
template<class R,
|
||||
typename std::enable_if<E == dynamic_extent &&
|
||||
detail::span_is_range<R, T>::value, int>::type = 0>
|
||||
constexpr span(R&& r) noexcept(noexcept(r.data()) && noexcept(r.size()))
|
||||
: s_(r.data(), r.size()) { }
|
||||
|
||||
template<class R,
|
||||
typename std::enable_if<E != dynamic_extent &&
|
||||
detail::span_is_range<R, T>::value, int>::type = 0>
|
||||
explicit constexpr span(R&& r) noexcept(noexcept(r.data()) &&
|
||||
noexcept(r.size()))
|
||||
: s_(r.data(), r.size()) { }
|
||||
|
||||
template<class U, std::size_t N,
|
||||
typename std::enable_if<detail::span_implicit<E, N>::value &&
|
||||
detail::span_copyable<T, E, U, N>::value, int>::type = 0>
|
||||
constexpr span(const span<U, N>& s) noexcept
|
||||
: s_(s.data(), s.size()) { }
|
||||
|
||||
template<class U, std::size_t N,
|
||||
typename std::enable_if<!detail::span_implicit<E, N>::value &&
|
||||
detail::span_copyable<T, E, U, N>::value, int>::type = 0>
|
||||
explicit constexpr span(const span<U, N>& s) noexcept
|
||||
: s_(s.data(), s.size()) { }
|
||||
|
||||
template<std::size_t C>
|
||||
constexpr span<T, C> first() const {
|
||||
static_assert(C <= E, "Count <= Extent");
|
||||
return span<T, C>(s_.p, C);
|
||||
}
|
||||
|
||||
template<std::size_t C>
|
||||
constexpr span<T, C> last() const {
|
||||
static_assert(C <= E, "Count <= Extent");
|
||||
return span<T, C>(s_.p + (s_.n - C), C);
|
||||
}
|
||||
|
||||
template<std::size_t O, std::size_t C = dynamic_extent>
|
||||
constexpr typename std::enable_if<C == dynamic_extent,
|
||||
span<T, detail::span_sub<E, O>::value> >::type subspan() const {
|
||||
static_assert(O <= E, "Offset <= Extent");
|
||||
return span<T, detail::span_sub<E, O>::value>(s_.p + O, s_.n - O);
|
||||
}
|
||||
|
||||
template<std::size_t O, std::size_t C = dynamic_extent>
|
||||
constexpr typename std::enable_if<C != dynamic_extent,
|
||||
span<T, C> >::type subspan() const {
|
||||
static_assert(O <= E && C <= E - O,
|
||||
"Offset <= Extent && Count <= Extent - Offset");
|
||||
return span<T, C>(s_.p + O, C);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> first(size_type c) const {
|
||||
return span<T, dynamic_extent>(s_.p, c);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> last(size_type c) const {
|
||||
return span<T, dynamic_extent>(s_.p + (s_.n - c), c);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> subspan(size_type o,
|
||||
size_type c = dynamic_extent) const {
|
||||
return span<T, dynamic_extent>(s_.p + o,
|
||||
c == dynamic_extent ? s_.n - o : c);
|
||||
}
|
||||
|
||||
constexpr size_type size() const noexcept {
|
||||
return s_.n;
|
||||
}
|
||||
|
||||
constexpr size_type size_bytes() const noexcept {
|
||||
return s_.n * sizeof(T);
|
||||
}
|
||||
|
||||
constexpr bool empty() const noexcept {
|
||||
return s_.n == 0;
|
||||
}
|
||||
|
||||
constexpr reference operator[](size_type i) const {
|
||||
return s_.p[i];
|
||||
}
|
||||
|
||||
constexpr reference front() const {
|
||||
return *s_.p;
|
||||
}
|
||||
|
||||
constexpr reference back() const {
|
||||
return s_.p[s_.n - 1];
|
||||
}
|
||||
|
||||
constexpr pointer data() const noexcept {
|
||||
return s_.p;
|
||||
}
|
||||
|
||||
constexpr iterator begin() const noexcept {
|
||||
return s_.p;
|
||||
}
|
||||
|
||||
constexpr iterator end() const noexcept {
|
||||
return s_.p + s_.n;
|
||||
}
|
||||
|
||||
constexpr reverse_iterator rbegin() const noexcept {
|
||||
return reverse_iterator(s_.p + s_.n);
|
||||
}
|
||||
|
||||
constexpr reverse_iterator rend() const noexcept {
|
||||
return reverse_iterator(s_.p);
|
||||
}
|
||||
|
||||
constexpr const_iterator cbegin() const noexcept {
|
||||
return s_.p;
|
||||
}
|
||||
|
||||
constexpr const_iterator cend() const noexcept {
|
||||
return s_.p + s_.n;
|
||||
}
|
||||
|
||||
constexpr const_reverse_iterator crbegin() const noexcept {
|
||||
return const_reverse_iterator(s_.p + s_.n);
|
||||
}
|
||||
|
||||
constexpr const_reverse_iterator crend() const noexcept {
|
||||
return const_reverse_iterator(s_.p);
|
||||
}
|
||||
|
||||
private:
|
||||
detail::span_store<T, E> s_;
|
||||
};
|
||||
|
||||
template<class T, std::size_t E>
|
||||
constexpr std::size_t span<T, E>::extent;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template<class I, class L>
|
||||
span(I*, L) -> span<I>;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
span(T(&)[N]) -> span<T, N>;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
span(std::array<T, N>&) -> span<T, N>;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
span(const std::array<T, N>&) -> span<const T, N>;
|
||||
|
||||
template<class R>
|
||||
span(R&&) -> span<typename detail::span_data<R>::type>;
|
||||
|
||||
template<class T, std::size_t E>
|
||||
span(span<T, E>) -> span<T, E>;
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_lib_byte
|
||||
template<class T, std::size_t E>
|
||||
inline span<const std::byte, detail::span_bytes<T, E>::value>
|
||||
as_bytes(span<T, E> s) noexcept
|
||||
{
|
||||
return span<const std::byte, detail::span_bytes<T,
|
||||
E>::value>(reinterpret_cast<const std::byte*>(s.data()),
|
||||
s.size_bytes());
|
||||
}
|
||||
|
||||
template<class T, std::size_t E>
|
||||
inline typename std::enable_if<!std::is_const<T>::value,
|
||||
span<std::byte, detail::span_bytes<T, E>::value> >::type
|
||||
as_writable_bytes(span<T, E> s) noexcept
|
||||
{
|
||||
return span<std::byte, detail::span_bytes<T,
|
||||
E>::value>(reinterpret_cast<std::byte*>(s.data()), s.size_bytes());
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
88
include/boost/core/verbose_terminate_handler.hpp
Normal file
88
include/boost/core/verbose_terminate_handler.hpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
|
||||
#define BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// Copyright 2022 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/throw_exception.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
BOOST_NORETURN inline void verbose_terminate_handler()
|
||||
{
|
||||
std::set_terminate( 0 );
|
||||
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
|
||||
std::fputs( "std::terminate called with exceptions disabled\n", stderr );
|
||||
|
||||
#else
|
||||
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch( std::exception const& x )
|
||||
{
|
||||
#if defined(BOOST_NO_RTTI)
|
||||
|
||||
char const * typeid_name = "unknown (RTTI is disabled)";
|
||||
|
||||
#else
|
||||
|
||||
char const * typeid_name = typeid( x ).name();
|
||||
|
||||
boost::core::scoped_demangled_name typeid_demangled_name( typeid_name );
|
||||
|
||||
if( typeid_demangled_name.get() != 0 )
|
||||
{
|
||||
typeid_name = typeid_demangled_name.get();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
std::fprintf( stderr,
|
||||
"std::terminate called after throwing an exception:\n\n"
|
||||
" type: %s\n"
|
||||
" what(): %s\n"
|
||||
" location: %s:%lu:%lu in function '%s'\n",
|
||||
|
||||
typeid_name,
|
||||
x.what(),
|
||||
loc.file_name(), static_cast<unsigned long>( loc.line() ),
|
||||
static_cast<unsigned long>( loc.column() ), loc.function_name()
|
||||
);
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
std::fputs( "std::terminate called after throwing an unknown exception\n", stderr );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::fflush( stdout );
|
||||
std::abort();
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_VERBOSE_TERMINATE_HANDLER_HPP_INCLUDED
|
||||
@@ -5,7 +5,9 @@
|
||||
#ifndef BOOST_ITERATOR_HPP
|
||||
#define BOOST_ITERATOR_HPP
|
||||
|
||||
// This header is obsolete and will be deprecated.
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<iterator>")
|
||||
|
||||
#include <iterator>
|
||||
#include <cstddef> // std::ptrdiff_t
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Copyright 2018-2021 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
|
||||
|
||||
@@ -6,7 +6,26 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits Boost::throw_exception)
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::type_traits)
|
||||
|
||||
boost_test(TYPE run SOURCES eif_constructors.cpp)
|
||||
boost_test(TYPE run SOURCES eif_dummy_arg_disambiguation.cpp)
|
||||
boost_test(TYPE run SOURCES eif_lazy.cpp)
|
||||
boost_test(TYPE run SOURCES eif_lazy_test.cpp)
|
||||
boost_test(TYPE run SOURCES eif_member_templates.cpp)
|
||||
boost_test(TYPE run SOURCES eif_namespace_disambiguation.cpp)
|
||||
boost_test(TYPE run SOURCES eif_no_disambiguation.cpp)
|
||||
boost_test(TYPE run SOURCES eif_partial_specializations.cpp)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::throw_exception)
|
||||
|
||||
boost_test(TYPE run SOURCES no_exceptions_support_test.cpp)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::utility)
|
||||
|
||||
boost_test(TYPE run SOURCES sv_conversion_test2.cpp)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
188
test/Jamfile.v2
188
test/Jamfile.v2
@@ -1,6 +1,6 @@
|
||||
# Boost.Core Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2014, 2017 Peter Dimov
|
||||
# Copyright (c) 2014-2021 Peter Dimov
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,6 +9,19 @@
|
||||
import modules ;
|
||||
import testing ;
|
||||
|
||||
project : requirements
|
||||
|
||||
<warnings>extra
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare ;
|
||||
|
||||
local warning-as-errors-off =
|
||||
"-<toolset>msvc:<warnings-as-errors>on"
|
||||
"-<toolset>gcc:<warnings-as-errors>on"
|
||||
"-<toolset>clang:<warnings-as-errors>on" ;
|
||||
|
||||
# quick test (for CI)
|
||||
run quick.cpp ;
|
||||
|
||||
@@ -18,51 +31,64 @@ run addressof_test2.cpp ;
|
||||
run addressof_np_test.cpp ;
|
||||
run addressof_fn_test.cpp ;
|
||||
compile addressof_constexpr_test.cpp ;
|
||||
compile-fail addressof_fail_rvalue.cpp ;
|
||||
compile-fail addressof_fail_rvalue.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
|
||||
run checked_delete_test.cpp ;
|
||||
compile-fail checked_delete_fail.cpp ;
|
||||
compile-fail checked_delete_fail2.cpp ;
|
||||
compile-fail checked_delete_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail checked_delete_fail2.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
|
||||
compile ref_ct_test.cpp ;
|
||||
run ref_test.cpp ;
|
||||
run ref_ref_test.cpp ;
|
||||
run ref_fn_test.cpp ;
|
||||
compile-fail ref_rv_fail1.cpp ;
|
||||
compile-fail ref_rv_fail2.cpp ;
|
||||
compile-fail ref_rv_fail3.cpp ;
|
||||
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 ;
|
||||
compile-fail ref_rv_fail1.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_rv_fail2.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_rv_fail3.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_rv_fail4.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_rv_fail5.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail2.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail3.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail4.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
run ref_cv_test.cpp ;
|
||||
run ref_conversion_test.cpp ;
|
||||
|
||||
run eif_constructors.cpp ;
|
||||
run eif_dummy_arg_disambiguation.cpp ;
|
||||
run eif_lazy.cpp ;
|
||||
run eif_lazy_test.cpp ;
|
||||
run eif_member_templates.cpp ;
|
||||
run eif_namespace_disambiguation.cpp ;
|
||||
run eif_no_disambiguation.cpp ;
|
||||
run eif_partial_specializations.cpp ;
|
||||
run eif_constructors.cpp : ;
|
||||
run eif_dummy_arg_disambiguation.cpp : ;
|
||||
run eif_lazy.cpp : ;
|
||||
run eif_lazy_test.cpp : ;
|
||||
run eif_member_templates.cpp : ;
|
||||
run eif_namespace_disambiguation.cpp : ;
|
||||
run eif_no_disambiguation.cpp : ;
|
||||
run eif_partial_specializations.cpp : ;
|
||||
|
||||
compile-fail noncopyable_compile_fail.cpp ;
|
||||
compile-fail noncopyable_compile_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
|
||||
run explicit_operator_bool.cpp ;
|
||||
run explicit_operator_bool_noexcept.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_conv_int.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_delete.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_shift.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_conv_int.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail explicit_operator_bool_compile_fail_delete.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail explicit_operator_bool_compile_fail_shift.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
|
||||
compile ignore_unused_test.cpp
|
||||
: <warnings>extra
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>msvc:<warnings-as-errors>on ;
|
||||
compile ignore_unused_test.cpp ;
|
||||
|
||||
run sp_typeinfo_test.cpp ;
|
||||
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
|
||||
@@ -112,9 +138,9 @@ run-fail lightweight_test_fail4.cpp ;
|
||||
run-fail lightweight_test_fail5.cpp ;
|
||||
run-fail lightweight_test_fail6.cpp ;
|
||||
run-fail lightweight_test_fail7.cpp ;
|
||||
run-fail lightweight_test_fail7.cpp : : : <rtti>off : lightweight_test_fail7_no_rtti ;
|
||||
run-fail lightweight_test_fail7.cpp : : : <rtti>off <toolset>gcc-4.4:<build>no : lightweight_test_fail7_no_rtti ;
|
||||
run-fail lightweight_test_fail8.cpp ;
|
||||
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
|
||||
run-fail lightweight_test_fail8.cpp : : : <rtti>off <toolset>gcc-4.4:<build>no : lightweight_test_fail8_no_rtti ;
|
||||
run-fail lightweight_test_fail9.cpp ;
|
||||
run-fail lightweight_test_fail10.cpp ;
|
||||
run-fail lightweight_test_fail11.cpp : ;
|
||||
@@ -151,8 +177,10 @@ run demangled_name_test.cpp
|
||||
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
|
||||
|
||||
run scoped_enum.cpp ;
|
||||
compile-fail scoped_enum_compile_fail_conv_from_int.cpp ;
|
||||
compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
|
||||
compile-fail scoped_enum_compile_fail_conv_from_int.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
compile-fail scoped_enum_compile_fail_conv_to_int.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
|
||||
run underlying_type.cpp ;
|
||||
|
||||
@@ -161,6 +189,9 @@ run pointer_traits_element_type_test.cpp ;
|
||||
run pointer_traits_difference_type_test.cpp ;
|
||||
run pointer_traits_rebind_test.cpp ;
|
||||
run pointer_traits_pointer_to_test.cpp ;
|
||||
run pointer_traits_sfinae_test.cpp ;
|
||||
run pointer_traits_rebind_sfinae_test.cpp ;
|
||||
run pointer_traits_pointer_to_sfinae_test.cpp ;
|
||||
run to_address_test.cpp ;
|
||||
|
||||
run exchange_test.cpp ;
|
||||
@@ -183,6 +214,7 @@ run default_allocator_test.cpp
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on ;
|
||||
run default_allocator_allocate_hint_test.cpp ;
|
||||
|
||||
run noinit_adaptor_test.cpp ;
|
||||
run alloc_construct_test.cpp ;
|
||||
@@ -208,6 +240,11 @@ run allocator_allocate_hint_test.cpp ;
|
||||
run allocator_deallocate_test.cpp ;
|
||||
run allocator_max_size_test.cpp ;
|
||||
run allocator_soccc_test.cpp ;
|
||||
run allocator_construct_test.cpp ;
|
||||
run allocator_destroy_test.cpp ;
|
||||
run allocator_construct_n_test.cpp ;
|
||||
run allocator_destroy_n_test.cpp ;
|
||||
run allocator_traits_test.cpp ;
|
||||
|
||||
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
|
||||
|
||||
@@ -228,24 +265,81 @@ run uncaught_exceptions.cpp
|
||||
run uncaught_exceptions_np.cpp
|
||||
: : : <exception-handling>on ;
|
||||
|
||||
run no_exceptions_support_test.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
|
||||
: : : $(pedantic-errors) ;
|
||||
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 bit_cast_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_rotate_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_countr_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_countl_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_width_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run has_single_bit_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_floor_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_ceil_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_popcount_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_endian_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
run type_name_test.cpp ;
|
||||
|
||||
run sv_types_test.cpp ;
|
||||
run sv_construct_test.cpp ;
|
||||
run sv_iteration_test.cpp ;
|
||||
run sv_element_access_test.cpp ;
|
||||
run sv_modifiers_test.cpp ;
|
||||
run sv_copy_test.cpp ;
|
||||
run sv_substr_test.cpp ;
|
||||
run sv_compare_test.cpp ;
|
||||
run sv_starts_with_test.cpp ;
|
||||
run sv_ends_with_test.cpp ;
|
||||
run sv_find_test.cpp ;
|
||||
run sv_rfind_test.cpp ;
|
||||
run sv_find_first_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_find_last_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_find_first_not_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_find_last_not_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_contains_test.cpp ;
|
||||
run sv_eq_test.cpp ;
|
||||
run sv_lt_test.cpp ;
|
||||
run sv_stream_insert_test.cpp ;
|
||||
run sv_conversion_test.cpp ;
|
||||
run sv_conversion_test2.cpp : ;
|
||||
run sv_common_reference_test.cpp ;
|
||||
compile sv_common_reference_test2.cpp ;
|
||||
compile sv_windows_h_test.cpp ;
|
||||
|
||||
run span_test.cpp ;
|
||||
run span_types_test.cpp ;
|
||||
run span_constructible_test.cpp ;
|
||||
run span_deduction_guide_test.cpp ;
|
||||
run as_bytes_test.cpp ;
|
||||
run as_writable_bytes_test.cpp ;
|
||||
compile span_boost_begin_test.cpp ;
|
||||
|
||||
run splitmix64_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
run-fail verbose_terminate_handler_fail.cpp : ;
|
||||
run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off : verbose_terminate_handler_fail_nx ;
|
||||
run-fail verbose_terminate_handler_fail.cpp : : : <rtti>off : verbose_terminate_handler_fail_nr ;
|
||||
run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off <rtti>off : verbose_terminate_handler_fail_nxr ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
||||
@@ -10,6 +10,10 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/alloc_construct.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4100) // unreferenced parameter 'ptr'
|
||||
#endif
|
||||
|
||||
class type {
|
||||
public:
|
||||
explicit type(int x)
|
||||
|
||||
@@ -15,20 +15,16 @@ struct A1 {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -20,20 +20,16 @@ struct A1 {
|
||||
};
|
||||
};
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
47
test/allocator_construct_n_test.cpp
Normal file
47
test/allocator_construct_n_test.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright 2022 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;
|
||||
A() { }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A<int> a;
|
||||
int i[3] = { 5, 5, 5 };
|
||||
boost::allocator_construct_n(a, &i[0], 3);
|
||||
BOOST_TEST_EQ(i[0], 0);
|
||||
BOOST_TEST_EQ(i[1], 0);
|
||||
BOOST_TEST_EQ(i[2], 0);
|
||||
}
|
||||
{
|
||||
A<int> a;
|
||||
int i[4] = { 5, 5, 5, 5 };
|
||||
int j[2] = { 1, 2 };
|
||||
boost::allocator_construct_n(a, &i[0], 4, &j[0], 2);
|
||||
BOOST_TEST_EQ(i[0], 1);
|
||||
BOOST_TEST_EQ(i[1], 2);
|
||||
BOOST_TEST_EQ(i[2], 1);
|
||||
BOOST_TEST_EQ(i[3], 2);
|
||||
}
|
||||
{
|
||||
A<int> a;
|
||||
int i[3] = { 5, 5, 5 };
|
||||
int j[3] = { 1, 2, 3 };
|
||||
boost::allocator_construct_n(a, &i[0], 3, &j[0]);
|
||||
BOOST_TEST_EQ(i[0], 1);
|
||||
BOOST_TEST_EQ(i[1], 2);
|
||||
BOOST_TEST_EQ(i[2], 3);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -36,7 +36,7 @@ int main()
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A1<int> a;
|
||||
A2<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 6);
|
||||
|
||||
66
test/allocator_destroy_n_test.cpp
Normal file
66
test/allocator_destroy_n_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2022 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[3];
|
||||
boost::allocator_destroy_n(a, &s[0], 3);
|
||||
BOOST_TEST_EQ(S::count, 0);
|
||||
::new((void*)&s[0]) S();
|
||||
::new((void*)&s[1]) S();
|
||||
::new((void*)&s[2]) S();
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A2<int> a;
|
||||
int i[3] = { 5, 5, 5 };
|
||||
boost::allocator_destroy_n(a, &i[0], 3);
|
||||
BOOST_TEST_EQ(i[0], 0);
|
||||
BOOST_TEST_EQ(i[1], 0);
|
||||
BOOST_TEST_EQ(i[2], 0);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ int main()
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A1<int> a;
|
||||
A2<int> a;
|
||||
int i = 5;
|
||||
boost::allocator_destroy(a, &i);
|
||||
BOOST_TEST_EQ(i, 0);
|
||||
|
||||
@@ -15,20 +15,16 @@ struct A1 {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ struct A1 {
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
@@ -24,24 +23,25 @@ struct A2 {
|
||||
template<class T>
|
||||
struct A3 {
|
||||
typedef T value_type;
|
||||
typedef std::false_type is_always_equal;
|
||||
struct is_always_equal {
|
||||
static const bool value = false;
|
||||
};
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct A4 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type is_always_equal;
|
||||
struct is_always_equal {
|
||||
static const bool value = true;
|
||||
};
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -19,21 +19,17 @@ struct A1 {
|
||||
}
|
||||
};
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -14,21 +14,19 @@ 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;
|
||||
struct propagate_on_container_copy_assignment {
|
||||
static const bool value = true;
|
||||
};
|
||||
};
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -14,21 +14,19 @@ 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;
|
||||
struct propagate_on_container_move_assignment {
|
||||
static const bool value = true;
|
||||
};
|
||||
};
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -14,21 +14,19 @@ 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;
|
||||
struct propagate_on_container_swap {
|
||||
static const bool value = true;
|
||||
};
|
||||
};
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -15,20 +15,16 @@ struct A1 {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -18,20 +18,16 @@ struct A1 {
|
||||
};
|
||||
};
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ struct A1 {
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
@@ -27,15 +26,12 @@ struct A2 {
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
114
test/allocator_traits_test.cpp
Normal file
114
test/allocator_traits_test.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
Copyright 2021 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_traits.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
class creator {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef void* void_pointer;
|
||||
typedef const void* const_void_pointer;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
explicit creator(int value) BOOST_NOEXCEPT
|
||||
: state_(value) { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>& other) BOOST_NOEXCEPT
|
||||
: state_(other.state) { }
|
||||
|
||||
std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
return static_cast<std::size_t>(-1) / sizeof(T);
|
||||
}
|
||||
|
||||
T* allocate(std::size_t n, const void* = 0) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * n));
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t) {
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
int state() const {
|
||||
return state_;
|
||||
}
|
||||
|
||||
private:
|
||||
int state_;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator==(const creator<T>& lhs,
|
||||
const creator<U>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs.state() == rhs.state();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator!=(const creator<T>& lhs,
|
||||
const creator<U>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(creator<int>,
|
||||
boost::allocator_traits<creator<int> >::allocator_type);
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::allocator_traits<creator<int> >::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(int*,
|
||||
boost::allocator_traits<creator<int> >::pointer);
|
||||
BOOST_TEST_TRAIT_SAME(const int*,
|
||||
boost::allocator_traits<creator<int> >::const_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(void*,
|
||||
boost::allocator_traits<creator<int> >::void_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(const void*,
|
||||
boost::allocator_traits<creator<int> >::const_void_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::allocator_traits<creator<int> >::difference_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::allocator_traits<creator<int> >::size_type);
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
|
||||
propagate_on_container_copy_assignment));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
|
||||
propagate_on_container_move_assignment));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
|
||||
propagate_on_container_swap));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_traits<creator<int> >::
|
||||
is_always_equal));
|
||||
BOOST_TEST_TRAIT_SAME(creator<char>,
|
||||
boost::allocator_traits<creator<int> >::
|
||||
rebind_traits<char>::allocator_type);
|
||||
creator<int> a(1);
|
||||
int* p1 = boost::allocator_traits<creator<int> >::allocate(a, 1);
|
||||
if (BOOST_TEST(p1)) {
|
||||
boost::allocator_traits<creator<int> >::construct(a, p1, 5);
|
||||
BOOST_TEST_EQ(*p1, 5);
|
||||
boost::allocator_traits<creator<int> >::destroy(a, p1);
|
||||
boost::allocator_traits<creator<int> >::deallocate(a, p1, 1);
|
||||
}
|
||||
int* p2 = boost::allocator_traits<creator<int> >::allocate(a, 1, 0);
|
||||
if (BOOST_TEST(p2)) {
|
||||
boost::allocator_traits<creator<int> >::deallocate(a, p2, 1);
|
||||
}
|
||||
BOOST_TEST_EQ(boost::allocator_traits<creator<int> >::max_size(a),
|
||||
static_cast<std::size_t>(-1) / sizeof(int));
|
||||
BOOST_TEST(boost::allocator_traits<creator<int> >::
|
||||
select_on_container_copy_construction(a) == a);
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -20,20 +20,16 @@ struct A1 {
|
||||
};
|
||||
};
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
42
test/as_bytes_test.cpp
Normal file
42
test/as_bytes_test.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <cstddef>
|
||||
#ifdef __cpp_lib_byte
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void test_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<const std::byte> s =
|
||||
boost::as_bytes(boost::span<int>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), reinterpret_cast<const std::byte*>(&a[0]));
|
||||
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
|
||||
}
|
||||
|
||||
void test_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<const std::byte, sizeof(int) * 4> s =
|
||||
boost::as_bytes(boost::span<int, 4>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), reinterpret_cast<const std::byte*>(&a[0]));
|
||||
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_dynamic();
|
||||
test_static();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
42
test/as_writable_bytes_test.cpp
Normal file
42
test/as_writable_bytes_test.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <cstddef>
|
||||
#ifdef __cpp_lib_byte
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void test_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<std::byte> s =
|
||||
boost::as_writable_bytes(boost::span<int>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), reinterpret_cast<std::byte*>(&a[0]));
|
||||
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
|
||||
}
|
||||
|
||||
void test_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<std::byte, sizeof(int) * 4> s =
|
||||
boost::as_writable_bytes(boost::span<int, 4>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), reinterpret_cast<std::byte*>(&a[0]));
|
||||
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_dynamic();
|
||||
test_static();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -38,14 +38,14 @@ int main()
|
||||
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::ulong_long_type>( 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 ) );
|
||||
test_bit_ceil( boost::uint64_t( 1 ) << 63 );
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
@@ -58,7 +58,7 @@ int main()
|
||||
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 ) );
|
||||
test_bit_ceil( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -27,7 +27,7 @@ int main()
|
||||
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 ) );
|
||||
test_countl( static_cast<boost::ulong_long_type>( 0 ) );
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
@@ -39,7 +39,7 @@ int main()
|
||||
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 ) );
|
||||
test_countl( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -27,7 +27,7 @@ int main()
|
||||
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 ) );
|
||||
test_countr( static_cast<boost::ulong_long_type>( 0 ) );
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
@@ -39,7 +39,7 @@ int main()
|
||||
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 ) );
|
||||
test_countr( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -9,9 +9,13 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::uint64_t v = static_cast<boost::uint64_t>( 0x0102030405060708ull );
|
||||
boost::uint64_t v = ( static_cast<boost::uint64_t>( 0x01020304u ) << 32 ) + 0x05060708u;
|
||||
|
||||
if( boost::core::endian::native == boost::core::endian::little )
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ int main()
|
||||
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 ) );
|
||||
test_bit_floor( static_cast<boost::ulong_long_type>( 0 ) );
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
@@ -46,7 +46,7 @@ int main()
|
||||
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 ) );
|
||||
test_bit_floor( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -26,7 +26,7 @@ int main()
|
||||
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 ) );
|
||||
test_popcount( static_cast<boost::ulong_long_type>( 0 ) );
|
||||
}
|
||||
|
||||
boost::detail::splitmix64 rng;
|
||||
@@ -39,7 +39,7 @@ int main()
|
||||
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 ) );
|
||||
test_popcount( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -103,26 +103,28 @@ int main()
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x44444444 );
|
||||
}
|
||||
|
||||
#define CONST64(x) ((boost::uint64_t(x) << 32) + (x))
|
||||
|
||||
{
|
||||
boost::uint64_t x = 0x1111111111111111;
|
||||
boost::uint64_t x = CONST64(0x11111111);
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x2222222222222222 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x8888888888888888 );
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x22222222) );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x88888888) );
|
||||
|
||||
x = 0x2222222222222222;
|
||||
x = CONST64(0x22222222);
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x4444444444444444 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x1111111111111111 );
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x44444444) );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x11111111) );
|
||||
|
||||
x = 0x4444444444444444;
|
||||
x = CONST64(0x44444444);
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x8888888888888888 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x2222222222222222 );
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x88888888) );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x22222222) );
|
||||
|
||||
x = 0x8888888888888888;
|
||||
x = CONST64(0x88888888);
|
||||
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), 0x1111111111111111 );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), 0x4444444444444444 );
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, 1 ), CONST64(0x11111111) );
|
||||
BOOST_TEST_EQ( +boost::core::rotr( x, 1 ), CONST64(0x44444444) );
|
||||
}
|
||||
|
||||
for( int i = -M; i <= M; ++i )
|
||||
@@ -152,7 +154,7 @@ int main()
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long long x = 0;
|
||||
boost::ulong_long_type x = 0;
|
||||
BOOST_TEST_EQ( boost::core::rotl( x, i ), x );
|
||||
BOOST_TEST_EQ( boost::core::rotr( x, i ), x );
|
||||
}
|
||||
@@ -168,7 +170,7 @@ int main()
|
||||
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 ) );
|
||||
test_rotate( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -87,7 +87,7 @@ int main()
|
||||
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 ) );
|
||||
test_width( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Copyright 2018, 2019, 2021 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
|
||||
|
||||
@@ -9,6 +9,8 @@ project(cmake_subdir_test LANGUAGES CXX)
|
||||
add_subdirectory(../.. boostorg/core)
|
||||
add_subdirectory(../../../assert boostorg/assert)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
add_subdirectory(../../../static_assert boostorg/static_assert)
|
||||
add_subdirectory(../../../throw_exception boostorg/throw_exception)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::core)
|
||||
|
||||
19
test/default_allocator_allocate_hint_test.cpp
Normal file
19
test/default_allocator_allocate_hint_test.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/default_allocator.hpp>
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::default_allocator<int> a;
|
||||
int* p = boost::allocator_allocate(a, 1, 0);
|
||||
BOOST_TEST(p != 0);
|
||||
a.deallocate(p, 1);
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
using boost::enable_if;
|
||||
using boost::disable_if;
|
||||
@@ -39,7 +40,7 @@ struct xstring
|
||||
disable_if<is_arithmetic<It> >::type* = 0)
|
||||
: data(end-begin) {}
|
||||
|
||||
int data;
|
||||
std::ptrdiff_t data;
|
||||
};
|
||||
|
||||
|
||||
@@ -58,4 +59,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ template <int N> struct dummy {
|
||||
|
||||
template<class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t, dummy<0> = 0) { return true; }
|
||||
arithmetic_object(T /*t*/, dummy<0> = 0) { return true; }
|
||||
|
||||
template<class T>
|
||||
typename disable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t, dummy<1> = 0) { return false; }
|
||||
arithmetic_object(T /*t*/, dummy<1> = 0) { return false; }
|
||||
|
||||
|
||||
int main()
|
||||
@@ -42,4 +42,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,21 +60,21 @@ namespace A {
|
||||
|
||||
template<class T>
|
||||
typename lazy_enable_if<is_int_or_double<T>, some_traits<T> >::type
|
||||
foo(T t) { return true; }
|
||||
foo(T /*t*/) { return true; }
|
||||
|
||||
template<class T>
|
||||
typename lazy_enable_if_c<is_int_or_double<T>::value, some_traits<T> >::type
|
||||
foo2(T t) { return true; }
|
||||
foo2(T /*t*/) { return true; }
|
||||
}
|
||||
|
||||
namespace B {
|
||||
template<class T>
|
||||
typename lazy_disable_if<is_int_or_double<T>, make_bool<T> >::type
|
||||
foo(T t) { return false; }
|
||||
foo(T /*t*/) { return false; }
|
||||
|
||||
template<class T>
|
||||
typename lazy_disable_if_c<is_int_or_double<T>::value, make_bool<T> >::type
|
||||
foo2(T t) { return false; }
|
||||
foo2(T /*t*/) { return false; }
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -95,4 +95,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ template<class T> struct not_
|
||||
namespace A {
|
||||
template<class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t) { return true; }
|
||||
arithmetic_object(T /*t*/) { return true; }
|
||||
}
|
||||
|
||||
namespace B {
|
||||
template<class T>
|
||||
typename enable_if<not_<is_arithmetic<T> >, bool>::type
|
||||
arithmetic_object(T t) { return false; }
|
||||
arithmetic_object(T /*t*/) { return false; }
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -47,4 +47,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ template<class T> struct not_
|
||||
|
||||
template<class T>
|
||||
typename enable_if<is_arithmetic<T>, bool>::type
|
||||
arithmetic_object(T t) { return true; }
|
||||
arithmetic_object(T /*t*/) { return true; }
|
||||
|
||||
template<class T>
|
||||
typename enable_if<not_<is_arithmetic<T> >, bool>::type
|
||||
arithmetic_object(T t) { return false; }
|
||||
arithmetic_object(T /*t*/) { return false; }
|
||||
|
||||
|
||||
int main()
|
||||
@@ -43,4 +43,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,11 @@ int main(int, char*[])
|
||||
BOOST_TEST(noexcept(static_cast< bool >(noexcept_val1)));
|
||||
BOOST_TEST(noexcept(static_cast< bool >(noexcept_val2)));
|
||||
|
||||
(void)val1;
|
||||
(void)val2;
|
||||
(void)noexcept_val1;
|
||||
(void)noexcept_val2;
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // std::auto_ptr
|
||||
#endif
|
||||
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -103,7 +103,7 @@ int main()
|
||||
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 ) );
|
||||
test_single_bit( static_cast<boost::ulong_long_type>( x ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_HEADERS
|
||||
#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// std::iterator template is deprecated in C++17. Some standard libraries emit warnings
|
||||
// that cannot be easily suppressed, so disable the tests in C++17 onwards.
|
||||
#if BOOST_CXX_VERSION < 201703
|
||||
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
@@ -67,3 +76,11 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else // BOOST_CXX_VERSION < 201703
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // BOOST_CXX_VERSION < 201703
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wstring-plus-int"
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/quick_exit.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
72
test/pointer_traits_pointer_to_sfinae_test.cpp
Normal file
72
test/pointer_traits_pointer_to_sfinae_test.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright 2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class has_pointer_to {
|
||||
template<class>
|
||||
struct result {
|
||||
char x, y;
|
||||
};
|
||||
|
||||
template<class O>
|
||||
static auto check(int) -> result<decltype(O::pointer_to)>;
|
||||
|
||||
template<class O>
|
||||
static char check(long);
|
||||
|
||||
public:
|
||||
static const bool value = sizeof(check<T>(0)) > 1;
|
||||
};
|
||||
|
||||
struct P1 { };
|
||||
|
||||
struct P2 {
|
||||
typedef int element_type;
|
||||
|
||||
static int* pointer_to(int& value) {
|
||||
return &value;
|
||||
}
|
||||
};
|
||||
|
||||
struct P3 {
|
||||
typedef void element_type;
|
||||
};
|
||||
|
||||
struct P4 {
|
||||
typedef int element_type;
|
||||
};
|
||||
|
||||
struct P5 {
|
||||
typedef int element_type;
|
||||
|
||||
static int* pointer_to() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST((!has_pointer_to<boost::pointer_traits<P1> >::value));
|
||||
BOOST_TEST(has_pointer_to<boost::pointer_traits<P2> >::value);
|
||||
BOOST_TEST(!has_pointer_to<boost::pointer_traits<P3> >::value);
|
||||
BOOST_TEST(!has_pointer_to<boost::pointer_traits<P4> >::value);
|
||||
BOOST_TEST(!has_pointer_to<boost::pointer_traits<P5> >::value);
|
||||
BOOST_TEST(has_pointer_to<boost::pointer_traits<int*> >::value);
|
||||
BOOST_TEST(!has_pointer_to<boost::pointer_traits<void*> >::value);
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
83
test/pointer_traits_rebind_sfinae_test.cpp
Normal file
83
test/pointer_traits_rebind_sfinae_test.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright 2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && \
|
||||
(!defined(BOOST_GCC) || (BOOST_GCC >= 40800)) && \
|
||||
(!defined(BOOST_MSVC) || (BOOST_MSVC >= 1900))
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class>
|
||||
struct valid {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_GCC) || (BOOST_GCC >= 50000)
|
||||
template<class, class, class = void>
|
||||
struct has_rebind {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct has_rebind<T, U,
|
||||
typename valid<typename T::template rebind<U> >::type> {
|
||||
static const bool value = true;
|
||||
};
|
||||
#else
|
||||
template<template<class> class T, class U>
|
||||
using defer = T<U>;
|
||||
|
||||
template<class T, class U>
|
||||
using rebind = defer<T::template rebind, U>;
|
||||
|
||||
template<class, class, template<class, class> class = rebind, class = void>
|
||||
struct has_rebind {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T, class U, template<class, class> class R>
|
||||
struct has_rebind<T, U, R, typename valid<R<T, U> >::type> {
|
||||
static const bool value = true;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct P1 { };
|
||||
|
||||
struct P2 {
|
||||
typedef int element_type;
|
||||
};
|
||||
|
||||
struct P3 {
|
||||
typedef int element_type;
|
||||
|
||||
template<class>
|
||||
struct rebind { };
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct S {
|
||||
typedef T element_type;
|
||||
};
|
||||
|
||||
typedef S<int> P4;
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST((!has_rebind<boost::pointer_traits<P1>, char>::value));
|
||||
BOOST_TEST((!has_rebind<boost::pointer_traits<P2>, char>::value));
|
||||
BOOST_TEST((has_rebind<boost::pointer_traits<P3>, char>::value));
|
||||
BOOST_TEST((has_rebind<boost::pointer_traits<P4>, char>::value));
|
||||
BOOST_TEST((has_rebind<boost::pointer_traits<int*>, char>::value));
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
Copyright 2017-2022 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -84,15 +84,49 @@ int main()
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
|
||||
boost::pointer_traits<P1<const R> >::rebind_to<int>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
|
||||
boost::pointer_traits<R*>::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<char>,
|
||||
boost::pointer_traits<P1<R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P2<char, R>,
|
||||
boost::pointer_traits<P2<R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P3<char, R, R>,
|
||||
boost::pointer_traits<P3<R, R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
boost::pointer_traits<R*>::rebind<void> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<void>,
|
||||
boost::pointer_traits<P1<R> >::rebind<void> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<R*,
|
||||
boost::pointer_traits<void*>::rebind<R> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<R>,
|
||||
boost::pointer_traits<P1<void> >::rebind<R> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
boost::pointer_traits<R*>::rebind<const int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<const int>,
|
||||
boost::pointer_traits<P1<R> >::rebind<const int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::pointer_traits<const R*>::rebind<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
|
||||
boost::pointer_traits<P1<const R> >::rebind<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
|
||||
boost::pointer_traits<E2<R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
|
||||
boost::pointer_traits<E3<R, R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
|
||||
boost::pointer_traits<E2<R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
|
||||
boost::pointer_traits<E3<R, R, R> >::rebind<char> >));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<char, R, R, R>,
|
||||
boost::pointer_traits<P<R, R, R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
|
||||
boost::pointer_traits<E<R, R, R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
|
||||
boost::pointer_traits<E<R, R, R, R> >::rebind<char> >));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<void>::type>));
|
||||
@@ -102,6 +136,14 @@ int main()
|
||||
boost::pointer_traits<E1<R> >::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<const R> >::rebind_to<int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind<void> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<void> >::rebind<R> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind<const int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<const R> >::rebind<int> >));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
101
test/pointer_traits_sfinae_test.cpp
Normal file
101
test/pointer_traits_sfinae_test.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright 2021 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/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class>
|
||||
struct valid {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class, class = void>
|
||||
struct has_pointer {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_pointer<T, typename valid<typename T::pointer>::type> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<class, class = void>
|
||||
struct has_element_type {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_element_type<T, typename valid<typename T::element_type>::type> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<class, class = void>
|
||||
struct has_difference_type {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_difference_type<T,
|
||||
typename valid<typename T::difference_type>::type> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<class, class, class = void>
|
||||
struct has_rebind_to_type {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct has_rebind_to_type<T, U,
|
||||
typename valid<typename T::template rebind_to<U>::type>::type> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
struct P1 { };
|
||||
|
||||
struct P2 {
|
||||
typedef int element_type;
|
||||
};
|
||||
|
||||
struct P3 {
|
||||
typedef int element_type;
|
||||
|
||||
template<class>
|
||||
struct rebind { };
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct S {
|
||||
typedef T element_type;
|
||||
};
|
||||
|
||||
typedef S<int> P4;
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(!has_pointer<boost::pointer_traits<P1> >::value);
|
||||
BOOST_TEST(!has_element_type<boost::pointer_traits<P1> >::value);
|
||||
BOOST_TEST(!has_difference_type<boost::pointer_traits<P1> >::value);
|
||||
BOOST_TEST((!has_rebind_to_type<boost::pointer_traits<P1>, char>::value));
|
||||
BOOST_TEST(has_pointer<boost::pointer_traits<P2> >::value);
|
||||
BOOST_TEST(has_element_type<boost::pointer_traits<P2> >::value);
|
||||
BOOST_TEST(has_difference_type<boost::pointer_traits<P2> >::value);
|
||||
BOOST_TEST((!has_rebind_to_type<boost::pointer_traits<P2>, char>::value));
|
||||
BOOST_TEST(has_pointer<boost::pointer_traits<P3> >::value);
|
||||
BOOST_TEST(has_element_type<boost::pointer_traits<P3> >::value);
|
||||
BOOST_TEST(has_difference_type<boost::pointer_traits<P3> >::value);
|
||||
BOOST_TEST((has_rebind_to_type<boost::pointer_traits<P3>, char>::value));
|
||||
BOOST_TEST(has_pointer<boost::pointer_traits<P4> >::value);
|
||||
BOOST_TEST(has_element_type<boost::pointer_traits<P4> >::value);
|
||||
BOOST_TEST(has_difference_type<boost::pointer_traits<P4> >::value);
|
||||
BOOST_TEST((has_rebind_to_type<boost::pointer_traits<P4>, char>::value));
|
||||
BOOST_TEST(has_pointer<boost::pointer_traits<int*> >::value);
|
||||
BOOST_TEST(has_element_type<boost::pointer_traits<int*> >::value);
|
||||
BOOST_TEST(has_difference_type<boost::pointer_traits<int*> >::value);
|
||||
BOOST_TEST((has_rebind_to_type<boost::pointer_traits<int*>, char>::value));
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
// Test for quick_exit.hpp
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
@@ -7,6 +6,9 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#include <boost/core/quick_exit.hpp>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
// Test for quick_exit.hpp
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
@@ -7,6 +6,9 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#include <boost/core/quick_exit.hpp>
|
||||
|
||||
|
||||
@@ -21,10 +21,16 @@ void ref_test(boost::reference_wrapper<U>)
|
||||
BOOST_STATIC_ASSERT((boost::core::is_same<T,type>::value));
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void assignable_test_(T x1, T x2)
|
||||
{
|
||||
x1 = x2;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void assignable_test(T x)
|
||||
{
|
||||
x = x;
|
||||
assignable_test_( x, x );
|
||||
}
|
||||
|
||||
template< bool R, typename T >
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4244) // conversion from enum_type to underlying_type
|
||||
#endif
|
||||
|
||||
BOOST_SCOPED_ENUM_DECLARE_BEGIN(namespace_enum1)
|
||||
{
|
||||
value0,
|
||||
@@ -142,6 +146,7 @@ void check_underlying_type()
|
||||
// The real check for the type is in the underlying_type trait test.
|
||||
namespace_enum2 enum1 = namespace_enum2::value1;
|
||||
BOOST_TEST(sizeof(enum1) == sizeof(unsigned char));
|
||||
(void)enum1;
|
||||
}
|
||||
|
||||
int main(int, char*[])
|
||||
|
||||
32
test/span_boost_begin_test.cpp
Normal file
32
test/span_boost_begin_test.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2022 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#include <boost/core/span.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
namespace begin_ {
|
||||
|
||||
template<class T>
|
||||
void begin(T&) { }
|
||||
|
||||
} // begin_
|
||||
|
||||
using namespace begin_;
|
||||
|
||||
} // boost
|
||||
|
||||
template class boost::span<float>;
|
||||
|
||||
void function()
|
||||
{
|
||||
std::vector<int> y;
|
||||
boost::begin(y);
|
||||
}
|
||||
#endif
|
||||
200
test/span_constructible_test.cpp
Normal file
200
test/span_constructible_test.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct range {
|
||||
T* data() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const T* data() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct base { };
|
||||
|
||||
struct derived
|
||||
: base { };
|
||||
|
||||
void test_default()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<
|
||||
boost::span<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<
|
||||
boost::span<int, 0> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<
|
||||
boost::span<int, 2> >));
|
||||
}
|
||||
|
||||
void test_data_size()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
int*, std::size_t>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
int*, std::size_t>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
int, std::size_t>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
const int*, std::size_t>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
|
||||
derived*, std::size_t>));
|
||||
}
|
||||
|
||||
void test_first_last()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
int*, int*>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
int*, const int*>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
int*, int*>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
int, int*>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
const int*, int*>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
|
||||
derived*, derived*>));
|
||||
}
|
||||
|
||||
void test_array()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
int(&)[4]>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int, 4>,
|
||||
int(&)[4]>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 2>,
|
||||
int(&)[4]>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
|
||||
int(&)[2]>));
|
||||
}
|
||||
|
||||
void test_std_array()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
std::array<int, 4>&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
std::array<int, 4>&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int, 4>,
|
||||
std::array<int, 4>&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int,
|
||||
4>, std::array<int, 4>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
std::array<const int, 4>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
|
||||
std::array<derived, 4>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 2>,
|
||||
std::array<int, 4>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
|
||||
std::array<const int, 4>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base, 4>,
|
||||
std::array<derived, 4>&>));
|
||||
}
|
||||
|
||||
void test_const_std_array()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
const std::array<int, 4> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int,
|
||||
4>, const std::array<int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
const std::array<int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<const
|
||||
base>, const std::array<derived, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<const int,
|
||||
2>, const std::array<int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
|
||||
const std::array<int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<const
|
||||
base, 4>, const std::array<derived, 4> >));
|
||||
}
|
||||
|
||||
void test_range()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
range<int>&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
range<int>&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
range<int> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
int*>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
range<int> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
const range<int>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
|
||||
range<derived>&>));
|
||||
}
|
||||
|
||||
void test_span()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
boost::span<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
|
||||
boost::span<int, 4> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int, 4>,
|
||||
boost::span<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int,
|
||||
4>, boost::span<int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
boost::span<const int> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
|
||||
boost::span<derived> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 2>,
|
||||
boost::span<int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
|
||||
boost::span<const int, 4> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base, 4>,
|
||||
boost::span<derived, 4> >));
|
||||
}
|
||||
|
||||
void test_copy()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible<
|
||||
boost::span<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible<
|
||||
boost::span<int, 4> >));
|
||||
}
|
||||
|
||||
void test_assign()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable<
|
||||
boost::span<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable<
|
||||
boost::span<int, 4> >));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_data_size();
|
||||
test_first_last();
|
||||
test_array();
|
||||
test_std_array();
|
||||
test_const_std_array();
|
||||
test_range();
|
||||
test_span();
|
||||
test_copy();
|
||||
test_assign();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
116
test/span_deduction_guide_test.cpp
Normal file
116
test/span_deduction_guide_test.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifdef __cpp_deduction_guides
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class range {
|
||||
public:
|
||||
T* data() {
|
||||
return &v_[0];
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
return 4;
|
||||
}
|
||||
|
||||
private:
|
||||
T v_[4];
|
||||
};
|
||||
|
||||
void test_data_size()
|
||||
{
|
||||
int a[4];
|
||||
boost::span s(&a[0], 4);
|
||||
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_first_last()
|
||||
{
|
||||
int a[4];
|
||||
boost::span s(&a[0], &a[4]);
|
||||
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_array()
|
||||
{
|
||||
int a[4];
|
||||
boost::span s(a);
|
||||
BOOST_TEST_EQ(s.extent, 4);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_std_array()
|
||||
{
|
||||
std::array<int, 4> a;
|
||||
boost::span s(a);
|
||||
BOOST_TEST_EQ(s.extent, 4);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_const_std_array()
|
||||
{
|
||||
const std::array<int, 4> a = std::array<int, 4>();
|
||||
boost::span s(a);
|
||||
BOOST_TEST_EQ(s.extent, 4);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_range()
|
||||
{
|
||||
range<int> c;
|
||||
boost::span s(c);
|
||||
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
|
||||
BOOST_TEST_EQ(s.data(), c.data());
|
||||
BOOST_TEST_EQ(s.size(), c.size());
|
||||
}
|
||||
|
||||
void test_span_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span s(boost::span<int>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_span_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span s(boost::span<int, 4>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.extent, 4);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_data_size();
|
||||
test_first_last();
|
||||
test_array();
|
||||
test_std_array();
|
||||
test_const_std_array();
|
||||
test_range();
|
||||
test_span_dynamic();
|
||||
test_span_static();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
419
test/span_test.cpp
Normal file
419
test/span_test.cpp
Normal file
@@ -0,0 +1,419 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class range {
|
||||
public:
|
||||
T* data() {
|
||||
return &v_[0];
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
return 4;
|
||||
}
|
||||
|
||||
private:
|
||||
T v_[4];
|
||||
};
|
||||
|
||||
void test_extent()
|
||||
{
|
||||
BOOST_TEST_EQ(boost::span<int>::extent,
|
||||
boost::dynamic_extent);
|
||||
BOOST_TEST_EQ((boost::span<int, 2>::extent), 2);
|
||||
}
|
||||
|
||||
void test_default_construct_dynamic()
|
||||
{
|
||||
boost::span<int> s;
|
||||
BOOST_TEST_EQ(s.data(), static_cast<int*>(0));
|
||||
BOOST_TEST_EQ(s.size(), 0);
|
||||
}
|
||||
|
||||
void test_default_construct_static()
|
||||
{
|
||||
boost::span<int, 0> s;
|
||||
BOOST_TEST_EQ(s.data(), static_cast<int*>(0));
|
||||
BOOST_TEST_EQ(s.size(), 0);
|
||||
}
|
||||
|
||||
void test_construct_data_size()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s(&a[0], 4);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_first_last()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s(&a[0], &a[4]);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_array_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s(a);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_array_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 4> s(a);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_std_array_dynamic()
|
||||
{
|
||||
std::array<int, 4> a;
|
||||
boost::span<int> s(a);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_construct_std_array_static()
|
||||
{
|
||||
std::array<int, 4> a;
|
||||
boost::span<int, 4> s(a);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_construct_const_std_array_dynamic()
|
||||
{
|
||||
const std::array<int, 4> a = std::array<int, 4>();
|
||||
boost::span<const int> s(a);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_construct_const_std_array_static()
|
||||
{
|
||||
const std::array<int, 4> a = std::array<int, 4>();
|
||||
boost::span<const int, 4> s(a);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_construct_range()
|
||||
{
|
||||
range<int> c;
|
||||
boost::span<int> s(c);
|
||||
BOOST_TEST_EQ(s.data(), c.data());
|
||||
BOOST_TEST_EQ(s.size(), c.size());
|
||||
}
|
||||
|
||||
void test_construct_span_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<const int> s(boost::span<int>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_span_dynamic_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s(boost::span<int, 4>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_span_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<const int, 4> s(boost::span<int, 4>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_construct_span_static_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 4> s(boost::span<int>(&a[0], 4));
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_copy_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s1(&a[0], 4);
|
||||
boost::span<int> s2(s1);
|
||||
BOOST_TEST_EQ(s2.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s2.size(), 4);
|
||||
}
|
||||
|
||||
void test_copy_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 4> s1(&a[0], 4);
|
||||
boost::span<int, 4> s2(s1);
|
||||
BOOST_TEST_EQ(s2.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s2.size(), 4);
|
||||
}
|
||||
|
||||
void test_assign_dynamic()
|
||||
{
|
||||
boost::span<int> s;
|
||||
int a[4];
|
||||
s = boost::span<int>(&a[0], 4);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_assign_static()
|
||||
{
|
||||
int a1[4];
|
||||
boost::span<int, 4> s(&a1[0], 4);
|
||||
int a2[4];
|
||||
s = boost::span<int, 4>(&a2[0], 4);
|
||||
BOOST_TEST_EQ(s.data(), &a2[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_first()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 2> s = boost::span<int>(&a[0],
|
||||
4).first<2>();
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_last()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 2> s = boost::span<int>(&a[0], 4).last<2>();
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_subspan_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s = boost::span<int>(&a[0], 4).subspan<2>();
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_subspan_static()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 2> s = boost::span<int, 4>(&a[0],
|
||||
4).subspan<2>();
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_subspan()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 1> s = boost::span<int>(&a[0],
|
||||
4).subspan<2, 1>();
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 1);
|
||||
}
|
||||
|
||||
void test_first_size()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s = boost::span<int>(&a[0], 4).first(2);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_last_size()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s = boost::span<int>(&a[0], 4).last(2);
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_subspan_range()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s = boost::span<int>(&a[0], 4).subspan(2);
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_subspan_range_count()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s = boost::span<int>(&a[0],
|
||||
4).subspan(2, 1);
|
||||
BOOST_TEST_EQ(s.data(), &a[2]);
|
||||
BOOST_TEST_EQ(s.size(), 1);
|
||||
}
|
||||
|
||||
void test_size()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).size()), 4);
|
||||
}
|
||||
|
||||
void test_size_bytes()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).size_bytes()),
|
||||
4 * sizeof(int));
|
||||
}
|
||||
|
||||
void test_empty_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST(boost::span<int>().empty());
|
||||
BOOST_TEST_NOT((boost::span<int>(&a[0], 4).empty()));
|
||||
}
|
||||
|
||||
void test_empty_static()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST((boost::span<int, 0>().empty()));
|
||||
BOOST_TEST_NOT((boost::span<int, 4>(&a[0], 4).empty()));
|
||||
}
|
||||
|
||||
void test_index()
|
||||
{
|
||||
int a[4] = { 1, 2, 3, 4 };
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4)[2]), 3);
|
||||
}
|
||||
|
||||
void test_front()
|
||||
{
|
||||
int a[4] = { 1, 2, 3, 4 };
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).front()), 1);
|
||||
}
|
||||
|
||||
void test_back()
|
||||
{
|
||||
int a[4] = { 1, 2, 3, 4 };
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).back()), 4);
|
||||
}
|
||||
|
||||
void test_data()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).data()), &a[0]);
|
||||
}
|
||||
|
||||
void test_begin()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).begin()), &a[0]);
|
||||
}
|
||||
|
||||
void test_end()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).end()), &a[4]);
|
||||
}
|
||||
|
||||
void test_rbegin()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).rbegin().base()), &a[4]);
|
||||
}
|
||||
|
||||
void test_rend()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).rend().base()), &a[0]);
|
||||
}
|
||||
|
||||
void test_cbegin()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).cbegin()), &a[0]);
|
||||
}
|
||||
|
||||
void test_cend()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).cend()), &a[4]);
|
||||
}
|
||||
|
||||
void test_crbegin()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).crbegin().base()), &a[4]);
|
||||
}
|
||||
|
||||
void test_crend()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).crend().base()), &a[0]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_extent();
|
||||
test_default_construct_dynamic();
|
||||
test_default_construct_static();
|
||||
test_construct_data_size();
|
||||
test_construct_first_last();
|
||||
test_construct_array_dynamic();
|
||||
test_construct_array_static();
|
||||
test_construct_std_array_dynamic();
|
||||
test_construct_std_array_static();
|
||||
test_construct_const_std_array_dynamic();
|
||||
test_construct_const_std_array_static();
|
||||
test_construct_range();
|
||||
test_construct_span_dynamic();
|
||||
test_construct_span_dynamic_static();
|
||||
test_construct_span_static();
|
||||
test_construct_span_static_dynamic();
|
||||
test_copy_dynamic();
|
||||
test_copy_static();
|
||||
test_assign_dynamic();
|
||||
test_assign_static();
|
||||
test_first();
|
||||
test_last();
|
||||
test_subspan_dynamic();
|
||||
test_subspan_static();
|
||||
test_subspan();
|
||||
test_first_size();
|
||||
test_last_size();
|
||||
test_subspan_range();
|
||||
test_subspan_range_count();
|
||||
test_size();
|
||||
test_size_bytes();
|
||||
test_empty_dynamic();
|
||||
test_empty_static();
|
||||
test_index();
|
||||
test_front();
|
||||
test_back();
|
||||
test_data();
|
||||
test_begin();
|
||||
test_end();
|
||||
test_rbegin();
|
||||
test_rend();
|
||||
test_cbegin();
|
||||
test_cend();
|
||||
test_crbegin();
|
||||
test_crend();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
136
test/span_types_test.cpp
Normal file
136
test/span_types_test.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
void test_element_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::span<int>::element_type);
|
||||
BOOST_TEST_TRAIT_SAME(char,
|
||||
boost::span<char>::element_type);
|
||||
}
|
||||
|
||||
void test_value_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(char,
|
||||
boost::span<char>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::span<int>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::span<const int>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::span<volatile int>::value_type);
|
||||
BOOST_TEST_TRAIT_SAME(int,
|
||||
boost::span<const volatile int>::value_type);
|
||||
}
|
||||
|
||||
void test_size_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::span<char>::size_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::size_t,
|
||||
boost::span<int>::size_type);
|
||||
}
|
||||
|
||||
void test_difference_type()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::span<char>::difference_type);
|
||||
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
|
||||
boost::span<int>::difference_type);
|
||||
}
|
||||
|
||||
void test_pointer()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(char*,
|
||||
boost::span<char>::pointer);
|
||||
BOOST_TEST_TRAIT_SAME(int*,
|
||||
boost::span<int>::pointer);
|
||||
}
|
||||
|
||||
void test_const_pointer()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(const char*,
|
||||
boost::span<char>::const_pointer);
|
||||
BOOST_TEST_TRAIT_SAME(const int*,
|
||||
boost::span<int>::const_pointer);
|
||||
}
|
||||
|
||||
void test_reference()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(char&,
|
||||
boost::span<char>::reference);
|
||||
BOOST_TEST_TRAIT_SAME(int&,
|
||||
boost::span<int>::reference);
|
||||
}
|
||||
|
||||
void test_const_reference()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(const char&,
|
||||
boost::span<char>::const_reference);
|
||||
BOOST_TEST_TRAIT_SAME(const int&,
|
||||
boost::span<int>::const_reference);
|
||||
}
|
||||
|
||||
void test_iterator()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(char*,
|
||||
boost::span<char>::iterator);
|
||||
BOOST_TEST_TRAIT_SAME(int*,
|
||||
boost::span<int>::iterator);
|
||||
}
|
||||
|
||||
void test_const_iterator()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(const char*,
|
||||
boost::span<char>::const_iterator);
|
||||
BOOST_TEST_TRAIT_SAME(const int*,
|
||||
boost::span<int>::const_iterator);
|
||||
}
|
||||
|
||||
void test_reverse_iterator()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<char*>,
|
||||
boost::span<char>::reverse_iterator);
|
||||
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<int*>,
|
||||
boost::span<int>::reverse_iterator);
|
||||
}
|
||||
|
||||
void test_const_reverse_iterator()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<const char*>,
|
||||
boost::span<char>::const_reverse_iterator);
|
||||
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<const int*>,
|
||||
boost::span<int>::const_reverse_iterator);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_element_type();
|
||||
test_value_type();
|
||||
test_size_type();
|
||||
test_difference_type();
|
||||
test_pointer();
|
||||
test_const_pointer();
|
||||
test_reference();
|
||||
test_const_reference();
|
||||
test_iterator();
|
||||
test_const_iterator();
|
||||
test_reverse_iterator();
|
||||
test_const_reverse_iterator();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
38
test/splitmix64_test.cpp
Normal file
38
test/splitmix64_test.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Test for boost/core/detail/splitmix64.hpp
|
||||
//
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/splitmix64.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::detail::splitmix64 rng;
|
||||
|
||||
boost::uint64_t r1 = rng(), x1 = ( boost::uint64_t(0xe220a839u) << 32 ) + 0x7b1dcdafu;
|
||||
BOOST_TEST_EQ( r1, x1 );
|
||||
|
||||
for( int i = 0; i < 1000; ++i ) rng();
|
||||
|
||||
boost::uint64_t r2 = rng(), x2 = ( boost::uint64_t(0xdcad513cu) << 32 ) + 0x211f942du;
|
||||
BOOST_TEST_EQ( r2, x2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::detail::splitmix64 rng( 12345 );
|
||||
|
||||
boost::uint64_t r1 = rng(), x1 = ( boost::uint64_t(0x22118258u) << 32 ) + 0xa9d111a0u;
|
||||
BOOST_TEST_EQ( r1, x1 );
|
||||
|
||||
for( int i = 0; i < 1000; ++i ) rng();
|
||||
|
||||
boost::uint64_t r2 = rng(), x2 = ( boost::uint64_t(0xaaefb4b6u) << 32 ) + 0x5c15e958u;
|
||||
BOOST_TEST_EQ( r2, x2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/sv_common_reference_test.cpp
Normal file
34
test/sv_common_reference_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
|
||||
#if defined(BOOST_NO_CXX20_HDR_CONCEPTS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX20_HDR_CONCEPTS is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <concepts>
|
||||
#include <type_traits>
|
||||
|
||||
using T = std::common_reference_t< boost::core::string_view&&, std::string& >;
|
||||
|
||||
static_assert( std::common_reference_with< boost::core::string_view&&, std::string& > );
|
||||
static_assert( std::common_reference_with< boost::core::wstring_view&&, std::wstring const& > );
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME( std::common_reference_t< boost::core::string_view&&, std::string& >, boost::core::string_view );
|
||||
BOOST_TEST_TRAIT_SAME( std::common_reference_t< boost::core::wstring_view&&, std::wstring const& >, boost::core::wstring_view );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
24
test/sv_common_reference_test2.cpp
Normal file
24
test/sv_common_reference_test2.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
|
||||
#if !defined(__cpp_lib_ranges)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because __cpp_lib_ranges is not defined" )
|
||||
|
||||
#else
|
||||
|
||||
struct Iterator
|
||||
{
|
||||
using value_type = std::string;
|
||||
boost::core::string_view operator*() const noexcept;
|
||||
};
|
||||
|
||||
static_assert( std::indirectly_readable<Iterator> );
|
||||
|
||||
#endif
|
||||
145
test/sv_compare_test.cpp
Normal file
145
test/sv_compare_test.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::size_t const npos = boost::core::string_view::npos;
|
||||
|
||||
{
|
||||
boost::core::string_view sv1( "" );
|
||||
boost::core::string_view sv2( "" );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 0, sv2 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 1, sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 0, sv2 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 1, sv2 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, npos, sv2 ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 0, sv2, 0, 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 1, sv2, 0, 1 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 0, sv2, 0, 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 1, sv2, 0, 1 ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 0, 0, sv2, 1, 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 0, 1, sv2, 1, 1 ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( "" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( "1" ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 0, "" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 0, 0, "1" ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 1, "" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 0, 1, "1" ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 0, "" ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 1, "1" ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 0, "", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 0, "1", 0 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 0, 0, "1", 1 ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 1, "", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 1, "1", 0 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 0, 1, "1", 1 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 0, "", 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 1, "1", 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 1, 1, "1", 1 ), std::out_of_range );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv1( "123412345" );
|
||||
boost::core::string_view sv2( "1234" );
|
||||
|
||||
BOOST_TEST_GT( sv1.compare( sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_LT( sv1.compare( 0, 3, sv2 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 4, sv2 ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 0, 5, sv2 ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 0, npos, sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_LT( sv1.compare( 1, 0, sv2 ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 1, 1, sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_LT( sv1.compare( 4, 3, sv2 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 4, 4, sv2 ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 4, 5, sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_LT( sv1.compare( 9, 0, sv2 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 9, 1, sv2 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, 0, sv2 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, 1, sv2 ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_GT( sv1.compare( 0, 3, sv2, 0, 2 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 3, sv2, 0, 3 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 0, 3, sv2, 0, 4 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 0, 3, sv2, 0, 5 ), 0 );
|
||||
|
||||
BOOST_TEST_GT( sv1.compare( 0, 4, sv2, 0, 3 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 4, sv2, 0, 4 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 4, sv2, 0, 5 ), 0 );
|
||||
|
||||
BOOST_TEST_LT( sv1.compare( 5, 2, sv2, 1, npos ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 5, 3, sv2, 1, npos ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 5, 4, sv2, 1, npos ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 9, 0, sv2, 0, 0 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 9, 1, sv2, 0, 1 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, 0, sv2, 0, 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, 1, sv2, 0, 1 ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 0, 0, sv2, 4, 0 ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 0, 1, sv2, 4, 1 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 0, 0, sv2, 5, 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 0, 1, sv2, 5, 1 ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_GT( sv1.compare( "" ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( "12341234" ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( "123412344" ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( "123412345" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( "123412346" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( "1234123456" ), 0 );
|
||||
|
||||
BOOST_TEST_GT( sv1.compare( 4, 3, "" ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 4, 3, "1" ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 4, 3, "12" ), 0 );
|
||||
BOOST_TEST_GT( sv1.compare( 4, 3, "122" ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 4, 3, "123" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 4, 3, "124" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 4, 3, "1234" ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 9, 0, "" ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 9, 1, "1" ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, 0, "" ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, 1, "1" ), std::out_of_range );
|
||||
|
||||
BOOST_TEST_GT( sv1.compare( 4, npos, "123456", 4 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 4, npos, "123456", 5 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 4, npos, "123456", 6 ), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv1.compare( 9, npos, "", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv1.compare( 9, npos, "1", 0 ), 0 );
|
||||
BOOST_TEST_LT( sv1.compare( 9, npos, "1", 1 ), 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, npos, "", 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, npos, "1", 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv1.compare( 10, npos, "1", 1 ), std::out_of_range );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
346
test/sv_construct_test.cpp
Normal file
346
test/sv_construct_test.cpp
Normal file
@@ -0,0 +1,346 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
# include <memory_resource>
|
||||
#endif
|
||||
|
||||
template<class It> std::reverse_iterator<It> make_reverse_iterator( It it )
|
||||
{
|
||||
return std::reverse_iterator<It>( it );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv;
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), static_cast<char const*>(0) );
|
||||
BOOST_TEST_EQ( sv.size(), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "";
|
||||
|
||||
boost::core::string_view sv( s );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), s );
|
||||
BOOST_TEST_EQ( sv.size(), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "123";
|
||||
|
||||
boost::core::string_view sv( s );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), s );
|
||||
BOOST_TEST_EQ( sv.size(), 3 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "123";
|
||||
|
||||
boost::core::string_view sv( s, 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), s );
|
||||
BOOST_TEST_EQ( sv.size(), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "123";
|
||||
|
||||
boost::core::string_view sv( s, 2 );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), s );
|
||||
BOOST_TEST_EQ( sv.size(), 2 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "123";
|
||||
|
||||
boost::core::string_view sv( s, s );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), s );
|
||||
BOOST_TEST_EQ( sv.size(), 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "123";
|
||||
|
||||
boost::core::string_view sv( s, s + 2 );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), s );
|
||||
BOOST_TEST_EQ( sv.size(), 2 );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::string str = "123";
|
||||
|
||||
boost::core::string_view sv( str );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), str.data() );
|
||||
BOOST_TEST_EQ( sv.size(), str.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
{
|
||||
std::string_view str = "123";
|
||||
|
||||
boost::core::string_view sv( str );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), str.data() );
|
||||
BOOST_TEST_EQ( sv.size(), str.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
|
||||
{
|
||||
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
|
||||
|
||||
pmr_string str = "123";
|
||||
|
||||
boost::core::string_view sv( str );
|
||||
|
||||
BOOST_TEST_EQ( sv.data(), str.data() );
|
||||
BOOST_TEST_EQ( sv.size(), str.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.begin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
|
||||
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
|
||||
|
||||
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
|
||||
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
|
||||
|
||||
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
|
||||
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
|
||||
|
||||
BOOST_TEST_EQ( sv.length(), sv.size() );
|
||||
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
|
||||
|
||||
if( !sv.empty() )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv.front(), sv.data() );
|
||||
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
71
test/sv_contains_test.cpp
Normal file
71
test/sv_contains_test.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv( "" );
|
||||
|
||||
BOOST_TEST( sv.contains( boost::core::string_view() ) );
|
||||
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "" ) ) );
|
||||
BOOST_TEST( !sv.contains( boost::core::string_view( "1" ) ) );
|
||||
|
||||
BOOST_TEST( !sv.contains( '1' ) );
|
||||
|
||||
BOOST_TEST( sv.contains( "" ) );
|
||||
BOOST_TEST( !sv.contains( "1" ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "123123" );
|
||||
|
||||
BOOST_TEST( sv.contains( boost::core::string_view() ) );
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "" ) ) );
|
||||
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "1" ) ) );
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "2" ) ) );
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "3" ) ) );
|
||||
BOOST_TEST( !sv.contains( boost::core::string_view( "4" ) ) );
|
||||
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "12" ) ) );
|
||||
BOOST_TEST( sv.contains( boost::core::string_view( "23" ) ) );
|
||||
BOOST_TEST( !sv.contains( boost::core::string_view( "34" ) ) );
|
||||
BOOST_TEST( !sv.contains( boost::core::string_view( "21" ) ) );
|
||||
|
||||
BOOST_TEST( sv.contains( '1' ) );
|
||||
BOOST_TEST( sv.contains( '2' ) );
|
||||
BOOST_TEST( sv.contains( '3' ) );
|
||||
BOOST_TEST( !sv.contains( '4' ) );
|
||||
|
||||
BOOST_TEST( sv.contains( "" ) );
|
||||
|
||||
BOOST_TEST( sv.contains( "1" ) );
|
||||
BOOST_TEST( sv.contains( "2" ) );
|
||||
BOOST_TEST( sv.contains( "3" ) );
|
||||
BOOST_TEST( !sv.contains( "4" ) );
|
||||
|
||||
BOOST_TEST( sv.contains( "12" ) );
|
||||
BOOST_TEST( sv.contains( "23" ) );
|
||||
BOOST_TEST( !sv.contains( "34" ) );
|
||||
BOOST_TEST( !sv.contains( "21" ) );
|
||||
|
||||
BOOST_TEST( sv.contains( "123" ) );
|
||||
BOOST_TEST( !sv.contains( "234" ) );
|
||||
BOOST_TEST( sv.contains( "231" ) );
|
||||
BOOST_TEST( !sv.contains( "321" ) );
|
||||
|
||||
BOOST_TEST( !sv.contains( "1234" ) );
|
||||
BOOST_TEST( sv.contains( "1231" ) );
|
||||
|
||||
BOOST_TEST( sv.contains( "123123" ) );
|
||||
BOOST_TEST( !sv.contains( "1231231" ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
54
test/sv_conversion_test.cpp
Normal file
54
test/sv_conversion_test.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
# include <memory_resource>
|
||||
#endif
|
||||
|
||||
boost::core::string_view f( boost::core::string_view const& str )
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::string s1( "123" );
|
||||
std::string s2 = f( s1 );
|
||||
|
||||
BOOST_TEST_EQ( s1, s2 );
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
{
|
||||
std::string_view s1( "123" );
|
||||
std::string_view s2 = f( s1 );
|
||||
|
||||
BOOST_TEST_EQ( s1, s2 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
|
||||
{
|
||||
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
|
||||
|
||||
pmr_string s1( "123" );
|
||||
pmr_string s2 = f( s1 );
|
||||
|
||||
BOOST_TEST_EQ( s1, s2 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
32
test/sv_conversion_test2.cpp
Normal file
32
test/sv_conversion_test2.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/utility/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
boost::core::string_view f( boost::core::string_view const& str )
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::string s1( "123" );
|
||||
std::string s2 = f( s1 );
|
||||
|
||||
BOOST_TEST_EQ( s1, s2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::string_view s1( "123" );
|
||||
boost::string_view s2 = f( s1 );
|
||||
|
||||
BOOST_TEST_EQ( s1, s2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
52
test/sv_copy_test.cpp
Normal file
52
test/sv_copy_test.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv;
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( 0, 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.copy( 0, 0, 0 ), 0 );
|
||||
BOOST_TEST_THROWS( sv.copy( 0, 0, 1 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv.copy( 0, 0, boost::core::string_view::npos ), std::out_of_range );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "12345" );
|
||||
char buffer[ 8 ] = {};
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( buffer, 0 ), 0 );
|
||||
BOOST_TEST_EQ( buffer[0], 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( buffer, 0, 0 ), 0 );
|
||||
BOOST_TEST_EQ( buffer[0], 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( buffer, 0, 1 ), 0 );
|
||||
BOOST_TEST_EQ( buffer[0], 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv.copy( buffer, 0, boost::core::string_view::npos ), std::out_of_range );
|
||||
BOOST_TEST_EQ( buffer[0], 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( buffer, 1 ), 1 );
|
||||
BOOST_TEST_EQ( buffer[0], '1' );
|
||||
BOOST_TEST_EQ( buffer[1], 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( buffer, 1, 1 ), 1 );
|
||||
BOOST_TEST_EQ( buffer[0], '2' );
|
||||
BOOST_TEST_EQ( buffer[1], 0 );
|
||||
|
||||
BOOST_TEST_EQ( sv.copy( buffer, 8 ), 5 );
|
||||
BOOST_TEST_CSTR_EQ( buffer, "12345" );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
41
test/sv_element_access_test.cpp
Normal file
41
test/sv_element_access_test.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv( "12345" );
|
||||
|
||||
for( std::size_t i = 0; i < 5; ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( &sv[ i ], sv.data() + i );
|
||||
BOOST_TEST_EQ( &sv.at( i ), sv.data() + i );
|
||||
}
|
||||
|
||||
BOOST_TEST_THROWS( sv.at( 5 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv.at( boost::core::string_view::npos ), std::out_of_range );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv;
|
||||
|
||||
BOOST_TEST_THROWS( sv.at( 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv.at( 1 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv.at( boost::core::string_view::npos ), std::out_of_range );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "12345", 0 );
|
||||
|
||||
BOOST_TEST_THROWS( sv.at( 0 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv.at( 1 ), std::out_of_range );
|
||||
BOOST_TEST_THROWS( sv.at( boost::core::string_view::npos ), std::out_of_range );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
50
test/sv_ends_with_test.cpp
Normal file
50
test/sv_ends_with_test.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv( "" );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "" ) );
|
||||
|
||||
BOOST_TEST( !sv.ends_with( boost::core::string_view( "1" ) ) );
|
||||
BOOST_TEST( !sv.ends_with( '1' ) );
|
||||
BOOST_TEST( !sv.ends_with( "1" ) );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "123" );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "" ) );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "3" ) ) );
|
||||
BOOST_TEST( sv.ends_with( '3' ) );
|
||||
BOOST_TEST( sv.ends_with( "3" ) );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "23" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "23" ) );
|
||||
|
||||
BOOST_TEST( sv.ends_with( boost::core::string_view( "123" ) ) );
|
||||
BOOST_TEST( sv.ends_with( "123" ) );
|
||||
|
||||
BOOST_TEST( !sv.ends_with( boost::core::string_view( "1234" ) ) );
|
||||
BOOST_TEST( !sv.ends_with( "1234" ) );
|
||||
|
||||
BOOST_TEST( !sv.ends_with( boost::core::string_view( "2" ) ) );
|
||||
BOOST_TEST( !sv.ends_with( '2' ) );
|
||||
BOOST_TEST( !sv.ends_with( "2" ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
113
test/sv_eq_test.cpp
Normal file
113
test/sv_eq_test.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cstddef>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
# include <memory_resource>
|
||||
#endif
|
||||
|
||||
#define TEST_EQ(x, y) \
|
||||
BOOST_TEST_EQ(x, y); \
|
||||
BOOST_TEST_NOT((x) != (y)); \
|
||||
BOOST_TEST_LE(x, y); \
|
||||
BOOST_TEST_GE(x, y); \
|
||||
BOOST_TEST_NOT((x) < (y)); \
|
||||
BOOST_TEST_NOT((x) > (y))
|
||||
|
||||
#define TEST_NE(x, y) \
|
||||
BOOST_TEST_NE(x, y); \
|
||||
BOOST_TEST_NOT((x) == (y)); \
|
||||
BOOST_TEST((x) < (y) || (x) > (y));
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::string_view sv1( "" );
|
||||
boost::core::string_view sv2( "" );
|
||||
boost::core::string_view sv3( "123" );
|
||||
boost::core::string_view sv4( "123" );
|
||||
boost::core::string_view sv5( "12345" );
|
||||
boost::core::string_view sv6( "12345" );
|
||||
|
||||
TEST_EQ( sv1, sv1 );
|
||||
TEST_EQ( sv1, sv2 );
|
||||
TEST_NE( sv1, sv3 );
|
||||
TEST_NE( sv1, sv5 );
|
||||
|
||||
TEST_EQ( sv3, sv3 );
|
||||
TEST_EQ( sv3, sv4 );
|
||||
TEST_NE( sv3, sv1 );
|
||||
TEST_NE( sv3, sv5 );
|
||||
|
||||
TEST_EQ( sv5, sv5 );
|
||||
TEST_EQ( sv5, sv6 );
|
||||
TEST_NE( sv5, sv1 );
|
||||
TEST_NE( sv5, sv3 );
|
||||
|
||||
BOOST_TEST_EQ( sv1, std::string( "" ) );
|
||||
BOOST_TEST_EQ( std::string( "" ), sv1 );
|
||||
|
||||
BOOST_TEST_NE( sv1, std::string( "1" ) );
|
||||
BOOST_TEST_NE( std::string( "1" ), sv1 );
|
||||
|
||||
BOOST_TEST_EQ( sv3, std::string( "123" ) );
|
||||
BOOST_TEST_EQ( std::string( "123" ), sv3 );
|
||||
|
||||
BOOST_TEST_NE( sv3, std::string( "122" ) );
|
||||
BOOST_TEST_NE( std::string( "122" ), sv3 );
|
||||
|
||||
BOOST_TEST_EQ( sv1, "" );
|
||||
BOOST_TEST_EQ( "", sv1 );
|
||||
|
||||
BOOST_TEST_NE( sv1, "1" );
|
||||
BOOST_TEST_NE( "1", sv1 );
|
||||
|
||||
BOOST_TEST_EQ( sv3, "123" );
|
||||
BOOST_TEST_EQ( "123", sv3 );
|
||||
|
||||
BOOST_TEST_NE( sv3, "122" );
|
||||
BOOST_TEST_NE( "122", sv3 );
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
BOOST_TEST_EQ( sv1, std::string_view( "" ) );
|
||||
BOOST_TEST_EQ( std::string_view( "" ), sv1 );
|
||||
|
||||
BOOST_TEST_NE( sv1, std::string_view( "1" ) );
|
||||
BOOST_TEST_NE( std::string_view( "1" ), sv1 );
|
||||
|
||||
BOOST_TEST_EQ( sv3, std::string_view( "123" ) );
|
||||
BOOST_TEST_EQ( std::string_view( "123" ), sv3 );
|
||||
|
||||
BOOST_TEST_NE( sv3, std::string_view( "122" ) );
|
||||
BOOST_TEST_NE( std::string_view( "122" ), sv3 );
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
|
||||
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
|
||||
|
||||
BOOST_TEST_EQ( sv1, pmr_string( "" ) );
|
||||
BOOST_TEST_EQ( pmr_string( "" ), sv1 );
|
||||
|
||||
BOOST_TEST_NE( sv1, pmr_string( "1" ) );
|
||||
BOOST_TEST_NE( pmr_string( "1" ), sv1 );
|
||||
|
||||
BOOST_TEST_EQ( sv3, pmr_string( "123" ) );
|
||||
BOOST_TEST_EQ( pmr_string( "123" ), sv3 );
|
||||
|
||||
BOOST_TEST_NE( sv3, pmr_string( "122" ) );
|
||||
BOOST_TEST_NE( pmr_string( "122" ), sv3 );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
648
test/sv_find_first_not_of_test.cpp
Normal file
648
test/sv_find_first_not_of_test.cpp
Normal file
@@ -0,0 +1,648 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::size_t const npos = boost::core::string_view::npos;
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view() ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ) ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ) ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1' ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "" ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1" ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "12", 0, 0 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "12", 1, 0 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "12", 0, 1 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "12", 1, 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "12", 0, 2 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "12", 1, 2 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::wstring_view sv( L"" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view() ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ) ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ) ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1' ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"" ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1" ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 0, 0 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 1, 0 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 0, 1 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 1, 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 0, 2 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 1, 2 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "123123" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view() ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ) ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ) ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ) ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ) ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 4 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1' ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '1', 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3' ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '3', 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9' ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( '9', 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "" ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1" ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "1", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23" ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 4 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "23", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 0 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 0 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 0 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 0 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 0 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 1 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 1 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 1 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 1 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 1 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 2 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 2 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 3 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::wstring_view sv( L"123123" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view() ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ) ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ) ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ) ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ) ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 4 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1' ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3' ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9' ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"" ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1" ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23" ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 4 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 0 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 0 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 0 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 0 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 0 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 1 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 1 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 1 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 1 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 1 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 2 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 2 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 3 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::wstring_view sv( L"\x101\x102\x103\x101\x102\x103" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 0 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 0 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 0 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 0 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 0 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 1 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 1 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 1 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 1 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 1 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 1 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 2 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 2 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 2 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 3 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "123a123B123c" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789" ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 4 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 5 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 6 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 7 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 8 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 9 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 10 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 11 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 12 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::wstring_view sv( L"123a123B123c" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789" ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 4 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 5 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 6 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 7 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 8 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 9 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 10 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 11 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 12 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::string_view sv( "abc1abc2abc3" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::wstring_view sv( L"abc1abc2abc3" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
char str[ 256 ];
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
str[ i ] = static_cast< unsigned char >( i );
|
||||
}
|
||||
|
||||
boost::core::string_view sv( str, 256 );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( sv ), npos );
|
||||
|
||||
std::string str2( sv.data(), sv.size() );
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
std::string str3( str2 );
|
||||
|
||||
str3[ i ] = ~str3[ i ];
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i );
|
||||
}
|
||||
|
||||
std::reverse( str, str + 256 );
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
std::string str3( str2 );
|
||||
|
||||
str3[ i ] = ~str3[ i ];
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
wchar_t str[ 256 ];
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
str[ i ] = static_cast< wchar_t >( 0x100 + i );
|
||||
}
|
||||
|
||||
boost::core::wstring_view sv( str, 256 );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( sv ), npos );
|
||||
|
||||
std::wstring str2( sv.data(), sv.size() );
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
std::wstring str3( str2 );
|
||||
|
||||
str3[ i ] = ~str3[ i ];
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i );
|
||||
}
|
||||
|
||||
std::reverse( str, str + 256 );
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
std::wstring str3( str2 );
|
||||
|
||||
str3[ i ] = ~str3[ i ];
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i );
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
||||
|
||||
{
|
||||
boost::core::u8string_view sv( u8"123123" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"" ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1" ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 0 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 1 ), 1 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 2 ), 2 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 3 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 4 ), 4 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 5 ), 5 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23" ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 0 ), 0 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 4 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 7 ), npos );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 0 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 1 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 2 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 3 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 4 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 5 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 6 ), npos );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 7 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::u8string_view sv( u8"123a123B123c" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789" ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 4 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 5 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 6 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 7 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 8 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 9 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 10 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 11 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 12 ), npos );
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::u8string_view sv( u8"abc1abc2abc3" );
|
||||
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
|
||||
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user