1
0
forked from boostorg/core

Compare commits

...

49 Commits

Author SHA1 Message Date
Peter Dimov
e4adc769aa Disable use of std::launder under msvc-14.1. Fixes #160. 2024-01-04 04:07:34 +02:00
Peter Dimov
8af04d101c Update .drone.jsonnet 2024-01-04 02:45:24 +02:00
Peter Dimov
cece8ca5b4 Update .drone.jsonnet 2023-11-30 11:39:42 +02:00
Peter Dimov
6c95750f37 Use BOOST_GCC instead of BOOST_GCC_VERSION 2023-11-30 10:33:08 +02:00
Andrey Semashev
a9f1407d84 Added a sanity check to prevent duplicate definition of BOOST_CORE_HAS_BUILTIN_BIT_CAST. 2023-11-25 16:04:12 +03:00
Andrey Semashev
db0fd77af1 Added support for __builtin_bswap16. 2023-11-25 16:04:12 +03:00
Andrey Semashev
7cbbb08e7b Use libstdc++11 for clang prior to 16.
Clang prior to version 16 does not support libstdc++13 that is installed
by default in GHA image ubuntu 22.04 in C++20 mode.
2023-11-25 16:04:12 +03:00
Peter Dimov
ba6360e8ed Update test/Jamfile 2023-10-06 11:30:51 +03:00
Peter Dimov
2a70a0f239 Update ci.yml 2023-10-06 11:20:05 +03:00
Peter Dimov
31a2f7fb6b Merge pull request #158 from iskunk/feature/fix-intel-build
Fix Intel compiler build
2023-10-06 04:21:16 +03:00
Daniel Richard G
0120dbfe65 Fix Intel compiler build 2023-10-05 20:26:24 -04:00
Andrey Semashev
5f6fe65eb2 Merge pull request #149 from boostorg/feature/invoke_swap
Rename `boost::swap` to `boost::core::invoke_swap`, deprecate `boost::swap`
2023-08-25 14:50:06 +03:00
Peter Dimov
c7134904e2 Android doesn't support pthread_setcancelstate. Fixes #150. 2023-07-25 18:03:51 +03:00
Andrey Semashev
9fc2a2f1ac Renamed boost::swap to boost::core::invoke_swap, deprecated boost::swap.
The rename allows to avoid forming an infinite recursion in compile time
(because of noexcept specification that needs to resolve the unqualified call
to swap) or run time (in case if the boost::swap function is the only one
suitable for the passed arguments).

To avoid the compile-time recursion, removed noexcept specification from
boost::swap. The specification is still present in boost::core::invoke_swap.

Deprecated boost::swap and associated headers. boost::core::invoke_swap
is defined in a new boost/core/invoke_swap.hpp header.

Updated docs and tests. Removed tests that check inclusion of deprecated
headers.

Fixes https://github.com/boostorg/core/issues/148.
2023-07-12 12:17:07 +03:00
Peter Dimov
216999e552 Avoid -Wsign-conversion warning in checked_delete.hpp 2023-06-25 13:46:53 +03:00
Peter Dimov
66890c3f3d Use SwitchToThread instead of Sleep(0) is sp_thread_yield; the general consensus is that it's newer and 'smarter' 2023-06-18 21:54:13 +03:00
Andrey Semashev
8d6d20059a Switch CI to clang-15 from stock Ubuntu repos. 2023-06-05 03:13:05 +03:00
Peter Dimov
ee596e3d37 Update documentation 2023-06-02 20:39:42 +03:00
Peter Dimov
de8fe4fad7 Fix libc++16 failures 2023-06-02 19:32:28 +03:00
Peter Dimov
d4db3eccec Add Clang 16 to CI 2023-06-02 18:07:06 +03:00
Peter Dimov
3b96d237c0 Update test/CMakeLists.txt 2023-06-02 04:32:42 +03:00
Peter Dimov
0e71b6158d Add noexcept to yield primitives 2023-06-02 04:27:12 +03:00
Peter Dimov
23ef6d3531 Disable cancelation around nanosleep in sp_thread_sleep 2023-06-02 03:57:38 +03:00
Peter Dimov
e088fb8929 Add yield_prim_pthread_cancel_test 2023-06-02 03:27:29 +03:00
Peter Dimov
57151ab82e Update sp_thread_pause.hpp 2023-06-02 02:05:36 +03:00
Peter Dimov
992326b1c8 Decrease loop count of sp_thread_sleep_test 2023-06-02 02:04:46 +03:00
Peter Dimov
4e769d1cdd Add boost/core/yield_primitives.hpp 2023-06-01 23:08:32 +03:00
Peter Dimov
bf17035a2d Disable bit_cast_test_cx when __builtin_bit_cast is not available 2023-06-01 03:20:22 +03:00
Peter Dimov
5a3b4df5de Use __builtin_bit_cast when available 2023-06-01 02:38:57 +03:00
Peter Dimov
85527c4045 More -Wconversion fixes 2023-05-31 20:22:15 +03:00
Peter Dimov
7ab05d5de0 More -Wconversion fixes for GCC 10 and below 2023-05-31 19:54:43 +03:00
Peter Dimov
266fbe6449 Fix -Wconversion warnings 2023-05-31 18:53:35 +03:00
Peter Dimov
fd0de5f538 Add -Wconversion to pedantic-errors 2023-05-31 18:28:33 +03:00
Peter Dimov
350526f7c7 Update documentation 2023-05-31 02:29:32 +03:00
Peter Dimov
06fef712c9 Use MS _byteswap intrinsics 2023-05-30 21:12:25 +03:00
Peter Dimov
b7f7eb4f90 Avoid -Wlong-long under C++03 2023-05-30 19:27:42 +03:00
Peter Dimov
f41b8f38c4 Use __builtin_bswap under GCC and Clang 2023-05-30 19:22:00 +03:00
Peter Dimov
b591214103 Add byteswap to bit.hpp 2023-05-30 19:09:09 +03:00
Peter Dimov
6b9f0cbf57 Update revision history 2023-05-30 06:24:43 +03:00
Peter Dimov
ecee9257d5 Update revision history 2023-05-30 06:20:44 +03:00
Peter Dimov
6c7edac9b1 Fix 32 bit constexpr failures 2023-05-30 04:32:23 +03:00
Peter Dimov
049d3447ca Test 32 bit Windows on Drone 2023-05-30 04:24:28 +03:00
Peter Dimov
b2fe98edf8 Make bit manipulation functions constexpr on MSVC 19.25+. Closes #109. 2023-05-30 02:56:37 +03:00
Peter Dimov
42c8898d24 Add constexpr tests for bit.hpp. Refs #109. 2023-05-29 21:59:37 +03:00
Peter Dimov
f2eab6d6ff Update ci.yml 2023-05-21 15:26:47 +03:00
Peter Dimov
36fa78f53c Add support for incomplete classes to type_name<>. Refs #145. 2023-05-21 05:52:33 +03:00
Peter Dimov
97606908b7 Add type_name<> tests for incomplete types. Refs #145. 2023-05-21 05:40:24 +03:00
Peter Dimov
5eb54d1d36 Fix type_name<> for cv-qualified member pointers without variadic templates. Refs #145. 2023-05-21 05:33:21 +03:00
Peter Dimov
c91f8fabff Test whether type_name<> compiles for member pointers even without variadic templates. Refs #145. 2023-05-21 05:16:30 +03:00
75 changed files with 2035 additions and 356 deletions

View File

@@ -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(
@@ -359,24 +392,24 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
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' },
),
]

View File

@@ -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,31 +270,55 @@ 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
timeout-minutes: 120
runs-on: ${{matrix.os}}
@@ -551,6 +588,7 @@ jobs:
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
runs-on: ${{matrix.os}}
@@ -598,6 +636,7 @@ jobs:
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
runs-on: ${{matrix.os}}
@@ -655,6 +694,7 @@ jobs:
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
runs-on: ${{matrix.os}}
@@ -700,3 +740,183 @@ jobs:
run: |
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}}
steps:
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %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}}
steps:
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %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}}
steps:
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %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

View File

@@ -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;`

View File

@@ -1,12 +1,41 @@
[/
Copyright 2021 Peter Dimov
Copyright 2022 Andrey Semashev
Copyright 2022-2023 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.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

View File

@@ -83,3 +83,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]

View File

@@ -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
View 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]

View File

@@ -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

View File

@@ -30,16 +30,33 @@ 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;
}

View 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

View 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

View 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

View 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

View 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

View File

@@ -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 )
{

View File

@@ -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

View File

@@ -102,11 +102,23 @@ inline std::string fix_typeid_name( char const* n )
return r;
}
template<class T> std::string typeid_name()
// class types can be incomplete
template<class T> std::string typeid_name_impl( int T::* )
{
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 );
}
// template names
template<class T> std::string class_template_name()
@@ -862,6 +874,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 +884,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 +918,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

View 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

View File

@@ -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

View File

@@ -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

View File

@@ -38,6 +38,13 @@ 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)

View File

@@ -17,7 +17,7 @@ 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" ;
@@ -32,36 +32,36 @@ 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 ;
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 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 +75,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 ;
@@ -98,6 +98,8 @@ run visit_each_test.cpp ;
run get_pointer_test.cpp ;
local pedantic-errors = <warnings>pedantic
<toolset>gcc:<cxxflags>"-Wconversion"
<toolset>clang:<cxxflags>"-Wconversion"
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on ;
@@ -179,9 +181,9 @@ 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 ;
@@ -296,10 +298,23 @@ 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 ;
@@ -334,7 +349,7 @@ run sv_common_reference_test.cpp ;
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) ;
run span_test.cpp ;
run span_types_test.cpp ;
@@ -363,13 +378,21 @@ run memory_resource_test.cpp ;
run data_test.cpp ;
run size_test.cpp ;
run serialization_nvp_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<build>no ;
run serialization_split_free_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<link>static ;
run serialization_split_member_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<link>static ;
run serialization_construct_data_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<link>static ;
local with-serialization = <library>/boost//serialization/<warnings>off $(warnings-as-errors-off) <undefined-sanitizer>norecover:<link>static ;
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 : ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View 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();
}

View 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
View 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

View File

@@ -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
View 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

View File

@@ -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 );

View 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

View File

@@ -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 );

View 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

View 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

View File

@@ -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 );
}

View 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

View File

@@ -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 )
{

View 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

View File

@@ -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 );

View 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

View File

@@ -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 );

View 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

View 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();
}
}

View 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();
}
}

View 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();
}
}

View File

@@ -7,10 +7,19 @@
#include <boost/core/lightweight_test_trait.hpp>
#include <iterator>
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 160000
// std::char_traits<Ch> is deprecated for non-char types
typedef wchar_t Ch;
#else
struct Ch
{
};
#endif
int main()
{
typedef boost::core::basic_string_view<Ch> ch_string_view;

View File

@@ -7,12 +7,8 @@
# bring in rules for testing
import testing ;
compile swap_root_header_1.cpp ;
compile swap_root_header_2.cpp ;
compile swap_lib_header_1.cpp ;
compile swap_lib_header_2.cpp ;
compile swap_mixed_headers_1.cpp ;
compile swap_mixed_headers_2.cpp ;
compile swap_noexcept.cpp ;
compile-fail swap_const_wrapper_fail.cpp ;

View File

@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap.
// Tests swapping an array of arrays of swap_test_class objects by means of boost::core::invoke_swap.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -59,7 +59,7 @@ int main()
ptr2[i].set_data( static_cast<int>(i + number_of_elements) );
}
boost::swap(array1, array2);
boost::core::invoke_swap(array1, array2);
for (std::size_t i = 0; i < number_of_elements; ++i)
{

View File

@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of arrays of integers by means of boost::swap.
// Tests swapping an array of arrays of integers by means of boost::core::invoke_swap.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -32,7 +32,7 @@ int main()
ptr2[i] = static_cast<int>(i + number_of_elements);
}
boost::swap(array1, array2);
boost::core::invoke_swap(array1, array2);
for (std::size_t i = 0; i < number_of_elements; ++i)
{

View File

@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of arrays of swap_test_class objects by means of boost::swap.
// Tests swapping an array of arrays of swap_test_class objects by means of boost::core::invoke_swap.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -54,7 +54,7 @@ int main()
std::copy(initial_array2, initial_array2 + array_size, array2);
swap_test_class::reset();
boost::swap(array1, array2);
boost::core::invoke_swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));

View File

@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of integers by means of boost::swap.
// Tests swapping an array of integers by means of boost::core::invoke_swap.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -27,7 +27,7 @@ int main()
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
boost::swap(array1, array2);
boost::core::invoke_swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));

View File

@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping an array of swap_test_template<int> objects by means of boost::swap.
// Tests swapping an array of swap_test_template<int> objects by means of boost::core::invoke_swap.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -60,7 +60,7 @@ int main()
std::copy(initial_array2, initial_array2 + array_size, array2);
swap_test_class::reset();
boost::swap(array1, array2);
boost::core::invoke_swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));
BOOST_CHECK(std::equal(array2, array2 + array_size, initial_array1));

View File

@@ -1,8 +1,8 @@
// Copyright 2018 Andrzej Krzemieński
// Copyright 2018 Andrzej Krzemieński
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>
namespace boost
{
@@ -14,7 +14,7 @@ template<class T> struct Wrapper
template<class T> inline void swap( Wrapper<T> & w, Wrapper<T> & v )
{
boost::swap( w, v );
boost::core::invoke_swap( w, v );
}
} // namespace boost

View File

@@ -6,5 +6,5 @@
// Tests that the swap header compiles as a standalone translation unit
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>

View File

@@ -6,6 +6,6 @@
// Tests that the swap header include guards work correctly
#include <boost/utility/swap.hpp>
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/invoke_swap.hpp>

View File

@@ -1,11 +0,0 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap headers work when both are included
#include <boost/swap.hpp>
#include <boost/utility/swap.hpp>

View File

@@ -1,12 +0,0 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap headers work when both are included
#include <boost/utility/swap.hpp>
#include <boost/swap.hpp>

View File

@@ -4,15 +4,15 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// boost::swap internally does an unqualified function call to swap.
// boost::core::invoke_swap internally does an unqualified function call to swap.
// This could have led to ambiguity or infinite recursion, when the
// objects to be swapped would themselves be from the boost namespace.
// If so, boost::swap itself might be found by argument dependent lookup.
// The implementation of boost::swap resolves this issue by giving
// boost::swap two template argumetns, thereby making it less specialized
// If so, boost::core::invoke_swap itself might be found by argument dependent lookup.
// The implementation of boost::core::invoke_swap resolves this issue by giving
// boost::core::invoke_swap two template argumetns, thereby making it less specialized
// than std::swap.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -33,7 +33,7 @@ int main()
boost::swap_test_class object2 = initial_value2;
boost::swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);

View File

@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests that boost::swap propagates noexcept specification correctly
// Tests that boost::core::invoke_swap propagates noexcept specification correctly
#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) && \
@@ -34,9 +34,9 @@ struct class_with_except_swap
} // namespace test_ns
static_assert(noexcept(boost::swap(test_ns::class_with_noexcept_swap::instance(), test_ns::class_with_noexcept_swap::instance())),
"boost::swap for class_with_noexcept_swap should have noexcept specification");
static_assert(!noexcept(boost::swap(test_ns::class_with_except_swap::instance(), test_ns::class_with_except_swap::instance())),
"boost::swap for class_with_except_swap should not have noexcept specification");
static_assert(noexcept(boost::core::invoke_swap(test_ns::class_with_noexcept_swap::instance(), test_ns::class_with_noexcept_swap::instance())),
"boost::core::invoke_swap for class_with_noexcept_swap should have noexcept specification");
static_assert(!noexcept(boost::core::invoke_swap(test_ns::class_with_except_swap::instance(), test_ns::class_with_except_swap::instance())),
"boost::core::invoke_swap for class_with_except_swap should not have noexcept specification");
#endif // !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) ...

View File

@@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -14,7 +14,7 @@ int main()
int object1 = 1;
int object2 = 2;
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1,2);
BOOST_CHECK_EQUAL(object2,1);

View File

@@ -1,10 +0,0 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap header compiles as a standalone translation unit
#include <boost/swap.hpp>

View File

@@ -1,11 +0,0 @@
// Copyright (c) 2007 Joseph Gauterin
//
// 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)
// Tests that the swap header include guards work correctly
#include <boost/swap.hpp>
#include <boost/swap.hpp>

View File

@@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -33,7 +33,7 @@ int main()
boost::swap_test_class object2 = initial_value2;
boost::swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);

View File

@@ -8,13 +8,13 @@
// properly swapped, when both boost and the other namespace have a custom
// swap function for that class. Note that it shouldn't be necessary for a class
// in an other namespace to have a custom swap function in boost, because the
// boost::swap utility should find the swap function in the other namespace, by
// argument dependent lookup (ADL). Unfortunately ADL isn't fully implemented
// by some specific compiler versions, including Intel C++ 8.1, MSVC 7.1, and
// Borland 5.9.3. Users of those compilers might consider adding a swap overload
// boost::core::invoke_swap utility should find the swap function in the other
// namespace, by argument dependent lookup (ADL). Unfortunately ADL isn't fully
// implemented by some specific compiler versions, including Intel C++ 8.1, MSVC 7.1,
// and Borland 5.9.3. Users of those compilers might consider adding a swap overload
// to the boost namespace.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -52,7 +52,7 @@ int main()
other::swap_test_class object2 = initial_value2;
other::swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);

View File

@@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -27,7 +27,7 @@ int main()
swap_test_class object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);

View File

@@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -33,7 +33,7 @@ int main()
other::swap_test_class object2 = initial_value2;
other::swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);

View File

@@ -4,7 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -32,7 +32,7 @@ int main()
swap_test_class object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);

View File

@@ -4,11 +4,11 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::bitset<T> objects by means of boost::swap.
// Tests swapping std::bitset<T> objects by means of boost::core::invoke_swap.
// Unlike most other Standard C++ Library template classes,
// std::bitset<T> does not have its own std::swap overload.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -24,7 +24,7 @@ int main()
bitset_type object1 = initial_value1;
bitset_type object2 = initial_value2;
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1,initial_value2);
BOOST_CHECK_EQUAL(object2,initial_value1);

View File

@@ -4,11 +4,11 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::time_base::dateorder objects by means of boost::swap.
// Tests swapping std::time_base::dateorder objects by means of boost::core::invoke_swap.
// std::time_base::dateorder is an enumerated type. It does not have an
// std::swap overload or template specialization.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -23,7 +23,7 @@ int main()
std::time_base::dateorder object1 = initial_value1;
std::time_base::dateorder object2 = initial_value2;
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1,initial_value2);
BOOST_CHECK_EQUAL(object2,initial_value1);

View File

@@ -4,10 +4,10 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::string objects by means of boost::swap.
// Tests swapping std::string objects by means of boost::core::invoke_swap.
// std::string has its own std::swap overload.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -22,7 +22,7 @@ int main()
std::string object1 = initial_value1;
std::string object2 = initial_value2;
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1,initial_value2);
BOOST_CHECK_EQUAL(object2,initial_value1);

View File

@@ -4,11 +4,11 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::type_info pointers by means of boost::swap.
// Tests swapping std::type_info pointers by means of boost::core::invoke_swap.
// There is no std::swap overload or template specialization
// for std::type_info pointers.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -23,7 +23,7 @@ int main()
const std::type_info * ptr1 = initial_value1;
const std::type_info * ptr2 = initial_value2;
boost::swap(ptr1,ptr2);
boost::core::invoke_swap(ptr1,ptr2);
BOOST_CHECK_EQUAL(ptr1,initial_value2);
BOOST_CHECK_EQUAL(ptr2,initial_value1);

View File

@@ -4,10 +4,10 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::vector objects by means of boost::swap,
// Tests swapping std::vector objects by means of boost::core::invoke_swap,
// having boost::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -45,7 +45,7 @@ int main()
swap_test_class_type::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
BOOST_CHECK_EQUAL(object2.size(),initial_size1);

View File

@@ -4,10 +4,10 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::vector objects by means of boost::swap,
// Tests swapping std::vector objects by means of boost::core::invoke_swap,
// having ::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -38,7 +38,7 @@ int main()
swap_test_class::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
BOOST_CHECK_EQUAL(object2.size(),initial_size1);

View File

@@ -4,10 +4,10 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::vector objects by means of boost::swap,
// Tests swapping std::vector objects by means of boost::core::invoke_swap,
// having other::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
#define BOOST_CHECK_EQUAL BOOST_TEST_EQ
@@ -45,7 +45,7 @@ int main()
swap_test_class_type::reset();
boost::swap(object1,object2);
boost::core::invoke_swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
BOOST_CHECK_EQUAL(object2.size(),initial_size1);

View File

@@ -47,10 +47,14 @@ class B
{
};
class C;
template<class T1, class T2> struct X
{
};
template<class T1, class T2> struct Y;
enum E1
{
e1
@@ -63,6 +67,8 @@ enum class E2
e2
};
enum class E3;
#endif
struct Ch
@@ -115,12 +121,14 @@ int main()
TEST(A);
TEST(B);
TEST(C);
TEST(E1);
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
TEST(E2);
TEST(E3);
#endif
@@ -131,6 +139,10 @@ int main()
TEST(B&);
TEST(B const&);
TEST(C volatile);
TEST(C&);
TEST(C const&);
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
TEST(B&&);
@@ -141,6 +153,9 @@ int main()
TEST(A*);
TEST(B const* volatile*);
TEST(C*);
TEST(C const* volatile*);
TEST(void*);
TEST(void const* volatile*);
@@ -239,9 +254,18 @@ int main()
TEST(B(&)[1][2][3]);
TEST(B const volatile(***)[1][2][3]);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || !defined(BOOST_MSVC)
TEST(int A::*);
TEST(int const B::*);
#else
boost::core::type_name<int A::*>();
boost::core::type_name<int const B::*>();
#endif
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
TEST(void(A::*)());
@@ -249,6 +273,13 @@ int main()
TEST(void(A::*)() volatile);
TEST(void(A::*)() const volatile);
#else
boost::core::type_name<void(A::*)()>();
boost::core::type_name<void(A::*)() const>();
boost::core::type_name<void(A::*)() volatile>();
boost::core::type_name<void(A::*)() const volatile>();
#endif
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
@@ -274,10 +305,16 @@ int main()
TEST(std::pair<A, B>);
TEST(std::pair<A const*, B*> volatile&);
TEST(std::pair<C, C>);
TEST(std::pair<void, void>);
TEST(std::pair<std::pair<void, void>, void>);
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 160000
// std::char_traits<Ch> is deprecated for non-char types
#else
TEST(std::basic_string<Ch>);
#endif
TEST(std::string);
TEST(std::wstring);
@@ -298,6 +335,11 @@ int main()
TEST(X<A, B>);
TEST(X<A const&, B&> volatile&);
TEST(X<C, C>);
TEST(Y<A, B>);
TEST(Y<C, C>);
TEST(X<std::pair<void, void>, void>);
TEST(std::vector<int>);
@@ -364,7 +406,11 @@ int main()
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 160000
// std::char_traits<Ch> is deprecated for non-char types
#else
TEST(std::basic_string_view<Ch>);
#endif
TEST(std::string_view);
TEST(std::wstring_view);

View File

@@ -0,0 +1,54 @@
// Test that yield primitives aren't cancelation points
//
// 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>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if !defined(BOOST_HAS_PTHREADS)
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_HAS_PTHREADS is not defined" )
int main() {}
#else
#include <pthread.h>
pthread_mutex_t s_mx = PTHREAD_MUTEX_INITIALIZER;
void* threadfunc( void* )
{
pthread_mutex_lock( &s_mx );
pthread_mutex_unlock( &s_mx );
boost::core::sp_thread_pause();
boost::core::sp_thread_yield();
boost::core::sp_thread_sleep();
return 0;
}
int main()
{
pthread_mutex_lock( &s_mx );
pthread_t th;
pthread_create( &th, 0, threadfunc, 0 );
pthread_cancel( th );
pthread_mutex_unlock( &s_mx );
void* r;
pthread_join( th, &r );
BOOST_TEST_EQ( r, (void*)0 );
return boost::report_errors();
}
#endif

View File

@@ -0,0 +1,18 @@
// Test for yield_primitives.hpp compatibility with windows.h
//
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <windows.h>
#endif
#include <boost/core/yield_primitives.hpp>
int main()
{
boost::core::sp_thread_pause();
boost::core::sp_thread_yield();
boost::core::sp_thread_sleep();
}