forked from boostorg/core
Compare commits
125 Commits
feature/al
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f36d507f2 | ||
|
|
a77338b1cd | ||
|
|
965508d9e1 | ||
|
|
d03e58b77e | ||
|
|
f774295cdb | ||
|
|
c928c844da | ||
|
|
0a42ddabef | ||
|
|
04cc766db3 | ||
|
|
aa01ad8bf0 | ||
|
|
442e36f652 | ||
|
|
03040c7f5c | ||
|
|
8b31acf9a4 | ||
|
|
fd01cf788c | ||
|
|
31117ef800 | ||
|
|
083b41c17e | ||
|
|
a973490f53 | ||
|
|
8cc2fdad76 | ||
|
|
0fb4d92d83 | ||
|
|
76401063a6 | ||
|
|
c4bb59617c | ||
|
|
2d7e036416 | ||
|
|
4a0df827c1 | ||
|
|
59c0fb69f0 | ||
|
|
2f092c62fe | ||
|
|
ccfee3f638 | ||
|
|
45e7e1a91a | ||
|
|
ce20d15048 | ||
|
|
b077925d77 | ||
|
|
61191fc0a1 | ||
|
|
0a35bb6a20 | ||
|
|
95f0b35c36 | ||
|
|
7b1d3718c1 | ||
|
|
80e12e1116 | ||
|
|
6f70ee87a3 | ||
|
|
db20a49e48 | ||
|
|
a57c78221b | ||
|
|
e4adc769aa | ||
|
|
8af04d101c | ||
|
|
cece8ca5b4 | ||
|
|
6c95750f37 | ||
|
|
a9f1407d84 | ||
|
|
db0fd77af1 | ||
|
|
7cbbb08e7b | ||
|
|
ba6360e8ed | ||
|
|
2a70a0f239 | ||
|
|
31a2f7fb6b | ||
|
|
0120dbfe65 | ||
|
|
5f6fe65eb2 | ||
|
|
c7134904e2 | ||
|
|
9fc2a2f1ac | ||
|
|
216999e552 | ||
|
|
66890c3f3d | ||
|
|
8d6d20059a | ||
|
|
ee596e3d37 | ||
|
|
de8fe4fad7 | ||
|
|
d4db3eccec | ||
|
|
3b96d237c0 | ||
|
|
0e71b6158d | ||
|
|
23ef6d3531 | ||
|
|
e088fb8929 | ||
|
|
57151ab82e | ||
|
|
992326b1c8 | ||
|
|
4e769d1cdd | ||
|
|
bf17035a2d | ||
|
|
5a3b4df5de | ||
|
|
85527c4045 | ||
|
|
7ab05d5de0 | ||
|
|
266fbe6449 | ||
|
|
fd0de5f538 | ||
|
|
350526f7c7 | ||
|
|
06fef712c9 | ||
|
|
b7f7eb4f90 | ||
|
|
f41b8f38c4 | ||
|
|
b591214103 | ||
|
|
6b9f0cbf57 | ||
|
|
ecee9257d5 | ||
|
|
6c7edac9b1 | ||
|
|
049d3447ca | ||
|
|
b2fe98edf8 | ||
|
|
42c8898d24 | ||
|
|
f2eab6d6ff | ||
|
|
36fa78f53c | ||
|
|
97606908b7 | ||
|
|
5eb54d1d36 | ||
|
|
c91f8fabff | ||
|
|
5904fb5636 | ||
|
|
39978bde2b | ||
|
|
d5fa9ae50f | ||
|
|
2814b4ca1c | ||
|
|
c4e420f69d | ||
|
|
94628cb2f9 | ||
|
|
19f9aa93e1 | ||
|
|
2691efd1ca | ||
|
|
b6b1498275 | ||
|
|
379899ef15 | ||
|
|
3ab949d321 | ||
|
|
dbf0ea98b9 | ||
|
|
5afc91d52d | ||
|
|
f2a1532105 | ||
|
|
64e59db1f6 | ||
|
|
ceb4fff8fc | ||
|
|
0be25e19cc | ||
|
|
6debbeb377 | ||
|
|
4b859e3d39 | ||
|
|
38037b45f1 | ||
|
|
7664d7ab7e | ||
|
|
20d89b69db | ||
|
|
89c5a78129 | ||
|
|
249c5bece2 | ||
|
|
8977da6f50 | ||
|
|
edc0d935c0 | ||
|
|
7736b0b8ce | ||
|
|
90231ed7e0 | ||
|
|
1aa287e413 | ||
|
|
8c65a5b0e8 | ||
|
|
99515c341e | ||
|
|
42b3a3f111 | ||
|
|
c092532a71 | ||
|
|
3edd3aa982 | ||
|
|
c704d8b630 | ||
|
|
579a658129 | ||
|
|
4c7f35613e | ||
|
|
ece7a9ad9c | ||
|
|
5632ee0367 | ||
|
|
8052abb15c |
109
.drone.jsonnet
109
.drone.jsonnet
@@ -97,41 +97,40 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
|
||||
[
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.4",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
"Linux 16.04 GCC 4.4",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
|
||||
"g++-4.4",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.6 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
"Linux 16.04 GCC 4.6 32/64",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x', ADDRMD: '32,64' },
|
||||
"g++-4.6-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.7 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
"Linux 16.04 GCC 4.7 32/64",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x', ADDRMD: '32,64' },
|
||||
"g++-4.7-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.8* 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
"Linux 16.04 GCC 4.8 32/64",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
"g++-4.8-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.9 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
"Linux 16.04 GCC 4.9 32/64",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
"g++-4.9-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
@@ -194,17 +193,38 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 32 ASAN",
|
||||
"Linux 22.04 GCC 12 32/64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' },
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 64 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan,
|
||||
"g++-12-multilib",
|
||||
"Linux 23.04 GCC 13 32 ASAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 GCC 13 64 ASAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 GCC 13 32 UBSAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + ubsan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 GCC 13 64 UBSAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + ubsan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
@@ -313,16 +333,9 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14 UBSAN",
|
||||
"Linux 22.04 Clang 14",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
"clang-14",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-14",
|
||||
),
|
||||
|
||||
@@ -331,7 +344,27 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-15",
|
||||
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 Clang 16",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-16",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.10 Clang 17 UBSAN",
|
||||
"cppalliance/droneubuntu2310:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.10 Clang 17 ASAN",
|
||||
"cppalliance/droneubuntu2310:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
@@ -344,27 +377,39 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2015 msvc-14.0",
|
||||
"cppalliance/dronevs2015",
|
||||
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' },
|
||||
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2017 msvc-14.1",
|
||||
"cppalliance/dronevs2017",
|
||||
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
|
||||
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2019 msvc-14.2",
|
||||
"cppalliance/dronevs2019",
|
||||
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
|
||||
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2022 msvc-14.3",
|
||||
"cppalliance/dronevs2022:1",
|
||||
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
|
||||
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest', ADDRMD: '32,64' },
|
||||
),
|
||||
]
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
set -ex
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
DRONE_BUILD_DIR=$(pwd)
|
||||
|
||||
|
||||
445
.github/workflows/ci.yml
vendored
445
.github/workflows/ci.yml
vendored
@@ -1,5 +1,5 @@
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021-2022 Andrey Semashev
|
||||
# Copyright 2021-2024 Andrey Semashev
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
@@ -121,6 +121,13 @@ jobs:
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12-multilib
|
||||
- toolset: gcc-13
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
address-model: 32,64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.04
|
||||
install:
|
||||
- g++-13-multilib
|
||||
- name: UBSAN
|
||||
toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
@@ -221,34 +228,40 @@ jobs:
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-11
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-12
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-13
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-14
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-15
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
@@ -257,33 +270,57 @@ jobs:
|
||||
- clang-15
|
||||
- libc++-15-dev
|
||||
- libc++abi-15-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.04
|
||||
install:
|
||||
- clang-16
|
||||
- libc++-16-dev
|
||||
- libc++abi-16-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-17
|
||||
- libc++-17-dev
|
||||
- libc++abi-17-dev
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-14
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
ubsan: 1
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-14
|
||||
- libc++-14-dev
|
||||
- libc++abi-14-dev
|
||||
- clang-15
|
||||
- libc++-15-dev
|
||||
- libc++abi-15-dev
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-11
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-12
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-13
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-14
|
||||
|
||||
timeout-minutes: 120
|
||||
timeout-minutes: 45
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
@@ -312,8 +349,6 @@ jobs:
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
@@ -428,11 +463,25 @@ jobs:
|
||||
then
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
fi
|
||||
mkdir -p snapshot
|
||||
cd snapshot
|
||||
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
|
||||
then
|
||||
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
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
|
||||
mkdir -p libs
|
||||
rm -rf "libs/$LIBRARY"
|
||||
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
|
||||
rm -rf "../snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
@@ -451,7 +500,7 @@ jobs:
|
||||
- name: Run tests
|
||||
if: matrix.cmake_tests == ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
cd boost-root
|
||||
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
|
||||
if [ -n "${{matrix.build_variant}}" ]
|
||||
then
|
||||
@@ -466,7 +515,7 @@ jobs:
|
||||
if [ -n "${{matrix.ubsan}}" ]
|
||||
then
|
||||
export UBSAN_OPTIONS="print_stacktrace=1"
|
||||
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
|
||||
B2_ARGS+=("undefined-sanitizer=norecover" "linkflags=-fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
|
||||
fi
|
||||
if [ -n "${{matrix.cxxflags}}" ]
|
||||
then
|
||||
@@ -510,10 +559,9 @@ jobs:
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 45
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
@@ -527,10 +575,24 @@ jobs:
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
mkdir snapshot
|
||||
cd snapshot
|
||||
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
|
||||
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
|
||||
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
|
||||
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
|
||||
dir
|
||||
exit /b 1
|
||||
)
|
||||
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
if not exist "libs\" mkdir libs
|
||||
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
|
||||
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
@@ -539,7 +601,7 @@ jobs:
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
cd boost-root
|
||||
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:
|
||||
@@ -549,17 +611,19 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: |
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT -y ${{join(matrix.install, ' ')}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@@ -574,16 +638,34 @@ jobs:
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
mkdir -p snapshot
|
||||
cd snapshot
|
||||
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
|
||||
then
|
||||
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
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
|
||||
mkdir -p libs
|
||||
rm -rf "libs/$LIBRARY"
|
||||
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
|
||||
rm -rf "../snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
cd boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build . -- -j $BUILD_JOBS
|
||||
@@ -596,17 +678,19 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: |
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT -y ${{join(matrix.install, ' ')}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@@ -621,27 +705,45 @@ jobs:
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
mkdir -p snapshot
|
||||
cd snapshot
|
||||
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
|
||||
then
|
||||
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
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
|
||||
mkdir -p libs
|
||||
rm -rf "libs/$LIBRARY"
|
||||
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
|
||||
rm -rf "../snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
cd boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cd boost-root/__build__
|
||||
cmake --build . --target install -- -j $BUILD_JOBS
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cd boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build . -- -j $BUILD_JOBS
|
||||
ctest --output-on-failure --no-tests=error
|
||||
@@ -653,17 +755,23 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: |
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ninja-build ${{join(matrix.install, ' ')}}
|
||||
else
|
||||
brew install ninja ${{join(matrix.install, ' ')}}
|
||||
fi
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@@ -678,25 +786,264 @@ jobs:
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo BUILD_JOBS: $BUILD_JOBS
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
mkdir -p snapshot
|
||||
cd snapshot
|
||||
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
|
||||
then
|
||||
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
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
|
||||
mkdir -p libs
|
||||
rm -rf "libs/$LIBRARY"
|
||||
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
|
||||
rm -rf "../snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
cd boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
# Building tests on Mac OS using makefiles sometimes blocks until timeout, if multiple parallel build jobs are used. Use Ninja instead.
|
||||
cmake -G Ninja -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cd boost-root/__build__
|
||||
cmake --build . --target tests -- -j $BUILD_JOBS
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cd boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
windows-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
mkdir snapshot
|
||||
cd snapshot
|
||||
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
|
||||
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
|
||||
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
|
||||
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
|
||||
dir
|
||||
exit /b 1
|
||||
)
|
||||
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
if not exist "libs\" mkdir libs
|
||||
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
|
||||
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
|
||||
- name: Use library with add_subdirectory (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/libs/%LIBRARY%/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use library with add_subdirectory (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
mkdir snapshot
|
||||
cd snapshot
|
||||
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
|
||||
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
|
||||
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
|
||||
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
|
||||
dir
|
||||
exit /b 1
|
||||
)
|
||||
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
if not exist "libs\" mkdir libs
|
||||
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
|
||||
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
|
||||
- name: Install (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/__build__
|
||||
cmake --build . --target install --config Debug
|
||||
|
||||
- name: Install (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/__build__
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
- name: Use the installed library (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use the installed library (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
mkdir snapshot
|
||||
cd snapshot
|
||||
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
|
||||
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
|
||||
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
|
||||
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
|
||||
dir
|
||||
exit /b 1
|
||||
)
|
||||
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
if not exist "libs\" mkdir libs
|
||||
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
|
||||
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/__build__
|
||||
cmake --build . --target tests --config Debug
|
||||
|
||||
- name: Run tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Build tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/__build__
|
||||
cmake --build . --target tests --config Release
|
||||
|
||||
- name: Run tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
16
doc/bit.qbk
16
doc/bit.qbk
@@ -33,6 +33,11 @@ namespace core
|
||||
template<class To, class From>
|
||||
To bit_cast(From const& from) noexcept;
|
||||
|
||||
// byteswap
|
||||
|
||||
template<class T>
|
||||
constexpr T byteswap(T x) noexcept;
|
||||
|
||||
// Integral powers of 2
|
||||
|
||||
template<class T>
|
||||
@@ -102,6 +107,17 @@ constant expression context.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section byteswap]
|
||||
|
||||
`template<class T> constexpr T byteswap(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an integer type (i.e. one of `char`, `signed char`,
|
||||
`unsigned char`, `short`, `unsigned short`, `int`, `unsigned int`, `long`,
|
||||
`unsigned long`, `long long`, `unsigned long long`) without padding bits.
|
||||
* *Returns:* `x` with the storage bytes reversed.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Integral powers of 2]
|
||||
|
||||
`template<class T> constexpr bool has_single_bit(T x) noexcept;`
|
||||
|
||||
@@ -1,12 +1,57 @@
|
||||
[/
|
||||
Copyright 2021 Peter Dimov
|
||||
Copyright 2022 Andrey Semashev
|
||||
Copyright 2022-2024 Andrey Semashev
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section Revision History]
|
||||
|
||||
[section Changes in 1.85.0]
|
||||
|
||||
* Added a new [link core.functor `boost/core/functor.hpp`] header with a `functor` class template
|
||||
for wrapping a raw function into a function object class.
|
||||
* Changed [link core.null_deleter `null_deleter`], [link core.fclose_deleter `fclose_deleter`]
|
||||
and [link.checked_delete checked deleter] definitions so that they don't bring namespace `boost`
|
||||
into argument-dependent lookup in cases like this:
|
||||
```
|
||||
std::unique_ptr< std::FILE, boost::fclose_deleter > p1, p2;
|
||||
swap(p1, p2); // no longer looks for boost::swap as part of ADL
|
||||
```
|
||||
Users may need to either explicitly qualify the namespace of the called function or add a
|
||||
`using`-declaration.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.84.0]
|
||||
|
||||
* `boost::swap` utility function has been renamed to `boost::core::invoke_swap` to
|
||||
avoid forming a potential infinite recursion when the arguments are not swappable.
|
||||
The new function is defined in `boost/core/invoke_swap.hpp` and is functionally equivalent
|
||||
to `boost::swap`. The old `boost::swap` name is preserved for backward compatibility
|
||||
but deprecated and will be removed in a future release. Its `noexcept` specification
|
||||
has been removed to avoid compile errors caused by compile-time recursion.
|
||||
`BOOST_ALLOW_DEPRECATED_SYMBOLS` or `BOOST_ALLOW_DEPRECATED` can be defined to suppress
|
||||
deprecation warnings for the transition period. ([@https://github.com/boostorg/core/issues/148 #148])
|
||||
* Headers `boost/swap.hpp`, `boost/utility/swap.hpp` and `boost/core/swap.hpp` are
|
||||
deprecated and will be removed. Please, switch to `boost/core/invoke_swap.hpp`.
|
||||
`BOOST_ALLOW_DEPRECATED_HEADERS` or `BOOST_ALLOW_DEPRECATED` can be defined to suppress
|
||||
deprecation warnings.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.83.0]
|
||||
|
||||
* Added support for incomplete types to [link core.type_name `boost::core::type_name`].
|
||||
* Bit manipulation functions in [link core.bit `boost/core/bit.hpp`] are now
|
||||
`constexpr` on recent MSVC versions (VS2019 update 5 and later.)
|
||||
* Added `boost::core::byteswap` (an implementation of `std::byteswap` from
|
||||
C++23) to [link core.bit `boost/core/bit.hpp`].
|
||||
* Moved the yield primitives `sp_thread_pause`, `sp_thread_yield`, `sp_thread_sleep`
|
||||
from SmartPtr implementation details to `boost/core/yield_primitives.hpp`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.82.0]
|
||||
|
||||
* Added [link core.snprintf `boost/core/snprintf.hpp`] header with portable definitions of `snprintf`, `vsnprintf` and
|
||||
@@ -16,8 +61,21 @@
|
||||
or C++ standard library type traits instead.
|
||||
* Marked `boost::ref` member functions and associated methods with `noexcept`.
|
||||
* Marked `boost::swap` function with `noexcept`, depending on whether the type supports a non-throwing swap operation.
|
||||
* Added `boost::core::launder`, a portable implementation of `std::launder`.
|
||||
* Added `BOOST_CORE_ALIGNOF`, a portable implementation of `alignof`.
|
||||
* Added [link core.launder `boost::core::launder`], a portable implementation of `std::launder`.
|
||||
* Added [link core.alignof `BOOST_CORE_ALIGNOF`], a portable implementation of `alignof`.
|
||||
* Added [link core.max_align `boost::core::max_align_t`], a portable equivalent of `std::max_align_t`, and
|
||||
`boost::core::max_align`, the alignment of `max_align_t`.
|
||||
* Added [link core.memory_resource `boost::core::memory_resource`], a portable equivalent of `std::pmr::memory_resource`
|
||||
from C++17.
|
||||
* Added [link core.serialization `boost/core/serialization.hpp`], a collection of primitives allowing libraries to
|
||||
implement Boost.Serialization support for their types without including a Serialization header and thereby making
|
||||
their libraries depend on Serialization.
|
||||
* Added [link core.data `boost::data`], an implementation of `std::data`.
|
||||
* Added [link core.size `boost::size`], an implementation of `std::size`.
|
||||
* Updated `boost::span` to use `boost::data` which adds support for range
|
||||
construction from an `std::initializer_list`.
|
||||
* Added [link core.identity `boost::identity`], an implementation of
|
||||
`std::identity`. This facility has been moved from Boost.Functional.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
10
doc/core.qbk
10
doc/core.qbk
@@ -47,6 +47,7 @@ criteria for inclusion is that the utility component be:
|
||||
[include bit.qbk]
|
||||
[include checked_delete.qbk]
|
||||
[include cmath.qbk]
|
||||
[include data.qbk]
|
||||
[include default_allocator.qbk]
|
||||
[include demangle.qbk]
|
||||
[include empty_value.qbk]
|
||||
@@ -54,20 +55,28 @@ criteria for inclusion is that the utility component be:
|
||||
[include exchange.qbk]
|
||||
[include explicit_operator_bool.qbk]
|
||||
[include first_scalar.qbk]
|
||||
[include functor.qbk]
|
||||
[include identity.qbk]
|
||||
[include ignore_unused.qbk]
|
||||
[include is_same.qbk]
|
||||
[include launder.qbk]
|
||||
[include lightweight_test.qbk]
|
||||
[include make_span.qbk]
|
||||
[include max_align.qbk]
|
||||
[include memory_resource.qbk]
|
||||
[include no_exceptions_support.qbk]
|
||||
[include noinit_adaptor.qbk]
|
||||
[include noncopyable.qbk]
|
||||
[include null_deleter.qbk]
|
||||
[include fclose_deleter.qbk]
|
||||
[include nvp.qbk]
|
||||
[include pointer_in_range.qbk]
|
||||
[include pointer_traits.qbk]
|
||||
[include quick_exit.qbk]
|
||||
[include ref.qbk]
|
||||
[include scoped_enum.qbk]
|
||||
[include serialization.qbk]
|
||||
[include size.qbk]
|
||||
[include span.qbk]
|
||||
[include swap.qbk]
|
||||
[include typeinfo.qbk]
|
||||
@@ -76,3 +85,4 @@ criteria for inclusion is that the utility component be:
|
||||
[include uncaught_exceptions.qbk]
|
||||
[include use_default.qbk]
|
||||
[include verbose_terminate_handler.qbk]
|
||||
[include yield_primitives.qbk]
|
||||
|
||||
67
doc/data.qbk
Normal file
67
doc/data.qbk
Normal file
@@ -0,0 +1,67 @@
|
||||
[/
|
||||
Copyright 2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:data data]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/data.hpp> provides function templates `data`
|
||||
to obtain the pointer to the first element in a range.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class C>
|
||||
constexpr auto
|
||||
data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data());
|
||||
|
||||
template<class C>
|
||||
constexpr auto
|
||||
data(const C& c) noexcept(noexcept(c.data())) -> decltype(c.data());
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr T*
|
||||
data(T(&a)[N]) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr const T*
|
||||
data(std::initializer_list<T> l) noexcept;
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class C> constexpr auto data(C& c) noexcept(noexcept(c.data())) ->
|
||||
decltype(c.data());`]
|
||||
[Returns `c.data()`.]]
|
||||
[[`template<class C> constexpr auto data(const C& c)
|
||||
noexcept(noexcept(c.data())) -> decltype(c.data());`]
|
||||
[Returns `c.data()`.]]
|
||||
[[`template<class T, std::size_t N> constexpr T* data(T(&a)[N]) noexcept;`]
|
||||
[Returns `a`.]]
|
||||
[[`template<class T> constexpr const T* data(std::initializer_list<T> l)
|
||||
noexcept;`]
|
||||
[Returns `l.begin()`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
101
doc/functor.qbk
Normal file
101
doc/functor.qbk
Normal file
@@ -0,0 +1,101 @@
|
||||
[/
|
||||
/ Copyright (c) 2024 Andrey Semashev
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:functor functor]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Andrey Semashev
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/functor.hpp>]
|
||||
|
||||
[note This component requires a compiler supporting C++17 or newer.]
|
||||
|
||||
The header `<boost/core/functor.hpp>` defines the `boost::core::functor` class template
|
||||
that wraps a raw function specified in its template parameter into a function object class.
|
||||
The function object forwards any arguments passed to it to the wrapped function and returns
|
||||
the result of the call.
|
||||
|
||||
The `functor` wrapper can be useful in cases when a function object class type is required,
|
||||
for example, for use with smart pointers such as `std::unique_ptr`, where the actual logic
|
||||
of the function object is already implemented as a raw function, possibly provided by a
|
||||
third party library. Since `functor` is default-constructible and does not store a pointer
|
||||
to the wrapped function internally, using `functor` is less error-prone and more efficient
|
||||
than using the pointer to function instead. For example, with `std::unique_ptr` you don't
|
||||
need to pass a pointer to the deleter function in the `std::unique_ptr` constructor, and
|
||||
the `std::unique_ptr` object does not store and invoke a pointer to the deleter function.
|
||||
With `functor`, the deleter function becomes part of the `std::unique_ptr` type, which
|
||||
prevents mixing pointers with incompatible deleters.
|
||||
|
||||
```
|
||||
void my_deleter(void* p);
|
||||
|
||||
using malloc_ptr = std::unique_ptr< char, boost::core::functor< std::free > >;
|
||||
using my_ptr = std::unique_ptr< char, boost::core::functor< my_deleter > >;
|
||||
|
||||
my_ptr create_string(std::size_t size);
|
||||
void consume_string(my_ptr&& str);
|
||||
|
||||
malloc_ptr ptr1(static_cast< char* >(std::malloc(size)));
|
||||
// ptr1 = allocate_string(size); // error, cannot convert my_ptr to malloc_ptr
|
||||
my_ptr ptr2 = create_string(size); // ok
|
||||
|
||||
// consume_string(std::move(ptr1)); // error, cannot convert malloc_ptr&& to my_ptr
|
||||
consume_string(std::move(ptr2)); // ok
|
||||
```
|
||||
|
||||
Using `functor` may also be beneficial for reducing generated code sizes. For example, in
|
||||
order to avoid storing and invoking a pointer to the deleter function in `std::shared_ptr`,
|
||||
one may be inclined to use lambda functions to wrap the deleter function call like this:
|
||||
|
||||
```
|
||||
std::shared_ptr< int > ptr(static_cast< int* >(std::malloc(sizeof(int))), [](int* p) { std::free(p); });
|
||||
```
|
||||
|
||||
The problem is that every lambda function declaration introduces a unique type, even if
|
||||
the lambda function definition matches exactly one of the previously declared lambda
|
||||
functions. Thus, if `std::shared_ptr` objects like the one above are created in multiple
|
||||
places in the program, the definition of the shared pointer counter and associated code
|
||||
and data (e.g. virtual function table) will be duplicated for each instance.
|
||||
|
||||
Replacing the lambda function with `functor` solves this problem without sacrificing
|
||||
readability or efficiency:
|
||||
|
||||
```
|
||||
std::shared_ptr< int > ptr(static_cast< int* >(std::malloc(sizeof(int))), boost::core::functor< std::free >());
|
||||
```
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
```
|
||||
namespace boost::core {
|
||||
|
||||
template< auto Function >
|
||||
struct functor
|
||||
{
|
||||
template< typename... Args >
|
||||
decltype(auto) operator() (Args&&... args) const noexcept(...);
|
||||
};
|
||||
|
||||
} // namespace boost::core
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `template< typename... Args > decltype(auto) operator() (Args&&... args) const noexcept(...);`]
|
||||
|
||||
* *Effects:* `return Function(std::forward< Args >(args)...)`.
|
||||
* *Throws:* Nothing, unless invoking `Function` throws.
|
||||
* *Note:* This function only participates in overload resolution if `Function(std::forward< Args >(args)...)` is a valid call expression.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
61
doc/identity.qbk
Normal file
61
doc/identity.qbk
Normal file
@@ -0,0 +1,61 @@
|
||||
[/
|
||||
Copyright 2021-2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:identity identity]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/functional/identity.hpp> provides the function object
|
||||
`boost::identity` whose `operator()` returns its argument. It is an
|
||||
implementation of C++20's `std::identity` that supports C++03 and above.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
It is commonly used as the default projection in constrained algorithms.
|
||||
|
||||
```
|
||||
template<class Range, class Projection = boost::identity>
|
||||
void print(Range&& range, Projection projection = {});
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
struct identity {
|
||||
using is_transparent = unspecified;
|
||||
|
||||
template<class T>
|
||||
T&& operator()(T&& value) const noexcept;
|
||||
};
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Operators]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T> T&& operator()(T&& value) const noexcept;`]
|
||||
[Returns `std::forward<T>(value)`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
81
doc/make_span.qbk
Normal file
81
doc/make_span.qbk
Normal file
@@ -0,0 +1,81 @@
|
||||
[/
|
||||
Copyright 2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:make_span make_span]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/make_span.hpp> provides function templates `make_span`
|
||||
to conveniently create `span` objects. They are useful before C++17 where Class
|
||||
Template Argument Deduction (CTAD) is not available.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class I>
|
||||
constexpr span<I>
|
||||
make_span(I* d, std::size_t n) noexcept;
|
||||
|
||||
template<class I>
|
||||
constexpr span<I>
|
||||
make_span(I* b, I* e) noexcept;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr span<T, N>
|
||||
make_span(T(&a)[N]) noexcept;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr span<T, N>
|
||||
make_span(std::array<T, N>& a) noexcept;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr span<const T, N>
|
||||
make_span(const std::array<T, N>& a) noexcept;
|
||||
|
||||
template<class R>
|
||||
span<remove_pointer_t<iterator_t<R> > >
|
||||
make_span(R&& r);
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class I> span<I> make_span(I* f, std::size_t c);`]
|
||||
[Returns `span<I>(f, c)`.]]
|
||||
[[`template<class I> span<I> make_span(I* f, I* l);`]
|
||||
[Returns `span<I>(f, l)`.]]
|
||||
[[`template<class T, std::size_t N> span<T, N> make_span(T(&a)[N]);`]
|
||||
[Returns `span<T, N>(a)`.]]
|
||||
[[`template<class T, std::size_t N> span<T, N>
|
||||
make_span(std::array<T, N>& a);`]
|
||||
[Returns `span<T, N>(a)`.]]
|
||||
[[`template<class T, std::size_t N> span<const T, N>
|
||||
make_span(const std::array<T, N>& a);`]
|
||||
[Returns `span<const T, N>(a)`.]]
|
||||
[[`template<class R>
|
||||
span<remove_pointer_t<iterator_t<R> > >
|
||||
make_span(R&& r);`]
|
||||
[Returns `span<remove_pointer_t<iterator_t<R> > >(std::forward<R>(r))`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
42
doc/max_align.qbk
Normal file
42
doc/max_align.qbk
Normal file
@@ -0,0 +1,42 @@
|
||||
[/
|
||||
Copyright 2023 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:max_align max_align]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/max_align.hpp>]
|
||||
|
||||
The header `<boost/core/max_align.hpp>` defines the type
|
||||
`boost::core::max_align_t`, a portable equivalent of
|
||||
`std::max_align_t`, and the constant `boost::core::max_align`,
|
||||
the alignment of `max_align_t`.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
union max_align_t;
|
||||
|
||||
constexpr std::size_t max_align = alignof(max_align_t);
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
139
doc/memory_resource.qbk
Normal file
139
doc/memory_resource.qbk
Normal file
@@ -0,0 +1,139 @@
|
||||
[/
|
||||
Copyright 2023 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:memory_resource memory_resource]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/memory_resource.hpp>]
|
||||
|
||||
The header `<boost/core/memory_resource.hpp>` defines the class
|
||||
`boost::core::memory_resource`, a portable equivalent of
|
||||
`std::pmr::memory_resource` from C++17.
|
||||
|
||||
This is not a complete implementation of the standard `<memory_resource>`
|
||||
header; for such, one should use Boost.Container. The abstract base class
|
||||
is only provided by Core so that Boost libraries that provide and take
|
||||
advantage of PMR facilities such as concrete implementations of memory
|
||||
resources, or implementations of `polymorphic_allocator`, can interoperate.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
class memory_resource
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~memory_resource() = default;
|
||||
|
||||
[[nodiscard]] void* allocate( std::size_t bytes, std::size_t alignment = max_align );
|
||||
void deallocate( void* p, std::size_t bytes, std::size_t alignment = max_align );
|
||||
|
||||
bool is_equal( memory_resource const & other ) const noexcept;
|
||||
|
||||
private:
|
||||
|
||||
virtual void* do_allocate( std::size_t bytes, std::size_t alignment ) = 0;
|
||||
virtual void do_deallocate( void* p, std::size_t bytes, std::size_t alignment ) = 0;
|
||||
|
||||
virtual bool do_is_equal( memory_resource const& other ) const noexcept = 0;
|
||||
};
|
||||
|
||||
inline bool operator==( memory_resource const& a, memory_resource const& b ) noexcept;
|
||||
inline bool operator!=( memory_resource const& a, memory_resource const& b ) noexcept;
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `allocate`]
|
||||
|
||||
`[[nodiscard]] void* allocate( std::size_t bytes, std::size_t alignment = max_align );`
|
||||
|
||||
* *Returns:* `do_allocate( bytes, alignment )`.
|
||||
* *Remarks:* Implicitly creates objects in the returned region of storage.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `deallocate`]
|
||||
|
||||
`void deallocate( void* p, std::size_t bytes, std::size_t alignment = max_align );`
|
||||
|
||||
* *Effects:* `do_deallocate( bytes, alignment )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `is_equal`]
|
||||
|
||||
`bool is_equal( memory_resource const& other ) const noexcept;`
|
||||
|
||||
* *Returns:* `do_is_equal( other )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `do_allocate`]
|
||||
|
||||
`void* do_allocate( std::size_t bytes, std::size_t alignment ) = 0;`
|
||||
|
||||
* *Remarks:* A derived class should implement this member function to return
|
||||
a pointer to allocated storage of size at least `bytes` and alignment at
|
||||
least `alignment`.
|
||||
* *Throws:* An appropriate exception (by convention `std::bad_alloc` or
|
||||
derived) when storage with the specified size and alignment could not be
|
||||
obtained.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `do_deallocate`]
|
||||
|
||||
`void do_deallocate( void* p, std::size_t bytes, std::size_t alignment ) = 0;`
|
||||
|
||||
* *Remarks:* A derived class should implement this member function to deallocate
|
||||
a region of storage previously allocated by `do_allocate`.
|
||||
* *Throws:* Nothing.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `do_is_equal`]
|
||||
|
||||
`bool do_is_equal( memory_resource const& other ) const noexcept = 0;`
|
||||
|
||||
* *Remarks:* A derived class shall implement this function to return `true` if
|
||||
memory allocated from `*this` can be deallocated from `other` and vice-versa,
|
||||
otherwise `false`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `operator==`]
|
||||
|
||||
`bool operator==( memory_resource const& a, memory_resource const& b ) noexcept;`
|
||||
|
||||
* *Returns:* `&a == &b || a.is_equal( b )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `operator!=`]
|
||||
|
||||
`bool operator!=( memory_resource const& a, memory_resource const& b ) noexcept;`
|
||||
|
||||
* *Returns:* `!( a == b )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
81
doc/pointer_in_range.qbk
Normal file
81
doc/pointer_in_range.qbk
Normal file
@@ -0,0 +1,81 @@
|
||||
[/
|
||||
Copyright 2024 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:pointer_in_range pointer_in_range]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/pointer_in_range.hpp> provides the function template
|
||||
`boost::pointer_in_range` to check if a pointer is in a given range. This
|
||||
can be used in constant expressions in C++14 or higher when the compiler has a
|
||||
builtin to support `std::is_constant_evaluated`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following is an example of an allocator's deallocation function that does
|
||||
nothing if the pointer falls within a small automatically allocated buffer.
|
||||
|
||||
```
|
||||
template<class T, class N>
|
||||
void
|
||||
Allocator<T, N>::deallocate(pointer ptr, size_type)
|
||||
{
|
||||
if (!boost::pointer_in_range(ptr, buffer_, buffer_ + N)) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
constexpr bool pointer_in_range(const T* ptr, const T* begin, const T* end);
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T> constexpr bool pointer_in_range(const T* ptr,
|
||||
const T* begin, const T* end);`]
|
||||
[[variablelist
|
||||
[[Requires][`[begin,end)` is a valid range.]]
|
||||
[[Returns][`true` if `ptr` is in range `[begin,end)`, otherwise `false`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Notes]
|
||||
|
||||
If `boost::pointer_in_range` is not usable in constant expressions the macro
|
||||
`BOOST_CORE_NO_CONSTEXPR_POINTER_IN_RANGE` is defined.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section History]
|
||||
|
||||
Glen Fernandes implemented `pointer_in_range`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
145
doc/serialization.qbk
Normal file
145
doc/serialization.qbk
Normal file
@@ -0,0 +1,145 @@
|
||||
[/
|
||||
Copyright 2023 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:serialization serialization]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/serialization.hpp>]
|
||||
|
||||
The header `<boost/core/serialization.hpp>` implements primitives
|
||||
that are necessary to implement Boost.Serialization support without
|
||||
including a Boost.Serialization header and thereby making a library
|
||||
dependent on Boost.Serialization.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
#include <boost/core/nvp.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace serialization
|
||||
{
|
||||
|
||||
// forward declarations
|
||||
|
||||
template<class T> struct version;
|
||||
class access;
|
||||
|
||||
// core_version_type
|
||||
|
||||
struct core_version_type;
|
||||
|
||||
} // namespace serialization
|
||||
|
||||
namespace core
|
||||
{
|
||||
|
||||
// nvp
|
||||
|
||||
using serialization::nvp;
|
||||
using serialization::make_nvp;
|
||||
|
||||
// split_free
|
||||
|
||||
template<class Ar, class T> void split_free( Ar& ar, T& t, unsigned int v );
|
||||
|
||||
// split_member
|
||||
|
||||
template<class Ar, class T> void split_member( Ar& ar, T& t, unsigned int v );
|
||||
|
||||
// load_construct_data_adl
|
||||
|
||||
template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v );
|
||||
|
||||
// save_construct_data_adl
|
||||
|
||||
template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v );
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `core_version_type`]
|
||||
|
||||
``
|
||||
struct core_version_type
|
||||
{
|
||||
unsigned int version_;
|
||||
|
||||
core_version_type( unsigned int version ): version_( version ) {}
|
||||
operator unsigned int () const { return version_; }
|
||||
};
|
||||
``
|
||||
|
||||
`core_version_type` is a Core reimplementation of
|
||||
`boost::serialization::version_type`, needed to call ADL serialization
|
||||
primitives such as, for example, `load_construct_data` below.
|
||||
|
||||
It's defined in the `serialization` namespace instead of the `core`
|
||||
namespace because its only purpose is to add `boost::serialization` to
|
||||
the list of the associated namespaces of the corresponding call.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `split_free`]
|
||||
|
||||
`template<class Ar, class T> inline void split_free( Ar& ar, T& t, unsigned int v );`
|
||||
|
||||
`boost::core::split_free` is a Core reimplementation of
|
||||
`boost::serialization::split_free`.
|
||||
|
||||
* *Effects:*
|
||||
* If `Ar::is_saving::value` is `true`, calls `save( ar, t, core_version_type( v ) )`;
|
||||
* Otherwise, calls `load( ar, t, core_version_type( v ) )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `split_member`]
|
||||
|
||||
`template<class Ar, class T> void split_member( Ar& ar, T& t, unsigned int v );`
|
||||
|
||||
`boost::core::split_member` is a Core reimplementation of
|
||||
`boost::serialization::split_member`.
|
||||
|
||||
* *Effects:*
|
||||
* If `Ar::is_saving::value` is `true`, calls `t.save( ar, v )`;
|
||||
* Otherwise, calls `t.load( ar, v )`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `load_construct_data_adl`]
|
||||
|
||||
`template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v );`
|
||||
|
||||
`boost::core::load_construct_data_adl` is a Core reimplementation of
|
||||
`boost::serialization::load_construct_data_adl`.
|
||||
|
||||
* *Effects:* `load_construct_data( ar, t, serialization::core_version_type( v ) );`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section `save_construct_data_adl`]
|
||||
|
||||
`template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v );`
|
||||
|
||||
`boost::core::save_construct_data_adl` is a Core reimplementation of
|
||||
`boost::serialization::save_construct_data_adl`.
|
||||
|
||||
* *Effects:* `save_construct_data( ar, t, serialization::core_version_type( v ) );`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
54
doc/size.qbk
Normal file
54
doc/size.qbk
Normal file
@@ -0,0 +1,54 @@
|
||||
[/
|
||||
Copyright 2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:size size]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/size.hpp> provides function templates `size` to obtain
|
||||
the number of elements in a range.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class C>
|
||||
constexpr auto
|
||||
size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size());
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr std::size_t
|
||||
size(T(&)[N]) noexcept;
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[section Functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class C> constexpr auto size(const C& c)
|
||||
noexcept(noexcept(c.size())) -> decltype(c.size());`]
|
||||
[Returns `c.size()`.]]
|
||||
[[`template<class T, std::size_t N> constexpr std::size_t size(T(&)[N])
|
||||
noexcept;`]
|
||||
[Returns `N`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
10
doc/span.qbk
10
doc/span.qbk
@@ -149,7 +149,7 @@ 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())> >;
|
||||
span(R&&) -> span<remove_pointer_t<iterator_t<R> > >;
|
||||
|
||||
template<class T, std::size_t E>
|
||||
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
|
||||
@@ -227,13 +227,13 @@ constexpr span(R&& r);`]
|
||||
[`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())>(*)[],
|
||||
[`data(r)` is well-formed and
|
||||
`is_convertible_v<remove_pointer_t<iterator_t<R> >(*)[],
|
||||
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.]]]]]
|
||||
[[Effects][Constructs a `span` with data `data(r)` and size `r.size()`.]]
|
||||
[[Throws][What and when data(r) 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;`]
|
||||
|
||||
35
doc/swap.qbk
35
doc/swap.qbk
@@ -20,17 +20,17 @@
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/swap.hpp>]
|
||||
[section Header <boost/core/invoke_swap.hpp>]
|
||||
|
||||
[^template<class T> void swap(T& left, T& right) noexcept(['see below]);]
|
||||
[^template<class T> void invoke_swap(T& left, T& right) noexcept(['see below]);]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Introduction]
|
||||
|
||||
The template function `boost::swap` allows the values of two
|
||||
variables to be swapped, using argument dependent lookup to
|
||||
select a specialized swap function if available. If no
|
||||
The template function `boost::core::invoke_swap` allows the
|
||||
values of two variables to be swapped, using argument dependent
|
||||
lookup to select a specialized swap function if available. If no
|
||||
specialized swap function is available, `std::swap` is used.
|
||||
|
||||
[endsect]
|
||||
@@ -56,9 +56,9 @@ Although this is legal C++, no Boost libraries use this method,
|
||||
whereas many Boost libraries provide specialized swap functions
|
||||
in their own namespaces.
|
||||
|
||||
`boost::swap` also supports swapping built-in arrays. Note that
|
||||
`std::swap` originally did not do so, but a request to add an
|
||||
overload of `std::swap` for built-in arrays has been accepted
|
||||
`boost::core::invoke_swap` also supports swapping built-in arrays.
|
||||
Note that `std::swap` originally did not do so, but a request to
|
||||
add an overload of `std::swap` for built-in arrays has been accepted
|
||||
by the C++ Standards Committee[footnote
|
||||
[@http://open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#809
|
||||
LWG Defect Report 809: std::swap should be overloaded for array
|
||||
@@ -68,14 +68,15 @@ by the C++ Standards Committee[footnote
|
||||
|
||||
[section Exception Safety]
|
||||
|
||||
`boost::swap` provides the same exception guarantee as the
|
||||
underlying swap function used, with one exception; for an array
|
||||
`boost::core::invoke_swap` provides the same exception guarantee as
|
||||
the underlying swap function used, with one exception; for an array
|
||||
of type `T[n]`, where `n > 1` and the underlying swap function
|
||||
for `T` provides the strong exception guarantee, `boost::swap`
|
||||
provides only the basic exception guarantee.
|
||||
for `T` provides the strong exception guarantee,
|
||||
`boost::core::invoke_swap` provides only the basic exception guarantee.
|
||||
|
||||
In C++11 and later, `boost::swap` propagates the same `noexcept`
|
||||
specification as the one specified in the underlying swap function.
|
||||
In C++11 and later, `boost::core::invoke_swap` propagates the same
|
||||
`noexcept` specification as the one specified in the underlying swap
|
||||
function.
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -104,7 +105,7 @@ Or:
|
||||
[section Portability]
|
||||
|
||||
Several older compilers do not support argument dependent
|
||||
lookup. On these compilers `boost::swap` will call
|
||||
lookup. On these compilers `boost::core::invoke_swap` will call
|
||||
`std::swap`, ignoring any specialized swap functions that
|
||||
could be found as a result of argument dependent lookup.
|
||||
|
||||
@@ -118,7 +119,9 @@ could be found as a result of argument dependent lookup.
|
||||
tests, and documentation
|
||||
* *Steven Watanabe* - for the idea to make `boost::swap` less
|
||||
specialized than `std::swap`, thereby allowing the function
|
||||
to have the name 'swap' without introducing ambiguity
|
||||
to have the name 'swap' without introducing ambiguity. However,
|
||||
later the function was renamed to `boost::core::invoke_swap`
|
||||
to avoid potential infinite recursion.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
79
doc/yield_primitives.qbk
Normal file
79
doc/yield_primitives.qbk
Normal file
@@ -0,0 +1,79 @@
|
||||
[/
|
||||
Copyright 2023 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
https://boost.org/LICENSE_1_0.txt
|
||||
]
|
||||
|
||||
[section:yield_primitives Yield Primitives]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Peter Dimov
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/yield_primitives.hpp>]
|
||||
|
||||
The header `<boost/core/yield_primitives.hpp>` implements a
|
||||
collection of primitives that allow the current thread to
|
||||
yield the CPU in various ways.
|
||||
|
||||
Very low level, specialized functionality, generally only useful for
|
||||
implementing spinlocks. Normal synchronization primitives should
|
||||
almost always be preferable in application code.
|
||||
|
||||
[section Synopsis]
|
||||
|
||||
``
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
void sp_thread_pause() noexcept;
|
||||
void sp_thread_yield() noexcept;
|
||||
void sp_thread_sleep() noexcept;
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section sp_thread_pause]
|
||||
|
||||
`void sp_thread_pause() noexcept;`
|
||||
|
||||
Emits a PAUSE instruction (on x86) or a YIELD instruction (on ARM).
|
||||
|
||||
A portable equivalent of the GCC builtin function `__builtin_ia32_pause`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section sp_thread_yield]
|
||||
|
||||
`void sp_thread_yield() noexcept;`
|
||||
|
||||
Informs the scheduler that the current thread wishes to relinquish
|
||||
the rest of its timeslice.
|
||||
|
||||
A portable equivalent of POSIX `sched_yield`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section sp_thread_sleep]
|
||||
|
||||
`void sp_thread_sleep() noexcept;`
|
||||
|
||||
Sleeps for a short period, as if by calling POSIX `nanosleep` with
|
||||
a small, implementation-dependent, interval (usually one microsecond).
|
||||
|
||||
A more forcing yield primitive than `sp_thread_yield`, because it's
|
||||
generally not ignored even if all other waiting threads are of lower
|
||||
priority.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
#define BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
#ifndef BOOST_CORE_ALIGNOF_HPP_INCLUDED
|
||||
#define BOOST_CORE_ALIGNOF_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
@@ -54,4 +54,4 @@ template<class T> struct alignof_helper
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
#endif // #ifndef BOOST_CORE_ALIGNOF_HPP_INCLUDED
|
||||
|
||||
@@ -43,9 +43,17 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
#if defined(_STL_DISABLE_DEPRECATED_WARNING)
|
||||
_STL_DISABLE_DEPRECATED_WARNING
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning("-Wdeprecated-declarations")
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4996)
|
||||
#elif defined(BOOST_GCC) && BOOST_GCC >= 40600
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
@@ -807,9 +815,15 @@ using allocator_rebind_t = typename allocator_rebind<A, T>::type;
|
||||
|
||||
} /* boost */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning("-Wdeprecated-declarations")
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#elif defined(BOOST_GCC) && BOOST_GCC >= 40600
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(_STL_RESTORE_DEPRECATED_WARNING)
|
||||
_STL_RESTORE_DEPRECATED_WARNING
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
@@ -38,6 +39,27 @@
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1925
|
||||
# define BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL
|
||||
#endif
|
||||
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__builtin_bit_cast)
|
||||
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
||||
# endif
|
||||
# if __has_builtin(__builtin_bswap16)
|
||||
# define BOOST_CORE_HAS_BUILTIN_BSWAP16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_CORE_HAS_BUILTIN_BIT_CAST) && (defined(BOOST_MSVC) && BOOST_MSVC >= 1926)
|
||||
# define BOOST_CORE_HAS_BUILTIN_BIT_CAST
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_CORE_HAS_BUILTIN_BSWAP16) && (defined(BOOST_GCC) && BOOST_GCC >= 40800)
|
||||
# define BOOST_CORE_HAS_BUILTIN_BSWAP16
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
@@ -45,6 +67,16 @@ namespace core
|
||||
|
||||
// bit_cast
|
||||
|
||||
#if defined(BOOST_CORE_HAS_BUILTIN_BIT_CAST)
|
||||
|
||||
template<class To, class From>
|
||||
BOOST_CONSTEXPR To bit_cast( From const & from ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_bit_cast( To, from );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class To, class From>
|
||||
To bit_cast( From const & from ) BOOST_NOEXCEPT
|
||||
{
|
||||
@@ -55,6 +87,8 @@ To bit_cast( From const & from ) BOOST_NOEXCEPT
|
||||
return to;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// countl
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
@@ -102,10 +136,51 @@ BOOST_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if defined(_MSC_VER) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( __builtin_is_constant_evaluated() )
|
||||
{
|
||||
constexpr unsigned char mod37[ 37 ] = { 32, 31, 6, 30, 9, 5, 0, 29, 16, 8, 2, 4, 21, 0, 19, 28, 25, 15, 0, 7, 10, 1, 17, 3, 22, 20, 26, 0, 11, 18, 23, 27, 12, 24, 13, 14, 0 };
|
||||
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
|
||||
return mod37[ x % 37 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse( &r, x ) )
|
||||
{
|
||||
return 31 - static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 24;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 16;
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse( &r, x ) )
|
||||
@@ -116,44 +191,6 @@ inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static unsigned char const mod37[ 37 ] = { 32, 31, 6, 30, 9, 5, 0, 29, 16, 8, 2, 4, 21, 0, 19, 28, 25, 15, 0, 7, 10, 1, 17, 3, 22, 20, 26, 0, 11, 18, 23, 27, 12, 24, 13, 14, 0 };
|
||||
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
|
||||
return mod37[ x % 37 ];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse64( &r, x ) )
|
||||
{
|
||||
return 63 - static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return static_cast<boost::uint32_t>( x >> 32 ) != 0?
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ):
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
@@ -166,10 +203,98 @@ inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 16;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline int countl_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
static unsigned char const mod37[ 37 ] = { 32, 31, 6, 30, 9, 5, 0, 29, 16, 8, 2, 4, 21, 0, 19, 28, 25, 15, 0, 7, 10, 1, 17, 3, 22, 20, 26, 0, 11, 18, 23, 27, 12, 24, 13, 14, 0 };
|
||||
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
|
||||
return mod37[ x % 37 ];
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 24;
|
||||
}
|
||||
|
||||
inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) - 16;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_X64) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( __builtin_is_constant_evaluated() )
|
||||
{
|
||||
return static_cast<boost::uint32_t>( x >> 32 ) != 0?
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ):
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse64( &r, x ) )
|
||||
{
|
||||
return 63 - static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||
|
||||
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanReverse64( &r, x ) )
|
||||
{
|
||||
return 63 - static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<boost::uint32_t>( x >> 32 ) != 0?
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ):
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<boost::uint32_t>( x >> 32 ) != 0?
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x >> 32 ) ):
|
||||
boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ) + 32;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
BOOST_CXX14_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
@@ -250,10 +375,44 @@ BOOST_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if defined(_MSC_VER) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( __builtin_is_constant_evaluated() )
|
||||
{
|
||||
constexpr unsigned char mod37[ 37 ] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };
|
||||
return mod37[ ( -(boost::int32_t)x & x ) % 37 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward( &r, x ) )
|
||||
{
|
||||
return static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x100 );
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x10000 );
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward( &r, x ) )
|
||||
@@ -264,37 +423,6 @@ inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static unsigned char const mod37[ 37 ] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };
|
||||
return mod37[ ( -(boost::int32_t)x & x ) % 37 ];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward64( &r, x ) )
|
||||
{
|
||||
return static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
return static_cast<boost::uint32_t>( x ) != 0?
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ):
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
@@ -307,10 +435,91 @@ inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x10000 );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline int countr_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
static unsigned char const mod37[ 37 ] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };
|
||||
return mod37[ ( -(boost::int32_t)x & x ) % 37 ];
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x100 );
|
||||
}
|
||||
|
||||
inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) | 0x10000 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_X64) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( __builtin_is_constant_evaluated() )
|
||||
{
|
||||
return static_cast<boost::uint32_t>( x ) != 0?
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ):
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward64( &r, x ) )
|
||||
{
|
||||
return static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||
|
||||
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
unsigned long r;
|
||||
|
||||
if( _BitScanForward64( &r, x ) )
|
||||
{
|
||||
return static_cast<int>( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<boost::uint32_t>( x ) != 0?
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ):
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<boost::uint32_t>( x ) != 0?
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ):
|
||||
boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x >> 32 ) ) + 32;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
BOOST_CXX14_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
@@ -446,7 +655,7 @@ BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
unsigned const mask = std::numeric_limits<T>::digits - 1;
|
||||
return x << (s & mask) | x >> ((-s) & mask);
|
||||
return static_cast<T>( x << (static_cast<unsigned>( s ) & mask) | x >> (static_cast<unsigned>( -s ) & mask) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -455,7 +664,7 @@ BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
unsigned const mask = std::numeric_limits<T>::digits - 1;
|
||||
return x >> (s & mask) | x << ((-s) & mask);
|
||||
return static_cast<T>( x >> (static_cast<unsigned>( s ) & mask) | x << (static_cast<unsigned>( -s ) & mask) );
|
||||
}
|
||||
|
||||
// integral powers of 2
|
||||
@@ -484,7 +693,7 @@ BOOST_CONSTEXPR T bit_floor( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return x == 0? 0: T(1) << ( boost::core::bit_width( x ) - 1 );
|
||||
return x == 0? T(0): static_cast<T>( T(1) << ( boost::core::bit_width( x ) - 1 ) );
|
||||
}
|
||||
|
||||
namespace detail
|
||||
@@ -613,6 +822,128 @@ typedef endian::type endian_type;
|
||||
|
||||
#undef BOOST_CORE_BIT_NATIVE_INITIALIZER
|
||||
|
||||
// byteswap
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_CONSTEXPR inline boost::uint8_t byteswap_impl( boost::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
#if defined(BOOST_CORE_HAS_BUILTIN_BSWAP16)
|
||||
|
||||
BOOST_CONSTEXPR inline boost::uint16_t byteswap_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_bswap16( x );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOST_CONSTEXPR inline boost::uint16_t byteswap_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<boost::uint16_t>( x << 8 | x >> 8 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_bswap32( x );
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint64_t byteswap_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return __builtin_bswap64( x );
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( __builtin_is_constant_evaluated() )
|
||||
{
|
||||
boost::uint32_t step16 = x << 16 | x >> 16;
|
||||
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _byteswap_ulong( x );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint64_t byteswap_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( __builtin_is_constant_evaluated() )
|
||||
{
|
||||
boost::uint64_t step32 = x << 32 | x >> 32;
|
||||
boost::uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
|
||||
return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _byteswap_uint64( x );
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return _byteswap_ulong( x );
|
||||
}
|
||||
|
||||
inline boost::uint64_t byteswap_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return _byteswap_uint64( x );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint32_t byteswap_impl( boost::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
boost::uint32_t step16 = x << 16 | x >> 16;
|
||||
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline boost::uint64_t byteswap_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
boost::uint64_t step32 = x << 32 | x >> 32;
|
||||
boost::uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
|
||||
return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T> BOOST_CXX14_CONSTEXPR T byteswap( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer );
|
||||
|
||||
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) );
|
||||
|
||||
BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) )
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::byteswap_impl( static_cast<boost::uint8_t>( x ) ) );
|
||||
}
|
||||
else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint16_t) )
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::byteswap_impl( static_cast<boost::uint16_t>( x ) ) );
|
||||
}
|
||||
else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint32_t) )
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::byteswap_impl( static_cast<boost::uint32_t>( x ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return static_cast<T>( boost::core::detail::byteswap_impl( static_cast<boost::uint64_t>( x ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -30,19 +30,40 @@ namespace boost
|
||||
|
||||
template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
|
||||
{
|
||||
// intentionally complex - simplification causes regressions
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
|
||||
|
||||
static_assert( sizeof(T) != 0, "Type must be complete" );
|
||||
|
||||
#else
|
||||
|
||||
typedef char type_must_be_complete[ sizeof(T) ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
|
||||
#endif
|
||||
|
||||
delete x;
|
||||
}
|
||||
|
||||
template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
|
||||
{
|
||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
||||
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
|
||||
|
||||
static_assert( sizeof(T) != 0, "Type must be complete" );
|
||||
|
||||
#else
|
||||
|
||||
typedef char type_must_be_complete[ sizeof(T) ];
|
||||
(void) sizeof(type_must_be_complete);
|
||||
|
||||
#endif
|
||||
|
||||
delete [] x;
|
||||
}
|
||||
|
||||
// Block unintended ADL
|
||||
namespace checked_deleters
|
||||
{
|
||||
|
||||
template<class T> struct checked_deleter
|
||||
{
|
||||
typedef void result_type;
|
||||
@@ -66,6 +87,11 @@ template<class T> struct checked_array_deleter
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace checked_deleters
|
||||
|
||||
using checked_deleters::checked_deleter;
|
||||
using checked_deleters::checked_array_deleter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_CHECKED_DELETE_HPP
|
||||
|
||||
46
include/boost/core/data.hpp
Normal file
46
include/boost/core/data.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2023 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_DATA_HPP
|
||||
#define BOOST_CORE_DATA_HPP
|
||||
|
||||
#include <initializer_list>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class C>
|
||||
inline constexpr auto
|
||||
data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data())
|
||||
{
|
||||
return c.data();
|
||||
}
|
||||
|
||||
template<class C>
|
||||
inline constexpr auto
|
||||
data(const C& c) noexcept(noexcept(c.data())) -> decltype(c.data())
|
||||
{
|
||||
return c.data();
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline constexpr T*
|
||||
data(T(&a)[N]) noexcept
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline constexpr const T*
|
||||
data(std::initializer_list<T> l) noexcept
|
||||
{
|
||||
return l.begin();
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -35,9 +35,13 @@ inline void lwt_unattended()
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
# endif
|
||||
|
||||
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == 100 /*WINAPI_FAMILY_DESKTOP_APP*/
|
||||
|
||||
// disable message box on crash
|
||||
::_seterrormode( /*SEM_NOGPFAULTERRORBOX*/ 0x0002 );
|
||||
|
||||
#endif
|
||||
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
|
||||
58
include/boost/core/detail/minstd_rand.hpp
Normal file
58
include/boost/core/detail/minstd_rand.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef BOOST_CORE_DETAIL_MINSTD_RAND_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_MINSTD_RAND_HPP_INCLUDED
|
||||
|
||||
// Copyright 2017 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
|
||||
//
|
||||
// An implementation of minstd_rand that does not require
|
||||
// the Random library
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class minstd_rand
|
||||
{
|
||||
private:
|
||||
|
||||
boost::uint_least32_t x_;
|
||||
|
||||
enum { a = 48271, m = 2147483647 };
|
||||
|
||||
public:
|
||||
|
||||
minstd_rand(): x_( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
explicit minstd_rand( boost::uint_least32_t x ): x_( x % m )
|
||||
{
|
||||
if( x_ == 0 )
|
||||
{
|
||||
x_ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
boost::uint_least32_t operator()()
|
||||
{
|
||||
boost::uint_least64_t y = x_;
|
||||
|
||||
y = ( a * y ) % m;
|
||||
|
||||
x_ = static_cast<boost::uint_least32_t>( y );
|
||||
|
||||
return x_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_MINSTD_RAND_HPP_INCLUDED
|
||||
71
include/boost/core/detail/sp_thread_pause.hpp
Normal file
71
include/boost/core/detail/sp_thread_pause.hpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef BOOST_CORE_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/detail/sp_thread_pause.hpp
|
||||
//
|
||||
// inline void bost::core::sp_thread_pause();
|
||||
//
|
||||
// Emits a "pause" instruction.
|
||||
//
|
||||
// Copyright 2008, 2020, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__builtin_ia32_pause) && !defined(__INTEL_COMPILER)
|
||||
# define BOOST_CORE_HAS_BUILTIN_IA32_PAUSE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_CORE_HAS_BUILTIN_IA32_PAUSE)
|
||||
|
||||
# define BOOST_CORE_SP_PAUSE() __builtin_ia32_pause()
|
||||
|
||||
#elif defined(_MSC_VER) && ( defined(_M_IX86) || defined(_M_X64) )
|
||||
|
||||
# include <intrin.h>
|
||||
# define BOOST_CORE_SP_PAUSE() _mm_pause()
|
||||
|
||||
#elif defined(_MSC_VER) && ( defined(_M_ARM) || defined(_M_ARM64) )
|
||||
|
||||
# include <intrin.h>
|
||||
# define BOOST_CORE_SP_PAUSE() __yield()
|
||||
|
||||
#elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
|
||||
|
||||
# define BOOST_CORE_SP_PAUSE() __asm__ __volatile__( "rep; nop" : : : "memory" )
|
||||
|
||||
#elif defined(__GNUC__) && ( (defined(__ARM_ARCH) && __ARM_ARCH >= 8) || defined(__ARM_ARCH_8A__) || defined(__aarch64__) )
|
||||
|
||||
# define BOOST_CORE_SP_PAUSE() __asm__ __volatile__( "yield" : : : "memory" )
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_CORE_SP_PAUSE() ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
BOOST_FORCEINLINE void sp_thread_pause() BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_CORE_SP_PAUSE();
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_CORE_SP_PAUSE
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
|
||||
122
include/boost/core/detail/sp_thread_sleep.hpp
Normal file
122
include/boost/core/detail/sp_thread_sleep.hpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef BOOST_CORE_DETAIL_SP_THREAD_SLEEP_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_SP_THREAD_SLEEP_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/detail/sp_thread_sleep.hpp
|
||||
//
|
||||
// inline void bost::core::sp_thread_sleep();
|
||||
//
|
||||
// Cease execution for a while to yield to other threads,
|
||||
// as if by calling nanosleep() with an appropriate interval.
|
||||
//
|
||||
// Copyright 2008, 2020, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
|
||||
|
||||
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||
BOOST_PRAGMA_MESSAGE("Using Sleep(1) in sp_thread_sleep")
|
||||
#endif
|
||||
|
||||
#include <boost/core/detail/sp_win32_sleep.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void sp_thread_sleep() BOOST_NOEXCEPT
|
||||
{
|
||||
Sleep( 1 );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using boost::core::detail::sp_thread_sleep;
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#elif defined(BOOST_HAS_NANOSLEEP)
|
||||
|
||||
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||
BOOST_PRAGMA_MESSAGE("Using nanosleep() in sp_thread_sleep")
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
inline void sp_thread_sleep() BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
|
||||
|
||||
int oldst;
|
||||
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldst );
|
||||
|
||||
#endif
|
||||
|
||||
// g++ -Wextra warns on {} or {0}
|
||||
struct timespec rqtp = { 0, 0 };
|
||||
|
||||
// POSIX says that timespec has tv_sec and tv_nsec
|
||||
// But it doesn't guarantee order or placement
|
||||
|
||||
rqtp.tv_sec = 0;
|
||||
rqtp.tv_nsec = 1000;
|
||||
|
||||
nanosleep( &rqtp, 0 );
|
||||
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
|
||||
|
||||
pthread_setcancelstate( oldst, &oldst );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
|
||||
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||
BOOST_PRAGMA_MESSAGE("Using sp_thread_yield() in sp_thread_sleep")
|
||||
#endif
|
||||
|
||||
#include <boost/core/detail/sp_thread_yield.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
inline void sp_thread_sleep() BOOST_NOEXCEPT
|
||||
{
|
||||
sp_thread_yield();
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_SP_THREAD_SLEEP_HPP_INCLUDED
|
||||
100
include/boost/core/detail/sp_thread_yield.hpp
Normal file
100
include/boost/core/detail/sp_thread_yield.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#ifndef BOOST_CORE_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/detail/sp_thread_yield.hpp
|
||||
//
|
||||
// inline void bost::core::sp_thread_yield();
|
||||
//
|
||||
// Gives up the remainder of the time slice,
|
||||
// as if by calling sched_yield().
|
||||
//
|
||||
// Copyright 2008, 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
|
||||
|
||||
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||
BOOST_PRAGMA_MESSAGE("Using SwitchToThread() in sp_thread_yield")
|
||||
#endif
|
||||
|
||||
#include <boost/core/detail/sp_win32_sleep.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void sp_thread_yield() BOOST_NOEXCEPT
|
||||
{
|
||||
SwitchToThread();
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using boost::core::detail::sp_thread_yield;
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#elif defined(BOOST_HAS_SCHED_YIELD)
|
||||
|
||||
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||
BOOST_PRAGMA_MESSAGE("Using sched_yield() in sp_thread_yield")
|
||||
#endif
|
||||
|
||||
#ifndef _AIX
|
||||
# include <sched.h>
|
||||
#else
|
||||
// AIX's sched.h defines ::var which sometimes conflicts with Lambda's var
|
||||
extern "C" int sched_yield(void);
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
inline void sp_thread_yield() BOOST_NOEXCEPT
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
|
||||
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||
BOOST_PRAGMA_MESSAGE("Using sp_thread_pause() in sp_thread_yield")
|
||||
#endif
|
||||
|
||||
#include <boost/core/detail/sp_thread_pause.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
inline void sp_thread_yield() BOOST_NOEXCEPT
|
||||
{
|
||||
sp_thread_pause();
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
|
||||
54
include/boost/core/detail/sp_win32_sleep.hpp
Normal file
54
include/boost/core/detail/sp_win32_sleep.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef BOOST_CORE_DETAIL_SP_WIN32_SLEEP_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_SP_WIN32_SLEEP_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/core/detail/sp_win32_sleep.hpp
|
||||
//
|
||||
// Declares the Win32 Sleep() function.
|
||||
//
|
||||
// Copyright 2008, 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined( BOOST_USE_WINDOWS_H )
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if !defined( BOOST_USE_WINDOWS_H )
|
||||
|
||||
#if defined(__clang__) && defined(__x86_64__)
|
||||
// clang x64 warns that __stdcall is ignored
|
||||
# define BOOST_CORE_SP_STDCALL
|
||||
#else
|
||||
# define BOOST_CORE_SP_STDCALL __stdcall
|
||||
#endif
|
||||
|
||||
#if defined(__LP64__) // Cygwin 64
|
||||
extern "C" __declspec(dllimport) void BOOST_CORE_SP_STDCALL Sleep( unsigned int ms );
|
||||
#else
|
||||
extern "C" __declspec(dllimport) void BOOST_CORE_SP_STDCALL Sleep( unsigned long ms );
|
||||
#endif
|
||||
|
||||
extern "C" __declspec(dllimport) int BOOST_CORE_SP_STDCALL SwitchToThread();
|
||||
|
||||
#undef BOOST_CORE_SP_STDCALL
|
||||
|
||||
#endif // !defined( BOOST_USE_WINDOWS_H )
|
||||
|
||||
} // namespace detail
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_SP_WIN32_SLEEP_HPP_INCLUDED
|
||||
@@ -74,7 +74,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_first_of( Ch const* p_
|
||||
|
||||
for( std::size_t j = 0; j < n; ++j )
|
||||
{
|
||||
UCh ch = s[ j ];
|
||||
UCh ch = static_cast<UCh>( s[ j ] );
|
||||
|
||||
if( ch >= 0 && ch < 256 )
|
||||
{
|
||||
@@ -91,7 +91,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_first_of( Ch const* p_
|
||||
{
|
||||
for( std::size_t i = pos; i < n_; ++i )
|
||||
{
|
||||
UCh ch = p_[ i ];
|
||||
UCh ch = static_cast<UCh>( p_[ i ] );
|
||||
if( ch >= 0 && ch < 256 && table[ ch ] ) return i;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_last_of( Ch const* p_,
|
||||
|
||||
for( std::size_t j = 0; j < n; ++j )
|
||||
{
|
||||
UCh ch = s[ j ];
|
||||
UCh ch = static_cast<UCh>( s[ j ] );
|
||||
|
||||
if( ch >= 0 && ch < 256 )
|
||||
{
|
||||
@@ -150,7 +150,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_last_of( Ch const* p_,
|
||||
{
|
||||
do
|
||||
{
|
||||
UCh ch = p_[ i ];
|
||||
UCh ch = static_cast<UCh>( p_[ i ] );
|
||||
|
||||
if( ch >= 0 && ch < 256 && table[ ch ] ) return i;
|
||||
|
||||
@@ -199,7 +199,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_first_not_of( Ch const
|
||||
|
||||
for( std::size_t j = 0; j < n; ++j )
|
||||
{
|
||||
UCh ch = s[ j ];
|
||||
UCh ch = static_cast<UCh>( s[ j ] );
|
||||
|
||||
if( ch >= 0 && ch < 256 )
|
||||
{
|
||||
@@ -216,7 +216,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_first_not_of( Ch const
|
||||
{
|
||||
for( std::size_t i = pos; i < n_; ++i )
|
||||
{
|
||||
UCh ch = p_[ i ];
|
||||
UCh ch = static_cast<UCh>( p_[ i ] );
|
||||
if( !( ch >= 0 && ch < 256 && table[ ch ] ) ) return i;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_last_not_of( Ch const*
|
||||
|
||||
for( std::size_t j = 0; j < n; ++j )
|
||||
{
|
||||
UCh ch = s[ j ];
|
||||
UCh ch = static_cast<UCh>( s[ j ] );
|
||||
|
||||
if( ch >= 0 && ch < 256 )
|
||||
{
|
||||
@@ -283,7 +283,7 @@ template<class Ch> BOOST_CXX14_CONSTEXPR std::size_t find_last_not_of( Ch const*
|
||||
{
|
||||
do
|
||||
{
|
||||
UCh ch = p_[ i ];
|
||||
UCh ch = static_cast<UCh>( p_[ i ] );
|
||||
|
||||
if( !( ch >= 0 && ch < 256 && table[ ch ] ) ) return i;
|
||||
|
||||
@@ -381,7 +381,7 @@ public:
|
||||
}
|
||||
|
||||
template<class End> BOOST_CXX14_CONSTEXPR basic_string_view( Ch const* first, End last,
|
||||
typename boost::enable_if<boost::core::detail::is_same<End, Ch const*> >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( last - first )
|
||||
typename boost::enable_if<boost::core::detail::is_same<End, Ch const*> >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( static_cast<size_type>( last - first ) )
|
||||
{
|
||||
BOOST_ASSERT( last - first >= 0 );
|
||||
}
|
||||
@@ -392,7 +392,7 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch> > const& str ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
|
||||
BOOST_CONSTEXPR basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch> > const& str ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ public:
|
||||
|
||||
Ch const* r = traits_type::find( data() + pos, size() - pos, c );
|
||||
|
||||
return r? r - data(): npos;
|
||||
return r? static_cast<size_type>( r - data() ): npos;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR size_type find( Ch const* s, size_type pos, size_type n ) const BOOST_NOEXCEPT
|
||||
@@ -696,11 +696,11 @@ public:
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
p = traits_type::find( p, last - p, s[0] );
|
||||
p = traits_type::find( p, static_cast<size_type>( last - p ), s[0] );
|
||||
|
||||
if( p == 0 ) break;
|
||||
|
||||
if( traits_type::compare( p + 1, s + 1, n - 1 ) == 0 ) return p - data();
|
||||
if( traits_type::compare( p + 1, s + 1, n - 1 ) == 0 ) return static_cast<size_type>( p - data() );
|
||||
|
||||
++p;
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ public:
|
||||
template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str )
|
||||
{
|
||||
Ch const* p = str.data();
|
||||
std::streamsize n = str.size();
|
||||
std::streamsize n = static_cast<std::streamsize>( str.size() );
|
||||
|
||||
std::streamsize m = os.width();
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Block unintended ADL
|
||||
namespace fclose_deleter_ns {
|
||||
|
||||
//! A function object that closes a file
|
||||
struct fclose_deleter
|
||||
{
|
||||
@@ -41,6 +44,10 @@ struct fclose_deleter
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace fclose_deleter_ns
|
||||
|
||||
using fclose_deleter_ns::fclose_deleter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CORE_FCLOSE_DELETER_HPP
|
||||
|
||||
41
include/boost/core/functor.hpp
Normal file
41
include/boost/core/functor.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file functor.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 2024-01-23
|
||||
*
|
||||
* This header contains a \c functor implementation. This is a function object
|
||||
* that invokes a function that is specified as its template parameter.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_CORE_FUNCTOR_HPP
|
||||
#define BOOST_CORE_FUNCTOR_HPP
|
||||
|
||||
namespace boost::core {
|
||||
|
||||
// Block unintended ADL
|
||||
namespace functor_ns {
|
||||
|
||||
//! A function object that invokes a function specified as its template parameter
|
||||
template< auto Function >
|
||||
struct functor
|
||||
{
|
||||
template< typename... Args >
|
||||
auto operator() (Args&&... args) const noexcept(noexcept(Function(static_cast< Args&& >(args)...))) -> decltype(Function(static_cast< Args&& >(args)...))
|
||||
{
|
||||
return Function(static_cast< Args&& >(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace functor_ns
|
||||
|
||||
using functor_ns::functor;
|
||||
|
||||
} // namespace boost::core
|
||||
|
||||
#endif // BOOST_CORE_FUNCTOR_HPP
|
||||
61
include/boost/core/identity.hpp
Normal file
61
include/boost/core/identity.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright 2021-2023 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_IDENTITY_HPP
|
||||
#define BOOST_CORE_IDENTITY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct identity {
|
||||
typedef void is_transparent;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR T&& operator()(T&& value) const BOOST_NOEXCEPT {
|
||||
return std::forward<T>(value);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR const T& operator()(const T& value) const BOOST_NOEXCEPT {
|
||||
return value;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR T& operator()(T& value) const BOOST_NOEXCEPT {
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class>
|
||||
struct result { };
|
||||
|
||||
template<class T>
|
||||
struct result<identity(T&)> {
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T>
|
||||
struct result<identity(T)> {
|
||||
typedef T&& type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct result<identity(T&&)> {
|
||||
typedef T&& type;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
93
include/boost/core/invoke_swap.hpp
Normal file
93
include/boost/core/invoke_swap.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker
|
||||
// Copyright (C) 2023 Andrey Semashev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
#ifndef BOOST_CORE_INVOKE_SWAP_HPP
|
||||
#define BOOST_CORE_INVOKE_SWAP_HPP
|
||||
|
||||
// Note: the implementation of this utility contains various workarounds:
|
||||
// - invoke_swap_impl is put outside the boost namespace, to avoid infinite
|
||||
// recursion (causing stack overflow) when swapping objects of a primitive
|
||||
// type.
|
||||
// - std::swap is imported with a using-directive, rather than
|
||||
// a using-declaration, because some compilers (including MSVC 7.1,
|
||||
// Borland 5.9.3, and Intel 8.1) don't do argument-dependent lookup
|
||||
// when it has a using-declaration instead.
|
||||
// - The main entry function is called invoke_swap rather than swap
|
||||
// to avoid forming an infinite recursion when the arguments are not
|
||||
// swappable.
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
|
||||
#include <utility> // for std::swap (C++11)
|
||||
#else
|
||||
#include <algorithm> // for std::swap (C++98)
|
||||
#endif
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC) && (BOOST_GCC < 40700)
|
||||
// gcc 4.6 ICEs on noexcept specifications below
|
||||
#define BOOST_CORE_SWAP_NOEXCEPT_IF(x)
|
||||
#else
|
||||
#define BOOST_CORE_SWAP_NOEXCEPT_IF(x) BOOST_NOEXCEPT_IF(x)
|
||||
#endif
|
||||
|
||||
namespace boost_swap_impl {
|
||||
|
||||
// we can't use type_traits here
|
||||
|
||||
template<class T> struct is_const { enum _vt { value = 0 }; };
|
||||
template<class T> struct is_const<T const> { enum _vt { value = 1 }; };
|
||||
|
||||
// Use std::swap if argument dependent lookup fails.
|
||||
// We need to have this at namespace scope to be able to use unqualified swap() call
|
||||
// in noexcept specification.
|
||||
using namespace std;
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
inline void invoke_swap_impl(T& left, T& right) BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(swap(left, right)))
|
||||
{
|
||||
swap(left, right);
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_GPU_ENABLED
|
||||
inline void invoke_swap_impl(T (& left)[N], T (& right)[N])
|
||||
BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::invoke_swap_impl(left[0], right[0])))
|
||||
{
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
{
|
||||
::boost_swap_impl::invoke_swap_impl(left[i], right[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace boost_swap_impl
|
||||
|
||||
namespace boost {
|
||||
namespace core {
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
inline typename enable_if_c< !::boost_swap_impl::is_const<T>::value >::type
|
||||
invoke_swap(T& left, T& right)
|
||||
BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::invoke_swap_impl(left, right)))
|
||||
{
|
||||
::boost_swap_impl::invoke_swap_impl(left, right);
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_CORE_SWAP_NOEXCEPT_IF
|
||||
|
||||
#endif // BOOST_CORE_INVOKE_SWAP_HPP
|
||||
@@ -11,14 +11,28 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__builtin_launder)
|
||||
# define BOOST_CORE_HAS_BUILTIN_LAUNDER
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && !defined(BOOST_CORE_HAS_BUILTIN_LAUNDER)
|
||||
# include <new>
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1920
|
||||
|
||||
// msvc-14.1 suffers from internal compiler errors when using std::launder
|
||||
// https://github.com/boostorg/core/issues/160
|
||||
// https://github.com/boostorg/optional/issues/122
|
||||
|
||||
#elif (BOOST_CXX_VERSION >= 201703L) && !defined(BOOST_CORE_HAS_BUILTIN_LAUNDER)
|
||||
|
||||
#include <new>
|
||||
|
||||
#if defined(__cpp_lib_launder)
|
||||
# define BOOST_CORE_HAS_STD_LAUNDER
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
@@ -33,7 +47,7 @@ template<class T> T* launder( T* p )
|
||||
return __builtin_launder( p );
|
||||
}
|
||||
|
||||
#elif (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && defined(__cpp_lib_launder)
|
||||
#elif defined(BOOST_CORE_HAS_STD_LAUNDER)
|
||||
|
||||
template<class T> T* launder( T* p )
|
||||
{
|
||||
|
||||
@@ -153,6 +153,7 @@ inline void no_throw_failed_impl(const char* expr, const char* what, const char*
|
||||
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
# pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
|
||||
// specialize test output for char pointers to avoid printing as cstring
|
||||
|
||||
59
include/boost/core/make_span.hpp
Normal file
59
include/boost/core/make_span.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2023 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_MAKE_SPAN_HPP
|
||||
#define BOOST_CORE_MAKE_SPAN_HPP
|
||||
|
||||
#include <boost/core/span.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class I>
|
||||
inline constexpr span<I>
|
||||
make_span(I* f, std::size_t c) noexcept
|
||||
{
|
||||
return span<I>(f, c);
|
||||
}
|
||||
|
||||
template<class I>
|
||||
inline constexpr span<I>
|
||||
make_span(I* f, I* l) noexcept
|
||||
{
|
||||
return span<I>(f, l);
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline constexpr span<T, N>
|
||||
make_span(T(&a)[N]) noexcept
|
||||
{
|
||||
return span<T, N>(a);
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline constexpr span<T, N>
|
||||
make_span(std::array<T, N>& a) noexcept
|
||||
{
|
||||
return span<T, N>(a);
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline constexpr span<const T, N>
|
||||
make_span(const std::array<T, N>& a) noexcept
|
||||
{
|
||||
return span<const T, N>(a);
|
||||
}
|
||||
|
||||
template<class R>
|
||||
inline span<typename detail::span_data<R>::type>
|
||||
make_span(R&& r)
|
||||
{
|
||||
return span<typename detail::span_data<R>::type>(std::forward<R>(r));
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
82
include/boost/core/max_align.hpp
Normal file
82
include/boost/core/max_align.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
#define BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/alignof.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
// BOOST_CORE_HAS_FLOAT128
|
||||
|
||||
#if defined(BOOST_HAS_FLOAT128)
|
||||
|
||||
# define BOOST_CORE_HAS_FLOAT128
|
||||
|
||||
#elif defined(__SIZEOF_FLOAT128__)
|
||||
|
||||
# define BOOST_CORE_HAS_FLOAT128
|
||||
|
||||
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) && defined(__i386__)
|
||||
|
||||
# define BOOST_CORE_HAS_FLOAT128
|
||||
|
||||
#endif
|
||||
|
||||
// max_align_t, max_align
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
union max_align_t
|
||||
{
|
||||
char c;
|
||||
short s;
|
||||
int i;
|
||||
long l;
|
||||
|
||||
#if !defined(BOOST_NO_LONG_LONG)
|
||||
|
||||
boost::long_long_type ll;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
|
||||
boost::int128_type i128;
|
||||
|
||||
#endif
|
||||
|
||||
float f;
|
||||
double d;
|
||||
long double ld;
|
||||
|
||||
#if defined(BOOST_CORE_HAS_FLOAT128)
|
||||
|
||||
__float128 f128;
|
||||
|
||||
#endif
|
||||
|
||||
void* p;
|
||||
void (*pf) ();
|
||||
|
||||
int max_align_t::* pm;
|
||||
void (max_align_t::*pmf)();
|
||||
};
|
||||
|
||||
BOOST_CONSTEXPR_OR_CONST std::size_t max_align = BOOST_CORE_ALIGNOF( max_align_t );
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
|
||||
108
include/boost/core/memory_resource.hpp
Normal file
108
include/boost/core/memory_resource.hpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef BOOST_CORE_MEMORY_RESOURCE_HPP_INCLUDED
|
||||
#define BOOST_CORE_MEMORY_RESOURCE_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/max_align.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
// Define our own placement new to avoid the inclusion of <new>
|
||||
// (~9K extra lines) at Ion Gaztanhaga's request.
|
||||
//
|
||||
// We can use our own because [intro.object] p13 says:
|
||||
//
|
||||
// Any implicit or explicit invocation of a function named `operator new`
|
||||
// or `operator new[]` implicitly creates objects in the returned region of
|
||||
// storage and returns a pointer to a suitable created object.
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct placement_new_tag {};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
inline void* operator new( std::size_t, void* p, boost::core::detail::placement_new_tag )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void operator delete( void*, void*, boost::core::detail::placement_new_tag )
|
||||
{
|
||||
}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
class memory_resource
|
||||
{
|
||||
public:
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
virtual ~memory_resource() {}
|
||||
|
||||
#else
|
||||
|
||||
virtual ~memory_resource() = default;
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_ATTRIBUTE_NODISCARD void* allocate( std::size_t bytes, std::size_t alignment = max_align )
|
||||
{
|
||||
// https://github.com/boostorg/container/issues/199
|
||||
// https://cplusplus.github.io/LWG/issue3471
|
||||
|
||||
return ::operator new( bytes, do_allocate( bytes, alignment ), core::detail::placement_new_tag() );
|
||||
}
|
||||
|
||||
void deallocate( void* p, std::size_t bytes, std::size_t alignment = max_align )
|
||||
{
|
||||
do_deallocate( p, bytes, alignment );
|
||||
}
|
||||
|
||||
bool is_equal( memory_resource const & other ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return do_is_equal( other );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
virtual void* do_allocate( std::size_t bytes, std::size_t alignment ) = 0;
|
||||
virtual void do_deallocate( void* p, std::size_t bytes, std::size_t alignment ) = 0;
|
||||
|
||||
virtual bool do_is_equal( memory_resource const & other ) const BOOST_NOEXCEPT = 0;
|
||||
};
|
||||
|
||||
inline bool operator==( memory_resource const& a, memory_resource const& b ) BOOST_NOEXCEPT
|
||||
{
|
||||
return &a == &b || a.is_equal( b );
|
||||
}
|
||||
|
||||
inline bool operator!=( memory_resource const& a, memory_resource const& b ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( a == b );
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_MEMORY_RESOURCE_HPP_INCLUDED
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Block unintended ADL
|
||||
namespace null_deleter_ns {
|
||||
|
||||
//! A function object that does nothing and can be used as an empty deleter for \c shared_ptr
|
||||
struct null_deleter
|
||||
{
|
||||
@@ -39,6 +42,10 @@ struct null_deleter
|
||||
void operator() (T*) const BOOST_NOEXCEPT {}
|
||||
};
|
||||
|
||||
} // namespace null_deleter_ns
|
||||
|
||||
using null_deleter_ns::null_deleter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CORE_NULL_DELETER_HPP
|
||||
|
||||
49
include/boost/core/pointer_in_range.hpp
Normal file
49
include/boost/core/pointer_in_range.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2024 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_POINTER_IN_RANGE_HPP
|
||||
#define BOOST_CORE_POINTER_IN_RANGE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <functional>
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1925
|
||||
#define BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL
|
||||
#elif defined(__has_builtin)
|
||||
#if __has_builtin(__builtin_is_constant_evaluated)
|
||||
#define BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL)
|
||||
#define BOOST_CORE_NO_CONSTEXPR_POINTER_IN_RANGE
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
inline BOOST_CONSTEXPR bool
|
||||
pointer_in_range(const T* p, const T* b, const T* e)
|
||||
{
|
||||
#if defined(BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL)
|
||||
if ( __builtin_is_constant_evaluated()) {
|
||||
for (; b != e; ++b) {
|
||||
if (b == p) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return std::less_equal<const T*>()(b, p) && std::less<const T*>()(p, e);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
131
include/boost/core/serialization.hpp
Normal file
131
include/boost/core/serialization.hpp
Normal file
@@ -0,0 +1,131 @@
|
||||
#ifndef BOOST_CORE_SERIALIZATION_HPP_INCLUDED
|
||||
#define BOOST_CORE_SERIALIZATION_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// Utilities needed to implement serialization support
|
||||
// without including a Boost.Serialization header
|
||||
|
||||
#include <boost/core/nvp.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
|
||||
// Forward declarations (needed for specializations)
|
||||
|
||||
template<class T> struct version;
|
||||
|
||||
class access;
|
||||
|
||||
// Our own version_type replacement. This has to be in
|
||||
// the `serialization` namespace, because its only purpose
|
||||
// is to add `serialization` as an associated namespace.
|
||||
|
||||
struct core_version_type
|
||||
{
|
||||
unsigned int version_;
|
||||
|
||||
core_version_type( unsigned int version ): version_( version ) {}
|
||||
operator unsigned int () const { return version_; }
|
||||
};
|
||||
|
||||
} // namespace serialization
|
||||
|
||||
namespace core
|
||||
{
|
||||
|
||||
// nvp
|
||||
|
||||
using serialization::nvp;
|
||||
using serialization::make_nvp;
|
||||
|
||||
// split_free
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<bool IsSaving> struct load_or_save_f;
|
||||
|
||||
template<> struct load_or_save_f<true>
|
||||
{
|
||||
template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
|
||||
{
|
||||
save( a, t, serialization::core_version_type( v ) );
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct load_or_save_f<false>
|
||||
{
|
||||
template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
|
||||
{
|
||||
load( a, t, serialization::core_version_type( v ) );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class A, class T> inline void split_free( A& a, T& t, unsigned int v )
|
||||
{
|
||||
detail::load_or_save_f< A::is_saving::value >()( a, t, v );
|
||||
}
|
||||
|
||||
// split_member
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<bool IsSaving, class Access = serialization::access> struct load_or_save_m;
|
||||
|
||||
template<class Access> struct load_or_save_m<true, Access>
|
||||
{
|
||||
template<class A, class T> void operator()( A& a, T const& t, unsigned int v ) const
|
||||
{
|
||||
Access::member_save( a, t, v );
|
||||
}
|
||||
};
|
||||
|
||||
template<class Access> struct load_or_save_m<false, Access>
|
||||
{
|
||||
template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
|
||||
{
|
||||
Access::member_load( a, t, v );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class A, class T> inline void split_member( A& a, T& t, unsigned int v )
|
||||
{
|
||||
detail::load_or_save_m< A::is_saving::value >()( a, t, v );
|
||||
}
|
||||
|
||||
// load_construct_data_adl
|
||||
|
||||
template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v )
|
||||
{
|
||||
load_construct_data( ar, t, serialization::core_version_type( v ) );
|
||||
}
|
||||
|
||||
// save_construct_data_adl
|
||||
|
||||
template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v )
|
||||
{
|
||||
save_construct_data( ar, t, serialization::core_version_type( v ) );
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_SERIALIZATION_HPP_INCLUDED
|
||||
31
include/boost/core/size.hpp
Normal file
31
include/boost/core/size.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2023 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_SIZE_HPP
|
||||
#define BOOST_CORE_SIZE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class C>
|
||||
inline constexpr auto
|
||||
size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size())
|
||||
{
|
||||
return c.size();
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline constexpr std::size_t
|
||||
size(T(&)[N]) noexcept
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
Copyright 2019-2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -8,10 +8,10 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_SPAN_HPP
|
||||
#define BOOST_CORE_SPAN_HPP
|
||||
|
||||
#include <boost/core/data.hpp>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -39,10 +39,8 @@ struct span_compatible {
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct span_uncvref {
|
||||
typedef typename std::remove_cv<typename
|
||||
std::remove_reference<T>::type>::type type;
|
||||
};
|
||||
using span_uncvref = typename std::remove_cv<typename
|
||||
std::remove_reference<T>::type>::type;
|
||||
|
||||
template<class>
|
||||
struct span_is_span {
|
||||
@@ -64,15 +62,16 @@ struct span_is_array<std::array<T, N> > {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
using span_ptr = decltype(boost::data(std::declval<T&>()));
|
||||
|
||||
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;
|
||||
typename std::enable_if<std::is_pointer<span_ptr<T> >::value>::type> {
|
||||
typedef typename std::remove_pointer<span_ptr<T> >::type type;
|
||||
};
|
||||
|
||||
template<class, class, class = void>
|
||||
@@ -102,9 +101,9 @@ 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_is_span<span_uncvref<R> >::value &&
|
||||
!span_is_array<span_uncvref<R> >::value &&
|
||||
!std::is_array<span_uncvref<R> >::value &&
|
||||
span_has_data<R, T>::value &&
|
||||
span_has_size<R>::value;
|
||||
};
|
||||
@@ -224,15 +223,16 @@ public:
|
||||
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()) { }
|
||||
constexpr span(R&& r) noexcept(noexcept(boost::data(r)) &&
|
||||
noexcept(r.size()))
|
||||
: s_(boost::data(r), 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()) &&
|
||||
explicit constexpr span(R&& r) noexcept(noexcept(boost::data(r)) &&
|
||||
noexcept(r.size()))
|
||||
: s_(r.data(), r.size()) { }
|
||||
: s_(boost::data(r), r.size()) { }
|
||||
|
||||
template<class U, std::size_t N,
|
||||
typename std::enable_if<detail::span_implicit<E, N>::value &&
|
||||
@@ -351,8 +351,10 @@ private:
|
||||
detail::span_store<T, E> s_;
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
template<class T, std::size_t E>
|
||||
constexpr std::size_t span<T, E>::extent;
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template<class I, class L>
|
||||
|
||||
@@ -10,80 +10,31 @@
|
||||
#define BOOST_CORE_SWAP_HPP
|
||||
|
||||
// Note: the implementation of this utility contains various workarounds:
|
||||
// - swap_impl is put outside the boost namespace, to avoid infinite
|
||||
// recursion (causing stack overflow) when swapping objects of a primitive
|
||||
// type.
|
||||
// - std::swap is imported with a using-directive, rather than
|
||||
// a using-declaration, because some compilers (including MSVC 7.1,
|
||||
// Borland 5.9.3, and Intel 8.1) don't do argument-dependent lookup
|
||||
// when it has a using-declaration instead.
|
||||
// - boost::swap has two template arguments, instead of one, to
|
||||
// avoid ambiguity when swapping objects of a Boost type that does
|
||||
// not have its own boost::swap overload.
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
|
||||
#include <utility> // for std::swap (C++11)
|
||||
#else
|
||||
#include <algorithm> // for std::swap (C++98)
|
||||
#endif
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
#include <boost/core/invoke_swap.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC) && (BOOST_GCC < 40700)
|
||||
// gcc 4.6 ICEs on noexcept specifications below
|
||||
#define BOOST_CORE_SWAP_NOEXCEPT_IF(x)
|
||||
#else
|
||||
#define BOOST_CORE_SWAP_NOEXCEPT_IF(x) BOOST_NOEXCEPT_IF(x)
|
||||
#endif
|
||||
|
||||
namespace boost_swap_impl
|
||||
{
|
||||
// we can't use type_traits here
|
||||
|
||||
template<class T> struct is_const { enum _vt { value = 0 }; };
|
||||
template<class T> struct is_const<T const> { enum _vt { value = 1 }; };
|
||||
|
||||
// Use std::swap if argument dependent lookup fails.
|
||||
// We need to have this at namespace scope to be able to use unqualified swap() call
|
||||
// in noexcept specification.
|
||||
using namespace std;
|
||||
|
||||
template<class T>
|
||||
BOOST_GPU_ENABLED
|
||||
void swap_impl(T& left, T& right) BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(swap(left, right)))
|
||||
{
|
||||
swap(left, right);
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_GPU_ENABLED
|
||||
void swap_impl(T (& left)[N], T (& right)[N])
|
||||
BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::swap_impl(left[0], right[0])))
|
||||
{
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
{
|
||||
::boost_swap_impl::swap_impl(left[i], right[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_HEADER_DEPRECATED("boost/core/invoke_swap.hpp")
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<class T1, class T2>
|
||||
BOOST_GPU_ENABLED
|
||||
typename enable_if_c< !boost_swap_impl::is_const<T1>::value && !boost_swap_impl::is_const<T2>::value >::type
|
||||
BOOST_DEPRECATED("This function is deprecated, use boost::core::invoke_swap instead.")
|
||||
inline typename enable_if_c< !boost_swap_impl::is_const<T1>::value && !boost_swap_impl::is_const<T2>::value >::type
|
||||
swap(T1& left, T2& right)
|
||||
BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::swap_impl(left, right)))
|
||||
{
|
||||
::boost_swap_impl::swap_impl(left, right);
|
||||
boost::core::invoke_swap(left, right);
|
||||
}
|
||||
}
|
||||
|
||||
#undef BOOST_CORE_SWAP_NOEXCEPT_IF
|
||||
|
||||
#endif // BOOST_CORE_SWAP_HPP
|
||||
|
||||
@@ -102,11 +102,24 @@ inline std::string fix_typeid_name( char const* n )
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class T> std::string typeid_name()
|
||||
// class types can be incomplete
|
||||
// but also abstract (T[1] doesn't form)
|
||||
template<class T> std::string typeid_name_impl( int T::*, T(*)[1] )
|
||||
{
|
||||
std::string r = fix_typeid_name( typeid(T[1]).name() );
|
||||
return r.substr( 0, r.size() - 4 ); // remove ' [1]' suffix
|
||||
}
|
||||
|
||||
template<class T> std::string typeid_name_impl( ... )
|
||||
{
|
||||
return fix_typeid_name( typeid(T).name() );
|
||||
}
|
||||
|
||||
template<class T> std::string typeid_name()
|
||||
{
|
||||
return typeid_name_impl<T>( 0, 0 );
|
||||
}
|
||||
|
||||
// template names
|
||||
|
||||
template<class T> std::string class_template_name()
|
||||
@@ -333,6 +346,8 @@ template<> struct tn_holder<boost::uint128_type>
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
|
||||
template<> struct tn_holder<wchar_t>
|
||||
{
|
||||
static std::string type_name( std::string const& suffix )
|
||||
@@ -341,6 +356,8 @@ template<> struct tn_holder<wchar_t>
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
|
||||
template<> struct tn_holder<char16_t>
|
||||
@@ -862,6 +879,8 @@ template<class T, std::size_t N> struct tn_holder<T const volatile[N]>
|
||||
|
||||
// pointers to members
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template<class R, class T> struct tn_holder<R T::*>
|
||||
{
|
||||
static std::string type_name( std::string const& suffix )
|
||||
@@ -870,7 +889,7 @@ template<class R, class T> struct tn_holder<R T::*>
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900 && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
|
||||
|
||||
template<class R, class T, class... A> struct tn_holder<R(T::*)(A...)>
|
||||
{
|
||||
@@ -904,7 +923,9 @@ template<class R, class T, class... A> struct tn_holder<R(T::*)(A...) const vola
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // #if defined(BOOST_MSVC) && BOOST_MSVC < 1900
|
||||
|
||||
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
// strings
|
||||
|
||||
|
||||
12
include/boost/core/yield_primitives.hpp
Normal file
12
include/boost/core/yield_primitives.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef BOOST_CORE_YIELD_PRIMITIVES_HPP_INCLUDED
|
||||
#define BOOST_CORE_YIELD_PRIMITIVES_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/sp_thread_pause.hpp>
|
||||
#include <boost/core/detail/sp_thread_yield.hpp>
|
||||
#include <boost/core/detail/sp_thread_sleep.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_CORE_YIELD_PRIMITIVES_HPP_INCLUDED
|
||||
@@ -10,8 +10,11 @@
|
||||
#define BOOST_SWAP_HPP
|
||||
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/swap.hpp instead.
|
||||
// use boost/core/invoke_swap.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
#include <boost/core/swap.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("boost/core/invoke_swap.hpp")
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
#define BOOST_UTILITY_SWAP_HPP
|
||||
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/swap.hpp instead.
|
||||
// use boost/core/invoke_swap.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
#include <boost/core/swap.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("boost/core/invoke_swap.hpp")
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,6 +31,20 @@ set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::config Boost::move Boost::smart
|
||||
|
||||
boost_test(TYPE run SOURCES fclose_deleter_test.cpp)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::serialization)
|
||||
|
||||
boost_test(TYPE run SOURCES serialization_nvp_test.cpp)
|
||||
boost_test(TYPE run SOURCES serialization_split_free_test.cpp)
|
||||
boost_test(TYPE run SOURCES serialization_split_member_test.cpp)
|
||||
boost_test(TYPE run SOURCES serialization_construct_data_test.cpp)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Threads::Threads)
|
||||
|
||||
boost_test(TYPE run SOURCES yield_prim_pthread_cancel_test.cpp)
|
||||
|
||||
endif()
|
||||
|
||||
add_subdirectory(swap)
|
||||
|
||||
185
test/Jamfile.v2
185
test/Jamfile.v2
@@ -17,11 +17,20 @@ project : requirements
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare ;
|
||||
|
||||
local warning-as-errors-off =
|
||||
local warnings-as-errors-off =
|
||||
"-<toolset>msvc:<warnings-as-errors>on"
|
||||
"-<toolset>gcc:<warnings-as-errors>on"
|
||||
"-<toolset>clang:<warnings-as-errors>on" ;
|
||||
|
||||
local pedantic-errors = <warnings>pedantic
|
||||
<toolset>gcc:<cxxflags>"-Wconversion"
|
||||
<toolset>gcc:<cxxflags>"-Wsign-conversion"
|
||||
<toolset>clang:<cxxflags>"-Wconversion"
|
||||
<toolset>clang:<cxxflags>"-Wsign-conversion"
|
||||
<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 ;
|
||||
|
||||
@@ -32,36 +41,41 @@ run addressof_np_test.cpp ;
|
||||
run addressof_fn_test.cpp ;
|
||||
compile addressof_constexpr_test.cpp ;
|
||||
compile-fail addressof_fail_rvalue.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
run checked_delete_test.cpp ;
|
||||
run checked_delete_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
compile-fail checked_delete_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail checked_delete_fail2.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail checked_deleter_compile_fail_adl.cpp
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail checked_array_deleter_compile_fail_adl.cpp
|
||||
: $(warnings-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
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_rv_fail2.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_rv_fail3.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_rv_fail4.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_rv_fail5.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail2.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail3.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail ref_implicit_fail4.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
run ref_cv_test.cpp ;
|
||||
run ref_conversion_test.cpp ;
|
||||
|
||||
@@ -75,18 +89,18 @@ run eif_no_disambiguation.cpp : ;
|
||||
run eif_partial_specializations.cpp : ;
|
||||
|
||||
compile-fail noncopyable_compile_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
run explicit_operator_bool.cpp ;
|
||||
run explicit_operator_bool_noexcept.cpp ;
|
||||
compile-fail explicit_operator_bool_compile_fail_conv_int.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail explicit_operator_bool_compile_fail_delete.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail explicit_operator_bool_compile_fail_shift.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
compile ignore_unused_test.cpp ;
|
||||
|
||||
@@ -97,11 +111,6 @@ run visit_each_test.cpp ;
|
||||
|
||||
run get_pointer_test.cpp ;
|
||||
|
||||
local pedantic-errors = <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
run lightweight_test_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run lightweight_test_test.cpp : : :
|
||||
@@ -179,13 +188,23 @@ run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output :
|
||||
|
||||
run scoped_enum.cpp ;
|
||||
compile-fail scoped_enum_compile_fail_conv_from_int.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
compile-fail scoped_enum_compile_fail_conv_to_int.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
run underlying_type.cpp ;
|
||||
|
||||
compile-fail null_deleter_compile_fail_adl.cpp
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
run fclose_deleter_test.cpp : : : <target-os>windows:<define>_CRT_SECURE_NO_WARNINGS <target-os>windows:<define>_CRT_SECURE_NO_DEPRECATE ;
|
||||
compile-fail fclose_deleter_compile_fail_adl.cpp
|
||||
: <target-os>windows:<define>_CRT_SECURE_NO_WARNINGS <target-os>windows:<define>_CRT_SECURE_NO_DEPRECATE $(warnings-as-errors-off) ;
|
||||
|
||||
run functor_test.cpp ;
|
||||
compile-fail functor_compile_fail_adl.cpp
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
|
||||
run pointer_traits_pointer_test.cpp ;
|
||||
run pointer_traits_element_type_test.cpp ;
|
||||
@@ -249,6 +268,7 @@ run allocator_destroy_test.cpp ;
|
||||
run allocator_construct_n_test.cpp ;
|
||||
run allocator_destroy_n_test.cpp ;
|
||||
run allocator_traits_test.cpp ;
|
||||
compile allocator_pmr_test.cpp ;
|
||||
|
||||
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
|
||||
|
||||
@@ -296,45 +316,79 @@ run bit_popcount_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_endian_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run bit_byteswap_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
compile-fail bit_width_fail.cpp
|
||||
: <warnings>off ;
|
||||
|
||||
compile bit_cast_test_cx.cpp ;
|
||||
compile bit_rotate_test_cx.cpp ;
|
||||
compile bit_countr_test_cx.cpp ;
|
||||
compile bit_countl_test_cx.cpp ;
|
||||
compile bit_width_test_cx.cpp ;
|
||||
compile has_single_bit_test_cx.cpp ;
|
||||
compile bit_floor_test_cx.cpp ;
|
||||
compile bit_ceil_test_cx.cpp ;
|
||||
compile bit_popcount_test_cx.cpp ;
|
||||
compile bit_byteswap_test_cx.cpp ;
|
||||
|
||||
run type_name_test.cpp ;
|
||||
|
||||
run snprintf_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_types_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_construct_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_iteration_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_element_access_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_modifiers_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_copy_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_substr_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_compare_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_starts_with_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_ends_with_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_find_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_rfind_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_find_first_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
: : : $(pedantic-errors) <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_find_last_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
: : : $(pedantic-errors) <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_find_first_not_of_test.cpp
|
||||
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
: : : $(pedantic-errors) <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 ;
|
||||
: : : $(pedantic-errors) <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
|
||||
run sv_contains_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_eq_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_lt_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_stream_insert_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_conversion_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run sv_conversion_test2.cpp : ;
|
||||
run sv_common_reference_test.cpp ;
|
||||
run sv_common_reference_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
compile sv_common_reference_test2.cpp ;
|
||||
compile sv_windows_h_test.cpp ;
|
||||
compile-fail sv_nullptr_fail.cpp
|
||||
: $(warning-as-errors-off) ;
|
||||
: $(warnings-as-errors-off) ;
|
||||
|
||||
compile sv_construct_test_cx.cpp ;
|
||||
compile sv_construct_test_cx2.cpp ;
|
||||
|
||||
run span_test.cpp ;
|
||||
run span_types_test.cpp ;
|
||||
@@ -343,6 +397,7 @@ run span_deduction_guide_test.cpp ;
|
||||
run as_bytes_test.cpp ;
|
||||
run as_writable_bytes_test.cpp ;
|
||||
compile span_boost_begin_test.cpp ;
|
||||
run make_span_test.cpp ;
|
||||
|
||||
run splitmix64_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
@@ -355,6 +410,38 @@ run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off <rtti>
|
||||
run launder_test.cpp ;
|
||||
|
||||
run alignof_test.cpp ;
|
||||
run max_align_test.cpp ;
|
||||
|
||||
run memory_resource_test.cpp ;
|
||||
|
||||
run data_test.cpp ;
|
||||
run size_test.cpp ;
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
local CPP11 = [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_constexpr cxx11_noexcept ] ;
|
||||
|
||||
local with-serialization = <library>/boost//serialization/<warnings>off $(warnings-as-errors-off) <undefined-sanitizer>norecover:<link>static $(CPP11) ;
|
||||
|
||||
run serialization_nvp_test.cpp : : : $(with-serialization) <undefined-sanitizer>norecover:<build>no ;
|
||||
run serialization_split_free_test.cpp : : : $(with-serialization) ;
|
||||
run serialization_split_member_test.cpp : : : $(with-serialization) ;
|
||||
run serialization_construct_data_test.cpp : : : $(with-serialization) ;
|
||||
|
||||
run identity_test.cpp ;
|
||||
run identity_rvalue_test.cpp ;
|
||||
|
||||
run sp_thread_pause_test.cpp ;
|
||||
run sp_thread_yield_test.cpp ;
|
||||
run sp_thread_sleep_test.cpp ;
|
||||
run yield_prim_windows_h_test.cpp ;
|
||||
run yield_prim_pthread_cancel_test.cpp : ;
|
||||
|
||||
run pointer_in_range_test.cpp ;
|
||||
compile pointer_in_range_constexpr_test.cpp ;
|
||||
|
||||
run minstd_rand_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
||||
22
test/allocator_pmr_test.cpp
Normal file
22
test/allocator_pmr_test.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Testing stdlib polymorphic allocators
|
||||
//
|
||||
// Copyright 2024 Braden Ganetsky
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
|
||||
#include <memory_resource>
|
||||
|
||||
void pmr_allocator_destroy_compiles(std::pmr::polymorphic_allocator<int>& alloc, int* p)
|
||||
{
|
||||
boost::allocator_destroy(alloc, p);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
26
test/bit_byteswap_test.cpp
Normal file
26
test/bit_byteswap_test.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Test for boost/core/bit.hpp (byteswap)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::int8_t)0x01 ), 0x01 );
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::uint8_t)0xF1 ), 0xF1 );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::int16_t)0x0102 ), 0x0201 );
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::uint16_t)0xF1E2 ), 0xE2F1 );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::int32_t)0x01020304 ), 0x04030201 );
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::uint32_t)0xF1E2D3C4u ), 0xC4D3E2F1u );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::int64_t)0x01020304 << 32 | 0x05060708 ), (boost::int64_t)0x08070605 << 32 | 0x04030201 );
|
||||
BOOST_TEST_EQ( boost::core::byteswap( (boost::uint64_t)0xF1E2D3C4u << 32 | 0xB5A69788u ), (boost::uint64_t)0x8897A6B5u << 32 | 0xC4D3E2F1u );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
37
test/bit_byteswap_test_cx.cpp
Normal file
37
test/bit_byteswap_test_cx.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// constexpr test for boost/core/bit.hpp (bit_width)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#elif defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC is " BOOST_STRINGIZE(BOOST_MSVC) )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::int8_t)0x01 ) == 0x01 );
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::uint8_t)0xF1 ) == 0xF1 );
|
||||
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::int16_t)0x0102 ) == 0x0201 );
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::uint16_t)0xF1E2 ) == 0xE2F1 );
|
||||
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::int32_t)0x01020304 ) == 0x04030201 );
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::uint32_t)0xF1E2D3C4u ) == 0xC4D3E2F1u );
|
||||
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::int64_t)0x0102030405060708ll ) == 0x0807060504030201ll );
|
||||
STATIC_ASSERT( boost::core::byteswap( (std::uint64_t)0xF1E2D3C4B5A69788ull ) == 0x8897A6B5C4D3E2F1ull );
|
||||
|
||||
#endif
|
||||
28
test/bit_cast_test_cx.cpp
Normal file
28
test/bit_cast_test_cx.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// constexpr test for boost/core/bit.hpp (bit_cast)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined" )
|
||||
|
||||
#elif !defined(BOOST_CORE_HAS_BUILTIN_BIT_CAST)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_CORE_HAS_BUILTIN_BIT_CAST is not defined" )
|
||||
|
||||
#else
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::bit_cast<boost::uint32_t>( 1.0f ) == 0x3F800000u );
|
||||
STATIC_ASSERT( boost::core::bit_cast<boost::uint64_t>( 1.0 ) == 0x3FF0000000000000ull );
|
||||
|
||||
#endif
|
||||
@@ -14,7 +14,7 @@ template<class T> void test_bit_ceil( T x )
|
||||
{
|
||||
if( !boost::core::has_single_bit( x ) )
|
||||
{
|
||||
x >>= 1;
|
||||
x = static_cast<T>( x >> 1 );
|
||||
}
|
||||
|
||||
T y = boost::core::bit_ceil( x );
|
||||
|
||||
26
test/bit_ceil_test_cx.cpp
Normal file
26
test/bit_ceil_test_cx.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// constexpr test for boost/core/bit.hpp (bit_ceil)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::bit_ceil( (unsigned char)0x74 ) == 0x80 );
|
||||
STATIC_ASSERT( boost::core::bit_ceil( (unsigned short)0x7400 ) == 0x8000 );
|
||||
STATIC_ASSERT( boost::core::bit_ceil( 0x740000u ) == 0x800000u );
|
||||
STATIC_ASSERT( boost::core::bit_ceil( 0x74000000ul ) == 0x80000000ul );
|
||||
STATIC_ASSERT( boost::core::bit_ceil( 0x7400000000ull ) == 0x8000000000ull );
|
||||
|
||||
#endif
|
||||
@@ -14,7 +14,7 @@ template<class T> void test_countl( T x )
|
||||
{
|
||||
x |= static_cast<T>( 1 ) << ( std::numeric_limits<T>::digits - 1 );
|
||||
|
||||
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x >>= 1 )
|
||||
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x = static_cast<T>( x >> 1 ) )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::countl_zero( x ), i );
|
||||
BOOST_TEST_EQ( boost::core::countl_one( static_cast<T>( ~x ) ), i );
|
||||
|
||||
41
test/bit_countl_test_cx.cpp
Normal file
41
test/bit_countl_test_cx.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// constexpr test for boost/core/bit.hpp (countl_zero, countl_one)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4310) // cast truncates constant value
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#elif defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC is " BOOST_STRINGIZE(BOOST_MSVC) )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <climits>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::countl_zero( (unsigned char)0x1F ) == CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_zero( (unsigned short)0x1F ) == sizeof(unsigned short) * CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_zero( 0x1Fu ) == sizeof(unsigned int) * CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_zero( 0x1Ful ) == sizeof(unsigned long) * CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_zero( 0x1Full ) == sizeof(unsigned long long) * CHAR_BIT - 5 );
|
||||
|
||||
STATIC_ASSERT( boost::core::countl_one( (unsigned char)~0x1Fu ) == CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_one( (unsigned short)~0x1Fu ) == sizeof(unsigned short) * CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_one( ~0x1Fu ) == sizeof(unsigned int) * CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_one( ~0x1Ful ) == sizeof(unsigned long) * CHAR_BIT - 5 );
|
||||
STATIC_ASSERT( boost::core::countl_one( ~0x1Full ) == sizeof(unsigned long long) * CHAR_BIT - 5 );
|
||||
|
||||
#endif
|
||||
@@ -14,7 +14,7 @@ template<class T> void test_countr( T x )
|
||||
{
|
||||
x |= 1;
|
||||
|
||||
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x <<= 1 )
|
||||
for( int i = 0; i <= std::numeric_limits<T>::digits; ++i, x = static_cast<T>( x << 1 ) )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::countr_zero( x ), i );
|
||||
BOOST_TEST_EQ( boost::core::countr_one( static_cast<T>( ~x ) ), i );
|
||||
|
||||
41
test/bit_countr_test_cx.cpp
Normal file
41
test/bit_countr_test_cx.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// constexpr test for boost/core/bit.hpp (countr_zero, countr_one)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4310) // cast truncates constant value
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#elif defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC is " BOOST_STRINGIZE(BOOST_MSVC) )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <climits>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::countr_zero( (unsigned char)0xF8 ) == 3 );
|
||||
STATIC_ASSERT( boost::core::countr_zero( (unsigned short)0xF800 ) == 11 );
|
||||
STATIC_ASSERT( boost::core::countr_zero( 0xF80000u ) == 19 );
|
||||
STATIC_ASSERT( boost::core::countr_zero( 0xF8000000ul ) == 27 );
|
||||
STATIC_ASSERT( boost::core::countr_zero( 0xF800000000ull ) == 35 );
|
||||
|
||||
STATIC_ASSERT( boost::core::countr_one( (unsigned char)~0xF8u ) == 3 );
|
||||
STATIC_ASSERT( boost::core::countr_one( (unsigned short)~0xF800u ) == 11 );
|
||||
STATIC_ASSERT( boost::core::countr_one( ~0xF80000u ) == 19 );
|
||||
STATIC_ASSERT( boost::core::countr_one( ~0xF8000000ul ) == 27 );
|
||||
STATIC_ASSERT( boost::core::countr_one( ~0xF800000000ull ) == 35 );
|
||||
|
||||
#endif
|
||||
30
test/bit_floor_test_cx.cpp
Normal file
30
test/bit_floor_test_cx.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// constexpr test for boost/core/bit.hpp (bit_floor)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#elif defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC is " BOOST_STRINGIZE(BOOST_MSVC) )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::bit_floor( (unsigned char)0x74 ) == 0x40 );
|
||||
STATIC_ASSERT( boost::core::bit_floor( (unsigned short)0x7400 ) == 0x4000 );
|
||||
STATIC_ASSERT( boost::core::bit_floor( 0x740000u ) == 0x400000u );
|
||||
STATIC_ASSERT( boost::core::bit_floor( 0x74000000ul ) == 0x40000000ul );
|
||||
STATIC_ASSERT( boost::core::bit_floor( 0x7400000000ull ) == 0x4000000000ull );
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
// Test for boost/core/bit.hpp (bit_ceil)
|
||||
// Test for boost/core/bit.hpp (popcount)
|
||||
//
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -14,7 +14,7 @@
|
||||
template<class T> void test_popcount( T x )
|
||||
{
|
||||
int k = 0;
|
||||
for( T y = x; y; y &= y - 1, ++k );
|
||||
for( T y = x; y; y = static_cast<T>( y & (y - 1) ), ++k );
|
||||
|
||||
BOOST_TEST_EQ( boost::core::popcount( x ), k ) || ( std::cerr << "x: " << +x << std::endl );
|
||||
}
|
||||
|
||||
30
test/bit_popcount_test_cx.cpp
Normal file
30
test/bit_popcount_test_cx.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// constexpr test for boost/core/bit.hpp (popcount)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER / 10 == 191
|
||||
# pragma warning(disable: 4307) // '*': integral constant overflow
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::popcount( (unsigned char)0x74 ) == 4 );
|
||||
STATIC_ASSERT( boost::core::popcount( (unsigned short)0x7400 ) == 4 );
|
||||
STATIC_ASSERT( boost::core::popcount( 0x740000u ) == 4 );
|
||||
STATIC_ASSERT( boost::core::popcount( 0x74000000ul ) == 4 );
|
||||
STATIC_ASSERT( boost::core::popcount( 0x7400000000ull ) == 4 );
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,7 @@ template<class T> void test_rotate( T x )
|
||||
BOOST_TEST_EQ( +boost::core::rotl( x, -i ), +boost::core::rotr( x, i ) );
|
||||
|
||||
unsigned const width = std::numeric_limits<T>::digits;
|
||||
unsigned r = i & ( width - 1 );
|
||||
unsigned r = static_cast<unsigned>( i ) & ( width - 1 );
|
||||
|
||||
if( r == 0 )
|
||||
{
|
||||
|
||||
33
test/bit_rotate_test_cx.cpp
Normal file
33
test/bit_rotate_test_cx.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// constexpr test for boost/core/bit.hpp (rotl, rotr)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::rotl( (std::uint8_t)0x11, 1 ) == 0x22 );
|
||||
STATIC_ASSERT( boost::core::rotr( (std::uint8_t)0x11, 1 ) == 0x88 );
|
||||
|
||||
STATIC_ASSERT( boost::core::rotl( (std::uint16_t)0x1111, 1 ) == 0x2222 );
|
||||
STATIC_ASSERT( boost::core::rotr( (std::uint16_t)0x1111, 1 ) == 0x8888 );
|
||||
|
||||
STATIC_ASSERT( boost::core::rotl( (std::uint32_t)0x11111111, 1 ) == 0x22222222 );
|
||||
STATIC_ASSERT( boost::core::rotr( (std::uint32_t)0x11111111, 1 ) == 0x88888888 );
|
||||
|
||||
STATIC_ASSERT( boost::core::rotl( (std::uint64_t)0x1111111111111111, 1 ) == 0x2222222222222222 );
|
||||
STATIC_ASSERT( boost::core::rotr( (std::uint64_t)0x1111111111111111, 1 ) == 0x8888888888888888 );
|
||||
|
||||
#endif
|
||||
@@ -24,7 +24,7 @@ int main()
|
||||
|
||||
x = 1;
|
||||
|
||||
for( int i = 0; i < 8; ++i, x <<= 1 )
|
||||
for( int i = 0; i < 8; ++i, x = static_cast<boost::uint8_t>( x << 1 ) )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint8_t>( x | ( x >> 1 ) ) ), i+1 );
|
||||
@@ -39,7 +39,7 @@ int main()
|
||||
|
||||
x = 1;
|
||||
|
||||
for( int i = 0; i < 16; ++i, x <<= 1 )
|
||||
for( int i = 0; i < 16; ++i, x = static_cast<boost::uint16_t>( x << 1 ) )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::bit_width( x ), i+1 );
|
||||
BOOST_TEST_EQ( boost::core::bit_width( static_cast<boost::uint16_t>( x | ( x >> 1 ) ) ), i+1 );
|
||||
|
||||
30
test/bit_width_test_cx.cpp
Normal file
30
test/bit_width_test_cx.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// constexpr test for boost/core/bit.hpp (bit_width)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#elif defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC is " BOOST_STRINGIZE(BOOST_MSVC) )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::bit_width( (unsigned char)0x74 ) == 7 );
|
||||
STATIC_ASSERT( boost::core::bit_width( (unsigned short)0x7400 ) == 15 );
|
||||
STATIC_ASSERT( boost::core::bit_width( 0x740000u ) == 23 );
|
||||
STATIC_ASSERT( boost::core::bit_width( 0x74000000ul ) == 31 );
|
||||
STATIC_ASSERT( boost::core::bit_width( 0x7400000000ull ) == 39 );
|
||||
|
||||
#endif
|
||||
30
test/checked_array_deleter_compile_fail_adl.cpp
Normal file
30
test/checked_array_deleter_compile_fail_adl.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file checked_array_deleter_compile_fail_adl.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 07.02.2024
|
||||
*
|
||||
* This file tests that \c boost::checked_array_deleter doesn't bring namespace
|
||||
* \c boost into ADL.
|
||||
*/
|
||||
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
void check_adl(checked_array_deleter< int > const&)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
// Must not find boost::check_adl
|
||||
check_adl(boost::checked_array_deleter< int >());
|
||||
}
|
||||
30
test/checked_deleter_compile_fail_adl.cpp
Normal file
30
test/checked_deleter_compile_fail_adl.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file checked_deleter_compile_fail_adl.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 07.02.2024
|
||||
*
|
||||
* This file tests that \c boost::checked_deleter doesn't bring namespace
|
||||
* \c boost into ADL.
|
||||
*/
|
||||
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
void check_adl(checked_deleter< int > const&)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
// Must not find boost::check_adl
|
||||
check_adl(boost::checked_deleter< int >());
|
||||
}
|
||||
68
test/data_test.cpp
Normal file
68
test/data_test.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright 2023 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/data.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class range {
|
||||
public:
|
||||
int* data() {
|
||||
return &v_[0];
|
||||
}
|
||||
|
||||
const int* data() const {
|
||||
return &v_[0];
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
return 4;
|
||||
}
|
||||
|
||||
private:
|
||||
int v_[4];
|
||||
};
|
||||
|
||||
void test_range()
|
||||
{
|
||||
range c;
|
||||
BOOST_TEST_EQ(boost::data(c), c.data());
|
||||
}
|
||||
|
||||
void test_const_range()
|
||||
{
|
||||
const range c = range();
|
||||
BOOST_TEST_EQ(boost::data(c), c.data());
|
||||
}
|
||||
|
||||
void test_array()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ(boost::data(a), a);
|
||||
}
|
||||
|
||||
void test_initializer_list()
|
||||
{
|
||||
std::initializer_list<int> l{1, 2, 3, 4};
|
||||
BOOST_TEST_EQ(boost::data(l), l.begin());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_range();
|
||||
test_const_range();
|
||||
test_array();
|
||||
test_initializer_list();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
30
test/fclose_deleter_compile_fail_adl.cpp
Normal file
30
test/fclose_deleter_compile_fail_adl.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file fclose_deleter_compile_fail_adl.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 02.02.2024
|
||||
*
|
||||
* This file tests that \c boost::fclose_deleter doesn't bring namespace
|
||||
* \c boost into ADL.
|
||||
*/
|
||||
|
||||
#include <boost/core/fclose_deleter.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
void check_adl(fclose_deleter const&)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
// Must not find boost::check_adl
|
||||
check_adl(boost::fclose_deleter());
|
||||
}
|
||||
32
test/functor_compile_fail_adl.cpp
Normal file
32
test/functor_compile_fail_adl.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file functor_compile_fail_adl.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 02.02.2024
|
||||
*
|
||||
* This file tests that \c boost::core::functor doesn't bring namespace
|
||||
* \c boost::core into ADL.
|
||||
*/
|
||||
|
||||
#include <boost/core/functor.hpp>
|
||||
|
||||
void func() {}
|
||||
|
||||
namespace boost::core {
|
||||
|
||||
void check_adl(functor< ::func > const&)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace boost::core
|
||||
|
||||
int main()
|
||||
{
|
||||
// Must not find boost::check_adl
|
||||
check_adl(boost::core::functor< ::func >());
|
||||
}
|
||||
202
test/functor_test.cpp
Normal file
202
test/functor_test.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file functor_test.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 2024-01-23
|
||||
*
|
||||
* This file contains tests for \c boost::core::functor.
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_AUTO_NONTYPE_TEMPLATE_PARAMS)
|
||||
|
||||
#include <boost/core/functor.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
#if (defined(__cpp_lib_is_invocable) && (__cpp_lib_is_invocable >= 201703l)) || \
|
||||
(defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (BOOST_CXX_VERSION >= 201703l))
|
||||
|
||||
namespace test {
|
||||
|
||||
using std::is_invocable;
|
||||
|
||||
} // namespace test
|
||||
|
||||
#else
|
||||
|
||||
namespace test {
|
||||
|
||||
// A simplified implementation that does not support member function pointers
|
||||
template< typename Func, typename... Args >
|
||||
struct is_invocable_impl
|
||||
{
|
||||
template< typename F = Func, typename = decltype(std::declval< F >()(std::declval< Args >()...)) >
|
||||
static std::true_type _check_invocable(int);
|
||||
static std::false_type _check_invocable(...);
|
||||
|
||||
typedef decltype(is_invocable_impl::_check_invocable(0)) type;
|
||||
};
|
||||
|
||||
template< typename Func, typename... Args >
|
||||
struct is_invocable : public is_invocable_impl< Func, Args... >::type { };
|
||||
|
||||
} // namespace test
|
||||
|
||||
#endif
|
||||
|
||||
int g_n = 0;
|
||||
|
||||
void void_func()
|
||||
{
|
||||
++g_n;
|
||||
}
|
||||
|
||||
int int_func()
|
||||
{
|
||||
return ++g_n;
|
||||
}
|
||||
|
||||
int& int_ref_func()
|
||||
{
|
||||
++g_n;
|
||||
return g_n;
|
||||
}
|
||||
|
||||
void void_add1(int x)
|
||||
{
|
||||
g_n += x;
|
||||
}
|
||||
|
||||
int add2(int x, int y)
|
||||
{
|
||||
return x + y;
|
||||
}
|
||||
|
||||
namespace test_ns {
|
||||
|
||||
int add3(int x, int y, int z)
|
||||
{
|
||||
return x + y + z;
|
||||
}
|
||||
|
||||
} // namespace test_ns
|
||||
|
||||
int int_func_noexcept() noexcept
|
||||
{
|
||||
return ++g_n;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::core::functor< void_func > fun;
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< void_func >& >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< void_func > const& >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< void_func > const&, int >));
|
||||
BOOST_TEST_EQ(noexcept(fun()), false);
|
||||
fun();
|
||||
BOOST_TEST_EQ(g_n, 1);
|
||||
fun();
|
||||
BOOST_TEST_EQ(g_n, 2);
|
||||
}
|
||||
|
||||
g_n = 0;
|
||||
{
|
||||
boost::core::functor< int_func > fun;
|
||||
int res = fun();
|
||||
BOOST_TEST_EQ(res, 1);
|
||||
BOOST_TEST_EQ(g_n, 1);
|
||||
res = fun();
|
||||
BOOST_TEST_EQ(res, 2);
|
||||
BOOST_TEST_EQ(g_n, 2);
|
||||
}
|
||||
|
||||
g_n = 0;
|
||||
{
|
||||
boost::core::functor< int_ref_func > fun;
|
||||
int& res1 = fun();
|
||||
BOOST_TEST_EQ(&res1, &g_n);
|
||||
BOOST_TEST_EQ(res1, 1);
|
||||
int& res2 = fun();
|
||||
BOOST_TEST_EQ(&res2, &g_n);
|
||||
BOOST_TEST_EQ(res2, 2);
|
||||
}
|
||||
|
||||
g_n = 0;
|
||||
{
|
||||
boost::core::functor< void_add1 > fun;
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< void_add1 >& >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< void_add1 > const& >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< void_add1 >&, int >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< void_add1 > const&, int >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< void_add1 >&, short int >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< void_add1 > const&, short int >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< void_add1 > const&, int, int >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< void_add1 > const&, const char* >));
|
||||
fun(10);
|
||||
BOOST_TEST_EQ(g_n, 10);
|
||||
fun(20);
|
||||
BOOST_TEST_EQ(g_n, 30);
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::functor< add2 > fun;
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< add2 >& >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< add2 > const& >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< add2 >&, int >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< add2 > const&, int >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< add2 >&, int, int >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< add2 > const&, int, int >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< add2 >&, short int, signed char >));
|
||||
BOOST_TEST_TRAIT_TRUE((test::is_invocable< boost::core::functor< add2 > const&, short int, signed char >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< add2 > const&, const char* >));
|
||||
BOOST_TEST_TRAIT_FALSE((test::is_invocable< boost::core::functor< add2 > const&, const char*, float >));
|
||||
int res = fun(10, 20);
|
||||
BOOST_TEST_EQ(res, 30);
|
||||
res = fun(30, 40);
|
||||
BOOST_TEST_EQ(res, 70);
|
||||
}
|
||||
|
||||
{
|
||||
boost::core::functor< test_ns::add3 > fun;
|
||||
int res = fun(10, 20, 30);
|
||||
BOOST_TEST_EQ(res, 60);
|
||||
res = fun(40, 50, 60);
|
||||
BOOST_TEST_EQ(res, 150);
|
||||
}
|
||||
|
||||
g_n = 0;
|
||||
{
|
||||
boost::core::functor< int_func_noexcept > fun;
|
||||
BOOST_TEST_EQ(noexcept(fun()), true);
|
||||
int res = fun();
|
||||
BOOST_TEST_EQ(res, 1);
|
||||
BOOST_TEST_EQ(g_n, 1);
|
||||
res = fun();
|
||||
BOOST_TEST_EQ(res, 2);
|
||||
BOOST_TEST_EQ(g_n, 2);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else // !defined(BOOST_NO_CXX17_AUTO_NONTYPE_TEMPLATE_PARAMS)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Test skipped because C++17 auto non-type template parameters are not supported")
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX17_AUTO_NONTYPE_TEMPLATE_PARAMS)
|
||||
@@ -28,7 +28,7 @@ int main()
|
||||
|
||||
x = 2;
|
||||
|
||||
for( int i = 1; i < 8; ++i, x <<= 1 )
|
||||
for( int i = 1; i < 8; ++i, x = static_cast<boost::uint8_t>( x << 1 ) )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint8_t>( x | ( x >> 1 ) ) ), false );
|
||||
@@ -47,7 +47,7 @@ int main()
|
||||
|
||||
x = 2;
|
||||
|
||||
for( int i = 1; i < 16; ++i, x <<= 1 )
|
||||
for( int i = 1; i < 16; ++i, x = static_cast<boost::uint16_t>( x << 1 ) )
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( x ), true );
|
||||
BOOST_TEST_EQ( boost::core::has_single_bit( static_cast<boost::uint16_t>( x | ( x >> 1 ) ) ), false );
|
||||
|
||||
35
test/has_single_bit_test_cx.cpp
Normal file
35
test/has_single_bit_test_cx.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// constexpr test for boost/core/bit.hpp (has_single_bit)
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
STATIC_ASSERT( boost::core::has_single_bit( (unsigned char)0x80 ) == true );
|
||||
STATIC_ASSERT( boost::core::has_single_bit( (unsigned char)0x90 ) == false );
|
||||
|
||||
STATIC_ASSERT( boost::core::has_single_bit( (unsigned short)0x8000 ) == true );
|
||||
STATIC_ASSERT( boost::core::has_single_bit( (unsigned short)0x9000 ) == false );
|
||||
|
||||
STATIC_ASSERT( boost::core::has_single_bit( 0x800000u ) == true );
|
||||
STATIC_ASSERT( boost::core::has_single_bit( 0x900000u ) == false );
|
||||
|
||||
STATIC_ASSERT( boost::core::has_single_bit( 0x80000000ul ) == true );
|
||||
STATIC_ASSERT( boost::core::has_single_bit( 0x90000000ul ) == false );
|
||||
|
||||
STATIC_ASSERT( boost::core::has_single_bit( 0x8000000000ull ) == true );
|
||||
STATIC_ASSERT( boost::core::has_single_bit( 0x9000000000ull ) == false );
|
||||
|
||||
#endif
|
||||
69
test/identity_rvalue_test.cpp
Normal file
69
test/identity_rvalue_test.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright 2021-2023 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_RVALUE_REFERENCES)
|
||||
#include <boost/core/identity.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
bool test(std::string&&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test(const std::string&&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool test(T&&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void simple_test()
|
||||
{
|
||||
typedef std::string string;
|
||||
BOOST_TEST(boost::identity()(string("a")) == string("a"));
|
||||
BOOST_TEST(test(boost::identity()(string("a"))));
|
||||
typedef const std::string cstring;
|
||||
BOOST_TEST(boost::identity()(cstring("a")) == cstring("a"));
|
||||
BOOST_TEST(test(boost::identity()(cstring("a"))));
|
||||
}
|
||||
|
||||
void algorithm_test()
|
||||
{
|
||||
std::vector<std::string> v1;
|
||||
v1.push_back(std::string("a"));
|
||||
v1.push_back(std::string("b"));
|
||||
v1.push_back(std::string("c"));
|
||||
std::vector<std::string> v2(v1);
|
||||
std::vector<std::string> v3;
|
||||
std::transform(std::make_move_iterator(v2.begin()),
|
||||
std::make_move_iterator(v2.end()),
|
||||
std::back_inserter(v3),
|
||||
boost::identity());
|
||||
BOOST_TEST(v3 == v1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
simple_test();
|
||||
algorithm_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
66
test/identity_test.cpp
Normal file
66
test/identity_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2021-2023 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/identity.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
bool test(std::string&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test(const std::string&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool test(T&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool test(const T&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void simple_test()
|
||||
{
|
||||
std::string s1("a");
|
||||
BOOST_TEST(boost::identity()(s1) == s1);
|
||||
BOOST_TEST(&boost::identity()(s1) == &s1);
|
||||
BOOST_TEST(test(boost::identity()(s1)));
|
||||
const std::string s2("a");
|
||||
BOOST_TEST(boost::identity()(s2) == s2);
|
||||
BOOST_TEST(&boost::identity()(s2) == &s2);
|
||||
BOOST_TEST(test(boost::identity()(s2)));
|
||||
}
|
||||
|
||||
void algorithm_test()
|
||||
{
|
||||
std::vector<std::string> v1;
|
||||
v1.push_back(std::string("a"));
|
||||
v1.push_back(std::string("b"));
|
||||
v1.push_back(std::string("c"));
|
||||
std::vector<std::string> v2;
|
||||
std::transform(v1.begin(), v1.end(), std::back_inserter(v2),
|
||||
boost::identity());
|
||||
BOOST_TEST(v2 == v1);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
simple_test();
|
||||
algorithm_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
100
test/make_span_test.cpp
Normal file
100
test/make_span_test.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
Copyright 2023 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/make_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<int> s = boost::make_span(&a[0], 4);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_first_last()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int> s = boost::make_span(&a[0], &a[4]);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_array()
|
||||
{
|
||||
int a[4];
|
||||
boost::span<int, 4> s = boost::make_span(a);
|
||||
BOOST_TEST_EQ(s.data(), &a[0]);
|
||||
BOOST_TEST_EQ(s.size(), 4);
|
||||
}
|
||||
|
||||
void test_std_array()
|
||||
{
|
||||
std::array<int, 4> a;
|
||||
boost::span<int, 4> s = boost::make_span(a);
|
||||
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<const int> s = boost::make_span(a);
|
||||
BOOST_TEST_EQ(s.data(), a.data());
|
||||
BOOST_TEST_EQ(s.size(), a.size());
|
||||
}
|
||||
|
||||
void test_range()
|
||||
{
|
||||
range<int> c;
|
||||
boost::span<int> s = boost::make_span(c);
|
||||
BOOST_TEST_EQ(s.data(), c.data());
|
||||
BOOST_TEST_EQ(s.size(), c.size());
|
||||
}
|
||||
|
||||
void test_initializer_list()
|
||||
{
|
||||
std::initializer_list<int> l{1, 2};
|
||||
boost::span<const int> s = boost::make_span(l);
|
||||
BOOST_TEST_EQ(s.data(), l.begin());
|
||||
BOOST_TEST_EQ(s.size(), l.size());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_data_size();
|
||||
test_first_last();
|
||||
test_array();
|
||||
test_std_array();
|
||||
test_const_std_array();
|
||||
test_range();
|
||||
test_initializer_list();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
63
test/max_align_test.cpp
Normal file
63
test/max_align_test.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/max_align.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 40900
|
||||
# define BOOST_NO_STD_MAX_ALIGN_T
|
||||
#endif
|
||||
|
||||
struct X
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( boost::core::max_align, boost::alignment_of<boost::core::max_align_t>::value );
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<char>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<short>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<int>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<long>::value );
|
||||
|
||||
#if !defined(BOOST_NO_LONG_LONG)
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<boost::long_long_type>::value );
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<boost::int128_type>::value );
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<float>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<double>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<long double>::value );
|
||||
|
||||
#if defined(BOOST_CORE_HAS_FLOAT128)
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<__float128>::value );
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<void*>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<void(*)()>::value );
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<int X::*>::value );
|
||||
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<void (X::*)()>::value );
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALIGNOF) && !defined(BOOST_NO_STD_MAX_ALIGN_T)
|
||||
|
||||
BOOST_TEST_GE( boost::core::max_align, alignof( std::max_align_t ) );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
141
test/memory_resource_test.cpp
Normal file
141
test/memory_resource_test.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/memory_resource.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <new>
|
||||
#include <cstddef>
|
||||
|
||||
static bool do_allocate_called;
|
||||
static std::size_t do_allocate_bytes;
|
||||
static std::size_t do_allocate_alignment;
|
||||
|
||||
static bool do_deallocate_called;
|
||||
static void* do_deallocate_p;
|
||||
static std::size_t do_deallocate_bytes;
|
||||
static std::size_t do_deallocate_alignment;
|
||||
|
||||
struct R1: public boost::core::memory_resource
|
||||
{
|
||||
void* do_allocate( std::size_t bytes, std::size_t alignment )
|
||||
{
|
||||
do_allocate_called = true;
|
||||
do_allocate_bytes = bytes;
|
||||
do_allocate_alignment = alignment;
|
||||
|
||||
return ::operator new( bytes );
|
||||
}
|
||||
|
||||
void do_deallocate( void* p, std::size_t bytes, std::size_t alignment )
|
||||
{
|
||||
do_deallocate_called = true;
|
||||
do_deallocate_p = p;
|
||||
do_deallocate_bytes = bytes;
|
||||
do_deallocate_alignment = alignment;
|
||||
|
||||
::operator delete( p );
|
||||
}
|
||||
|
||||
bool do_is_equal( memory_resource const & /*other*/ ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct R2: public boost::core::memory_resource
|
||||
{
|
||||
void* do_allocate( std::size_t bytes, std::size_t /*alignment*/ )
|
||||
{
|
||||
return ::operator new( bytes );
|
||||
}
|
||||
|
||||
void do_deallocate( void* p, std::size_t /*bytes*/, std::size_t /*alignment*/ )
|
||||
{
|
||||
::operator delete( p );
|
||||
}
|
||||
|
||||
bool do_is_equal( memory_resource const & other ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return this == &other;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
R1 r1;
|
||||
|
||||
do_allocate_called = false;
|
||||
do_allocate_bytes = 0;
|
||||
do_allocate_alignment = 0;
|
||||
|
||||
void* p = r1.allocate( 31 );
|
||||
|
||||
BOOST_TEST( do_allocate_called );
|
||||
BOOST_TEST_EQ( do_allocate_bytes, 31 );
|
||||
BOOST_TEST_EQ( do_allocate_alignment, boost::core::max_align );
|
||||
|
||||
do_deallocate_called = false;
|
||||
do_deallocate_p = 0;
|
||||
do_deallocate_bytes = 0;
|
||||
do_deallocate_alignment = 0;
|
||||
|
||||
r1.deallocate( p, 31 );
|
||||
|
||||
BOOST_TEST( do_deallocate_called );
|
||||
BOOST_TEST_EQ( do_deallocate_p, p );
|
||||
BOOST_TEST_EQ( do_deallocate_bytes, 31 );
|
||||
BOOST_TEST_EQ( do_deallocate_alignment, boost::core::max_align );
|
||||
}
|
||||
|
||||
{
|
||||
R1 r1;
|
||||
|
||||
do_allocate_called = false;
|
||||
do_allocate_bytes = 0;
|
||||
do_allocate_alignment = 0;
|
||||
|
||||
void* p = r1.allocate( 1, 8 );
|
||||
|
||||
BOOST_TEST( do_allocate_called );
|
||||
BOOST_TEST_EQ( do_allocate_bytes, 1 );
|
||||
BOOST_TEST_EQ( do_allocate_alignment, 8 );
|
||||
|
||||
do_deallocate_called = false;
|
||||
do_deallocate_p = 0;
|
||||
do_deallocate_bytes = 0;
|
||||
do_deallocate_alignment = 0;
|
||||
|
||||
r1.deallocate( p, 1, 8 );
|
||||
|
||||
BOOST_TEST( do_deallocate_called );
|
||||
BOOST_TEST_EQ( do_deallocate_p, p );
|
||||
BOOST_TEST_EQ( do_deallocate_bytes, 1 );
|
||||
BOOST_TEST_EQ( do_deallocate_alignment, 8 );
|
||||
}
|
||||
|
||||
{
|
||||
R1 r1;
|
||||
R1 r2;
|
||||
|
||||
BOOST_TEST( r1 == r1 );
|
||||
BOOST_TEST_NOT( r1 != r1 );
|
||||
|
||||
BOOST_TEST( r1 == r2 );
|
||||
BOOST_TEST_NOT( r1 != r2 );
|
||||
}
|
||||
|
||||
{
|
||||
R2 r1;
|
||||
R2 r2;
|
||||
|
||||
BOOST_TEST( r1 == r1 );
|
||||
BOOST_TEST_NOT( r1 != r1 );
|
||||
|
||||
BOOST_TEST_NOT( r1 == r2 );
|
||||
BOOST_TEST( r1 != r2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
38
test/minstd_rand_test.cpp
Normal file
38
test/minstd_rand_test.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Test for boost/core/detail/minstd_rand.hpp
|
||||
//
|
||||
// Copyright 2022, 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/minstd_rand.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::detail::minstd_rand rng;
|
||||
|
||||
boost::uint_least32_t r1 = rng(), x1 = 48271;
|
||||
BOOST_TEST_EQ( r1, x1 );
|
||||
|
||||
for( int i = 0; i < 1000; ++i ) rng();
|
||||
|
||||
boost::uint_least32_t r2 = rng(), x2 = 2076422031;
|
||||
BOOST_TEST_EQ( r2, x2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::detail::minstd_rand rng( 12345 );
|
||||
|
||||
boost::uint_least32_t r1 = rng(), x1 = 595905495;
|
||||
BOOST_TEST_EQ( r1, x1 );
|
||||
|
||||
for( int i = 0; i < 1000; ++i ) rng();
|
||||
|
||||
boost::uint_least32_t r2 = rng(), x2 = 1065162103;
|
||||
BOOST_TEST_EQ( r2, x2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
30
test/null_deleter_compile_fail_adl.cpp
Normal file
30
test/null_deleter_compile_fail_adl.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2024.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file fclose_deleter_compile_fail_adl.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 02.02.2024
|
||||
*
|
||||
* This file tests that \c boost::null_deleter doesn't bring namespace
|
||||
* \c boost into ADL.
|
||||
*/
|
||||
|
||||
#include <boost/core/null_deleter.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
void check_adl(null_deleter const&)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
int main()
|
||||
{
|
||||
// Must not find boost::check_adl
|
||||
check_adl(boost::null_deleter());
|
||||
}
|
||||
31
test/pointer_in_range_constexpr_test.cpp
Normal file
31
test/pointer_in_range_constexpr_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2024 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_in_range.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#if !defined(BOOST_CORE_NO_CONSTEXPR_POINTER_IN_RANGE)
|
||||
int a[4] = { 0, 0, 0, 0 };
|
||||
int n = 0;
|
||||
const int b[4] = { 0, 0, 0, 0 };
|
||||
const int m = 0;
|
||||
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(&a[0], &a[1], a + 4));
|
||||
BOOST_STATIC_ASSERT(boost::pointer_in_range(&a[1], &a[1], a + 4));
|
||||
BOOST_STATIC_ASSERT(boost::pointer_in_range(&a[2], &a[1], a + 4));
|
||||
BOOST_STATIC_ASSERT(boost::pointer_in_range(&a[3], &a[1], a + 4));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(a + 4, &a[1], a + 4));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(&n, &a[0], &a[3]));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(&m, &a[0], &a[3]));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(&b[0], &b[1], b + 4));
|
||||
BOOST_STATIC_ASSERT(boost::pointer_in_range(&b[1], &b[1], b + 4));
|
||||
BOOST_STATIC_ASSERT(boost::pointer_in_range(&b[2], &b[1], b + 4));
|
||||
BOOST_STATIC_ASSERT(boost::pointer_in_range(&b[3], &b[1], b + 4));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(b + 4, &b[1], b + 4));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(&n, &b[0], &b[3]));
|
||||
BOOST_STATIC_ASSERT(!boost::pointer_in_range(&m, &b[0], &b[3]));
|
||||
#endif
|
||||
32
test/pointer_in_range_test.cpp
Normal file
32
test/pointer_in_range_test.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2024 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_in_range.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int a[4] = { 0, 0, 0, 0 };
|
||||
int n = 0;
|
||||
const int b[4] = { 0, 0, 0, 0 };
|
||||
const int m = 0;
|
||||
BOOST_TEST(!boost::pointer_in_range(&a[0], &a[1], a + 4));
|
||||
BOOST_TEST(boost::pointer_in_range(&a[1], &a[1], a + 4));
|
||||
BOOST_TEST(boost::pointer_in_range(&a[2], &a[1], a + 4));
|
||||
BOOST_TEST(boost::pointer_in_range(&a[3], &a[1], a + 4));
|
||||
BOOST_TEST(!boost::pointer_in_range(a + 4, &a[1], a + 4));
|
||||
BOOST_TEST(!boost::pointer_in_range(&n, &a[0], &a[3]));
|
||||
BOOST_TEST(!boost::pointer_in_range(&m, &a[0], &a[3]));
|
||||
BOOST_TEST(!boost::pointer_in_range(&b[0], &b[1], b + 4));
|
||||
BOOST_TEST(boost::pointer_in_range(&b[1], &b[1], b + 4));
|
||||
BOOST_TEST(boost::pointer_in_range(&b[2], &b[1], b + 4));
|
||||
BOOST_TEST(boost::pointer_in_range(&b[3], &b[1], b + 4));
|
||||
BOOST_TEST(!boost::pointer_in_range(b + 4, &b[1], b + 4));
|
||||
BOOST_TEST(!boost::pointer_in_range(&n, &b[0], &b[3]));
|
||||
BOOST_TEST(!boost::pointer_in_range(&m, &b[0], &b[3]));
|
||||
return boost::report_errors();
|
||||
}
|
||||
102
test/serialization_construct_data_test.cpp
Normal file
102
test/serialization_construct_data_test.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wdeprecated-copy" )
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-copy"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/core/serialization.hpp>
|
||||
#include <new>
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
explicit X( int v ): v_( v ) {}
|
||||
|
||||
template<class Ar> void serialize( Ar& /*ar*/, unsigned /*v*/ )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class Ar> void save_construct_data( Ar& ar, X const* t, unsigned /*v*/ )
|
||||
{
|
||||
ar << t->v_;
|
||||
}
|
||||
|
||||
template<class Ar> void load_construct_data( Ar& ar, X* t, unsigned /*v*/ )
|
||||
{
|
||||
int v;
|
||||
ar >> v;
|
||||
|
||||
::new( t ) X( v );
|
||||
}
|
||||
|
||||
struct Y
|
||||
{
|
||||
X x1, x2;
|
||||
|
||||
explicit Y( int v1, int v2 ): x1( v1 ), x2( v2 ) {}
|
||||
|
||||
private:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Ar> void load( Ar& ar, unsigned v )
|
||||
{
|
||||
boost::core::load_construct_data_adl( ar, &x1, v );
|
||||
ar >> x1;
|
||||
|
||||
boost::core::load_construct_data_adl( ar, &x2, v );
|
||||
ar >> x2;
|
||||
}
|
||||
|
||||
template<class Ar> void save( Ar& ar, unsigned v ) const
|
||||
{
|
||||
boost::core::save_construct_data_adl( ar, &x1, v );
|
||||
ar << x1;
|
||||
|
||||
boost::core::save_construct_data_adl( ar, &x2, v );
|
||||
ar << x2;
|
||||
}
|
||||
|
||||
template<class Ar> void serialize( Ar& ar, unsigned v )
|
||||
{
|
||||
boost::core::split_member( ar, *this, v );
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
Y y1( 7, 11 );
|
||||
|
||||
{
|
||||
boost::archive::text_oarchive ar( os );
|
||||
ar << y1;
|
||||
}
|
||||
|
||||
std::string s = os.str();
|
||||
|
||||
Y y2( 0, 0 );
|
||||
|
||||
{
|
||||
std::istringstream is( s );
|
||||
boost::archive::text_iarchive ar( is );
|
||||
ar >> y2;
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( y1.x1.v_, y2.x1.v_ );
|
||||
BOOST_TEST_EQ( y1.x2.v_, y2.x2.v_ );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
55
test/serialization_nvp_test.cpp
Normal file
55
test/serialization_nvp_test.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wdeprecated-copy" )
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-copy"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/core/serialization.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int a, b;
|
||||
|
||||
template<class Ar> void serialize( Ar& ar, unsigned /*v*/ )
|
||||
{
|
||||
ar & boost::core::make_nvp( "a", a );
|
||||
ar & boost::core::make_nvp( "b", b );
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
X x1 = { 7, 11 };
|
||||
|
||||
{
|
||||
boost::archive::xml_oarchive ar( os );
|
||||
ar << boost::core::make_nvp( "x1", x1 );
|
||||
}
|
||||
|
||||
std::string s = os.str();
|
||||
|
||||
X x2 = { 0, 0 };
|
||||
|
||||
{
|
||||
std::istringstream is( s );
|
||||
boost::archive::xml_iarchive ar( is );
|
||||
ar >> boost::make_nvp( "x2", x2 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( x1.a, x2.a );
|
||||
BOOST_TEST_EQ( x1.b, x2.b );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
66
test/serialization_split_free_test.cpp
Normal file
66
test/serialization_split_free_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wdeprecated-copy" )
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-copy"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/core/serialization.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int a, b;
|
||||
};
|
||||
|
||||
template<class Ar> void load( Ar& ar, X& x, unsigned /*v*/ )
|
||||
{
|
||||
ar >> x.a;
|
||||
ar >> x.b;
|
||||
}
|
||||
|
||||
template<class Ar> void save( Ar& ar, X const& x, unsigned /*v*/ )
|
||||
{
|
||||
ar << x.a;
|
||||
ar << x.b;
|
||||
}
|
||||
|
||||
template<class Ar> void serialize( Ar& ar, X& x, unsigned v )
|
||||
{
|
||||
boost::core::split_free( ar, x, v );
|
||||
}
|
||||
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
X x1 = { 7, 11 };
|
||||
|
||||
{
|
||||
boost::archive::text_oarchive ar( os );
|
||||
ar << x1;
|
||||
}
|
||||
|
||||
std::string s = os.str();
|
||||
|
||||
X x2 = { 0, 0 };
|
||||
|
||||
{
|
||||
std::istringstream is( s );
|
||||
boost::archive::text_iarchive ar( is );
|
||||
ar >> x2;
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( x1.a, x2.a );
|
||||
BOOST_TEST_EQ( x1.b, x2.b );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
70
test/serialization_split_member_test.cpp
Normal file
70
test/serialization_split_member_test.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wdeprecated-copy" )
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-copy"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/core/serialization.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int a, b;
|
||||
|
||||
private:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Ar> void load( Ar& ar, unsigned /*v*/ )
|
||||
{
|
||||
ar >> a;
|
||||
ar >> b;
|
||||
}
|
||||
|
||||
template<class Ar> void save( Ar& ar, unsigned /*v*/ ) const
|
||||
{
|
||||
ar << a;
|
||||
ar << b;
|
||||
}
|
||||
|
||||
template<class Ar> void serialize( Ar& ar, unsigned v )
|
||||
{
|
||||
boost::core::split_member( ar, *this, v );
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
X x1 = { 7, 11 };
|
||||
|
||||
{
|
||||
boost::archive::text_oarchive ar( os );
|
||||
ar << x1;
|
||||
}
|
||||
|
||||
std::string s = os.str();
|
||||
|
||||
X x2 = { 0, 0 };
|
||||
|
||||
{
|
||||
std::istringstream is( s );
|
||||
boost::archive::text_iarchive ar( is );
|
||||
ar >> x2;
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( x1.a, x2.a );
|
||||
BOOST_TEST_EQ( x1.b, x2.b );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
42
test/size_test.cpp
Normal file
42
test/size_test.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright 2023 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/size.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct range {
|
||||
std::size_t size() const {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
|
||||
void test_range()
|
||||
{
|
||||
range c;
|
||||
BOOST_TEST_EQ(boost::size(c), 4);
|
||||
}
|
||||
|
||||
void test_array()
|
||||
{
|
||||
int a[4];
|
||||
BOOST_TEST_EQ(boost::size(a), 4);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_range();
|
||||
test_array();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
15
test/sp_thread_pause_test.cpp
Normal file
15
test/sp_thread_pause_test.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// Test for sp_thread_pause
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/yield_primitives.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
for( int i = 0; i < 1048576; ++i )
|
||||
{
|
||||
boost::core::sp_thread_pause();
|
||||
}
|
||||
}
|
||||
15
test/sp_thread_sleep_test.cpp
Normal file
15
test/sp_thread_sleep_test.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// Test for sp_thread_sleep
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/yield_primitives.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
for( int i = 0; i < 100; ++i )
|
||||
{
|
||||
boost::core::sp_thread_sleep();
|
||||
}
|
||||
}
|
||||
15
test/sp_thread_yield_test.cpp
Normal file
15
test/sp_thread_yield_test.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// Test for sp_thread_yield
|
||||
//
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/yield_primitives.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
for( int i = 0; i < 10000; ++i )
|
||||
{
|
||||
boost::core::sp_thread_yield();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
Copyright 2019-2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -140,6 +140,14 @@ void test_range()
|
||||
range<derived>&>));
|
||||
}
|
||||
|
||||
void test_initializer_list()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
std::initializer_list<int> >));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
std::initializer_list<int> >));
|
||||
}
|
||||
|
||||
void test_span()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
|
||||
@@ -187,6 +195,7 @@ int main()
|
||||
test_std_array();
|
||||
test_const_std_array();
|
||||
test_range();
|
||||
test_initializer_list();
|
||||
test_span();
|
||||
test_copy();
|
||||
test_assign();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
Copyright 2019-2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -78,6 +78,15 @@ void test_range()
|
||||
BOOST_TEST_EQ(s.size(), c.size());
|
||||
}
|
||||
|
||||
void test_initializer_list()
|
||||
{
|
||||
std::initializer_list<int> l{1, 2};
|
||||
boost::span s(l);
|
||||
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
|
||||
BOOST_TEST_EQ(s.data(), l.begin());
|
||||
BOOST_TEST_EQ(s.size(), l.size());
|
||||
}
|
||||
|
||||
void test_span_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
@@ -104,6 +113,7 @@ int main()
|
||||
test_std_array();
|
||||
test_const_std_array();
|
||||
test_range();
|
||||
test_initializer_list();
|
||||
test_span_dynamic();
|
||||
test_span_static();
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
Copyright 2019-2023 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -118,6 +118,14 @@ void test_construct_range()
|
||||
BOOST_TEST_EQ(s.size(), c.size());
|
||||
}
|
||||
|
||||
void test_construct_initializer_list()
|
||||
{
|
||||
std::initializer_list<int> l{1, 2};
|
||||
boost::span<const int> s(l);
|
||||
BOOST_TEST_EQ(s.data(), l.begin());
|
||||
BOOST_TEST_EQ(s.size(), l.size());
|
||||
}
|
||||
|
||||
void test_construct_span_dynamic()
|
||||
{
|
||||
int a[4];
|
||||
@@ -376,6 +384,7 @@ int main()
|
||||
test_construct_const_std_array_dynamic();
|
||||
test_construct_const_std_array_static();
|
||||
test_construct_range();
|
||||
test_construct_initializer_list();
|
||||
test_construct_span_dynamic();
|
||||
test_construct_span_dynamic_static();
|
||||
test_construct_span_static();
|
||||
|
||||
@@ -4,6 +4,18 @@
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
# if defined(__apple_build_version__)
|
||||
// Under macOS, it's possible for the header
|
||||
// <memory_resource> to be present, but for
|
||||
// libc++.dylib to not have support for it.
|
||||
// https://github.com/boostorg/core/issues/162
|
||||
# define BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
147
test/sv_construct_test_cx.cpp
Normal file
147
test/sv_construct_test_cx.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
// Copyright 2021, 2024 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.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
constexpr boost::core::string_view sv;
|
||||
|
||||
STATIC_ASSERT( sv.data() == nullptr );
|
||||
STATIC_ASSERT( sv.size() == 0 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* s = "123";
|
||||
|
||||
constexpr boost::core::string_view sv( s, 0 );
|
||||
|
||||
STATIC_ASSERT( sv.data() == s );
|
||||
STATIC_ASSERT( sv.size() == 0 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* s = "123";
|
||||
|
||||
constexpr boost::core::string_view sv( s, 2 );
|
||||
|
||||
STATIC_ASSERT( sv.data() == s );
|
||||
STATIC_ASSERT( sv.size() == 2 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* s = "123";
|
||||
|
||||
constexpr boost::core::string_view sv( s, s );
|
||||
|
||||
STATIC_ASSERT( sv.data() == s );
|
||||
STATIC_ASSERT( sv.size() == 0 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* s = "123";
|
||||
|
||||
constexpr boost::core::string_view sv( s, s + 2 );
|
||||
|
||||
STATIC_ASSERT( sv.data() == s );
|
||||
STATIC_ASSERT( sv.size() == 2 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
{
|
||||
constexpr std::string_view str( "123", 3 );
|
||||
|
||||
constexpr boost::core::string_view sv( str );
|
||||
|
||||
STATIC_ASSERT( sv.data() == str.data() );
|
||||
STATIC_ASSERT( sv.size() == str.size() );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
75
test/sv_construct_test_cx2.cpp
Normal file
75
test/sv_construct_test_cx2.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright 2021, 2024 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.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
int main() {}
|
||||
|
||||
#elif BOOST_CXX_VERSION < 201703L
|
||||
|
||||
// std::char_traits is not constexpr in C++14
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_CXX_VERSION < 201703L" )
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 70300
|
||||
|
||||
// std::char_traits is not constexpr in libstdc++ 7.2
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_LIBSTDCXX_VERSION < 70300" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
constexpr char const* s = "";
|
||||
|
||||
constexpr boost::core::string_view sv( s );
|
||||
|
||||
STATIC_ASSERT( sv.data() == s );
|
||||
STATIC_ASSERT( sv.size() == 0 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* s = "123";
|
||||
|
||||
constexpr boost::core::string_view sv( s );
|
||||
|
||||
STATIC_ASSERT( sv.data() == s );
|
||||
STATIC_ASSERT( sv.size() == 3 );
|
||||
|
||||
STATIC_ASSERT( sv.begin() == sv.data() );
|
||||
STATIC_ASSERT( sv.end() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.cbegin() == sv.data() );
|
||||
STATIC_ASSERT( sv.cend() == sv.data() + sv.size() );
|
||||
|
||||
STATIC_ASSERT( sv.length() == sv.size() );
|
||||
STATIC_ASSERT( sv.empty() == ( sv.size() == 0 ) );
|
||||
|
||||
STATIC_ASSERT( sv.max_size() == boost::core::string_view::npos );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -4,6 +4,18 @@
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
|
||||
# if defined(__apple_build_version__)
|
||||
// Under macOS, it's possible for the header
|
||||
// <memory_resource> to be present, but for
|
||||
// libc++.dylib to not have support for it.
|
||||
// https://github.com/boostorg/core/issues/162
|
||||
# define BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
# include <string_view>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user