forked from boostorg/core
Compare commits
44 Commits
feature/po
...
feature/lw
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8caca51c4d | ||
|
|
2d302c1666 | ||
|
|
6299da9273 | ||
|
|
843e0f7bb0 | ||
|
|
ddc6cc25a9 | ||
|
|
86bf1d4aec | ||
|
|
75c765cc13 | ||
|
|
2286749f97 | ||
|
|
23fa5d30f3 | ||
|
|
d428335758 | ||
|
|
be8790115c | ||
|
|
2778c5cca6 | ||
|
|
d5b7c3c0dc | ||
|
|
db916e4673 | ||
|
|
3eaba7afc0 | ||
|
|
ad20fadde7 | ||
|
|
a67ec1f75c | ||
|
|
5e95d28eb6 | ||
|
|
65377a2e13 | ||
|
|
b407b5d87d | ||
|
|
013c7856ce | ||
|
|
1c79871f0f | ||
|
|
09f2aa123a | ||
|
|
9cbf3ac420 | ||
|
|
fd615f3bfe | ||
|
|
a7f76af262 | ||
|
|
860eed6baf | ||
|
|
66a742f41e | ||
|
|
2cc3e23447 | ||
|
|
00f4f11f14 | ||
|
|
3510f6244b | ||
|
|
89852794ca | ||
|
|
0ac87736f8 | ||
|
|
1fa592c9ec | ||
|
|
162a4e1d24 | ||
|
|
68f8f36b04 | ||
|
|
414dfb4668 | ||
|
|
1b3a907394 | ||
|
|
ab23246301 | ||
|
|
48bc47cce2 | ||
|
|
e3745b2072 | ||
|
|
4162dbed57 | ||
|
|
38937b0fa3 | ||
|
|
8503c536dc |
197
.github/workflows/ci.yml
vendored
197
.github/workflows/ci.yml
vendored
@@ -1,5 +1,5 @@
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
# Copyright 2021-2022 Andrey Semashev
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
# Linux, gcc
|
||||
- toolset: gcc-4.4
|
||||
cxxstd: "98,0x"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.4
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.6
|
||||
cxxstd: "03,0x"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.6
|
||||
@@ -48,45 +48,49 @@ jobs:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.7
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-7
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-9
|
||||
- toolset: gcc-10
|
||||
@@ -95,18 +99,18 @@ jobs:
|
||||
install:
|
||||
- g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-11
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12
|
||||
- name: UBSAN
|
||||
toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
ubsan: 1
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
@@ -116,66 +120,72 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-7
|
||||
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-8
|
||||
- g++-7
|
||||
@@ -195,67 +205,67 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-14
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-13
|
||||
- libc++-13-dev
|
||||
- libc++abi-13-dev
|
||||
- clang-15
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-15
|
||||
- libc++-15-dev
|
||||
- libc++abi-15-dev
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
ubsan: 1
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
- clang-14
|
||||
- libc++-14-dev
|
||||
- libc++abi-14-dev
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
os: macos-11
|
||||
|
||||
timeout-minutes: 120
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -275,12 +285,18 @@ jobs:
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 perl git cmake
|
||||
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
|
||||
then
|
||||
PYTHON_PACKAGE="python-is-python3"
|
||||
else
|
||||
PYTHON_PACKAGE="python"
|
||||
fi
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake
|
||||
fi
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -367,6 +383,7 @@ jobs:
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
DEPINST_ARGS=()
|
||||
GIT_VERSION="$(git --version | sed -e 's/git version //')"
|
||||
GIT_HAS_JOBS=1
|
||||
if [ -f "/etc/debian_version" ]
|
||||
@@ -393,25 +410,16 @@ jobs:
|
||||
fi
|
||||
if [ "$GIT_HAS_JOBS" -ne 0 ]
|
||||
then
|
||||
GIT_ARGS="--jobs $GIT_FETCH_JOBS"
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
fi
|
||||
cd ..
|
||||
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule init tools/boost_install
|
||||
git submodule init libs/headers
|
||||
git submodule init tools/build
|
||||
git submodule init tools/cmake
|
||||
git submodule init libs/assert
|
||||
git submodule init libs/config
|
||||
git submodule init libs/static_assert
|
||||
git submodule init libs/throw_exception
|
||||
git submodule init libs/type_traits
|
||||
git submodule init libs/utility
|
||||
git submodule init libs/io
|
||||
git submodule update $GIT_ARGS
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
@@ -484,7 +492,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@@ -503,18 +511,8 @@ jobs:
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule init tools/boost_install
|
||||
git submodule init libs/headers
|
||||
git submodule init tools/build
|
||||
git submodule init tools/cmake
|
||||
git submodule init libs/assert
|
||||
git submodule init libs/config
|
||||
git submodule init libs/static_assert
|
||||
git submodule init libs/throw_exception
|
||||
git submodule init libs/type_traits
|
||||
git submodule init libs/utility
|
||||
git submodule init libs/io
|
||||
git submodule update --jobs %GIT_FETCH_JOBS%
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
@@ -529,15 +527,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -554,21 +551,21 @@ jobs:
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
cmake --build . -- -j $BUILD_JOBS
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
@@ -576,15 +573,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -601,14 +597,14 @@ jobs:
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
@@ -619,13 +615,13 @@ jobs:
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
cmake --build . --target install -- -j $BUILD_JOBS
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
cmake --build . -- -j $BUILD_JOBS
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-test:
|
||||
@@ -633,15 +629,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -658,14 +653,14 @@ jobs:
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
@@ -676,7 +671,7 @@ jobs:
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests
|
||||
cmake --build . --target tests -- -j $BUILD_JOBS
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
|
||||
15
appveyor.yml
15
appveyor.yml
@@ -60,24 +60,15 @@ environment:
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
install:
|
||||
- set GIT_FETCH_JOBS=8
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/utility
|
||||
- git submodule init libs/io
|
||||
- git submodule init tools/build
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 4
|
||||
- git submodule update --init tools/boostdep
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core\
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" core
|
||||
- cmd /c bootstrap
|
||||
- b2 headers
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ returns `a`.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
[section Acknowledgements]
|
||||
|
||||
Glen Fernandes implemented the allocator access utilities.
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ template<class T>
|
||||
constexpr T bit_floor(T x) noexcept;
|
||||
|
||||
template<class T>
|
||||
constexpr T bit_width(T x) noexcept;
|
||||
constexpr int bit_width(T x) noexcept;
|
||||
|
||||
// Rotating
|
||||
|
||||
@@ -119,7 +119,7 @@ constant expression context.
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* If `x == 0`, 0; otherwise the maximal value `y` such that `has_single_bit(y)` is `true` and `y <= x`.
|
||||
|
||||
`template<class T> constexpr T bit_width(T x) noexcept;`
|
||||
`template<class T> constexpr int bit_width(T x) noexcept;`
|
||||
|
||||
* *Requires:* `T` must be an unsigned integer type.
|
||||
* *Returns:* If `x == 0`, 0; otherwise one plus the base-2 logarithm of `x`, with any fractional part discarded.
|
||||
|
||||
@@ -1,16 +1,55 @@
|
||||
[/
|
||||
Copyright 2021 Peter Dimov
|
||||
Copyright 2022 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.82.0]
|
||||
|
||||
* Added [link core.snprintf `boost/core/snprintf.hpp`] header with portable definitions of `snprintf`, `vsnprintf` and
|
||||
their `wchar_t` counterparts.
|
||||
* Deprecated `boost/core/is_same.hpp` and `boost::core::is_same`. The header will be removed in a future release.
|
||||
Users are advised to use [@http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/index.html Boost.TypeTraits]
|
||||
or C++ standard library type traits instead.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.81.0]
|
||||
|
||||
* [link core.empty_value `empty_value`] members are now marked as `constexpr`.
|
||||
* Added [link core.fclose_deleter `fclose_deleter`], a deleter that calls `std::fclose` on a pointer to `std::FILE`.
|
||||
* Bit manipulation utilities in [link core.bit `boost/core/bit.hpp`] now explicitly require unsigned integers on input.
|
||||
([@https://github.com/boostorg/core/issues/129 #129])
|
||||
* `bit_width` now returns `int` instead of a value of the input argument type. This follows the
|
||||
resolution of [@https://cplusplus.github.io/LWG/issue3656 LWG3656].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.80.0]
|
||||
|
||||
* In [link core.allocator_access `boost/core/allocator_access.hpp`], added detection of `construct` and `destroy`
|
||||
members of an allocator.
|
||||
* `boost/core/alloc_construct.hpp` header is now deprecated and will be removed in a future release. Its functionality
|
||||
was moved to [link core.allocator_access `boost/core/allocator_access.hpp`]. In particular, new methods
|
||||
`allocator_construct_n` and `allocator_destroy_n` were added for allocating and destroying arrays.
|
||||
* Worked around MSVC bug that failed to compile [link core.span `span`] in C++17 mode when Boost.Range headers were included.
|
||||
([@https://github.com/boostorg/core/issues/105 #105], [@https://github.com/boostorg/core/pull/115 PR#115])
|
||||
* Added support for 128-bit integer types in [link core.type_name `type_name`].
|
||||
* In [link core.pointer_traits `pointer_traits`], pointer rebinding now supports C++03 compilers.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes in 1.79.0]
|
||||
|
||||
* Added `boost::allocator_traits`, an implementation of `std::allocator_traits`.
|
||||
* Made `boost::pointer_traits` SFINAE friendly.
|
||||
* `boost/iterator.hpp` is deprecated and will be removed in a future release. The header defines `boost::iterator` template, which is equivalent to `std::iterator` in `<iterator>` header. However, since `std::iterator` is itself deprecated in C++17, users are advised to remove `boost::iterator` or `std::iterator` use from their code.
|
||||
* `boost/iterator.hpp` is deprecated and will be removed in a future release. The header defines the
|
||||
`boost::iterator` template, which is equivalent to `std::iterator` in the `<iterator>` header. However,
|
||||
since `std::iterator` is itself deprecated in C++17, users are advised to remove the use of `boost::iterator`
|
||||
or `std::iterator` from their code.
|
||||
* Added `boost::core::verbose_terminate_handler`, a utility function intended
|
||||
to be passed to `std::set_terminate` that prints information about the
|
||||
uncaught exception to `stderr`.
|
||||
|
||||
@@ -60,6 +60,7 @@ criteria for inclusion is that the utility component be:
|
||||
[include noinit_adaptor.qbk]
|
||||
[include noncopyable.qbk]
|
||||
[include null_deleter.qbk]
|
||||
[include fclose_deleter.qbk]
|
||||
[include nvp.qbk]
|
||||
[include pointer_traits.qbk]
|
||||
[include quick_exit.qbk]
|
||||
@@ -69,6 +70,7 @@ criteria for inclusion is that the utility component be:
|
||||
[include swap.qbk]
|
||||
[include typeinfo.qbk]
|
||||
[include type_name.qbk]
|
||||
[include snprintf.qbk]
|
||||
[include uncaught_exceptions.qbk]
|
||||
[include use_default.qbk]
|
||||
[include verbose_terminate_handler.qbk]
|
||||
|
||||
@@ -125,7 +125,7 @@ return `nullptr` if demangling failed.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
[section Acknowledgements]
|
||||
|
||||
The implementation of `core::demangle` was taken from
|
||||
`boost/exception/detail/type_info.hpp`, which in turn was adapted
|
||||
|
||||
@@ -90,11 +90,11 @@ public:
|
||||
empty_value() = default;
|
||||
|
||||
template<class... Args>
|
||||
empty_value(empty_init_t, Args&&... args);
|
||||
constepxr empty_value(empty_init_t, Args&&... args);
|
||||
|
||||
const T& get() const noexcept;
|
||||
constepxr const T& get() const noexcept;
|
||||
|
||||
T& get() noexcept;
|
||||
constepxr T& get() noexcept;
|
||||
};
|
||||
|
||||
inline constexpr empty_init_t empty_init{ };
|
||||
@@ -121,8 +121,9 @@ inline constexpr empty_init_t empty_init{ };
|
||||
[section Constructors]
|
||||
|
||||
[variablelist
|
||||
[[`empty_value() = default;`][Default initialize the value]]
|
||||
[[`template<class... Args> empty_value(empty_init_t, Args&&... args);`]
|
||||
[[`constepxr empty_value() = default;`][Default initialize the value]]
|
||||
[[`template<class... Args>
|
||||
constepxr empty_value(empty_init_t, Args&&... args);`]
|
||||
[Initialize the value with `std::forward<Args>(args)...`]]]
|
||||
|
||||
[endsect]
|
||||
@@ -130,8 +131,8 @@ inline constexpr empty_init_t empty_init{ };
|
||||
[section Member functions]
|
||||
|
||||
[variablelist
|
||||
[[`const T& get() const noexcept;`][Returns the value]]
|
||||
[[`T& get() noexcept;`][Returns the value]]]
|
||||
[[`constepxr const T& get() const noexcept;`][Returns the value]]
|
||||
[[`constepxr T& get() noexcept;`][Returns the value]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -304,8 +304,8 @@ depends on the template arguments of the class. Note that
|
||||
again, the second argument to `enable_if` is not needed; the
|
||||
default (`void`) is the correct value.
|
||||
|
||||
The `enable_if_has_type` template is usable this scenario but instead of
|
||||
using a type traits to enable or disable a specialization, it use a
|
||||
The `enable_if_has_type` template is usable in this scenario but instead of
|
||||
using a type trait to enable or disable a specialization, it uses a
|
||||
SFINAE context to check for the existence of a dependent type inside
|
||||
its parameter. For example, the following structure extracts a dependent
|
||||
`value_type` from T if and only if `T::value_type` exists.
|
||||
|
||||
34
doc/fclose_deleter.qbk
Normal file
34
doc/fclose_deleter.qbk
Normal file
@@ -0,0 +1,34 @@
|
||||
[/
|
||||
/ Copyright (c) 2022 Andrey Semashev
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:fclose_deleter fclose_deleter]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Andrey Semashev
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/fclose_deleter.hpp>]
|
||||
|
||||
The header `<boost/core/fclose_deleter.hpp>` defines the `boost::fclose_deleter` function object,
|
||||
which can be used as a deleter with smart pointers such as `unique_ptr` or `shared_ptr` pointing to `std::FILE`.
|
||||
structures returned by `std::fopen` calls. The deleter calls `std::fclose` on the passed pointer, causing
|
||||
the file stream to be flushed and closed.
|
||||
|
||||
[section Example]
|
||||
``
|
||||
std::unique_ptr< std::FILE, boost::fclose_deleter > make_file(const char* filename, const char* open_mode)
|
||||
{
|
||||
return { std::fopen(filename, open_mode) };
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -51,7 +51,7 @@ int fun( int foo, int bar )
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
[section Acknowledgements]
|
||||
|
||||
`boost::ignore_unused()` was contributed by Adam Wulkiewicz.
|
||||
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
[section Header <boost/core/is_same.hpp>]
|
||||
|
||||
[warning This component is deprecated and will be removed in a future release.
|
||||
Users are recommended to use `boost::is_same` from
|
||||
[@http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/index.html Boost.TypeTraits]
|
||||
or `std::is_same` from C++ standard library `<type_traits>` instead.]
|
||||
|
||||
The header `<boost/core/is_same.hpp>` defines the class template
|
||||
`boost::core::is_same<T1,T2>`. It defines a nested integral constant
|
||||
`value` which is `true` when `T1` and `T2` are the same type, and
|
||||
|
||||
@@ -51,8 +51,16 @@ When using `lightweight_test.hpp`, *do not forget* to
|
||||
|
||||
namespace boost
|
||||
{
|
||||
int report_errors();
|
||||
}
|
||||
|
||||
int report_errors();
|
||||
|
||||
namespace core
|
||||
{
|
||||
|
||||
void lwt_init();
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
``
|
||||
|
||||
[endsect]
|
||||
@@ -246,6 +254,25 @@ Return the error count from `main`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section lwt_init]
|
||||
|
||||
``
|
||||
void boost::core::lwt_init()
|
||||
``
|
||||
|
||||
Performs one-time initialization. Disables the interactive message
|
||||
boxes displayed by the Microsoft Windows debug runtime library on
|
||||
`abort`, failing `assert`, and other abnormal program terminations
|
||||
(to facilitate unattended testing), and ensures that in case
|
||||
`boost::report_errors` is not called (a common mistake), the program
|
||||
ends with a nonzero exit code.
|
||||
|
||||
`lwt_init` is automatically called by the test macros. There is
|
||||
no need to call it explicitly, except in cases where a test fails due
|
||||
to e.g. an assertion failure before the first test macro is invoked.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
``
|
||||
@@ -326,14 +353,14 @@ parentheses.)
|
||||
|
||||
``
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
template<class T, class U> struct X
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
using boost::core::is_same;
|
||||
using boost::is_same;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -113,6 +113,9 @@ also not defined (`pointer_traits` is SFINAE-friendly).
|
||||
where `Args` is zero or more type arguments; otherwise, the member is not
|
||||
defined.]]]
|
||||
|
||||
[note When C++11 template aliases are not supported, the `type` for `rebind` is
|
||||
`T::rebind<U>::other` if such a type exists.]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member functions]
|
||||
@@ -121,7 +124,7 @@ also not defined (`pointer_traits` is SFINAE-friendly).
|
||||
[[`static pointer pointer_traits::pointer_to(element_type& v);`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, or if `T::pointer_to(v)` is not well formed,
|
||||
[If `element_type` is a void type, or if `T::pointer_to(v)` is not well-formed,
|
||||
this member is not defined.]]
|
||||
[[Returns]
|
||||
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
||||
@@ -162,7 +165,7 @@ also not defined (`pointer_traits` is SFINAE-friendly).
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
[section Acknowledgements]
|
||||
|
||||
Glen Fernandes implemented `pointer_traits` and `to_address` with reviews and
|
||||
guidance from Peter Dimov.
|
||||
|
||||
@@ -68,7 +68,7 @@ The type-expression `boost::unwrap_reference<T>::type` is
|
||||
|
||||
[xinclude ref_reference.xml]
|
||||
|
||||
[section Acknowledgments]
|
||||
[section Acknowledgements]
|
||||
|
||||
`ref` and `cref` were originally part of the Tuple library by
|
||||
Jaakko J\u00E4rvi. They were "promoted to `boost::` status" by
|
||||
|
||||
@@ -46,7 +46,7 @@ The user can portably declare such enumeration as follows:
|
||||
}
|
||||
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
|
||||
|
||||
These macros allows to use `future_errc` in almost all the cases as an scoped enum.
|
||||
These macros allow using `future_errc` in almost all the cases as a scoped enum.
|
||||
|
||||
future_errc ev = future_errc::no_state;
|
||||
|
||||
@@ -179,7 +179,7 @@ such cases.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgments]
|
||||
[section Acknowledgements]
|
||||
|
||||
This scoped enum emulation was developed by Beman Dawes, Vicente J. Botet Escriba and Anthony Williams.
|
||||
|
||||
|
||||
47
doc/snprintf.qbk
Normal file
47
doc/snprintf.qbk
Normal file
@@ -0,0 +1,47 @@
|
||||
[/
|
||||
/ Copyright (c) 2022 Andrey Semashev
|
||||
/
|
||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
/]
|
||||
|
||||
[section:snprintf snprintf]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Andrey Semashev
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Header <boost/core/snprintf.hpp>]
|
||||
|
||||
The header `<boost/core/snprintf.hpp>` provides portable definition of [@https://en.cppreference.com/w/c/io/fprintf `snprintf`],
|
||||
`vsnprintf` and their corresponding `wchar_t` counterparts. On a platform that supports these functions in the standard library,
|
||||
these definitions are equivalent to the standard functions. On other platforms (mainly, older MSVC versions) these functions
|
||||
are emulated through non-standard functions that have similar behavior.
|
||||
|
||||
Depending on the standard library, certain implementation differences are exposed to the user:
|
||||
|
||||
* Any non-standard behavior with respect to string format description are not hidden by the emulation.
|
||||
* Returned value of `boost::core::snprintf` in case if the output buffer is too small may not be equal to the number of characters
|
||||
that would have been written if the buffer was large enough. It is, however, equal or larger than the buffer size,
|
||||
which still allows the caller to detect the buffer overflow condition. The formatted output is still properly null-terminated
|
||||
in this case.
|
||||
|
||||
[note Unlike `snprintf`, `swprintf` does not return the number of characters to be written if the output buffer is too small
|
||||
but returns -1 instead. Furthermore, `swprintf` may or may not produce characters in the output buffer in this case.]
|
||||
|
||||
[section Example]
|
||||
``
|
||||
char buf[10];
|
||||
int n = boost::core::snprintf(buf, sizeof(buf), "%d", i);
|
||||
if (n < 0)
|
||||
throw std::runtime_error("Formatting error");
|
||||
if (n >= sizeof(buf))
|
||||
throw std::runtime_error("Formatting buffer overflow");
|
||||
``
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/use_default.hpp> provides the type `boost::use_default`
|
||||
which is used by other Boost libraries as a sentinel type in a templates to
|
||||
which is used by other Boost libraries as a sentinel type in templates to
|
||||
indicate defaults.
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -807,14 +807,14 @@ using allocator_rebind_t = typename allocator_rebind<A, T>::type;
|
||||
|
||||
} /* boost */
|
||||
|
||||
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_POP)
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#if defined(_STL_RESTORE_DEPRECATED_WARNING)
|
||||
_STL_RESTORE_DEPRECATED_WARNING
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#if defined(_LIBCPP_SUPPRESS_DEPRECATED_POP)
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -92,6 +92,8 @@ BOOST_CONSTEXPR inline int countl_impl( boost::ulong_long_type x ) BOOST_NOEXCEP
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return boost::core::detail::countl_impl( x );
|
||||
}
|
||||
|
||||
@@ -169,6 +171,8 @@ inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
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) )
|
||||
@@ -194,6 +198,8 @@ int countl_zero( T x ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countl_one( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return boost::core::countl_zero( static_cast<T>( ~x ) );
|
||||
}
|
||||
|
||||
@@ -234,6 +240,8 @@ BOOST_CONSTEXPR inline int countr_impl( boost::ulong_long_type x ) BOOST_NOEXCEP
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return boost::core::detail::countr_impl( x );
|
||||
}
|
||||
|
||||
@@ -304,6 +312,8 @@ inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
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) )
|
||||
@@ -329,6 +339,8 @@ int countr_zero( T x ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int countr_one( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return boost::core::countr_zero( static_cast<T>( ~x ) );
|
||||
}
|
||||
|
||||
@@ -377,6 +389,8 @@ BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( boost::ulong_long_type x
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return boost::core::detail::popcount_impl( x );
|
||||
}
|
||||
|
||||
@@ -408,6 +422,8 @@ BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint64_t x ) BOOST_NOEXCE
|
||||
template<class T>
|
||||
BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
|
||||
|
||||
BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) )
|
||||
@@ -427,6 +443,8 @@ BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
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);
|
||||
}
|
||||
@@ -434,6 +452,8 @@ BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
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);
|
||||
}
|
||||
@@ -443,21 +463,27 @@ BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return x != 0 && ( x & ( x - 1 ) ) == 0;
|
||||
}
|
||||
|
||||
// bit_width should return int, https://cplusplus.github.io/LWG/issue3656
|
||||
// bit_width returns `int` now, https://cplusplus.github.io/LWG/issue3656
|
||||
// has been applied to C++20 as a DR
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR T bit_width( T x ) BOOST_NOEXCEPT
|
||||
BOOST_CONSTEXPR int bit_width( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<T>(
|
||||
std::numeric_limits<T>::digits - boost::core::countl_zero( x ) );
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
return std::numeric_limits<T>::digits - boost::core::countl_zero( x );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -510,6 +536,8 @@ BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x )
|
||||
template<class T>
|
||||
BOOST_CXX14_CONSTEXPR T bit_ceil( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
|
||||
|
||||
BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) )
|
||||
|
||||
39
include/boost/core/detail/is_same.hpp
Normal file
39
include/boost/core/detail/is_same.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef BOOST_CORE_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
|
||||
// is_same<T1,T2>::value is true when T1 == T2
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template< class T1, class T2 > struct is_same
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( bool, value = false );
|
||||
};
|
||||
|
||||
template< class T > struct is_same< T, T >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( bool, value = true );
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
45
include/boost/core/detail/lwt_unattended.hpp
Normal file
45
include/boost/core/detail/lwt_unattended.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef BOOST_CORE_DETAIL_LWT_UNATTENDED_HPP_INCLUDED
|
||||
#define BOOST_CORE_DETAIL_LWT_UNATTENDED_HPP_INCLUDED
|
||||
|
||||
// Copyright 2014, 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <cstdlib>
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
# include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Setup unattended mode by disabling interactive popups on
|
||||
// assertion failures
|
||||
|
||||
inline void lwt_unattended()
|
||||
{
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1310)
|
||||
|
||||
// disable message boxes on assert(), abort()
|
||||
::_set_abort_behavior( 0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT );
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
|
||||
// disable message boxes on iterator debugging violations
|
||||
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CORE_DETAIL_LWT_UNATTENDED_HPP_INCLUDED
|
||||
@@ -14,7 +14,7 @@
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@@ -381,7 +381,7 @@ public:
|
||||
}
|
||||
|
||||
template<class End> BOOST_CXX14_CONSTEXPR basic_string_view( Ch const* first, End last,
|
||||
typename boost::enable_if<is_same<End, Ch const*> >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( last - first )
|
||||
typename boost::enable_if<boost::core::detail::is_same<End, Ch const*> >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( last - first )
|
||||
{
|
||||
BOOST_ASSERT( last - first >= 0 );
|
||||
}
|
||||
@@ -399,10 +399,26 @@ public:
|
||||
#endif
|
||||
|
||||
template<class Ch2> basic_string_view( boost::basic_string_view<Ch2, std::char_traits<Ch2> > const& str,
|
||||
typename boost::enable_if<is_same<Ch, Ch2> >::type* = 0 ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
|
||||
typename boost::enable_if<boost::core::detail::is_same<Ch, Ch2> >::type* = 0 ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
# if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
|
||||
basic_string_view( std::nullptr_t ) = delete;
|
||||
|
||||
# else
|
||||
|
||||
private:
|
||||
|
||||
basic_string_view( std::nullptr_t );
|
||||
|
||||
public:
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// BOOST_CONSTEXPR basic_string_view& operator=( basic_string_view const& ) BOOST_NOEXCEPT & = default;
|
||||
|
||||
// conversions
|
||||
@@ -414,7 +430,7 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
template<class Ch2, class En = typename boost::enable_if<is_same<Ch2, Ch> >::type>
|
||||
template<class Ch2, class En = typename boost::enable_if<boost::core::detail::is_same<Ch2, Ch> >::type>
|
||||
operator std::basic_string_view<Ch2>() const BOOST_NOEXCEPT
|
||||
{
|
||||
return std::basic_string_view<Ch>( data(), size() );
|
||||
@@ -423,7 +439,7 @@ public:
|
||||
#endif
|
||||
|
||||
template<class Ch2> operator boost::basic_string_view<Ch2,
|
||||
typename boost::enable_if<boost::core::is_same<Ch2, Ch>, std::char_traits<Ch> >::type> () const BOOST_NOEXCEPT
|
||||
typename boost::enable_if<boost::core::detail::is_same<Ch2, Ch>, std::char_traits<Ch> >::type> () const BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::basic_string_view< Ch, std::char_traits<Ch> >( data(), size() );
|
||||
}
|
||||
@@ -589,7 +605,7 @@ public:
|
||||
if( cmp != 0 ) return cmp;
|
||||
|
||||
if( size() == str.size() ) return 0;
|
||||
|
||||
|
||||
return size() < str.size()? -1: +1;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,37 +56,37 @@ public:
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
empty_value() = default;
|
||||
#else
|
||||
empty_value() { }
|
||||
BOOST_CONSTEXPR empty_value() { }
|
||||
#endif
|
||||
|
||||
empty_value(boost::empty_init_t)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t)
|
||||
: value_() { }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: value_(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value)
|
||||
: value_(std::forward<U>(value)) { }
|
||||
#endif
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, const U& value)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, const U& value)
|
||||
: value_(value) { }
|
||||
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U& value)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, U& value)
|
||||
: value_(value) { }
|
||||
#endif
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT {
|
||||
BOOST_CONSTEXPR const T& get() const BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
|
||||
T& get() BOOST_NOEXCEPT {
|
||||
BOOST_CXX14_CONSTEXPR T& get() BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
|
||||
@@ -104,37 +104,37 @@ public:
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
empty_value() = default;
|
||||
#else
|
||||
empty_value() { }
|
||||
BOOST_CONSTEXPR empty_value() { }
|
||||
#endif
|
||||
|
||||
empty_value(boost::empty_init_t)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t)
|
||||
: T() { }
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: T(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value)
|
||||
: T(std::forward<U>(value)) { }
|
||||
#endif
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, const U& value)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, const U& value)
|
||||
: T(value) { }
|
||||
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U& value)
|
||||
BOOST_CONSTEXPR empty_value(boost::empty_init_t, U& value)
|
||||
: T(value) { }
|
||||
#endif
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT {
|
||||
BOOST_CONSTEXPR const T& get() const BOOST_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& get() BOOST_NOEXCEPT {
|
||||
BOOST_CXX14_CONSTEXPR T& get() BOOST_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
46
include/boost/core/fclose_deleter.hpp
Normal file
46
include/boost/core/fclose_deleter.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2022.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file fclose_deleter.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 21.09.2022
|
||||
*
|
||||
* This header contains an \c fclose_deleter implementation. This is a deleter
|
||||
* function object that invokes <tt>std::fclose</tt> on the passed pointer to
|
||||
* a <tt>std::FILE</tt> structure.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_CORE_FCLOSE_DELETER_HPP
|
||||
#define BOOST_CORE_FCLOSE_DELETER_HPP
|
||||
|
||||
#include <cstdio>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
//! A function object that closes a file
|
||||
struct fclose_deleter
|
||||
{
|
||||
//! Function object result type
|
||||
typedef void result_type;
|
||||
/*!
|
||||
* Closes the file handle
|
||||
*/
|
||||
void operator() (std::FILE* p) const BOOST_NOEXCEPT
|
||||
{
|
||||
if (BOOST_LIKELY(!!p))
|
||||
std::fclose(p);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CORE_FCLOSE_DELETER_HPP
|
||||
@@ -1,12 +1,6 @@
|
||||
#ifndef BOOST_CORE_IS_SAME_HPP_INCLUDED
|
||||
#define BOOST_CORE_IS_SAME_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// is_same<T1,T2>::value is true when T1 == T2
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
@@ -16,6 +10,15 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/type_traits/is_same.hpp>")
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -23,15 +26,7 @@ namespace boost
|
||||
namespace core
|
||||
{
|
||||
|
||||
template< class T1, class T2 > struct is_same
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( bool, value = false );
|
||||
};
|
||||
|
||||
template< class T > struct is_same< T, T >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( bool, value = true );
|
||||
};
|
||||
using boost::core::detail::is_same;
|
||||
|
||||
} // namespace core
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/detail/lwt_unattended.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
@@ -32,11 +33,6 @@
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
# include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||
// some other stream, so allow user to configure output stream:
|
||||
@@ -46,42 +42,39 @@
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class test_result {
|
||||
class test_result
|
||||
{
|
||||
public:
|
||||
test_result()
|
||||
: report_(false)
|
||||
, errors_(0) {
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1310)
|
||||
// disable message boxes on assert(), abort()
|
||||
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
#endif
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
|
||||
// disable message boxes on iterator debugging violations
|
||||
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
|
||||
#endif
|
||||
|
||||
test_result(): report_( false ), errors_( 0 )
|
||||
{
|
||||
core::detail::lwt_unattended();
|
||||
}
|
||||
|
||||
~test_result() {
|
||||
if (!report_) {
|
||||
~test_result()
|
||||
{
|
||||
if( !report_ )
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "main() should return report_errors()" << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
int& errors() {
|
||||
int& errors()
|
||||
{
|
||||
return errors_;
|
||||
}
|
||||
|
||||
void done() {
|
||||
void done()
|
||||
{
|
||||
report_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool report_;
|
||||
int errors_;
|
||||
};
|
||||
@@ -197,11 +190,6 @@ inline unsigned long test_output_impl( char16_t const& v ) { return v; }
|
||||
inline unsigned long test_output_impl( char32_t const& v ) { return v; }
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
inline std::string test_output_impl( char const& v )
|
||||
{
|
||||
if( std::isprint( static_cast<unsigned char>( v ) ) )
|
||||
@@ -210,17 +198,17 @@ inline std::string test_output_impl( char const& v )
|
||||
}
|
||||
else
|
||||
{
|
||||
char buffer[ 8 ];
|
||||
std::sprintf( buffer, "\\x%02X", static_cast<unsigned char>( v ) );
|
||||
static const char char_table[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
char buffer[ 4 ];
|
||||
buffer[ 0 ] = '\\';
|
||||
buffer[ 1 ] = 'x';
|
||||
buffer[ 2 ] = char_table[ (static_cast<unsigned char>( v ) >> 4u) & 0x0f ];
|
||||
buffer[ 3 ] = char_table[ static_cast<unsigned char>( v ) & 0x0f ];
|
||||
|
||||
return buffer;
|
||||
return std::string( buffer, 4u );
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// predicates
|
||||
|
||||
struct lw_test_eq
|
||||
@@ -530,6 +518,15 @@ inline int report_errors()
|
||||
return errors < 256? errors: 255;
|
||||
}
|
||||
|
||||
namespace core
|
||||
{
|
||||
|
||||
inline void lwt_init()
|
||||
{
|
||||
boost::detail::test_results();
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/type_name.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
@@ -56,7 +56,7 @@ template<class T> inline bool test_trait_same_impl_( T )
|
||||
}
|
||||
|
||||
template<class T1, class T2> inline void test_trait_same_impl( char const * types,
|
||||
boost::core::is_same<T1, T2> same, char const * file, int line, char const * function )
|
||||
boost::core::detail::is_same<T1, T2> same, char const * file, int line, char const * function )
|
||||
{
|
||||
if( test_trait_same_impl_( same ) )
|
||||
{
|
||||
@@ -86,6 +86,6 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::detail::is_same< __VA_ARGS__ >(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP
|
||||
|
||||
173
include/boost/core/snprintf.hpp
Normal file
173
include/boost/core/snprintf.hpp
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2022.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file snprintf.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 06.12.2022
|
||||
*
|
||||
* \brief The header provides more portable definition of snprintf and vsnprintf,
|
||||
* as well as \c wchar_t counterparts.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_CORE_SNPRINTF_HPP_INCLUDED_
|
||||
#define BOOST_CORE_SNPRINTF_HPP_INCLUDED_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdarg>
|
||||
#if !defined(__MINGW64_VERSION_MAJOR)
|
||||
#include <climits>
|
||||
#endif
|
||||
|
||||
// MinGW32 and MinGW-w64 provide their own snprintf implementations that are compliant with the C standard.
|
||||
#define BOOST_CORE_DETAIL_MINGW_SNPRINTF
|
||||
|
||||
#elif (defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION < 140)
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdarg>
|
||||
#include <climits>
|
||||
|
||||
// MSVC snprintfs are not conforming but they are good enough for typical use cases.
|
||||
#define BOOST_CORE_DETAIL_MSVC_LEGACY_SNPRINTF
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace core {
|
||||
|
||||
#if defined(BOOST_CORE_DETAIL_MINGW_SNPRINTF) || defined(BOOST_CORE_DETAIL_MSVC_LEGACY_SNPRINTF)
|
||||
|
||||
#if defined(BOOST_CORE_DETAIL_MINGW_SNPRINTF)
|
||||
|
||||
inline int vsnprintf(char* buf, std::size_t size, const char* format, std::va_list args)
|
||||
{
|
||||
return __mingw_vsnprintf(buf, size, format, args);
|
||||
}
|
||||
|
||||
inline int vswprintf(wchar_t* buf, std::size_t size, const wchar_t* format, std::va_list args)
|
||||
{
|
||||
#if defined(__MINGW64_VERSION_MAJOR)
|
||||
int res = __mingw_vsnwprintf(buf, size, format, args);
|
||||
// __mingw_vsnwprintf returns the number of characters to be printed, but (v)swprintf is expected to return -1 on truncation
|
||||
if (static_cast< unsigned int >(res) >= size)
|
||||
res = -1;
|
||||
return res;
|
||||
#else
|
||||
// Legacy MinGW32 does not provide __mingw_vsnwprintf, so use _vsnwprintf from MSVC CRT
|
||||
if (BOOST_UNLIKELY(size == 0u || size > static_cast< std::size_t >(INT_MAX)))
|
||||
return -1;
|
||||
|
||||
int res = _vsnwprintf(buf, size, format, args);
|
||||
// (v)swprintf is expected to return -1 on truncation, so we only need to ensure the output is null-terminated
|
||||
if (static_cast< unsigned int >(res) >= size)
|
||||
{
|
||||
buf[size - 1u] = L'\0';
|
||||
res = -1;
|
||||
}
|
||||
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(BOOST_CORE_DETAIL_MSVC_LEGACY_SNPRINTF)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
// '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead.
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
inline int vsnprintf(char* buf, std::size_t size, const char* format, std::va_list args)
|
||||
{
|
||||
if (BOOST_UNLIKELY(size == 0u))
|
||||
return 0;
|
||||
if (BOOST_UNLIKELY(size > static_cast< std::size_t >(INT_MAX)))
|
||||
return -1;
|
||||
|
||||
buf[size - 1u] = '\0';
|
||||
int res = _vsnprintf(buf, size, format, args);
|
||||
if (static_cast< unsigned int >(res) >= size)
|
||||
{
|
||||
// _vsnprintf returns -1 if the output was truncated and in case of other errors.
|
||||
// Detect truncation by checking whether the output buffer was written over entirely.
|
||||
if (buf[size - 1u] != '\0')
|
||||
{
|
||||
buf[size - 1u] = '\0';
|
||||
res = static_cast< int >(size);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
inline int vswprintf(wchar_t* buf, std::size_t size, const wchar_t* format, std::va_list args)
|
||||
{
|
||||
if (BOOST_UNLIKELY(size == 0u || size > static_cast< std::size_t >(INT_MAX)))
|
||||
return -1;
|
||||
|
||||
int res = _vsnwprintf(buf, size, format, args);
|
||||
// (v)swprintf is expected to return -1 on truncation, so we only need to ensure the output is null-terminated
|
||||
if (static_cast< unsigned int >(res) >= size)
|
||||
{
|
||||
buf[size - 1u] = L'\0';
|
||||
res = -1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
inline int snprintf(char* buf, std::size_t size, const char* format, ...)
|
||||
{
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
int res = vsnprintf(buf, size, format, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline int swprintf(wchar_t* buf, std::size_t size, const wchar_t* format, ...)
|
||||
{
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
int res = vswprintf(buf, size, format, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
#else // defined(BOOST_CORE_DETAIL_MINGW_SNPRINTF) || defined(BOOST_CORE_DETAIL_MSVC_LEGACY_SNPRINTF)
|
||||
|
||||
// Standard-conforming compilers already have the correct snprintfs
|
||||
using ::snprintf;
|
||||
using ::vsnprintf;
|
||||
|
||||
using ::swprintf;
|
||||
using ::vswprintf;
|
||||
|
||||
#endif // defined(BOOST_CORE_DETAIL_MINGW_SNPRINTF) || defined(BOOST_CORE_DETAIL_MSVC_LEGACY_SNPRINTF)
|
||||
|
||||
} // namespace core
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CORE_SNPRINTF_HPP_INCLUDED_
|
||||
@@ -14,7 +14,6 @@
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
@@ -185,14 +184,23 @@ template<class T> std::string array_template_name()
|
||||
# pragma warning( disable: 4996 )
|
||||
#endif
|
||||
|
||||
// Use snprintf if available as some compilers (clang 14.0) issue deprecation warnings for sprintf
|
||||
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
||||
# define BOOST_CORE_DETAIL_SNPRINTF(buffer, format, arg) std::sprintf(buffer, format, arg)
|
||||
#else
|
||||
# define BOOST_CORE_DETAIL_SNPRINTF(buffer, format, arg) std::snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), format, arg)
|
||||
#endif
|
||||
|
||||
inline std::string tn_to_string( std::size_t n )
|
||||
{
|
||||
char buffer[ 32 ];
|
||||
std::sprintf( buffer, "%lu", static_cast< unsigned long >( n ) );
|
||||
BOOST_CORE_DETAIL_SNPRINTF( buffer, "%lu", static_cast< unsigned long >( n ) );
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#undef BOOST_CORE_DETAIL_SNPRINTF
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert)
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::type_traits)
|
||||
|
||||
@@ -27,6 +27,10 @@ set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::utility)
|
||||
|
||||
boost_test(TYPE run SOURCES sv_conversion_test2.cpp)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::config Boost::move Boost::smart_ptr)
|
||||
|
||||
boost_test(TYPE run SOURCES fclose_deleter_test.cpp)
|
||||
|
||||
endif()
|
||||
|
||||
add_subdirectory(swap)
|
||||
|
||||
@@ -148,6 +148,7 @@ run-fail lightweight_test_fail12.cpp ;
|
||||
run-fail lightweight_test_fail13.cpp ;
|
||||
run-fail lightweight_test_fail14.cpp ;
|
||||
run-fail lightweight_test_fail15.cpp ;
|
||||
run-fail lightweight_test_fail16.cpp : ;
|
||||
run-fail lightweight_test_lt_fail.cpp ;
|
||||
run-fail lightweight_test_le_fail.cpp ;
|
||||
run-fail lightweight_test_gt_fail.cpp ;
|
||||
@@ -174,7 +175,7 @@ run demangle_test.cpp
|
||||
run demangled_name_test.cpp
|
||||
: : : <test-info>always_show_run_output ;
|
||||
|
||||
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
|
||||
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
|
||||
|
||||
run scoped_enum.cpp ;
|
||||
compile-fail scoped_enum_compile_fail_conv_from_int.cpp
|
||||
@@ -184,6 +185,8 @@ compile-fail scoped_enum_compile_fail_conv_to_int.cpp
|
||||
|
||||
run underlying_type.cpp ;
|
||||
|
||||
run fclose_deleter_test.cpp : : : <target-os>windows:<define>_CRT_SECURE_NO_WARNINGS <target-os>windows:<define>_CRT_SECURE_NO_DEPRECATE ;
|
||||
|
||||
run pointer_traits_pointer_test.cpp ;
|
||||
run pointer_traits_element_type_test.cpp ;
|
||||
run pointer_traits_difference_type_test.cpp ;
|
||||
@@ -203,6 +206,7 @@ compile first_scalar_constexpr_test.cpp ;
|
||||
run empty_value_test.cpp ;
|
||||
run empty_value_size_test.cpp ;
|
||||
run empty_value_final_test.cpp ;
|
||||
run empty_value_constexpr_test.cpp ;
|
||||
|
||||
run quick_exit_test.cpp ;
|
||||
run-fail quick_exit_fail.cpp ;
|
||||
@@ -293,8 +297,13 @@ run bit_popcount_test.cpp
|
||||
run bit_endian_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
compile-fail bit_width_fail.cpp
|
||||
: <warnings>off ;
|
||||
|
||||
run type_name_test.cpp ;
|
||||
|
||||
run snprintf_test.cpp ;
|
||||
|
||||
run sv_types_test.cpp ;
|
||||
run sv_construct_test.cpp ;
|
||||
run sv_iteration_test.cpp ;
|
||||
@@ -324,6 +333,8 @@ run sv_conversion_test2.cpp : ;
|
||||
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) ;
|
||||
|
||||
run span_test.cpp ;
|
||||
run span_types_test.cpp ;
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -22,9 +22,9 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::allocator_const_pointer<A1<char> >::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const int*,
|
||||
boost::allocator_const_pointer<A2<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -27,9 +27,9 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::allocator_const_void_pointer<A1<char> >::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const void*,
|
||||
boost::allocator_const_void_pointer<A2<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -22,9 +22,9 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<short,
|
||||
boost::allocator_difference_type<A1<char> >::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::allocator_difference_type<A2<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -6,7 +6,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -6,7 +6,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -6,7 +6,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -22,9 +22,9 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::allocator_pointer<A1<char> >::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::allocator_pointer<A2<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -25,9 +25,9 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<A1<int>,
|
||||
boost::allocator_rebind<A1<char>, bool>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<A2<int>,
|
||||
boost::allocator_rebind<A2<char>, int>::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -24,11 +27,11 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::is_same<int,
|
||||
boost::allocator_size_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<
|
||||
std::make_unsigned<std::ptrdiff_t>::type,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::is_same<
|
||||
boost::make_unsigned<std::ptrdiff_t>::type,
|
||||
boost::allocator_size_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
@@ -16,7 +16,7 @@ struct A {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int,
|
||||
boost::allocator_value_type<A<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
@@ -27,9 +27,9 @@ struct A2 {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::allocator_void_pointer<A1<char> >::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<void*,
|
||||
boost::allocator_void_pointer<A2<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
13
test/bit_width_fail.cpp
Normal file
13
test/bit_width_fail.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// Negative test for boost/core/bit.hpp (bit_width)
|
||||
//
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/bit.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
// should fail, because 0 is a signed integral type
|
||||
return boost::core::bit_width( 0 );
|
||||
}
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_HEADERS
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <cstddef>
|
||||
#include <list>
|
||||
|
||||
@@ -62,7 +62,7 @@ struct iterator
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::core::is_same;
|
||||
using boost::is_same;
|
||||
|
||||
/*
|
||||
template<class Iterator> struct iterator_traits {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
// Testing all variations of lazy_enable_if.
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
@@ -26,7 +26,7 @@ using boost::lazy_disable_if_c;
|
||||
template <class T>
|
||||
struct is_int_or_double {
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
value = (boost::is_same<T, int>::value ||
|
||||
value = (boost::is_same<T, int>::value ||
|
||||
boost::is_same<T, double>::value));
|
||||
};
|
||||
|
||||
@@ -84,14 +84,14 @@ int main()
|
||||
BOOST_TEST(foo(1));
|
||||
BOOST_TEST(foo(1.0));
|
||||
|
||||
BOOST_TEST(!foo("1"));
|
||||
BOOST_TEST(!foo(static_cast<void*>(0)));
|
||||
BOOST_TEST(!foo("1"));
|
||||
BOOST_TEST(!foo(static_cast<void*>(0)));
|
||||
|
||||
BOOST_TEST(foo2(1));
|
||||
BOOST_TEST(foo2(1.0));
|
||||
|
||||
BOOST_TEST(!foo2("1"));
|
||||
BOOST_TEST(!foo2(static_cast<void*>(0)));
|
||||
BOOST_TEST(!foo2("1"));
|
||||
BOOST_TEST(!foo2(static_cast<void*>(0)));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
65
test/empty_value_constexpr_test.cpp
Normal file
65
test/empty_value_constexpr_test.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2022 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||
#include <boost/core/empty_value.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct empty {
|
||||
constexpr int value() const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
class type {
|
||||
public:
|
||||
explicit constexpr type(int count)
|
||||
: value_(count) { }
|
||||
|
||||
constexpr int value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
void test_int()
|
||||
{
|
||||
constexpr boost::empty_value<int> v(boost::empty_init_t(), 4);
|
||||
constexpr int c = v.get();
|
||||
BOOST_TEST_EQ(c, 4);
|
||||
}
|
||||
|
||||
void test_empty()
|
||||
{
|
||||
constexpr boost::empty_value<empty> v = boost::empty_init_t();
|
||||
constexpr int c = v.get().value();
|
||||
BOOST_TEST_EQ(c, 1);
|
||||
}
|
||||
|
||||
void test_type()
|
||||
{
|
||||
constexpr boost::empty_value<type> v(boost::empty_init_t(), 2);
|
||||
constexpr int c = v.get().value();
|
||||
BOOST_TEST_EQ(c, 2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_int();
|
||||
test_empty();
|
||||
test_type();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
73
test/fclose_deleter_test.cpp
Normal file
73
test/fclose_deleter_test.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2022.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file fclose_deleter_test.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 21.09.2022
|
||||
*
|
||||
* This file contains tests for \c boost::fclose_deleter.
|
||||
*/
|
||||
|
||||
#include <boost/core/fclose_deleter.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/move/unique_ptr.hpp>
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
boost::movelib::unique_ptr< std::FILE, boost::fclose_deleter > make_boost_unique_file(const char* filename)
|
||||
{
|
||||
return boost::movelib::unique_ptr< std::FILE, boost::fclose_deleter >(std::fopen(filename, "w"));
|
||||
}
|
||||
|
||||
boost::shared_ptr< std::FILE > make_boost_shared_file(const char* filename)
|
||||
{
|
||||
return boost::shared_ptr< std::FILE >(std::fopen(filename, "w"), boost::fclose_deleter());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
std::unique_ptr< std::FILE, boost::fclose_deleter > make_std_unique_file(const char* filename)
|
||||
{
|
||||
return std::unique_ptr< std::FILE, boost::fclose_deleter >(std::fopen(filename, "w"));
|
||||
}
|
||||
|
||||
std::shared_ptr< std::FILE > make_std_shared_file(const char* filename)
|
||||
{
|
||||
return std::shared_ptr< std::FILE >(std::fopen(filename, "w"), boost::fclose_deleter());
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* const filename = "fcd_test.txt";
|
||||
|
||||
std::FILE* file = std::fopen(filename, "w");
|
||||
if (file)
|
||||
{
|
||||
boost::fclose_deleter()(file);
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
make_boost_unique_file(filename);
|
||||
make_boost_shared_file(filename);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
make_std_unique_file(filename);
|
||||
make_std_shared_file(filename);
|
||||
#endif
|
||||
|
||||
// Test if the deleter can be called on a NULL pointer
|
||||
boost::shared_ptr< std::FILE >(static_cast< std::FILE* >(NULL), boost::fclose_deleter());
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
std::shared_ptr< std::FILE >(static_cast< std::FILE* >(NULL), boost::fclose_deleter());
|
||||
#endif
|
||||
|
||||
std::remove(filename);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Test for core::is_same<T1,T2>
|
||||
// Test for core::detail::is_same<T1,T2>
|
||||
//
|
||||
// Copyright 2014 Peter Dimov
|
||||
//
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X
|
||||
@@ -21,18 +21,18 @@ struct Y
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<X, X> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<Y, Y> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<void, void> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<int, int> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::is_same<void const volatile, void const volatile> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::detail::is_same<X, X> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::detail::is_same<Y, Y> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::detail::is_same<void, void> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::detail::is_same<int, int> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( boost::core::detail::is_same<void const volatile, void const volatile> ));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::is_same<X, Y> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::is_same<X, X const> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::is_same<X, void> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::is_same<X, int> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::is_same<int, void> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::is_same<void, void const volatile> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::detail::is_same<X, Y> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::detail::is_same<X, X const> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::detail::is_same<X, void> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::detail::is_same<X, int> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::detail::is_same<int, void> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( boost::core::detail::is_same<void, void const volatile> ));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#if BOOST_CXX_VERSION < 201703
|
||||
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
/*
|
||||
|
||||
@@ -60,7 +60,7 @@ struct R
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::core::is_same;
|
||||
using boost::is_same;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::iterator_category,C>));
|
||||
BOOST_TEST_TRAIT_TRUE((is_same<boost::iterator<C,T,D,P,R>::value_type,T>));
|
||||
|
||||
12
test/lightweight_test_fail16.cpp
Normal file
12
test/lightweight_test_fail16.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
// Should fail, because boost::report_errors() hasn't been called
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::core::lwt_init();
|
||||
}
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P { };
|
||||
@@ -19,23 +19,23 @@ struct E {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<int*>::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<P<int> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<long,
|
||||
boost::pointer_traits<E<int> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<void*>::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<P<void> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<long,
|
||||
boost::pointer_traits<E<void> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<const int*>::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<std::ptrdiff_t,
|
||||
boost::pointer_traits<P<const int> >::difference_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<long,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<long,
|
||||
boost::pointer_traits<E<const int> >::difference_type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P1 { };
|
||||
@@ -45,39 +45,39 @@ struct E {
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int,
|
||||
boost::pointer_traits<int*>::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int,
|
||||
boost::pointer_traits<P1<int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int,
|
||||
boost::pointer_traits<P2<int, char> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int,
|
||||
boost::pointer_traits<P3<int, char, char> >::element_type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int,
|
||||
boost::pointer_traits<P<int, char, char, char> >::element_type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<bool,
|
||||
boost::pointer_traits<E1<int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<bool,
|
||||
boost::pointer_traits<E2<int, int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<bool,
|
||||
boost::pointer_traits<E3<int, int, int> >::element_type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<bool,
|
||||
boost::pointer_traits<E<int, int, int, int> >::element_type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<void,
|
||||
boost::pointer_traits<void*>::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<void,
|
||||
boost::pointer_traits<P1<void> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<bool,
|
||||
boost::pointer_traits<E1<void> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const int,
|
||||
boost::pointer_traits<const int*>::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const int,
|
||||
boost::pointer_traits<P1<const int> >::element_type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<bool,
|
||||
boost::pointer_traits<E1<const int> >::element_type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,25 +6,25 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P { };
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::pointer_traits<int*>::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P<int>,
|
||||
boost::pointer_traits<P<int> >::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<void*,
|
||||
boost::pointer_traits<void*>::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<void>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P<void>,
|
||||
boost::pointer_traits<P<void> >::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const int*,
|
||||
boost::pointer_traits<const int*>::pointer>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<const int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P<const int>,
|
||||
boost::pointer_traits<P<const int> >::pointer>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/detail/is_same.hpp>
|
||||
|
||||
template<class T>
|
||||
struct P1 { };
|
||||
@@ -55,94 +55,94 @@ struct R { };
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<char*,
|
||||
boost::pointer_traits<R*>::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<char>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<char>,
|
||||
boost::pointer_traits<P1<R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P2<char, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P2<char, R>,
|
||||
boost::pointer_traits<P2<R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P3<char, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P3<char, R, R>,
|
||||
boost::pointer_traits<P3<R, R, R> >::rebind_to<char>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<char, R, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P<char, R, R, R>,
|
||||
boost::pointer_traits<P<R, R, R, R> >::rebind_to<char>::type>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<void*,
|
||||
boost::pointer_traits<R*>::rebind_to<void>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<void>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<void>,
|
||||
boost::pointer_traits<P1<R> >::rebind_to<void>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<R*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<R*,
|
||||
boost::pointer_traits<void*>::rebind_to<R>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<R>,
|
||||
boost::pointer_traits<P1<void> >::rebind_to<R>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const int*,
|
||||
boost::pointer_traits<R*>::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<const int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<const int>,
|
||||
boost::pointer_traits<P1<R> >::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::pointer_traits<const R*>::rebind_to<int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<int>,
|
||||
boost::pointer_traits<P1<const R> >::rebind_to<int>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<char*,
|
||||
boost::pointer_traits<R*>::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<char>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<char>,
|
||||
boost::pointer_traits<P1<R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P2<char, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P2<char, R>,
|
||||
boost::pointer_traits<P2<R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P3<char, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P3<char, R, R>,
|
||||
boost::pointer_traits<P3<R, R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<void*,
|
||||
boost::pointer_traits<R*>::rebind<void> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<void>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<void>,
|
||||
boost::pointer_traits<P1<R> >::rebind<void> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<R*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<R*,
|
||||
boost::pointer_traits<void*>::rebind<R> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<R>,
|
||||
boost::pointer_traits<P1<void> >::rebind<R> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<const int*,
|
||||
boost::pointer_traits<R*>::rebind<const int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<const int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<const int>,
|
||||
boost::pointer_traits<P1<R> >::rebind<const int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<int*,
|
||||
boost::pointer_traits<const R*>::rebind<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P1<int>,
|
||||
boost::pointer_traits<P1<const R> >::rebind<int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E2<bool, R>,
|
||||
boost::pointer_traits<E2<R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E3<bool, R, R>,
|
||||
boost::pointer_traits<E3<R, R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E2<bool, R>,
|
||||
boost::pointer_traits<E2<R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E3<bool, R, R>,
|
||||
boost::pointer_traits<E3<R, R, R> >::rebind<char> >));
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<char, R, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<P<char, R, R, R>,
|
||||
boost::pointer_traits<P<R, R, R, R> >::rebind<char> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E<bool, R, R, R>,
|
||||
boost::pointer_traits<E<R, R, R, R> >::rebind_to<char>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E<bool, R, R, R>,
|
||||
boost::pointer_traits<E<R, R, R, R> >::rebind<char> >));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<void>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<void> >::rebind_to<R>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind_to<const int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<const R> >::rebind_to<int>::type>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind<void> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<void> >::rebind<R> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<R> >::rebind<const int> >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::detail::is_same<E1<bool>,
|
||||
boost::pointer_traits<E1<const R> >::rebind<int> >));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/core/null_deleter.hpp>
|
||||
#include <boost/core/fclose_deleter.hpp>
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/underlying_type.hpp>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// compile-time test for "boost/ref.hpp" header content
|
||||
// compile-time test for "boost/core/ref.hpp" header content
|
||||
// see 'ref_test.cpp' for run-time part
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -17,8 +17,8 @@ template< typename T, typename U >
|
||||
void ref_test(boost::reference_wrapper<U>)
|
||||
{
|
||||
typedef typename boost::reference_wrapper<U>::type type;
|
||||
BOOST_STATIC_ASSERT((boost::core::is_same<U,type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::core::is_same<T,type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<U,type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T,type>::value));
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
@@ -42,14 +42,14 @@ void is_reference_wrapper_test(T)
|
||||
template< typename R, typename Ref >
|
||||
void cxx_reference_test(Ref)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::core::is_same<R,Ref>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<R,Ref>::value));
|
||||
}
|
||||
|
||||
template< typename R, typename Ref >
|
||||
void unwrap_reference_test(Ref)
|
||||
{
|
||||
typedef typename boost::unwrap_reference<Ref>::type type;
|
||||
BOOST_STATIC_ASSERT((boost::core::is_same<R,type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<R,type>::value));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#define BOOST_TEST_REF( x ) BOOST_TEST( &boost::ref( x ).get() == &x )
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
void f( boost::reference_wrapper< int > )
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
void f( boost::reference_wrapper< int const > )
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
void f( boost::reference_wrapper< int const > )
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T> void test( T const & t )
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// run-time test for "boost/ref.hpp" header content
|
||||
// run-time test for "boost/core/ref.hpp" header content
|
||||
// see 'ref_ct_test.cpp' for compile-time part
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
86
test/snprintf_test.cpp
Normal file
86
test/snprintf_test.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2022.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
/*!
|
||||
* \file snprintf_test.cpp
|
||||
* \author Andrey Semashev
|
||||
* \date 06.12.2022
|
||||
*
|
||||
* This file contains tests for \c boost::core::snprintf.
|
||||
*/
|
||||
|
||||
#include <boost/core/snprintf.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void test_snprintf()
|
||||
{
|
||||
char buf[11];
|
||||
std::memset(buf, 0xFF, sizeof(buf));
|
||||
|
||||
std::size_t buf_size = sizeof(buf) - 1u;
|
||||
|
||||
int res = boost::core::snprintf(buf, buf_size, "%s", "0123");
|
||||
BOOST_TEST_EQ(res, 4);
|
||||
int cmp_res = std::memcmp(buf, "0123", sizeof("0123"));
|
||||
BOOST_TEST_EQ(cmp_res, 0);
|
||||
|
||||
std::memset(buf, 0xFF, sizeof(buf));
|
||||
|
||||
// Suppress compiler checks for buffer overflow
|
||||
const char* volatile str = "0123456789";
|
||||
|
||||
res = boost::core::snprintf(buf, buf_size, "%s", str);
|
||||
BOOST_TEST_GE(res, 10);
|
||||
cmp_res = std::memcmp(buf, "012345678", sizeof("012345678"));
|
||||
BOOST_TEST_EQ(cmp_res, 0);
|
||||
BOOST_TEST_EQ(buf[10], static_cast< char >(~static_cast< char >(0)));
|
||||
|
||||
std::memset(buf, 0xFF, sizeof(buf));
|
||||
|
||||
res = boost::core::snprintf(buf, 0, "%s", str);
|
||||
BOOST_TEST_GE(res, 0);
|
||||
BOOST_TEST_EQ(buf[0], static_cast< char >(~static_cast< char >(0)));
|
||||
}
|
||||
|
||||
void test_swprintf()
|
||||
{
|
||||
wchar_t buf[11];
|
||||
std::memset(buf, 0xFF, sizeof(buf));
|
||||
|
||||
std::size_t buf_size = sizeof(buf) / sizeof(*buf) - 1u;
|
||||
|
||||
int res = boost::core::swprintf(buf, buf_size, L"%ls", L"0123");
|
||||
BOOST_TEST_EQ(res, 4);
|
||||
int cmp_res = std::memcmp(buf, L"0123", sizeof(L"0123"));
|
||||
BOOST_TEST_EQ(cmp_res, 0);
|
||||
|
||||
std::memset(buf, 0xFF, sizeof(buf));
|
||||
|
||||
// Suppress compiler checks for buffer overflow
|
||||
const wchar_t* volatile str = L"0123456789";
|
||||
|
||||
res = boost::core::swprintf(buf, buf_size, L"%ls", str);
|
||||
BOOST_TEST_LT(res, 0);
|
||||
// swprintf may or may not write to the buffer in case of overflow.
|
||||
// E.g. glibc 2.35 doesn't and libc on MacOS 11 does.
|
||||
BOOST_TEST_EQ(buf[10], static_cast< wchar_t >(~static_cast< wchar_t >(0)));
|
||||
|
||||
std::memset(buf, 0xFF, sizeof(buf));
|
||||
|
||||
res = boost::core::swprintf(buf, 0, L"%ls", str);
|
||||
BOOST_TEST_LT(res, 0);
|
||||
BOOST_TEST_EQ(buf[0], static_cast< wchar_t >(~static_cast< wchar_t >(0)));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_snprintf();
|
||||
test_swprintf();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
19
test/sv_nullptr_fail.cpp
Normal file
19
test/sv_nullptr_fail.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NULLPTR)
|
||||
|
||||
#error BOOST_NO_CXX11_NULLPTR is defined, test will be skipped.
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return boost::core::string_view( nullptr ).size() == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <iterator>
|
||||
|
||||
struct Ch
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <boost/core/underlying_type.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
@@ -63,9 +63,9 @@ struct underlying_type< native_enum >
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same< boost::underlying_type< emulated_enum >::type, unsigned char >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::is_same< boost::underlying_type< emulated_enum >::type, unsigned char >));
|
||||
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same< boost::underlying_type< native_enum >::type, unsigned short >));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::is_same< boost::underlying_type< native_enum >::type, unsigned short >));
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
Reference in New Issue
Block a user