1
0
forked from boostorg/core

Compare commits

..

66 Commits

Author SHA1 Message Date
Peter Dimov
3ec157eb6f Disable cmath_test_generic on msvc-8.0 2021-10-05 19:16:24 +03:00
Peter Dimov
75fc48ad32 Add a revision history section to documentation 2021-10-05 18:46:47 +03:00
Peter Dimov
6985b1ae25 Remove extra semicolons 2021-10-05 15:53:16 +03:00
Peter Dimov
8ab119135c Add overload for char8_t because Mac has no typeinfo for char8_t 2021-10-05 15:46:22 +03:00
Peter Dimov
1fd2cadddd g++ 4.4 has no string::front 2021-10-05 15:38:33 +03:00
Peter Dimov
bb0c6381f6 Add msvc workarounds 2021-10-05 08:04:01 +03:00
Peter Dimov
4f6f7c3799 Add tests for all fundamental types 2021-10-05 07:50:52 +03:00
Peter Dimov
cd1a8fd238 Support pointers to members 2021-10-05 07:25:35 +03:00
Peter Dimov
b0b48c5783 Support qualified function types 2021-10-05 07:05:34 +03:00
Peter Dimov
ccdf5ce031 Track the type suffix independently for better decomposition of functions and arrays 2021-10-05 06:45:41 +03:00
Peter Dimov
f833040d48 Disable msvc warnings around tn_is_function 2021-10-05 05:42:41 +03:00
Peter Dimov
b93317815c Apply msvc-12.0 (and below) workarounds 2021-10-05 05:30:37 +03:00
Peter Dimov
01bd23df5d Add tests for function types 2021-10-05 05:04:56 +03:00
Peter Dimov
36cec9a5cc Handle references to functions 2021-10-05 05:01:05 +03:00
Peter Dimov
5e382efa84 Fix std::ostream failure on libstdc++ 2021-10-01 15:51:13 +03:00
Peter Dimov
e260bb865d Add support for string_view 2021-10-01 15:07:19 +03:00
Peter Dimov
f884833b42 Add workaround for msvc-10.0 2021-09-30 03:21:31 +03:00
Peter Dimov
8265fe6405 Minor documentation fix 2021-09-29 21:55:40 +03:00
Peter Dimov
f7b04afe4d Add documentation for type_name 2021-09-29 21:34:23 +03:00
Peter Dimov
2c1eb07a68 Add test for scoped enums 2021-09-29 21:12:54 +03:00
Peter Dimov
a5cbddc466 Add test for enums 2021-09-29 21:09:19 +03:00
Peter Dimov
91a64b3bcf Add support for std::array 2021-09-29 21:02:39 +03:00
Peter Dimov
a039f8c318 Support -fno-rtti 2021-09-29 20:53:38 +03:00
Peter Dimov
bebb7349ba Add workarounds for msvc-12.0 and earlier 2021-09-29 20:05:23 +03:00
Peter Dimov
dc6e3261ec Use typedef instead of using 2021-09-29 19:51:16 +03:00
Peter Dimov
15a7d84858 Use basic_string<char8_t> instead of u8string 2021-09-29 19:50:14 +03:00
Peter Dimov
06023d4ffe Strip libstdc++ and libc++ inline namespaces 2021-09-29 19:34:37 +03:00
Peter Dimov
3e0bc52c32 Add <boost/core/type_name.hpp> 2021-09-29 19:13:12 +03:00
Andrey Semashev
b83f27a9e0 Another fix in git version check. 2021-09-26 20:35:37 +03:00
Andrey Semashev
578e3105b8 Fixed git version check on Mac OS. 2021-09-26 20:31:43 +03:00
Andrey Semashev
f34c4986c1 Added a timeout for GHA CI. 2021-09-15 20:45:23 +03:00
Andrey Semashev
cfd469d858 Removed unused reference to extra_tests variable in GHA config. 2021-09-15 18:27:17 +03:00
Peter Dimov
b1e01b53f3 Merge branch 'develop' into feature/cmath 2021-09-14 19:15:41 +03:00
Peter Dimov
177c093151 Automatically use generic cmath if FP_SUBNORMAL isn't defined 2021-09-14 18:57:33 +03:00
Peter Dimov
cffaabead8 Update and fix CMake test jobs 2021-09-14 18:49:03 +03:00
Peter Dimov
2715f9b5d8 Add a workaround for g++ 4.4, 4.6 2021-09-14 18:35:31 +03:00
Peter Dimov
8043bafb6b Add a generic cmath.hpp implementation, enabled when BOOST_CORE_USE_GENERIC_CMATH is defined 2021-09-14 16:50:34 +03:00
Andrey Semashev
f6bdb17fd9 Updated GitHub Actions config for better configurability.
Reworked extra package installation and added explicit specification
of external package sources. Moved some common constants to environment
variables. Removed installation of unneeded packages in the containers.
2021-09-12 18:28:02 +03:00
Andrey Semashev
cd6847aee8 Update GitHub Actions config to switch Ubuntu 16.04 jobs to Docker containers.
The Ubuntu 16.04 environment is scheduled to be removed from GitHub Actions
in September 2021. Migrate those jobs to Docker containers or Ubuntu 18.04.

Also, added some older compilers. Ported CMake tests from Travis CI.

Based on https://github.com/boostorg/core/pull/95.
Closes https://github.com/boostorg/core/pull/95.
2021-09-06 02:00:12 +03:00
Andrey Semashev
9ff312e2fb Updated README.md to refer to GitHub Actions instead of Travis. 2021-09-06 01:24:19 +03:00
Andrey Semashev
494927312d Removed Travis CI config file.
Travis CI no longer provides (adequate) service to open source projects,
so we have switched to GitHub Actions as a replacement.
2021-09-06 01:24:19 +03:00
Peter Dimov
df91243a1d Whether wchar_t is signed is implementation-defined 2021-08-21 20:28:47 +03:00
Andrey Semashev
f4b3d5dba6 Merge pull request #93 from sdarwin/feature/gha_fix
Small GHA fix, create destination dir
2021-07-27 23:53:44 +03:00
sdarwin
9f0b97c80b Small GHA fix, create destination dir 2021-07-27 13:35:51 -05:00
Andrey Semashev
ce53cc1f8f Changed quotes in format() expression. 2021-07-02 20:38:22 +03:00
Andrey Semashev
8fad14b804 Use gcc-7 toolchain for clang-8 CI job. 2021-07-02 20:35:45 +03:00
Andrey Semashev
24b6d89e7f Changed CI concurrency group format.
This should fix CI and also make concurrncy work for PRs.
2021-07-02 20:34:19 +03:00
Andrey Semashev
ffd79a28e1 Added concurrency settings to auto-cancel redundant CI jobs. 2021-07-02 20:03:50 +03:00
Andrey Semashev
aa97e418f2 Increased git fetch jobs on Windows and use CPU count for build jobs. 2021-07-02 19:33:06 +03:00
Andrey Semashev
f563d50d42 Use more git fetch jobs to speed up clones. 2021-07-02 19:19:48 +03:00
Andrey Semashev
c55a20dff2 Reverted gcc package removal and instead setup a dummy gcc toolset tree.
Removing gcc and libstdc++ packages did not fix the clang-8 test failures.

Instead, setup a dummy gcc toolset tree and point clang to it to force
the compiler detect and use an older libstdc++.
2021-07-02 19:14:04 +03:00
Andrey Semashev
bc508f8b4c Remove gcc-10 for clang-8 testing.
This is another attempt to make clang-8 tests not fail in C++20 mode. Remove
gcc-10 and libstdc++-10 to prevent clang using it.

Also, use apt-get instead of apt since the former is recommended to use in
scripts. This should silence apt warnings.
2021-07-02 16:15:59 +03:00
Andrey Semashev
03c5481dd4 Moved clang-8 to Bionic and gcc-10,11 to Focal.
clang-8 jobs fail in C++20 mode since it doesn't support
std::is_constant_evaluated, which is called from libstdc++-10 that is installed
in Focal image. Moving it back to Bionic should work around the issue
as it should use an older libstdc++ version.

gcc-10 and 11 were moved to Focal just to make this configuration tested.

Also, changed 2a to 20 for compilers that support this.
2021-07-02 11:52:44 +03:00
Andrey Semashev
8e7ee90080 Merge pull request #92 from evanmiller/develop
Restore support for ancient Mac OS
2021-07-02 01:59:50 +03:00
Evan Miller
128d9314d6 Restore support for ancient Mac OS
Mac OS 10.4 and earlier lack Availability.h, causing compilation to
fail. Rearrange the macro logic to include Availability.h only if we
already think there may be support for uncaught exceptions.
2021-07-01 16:32:40 -04:00
Peter Dimov
012d96a72b Use non-const references in non-variadic branch as well 2021-06-10 10:09:46 +03:00
Peter Dimov
27d700ec01 Use non-const references in ignore_unused to avoid g++-11 warning 2021-06-10 09:54:51 +03:00
Peter Dimov
507c182f4c Revert "Initialize variables in ignore_unused_test to avoid a g++-11 warning"
This reverts commit 1a011cde56.
2021-06-10 09:40:08 +03:00
Peter Dimov
1a011cde56 Initialize variables in ignore_unused_test to avoid a g++-11 warning 2021-06-10 08:25:28 +03:00
Peter Dimov
71c3d320d5 Update ci.yml 2021-06-10 07:20:24 +03:00
Peter Dimov
b3fa7ca565 Take care of gcc-4.4 in addition to gcc-4.4.7 2021-06-10 04:58:17 +03:00
Peter Dimov
d3aa4a2f12 Update .travis.yml 2021-06-10 04:56:26 +03:00
Peter Dimov
67107dbaf9 Update ci.yml 2021-06-10 04:22:36 +03:00
Peter Dimov
0b74f0d394 Update CMakeLists.txt 2021-06-10 02:03:10 +03:00
Peter Dimov
e53393357f Update .github/workflows 2021-04-19 18:11:37 +03:00
Peter Dimov
7daee1d41b Add -DBUILD_TESTING=ON to .yml files; it's not default anymore 2021-03-19 03:53:31 +02:00
15 changed files with 1932 additions and 309 deletions

View File

@@ -1,3 +1,9 @@
# Copyright 2020-2021 Peter Dimov
# Copyright 2021 Andrey Semashev
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on:
@@ -8,146 +14,448 @@ on:
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
UBSAN_OPTIONS: print_stacktrace=1
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.4
cxxstd: "98,0x"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.4
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.6
cxxstd: "03,0x"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.6
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.7
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.8
os: ubuntu-18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.9
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
install: g++-6
os: ubuntu-18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
- name: UBSAN
toolset: gcc-11
cxxstd: "03,11,14,17,20"
ubsan: 1
os: ubuntu-20.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.5
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.6
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.7
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.8
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.9
os: ubuntu-18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-4.0
os: ubuntu-18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
install: clang-5.0
os: ubuntu-18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
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-20.04
os: ubuntu-18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-12
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
os: ubuntu-20.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- name: UBSAN
toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
os: ubuntu-20.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
- name: CMake tests
cmake_tests: 1
os: ubuntu-20.04
timeout-minutes: 120
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 git cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
run: |
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
SOURCES=(${{join(matrix.sources, ' ')}})
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_HAS_SOURCE_ARGS=0
SOFTWARE_PROPERTIES_VERSION="$(dpkg-query --showformat='${Version}' --show software-properties-common)"
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.96.24.20"
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.98.10"
then
APT_ADD_REPO_HAS_SOURCE_ARGS=1
fi
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
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
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
then
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
then
GIT_HAS_JOBS=0
fi
else
declare -a GIT_VER=(${GIT_VERSION//./ })
declare -a GIT_MIN_VER=(2 8 0)
for ((i=0; i<${#GIT_VER[@]}; i++))
do
if [ -z "${GIT_MIN_VER[i]}" ]
then
GIT_MIN_VER[i]=0
fi
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
then
GIT_HAS_JOBS=0
break
fi
done
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
fi
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
cd ../boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"
- name: Run CMake tests
if: matrix.cmake_tests != ''
run: |
cd ../boost-root
mkdir __build_cmake_test__ && cd __build_cmake_test__
cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=$LIBRARY ..
cmake --build . --target tests
ctest --output-on-failure
- name: Run CMake subdir tests
if: matrix.cmake_tests != ''
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
cmake ..
cmake --build .
cmake --build . --target check
- name: Run CMake install tests
if: matrix.cmake_tests != ''
run: |
cd ../boost-root
mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build . --target install
cd ../libs/$LIBRARY/test/cmake_install_test
mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
cmake --build . --target check
windows:
strategy:
@@ -175,27 +483,27 @@ jobs:
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
cd ../boost-root
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release

View File

@@ -1,208 +0,0 @@
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
dist: xenial
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
addons:
apt:
packages:
- g++-multilib
- os: linux
arch: arm64
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
arch: ppc64le
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
- os: linux
arch: s390x
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-11
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- libc++abi-dev
- os: freebsd
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode7.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode8.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode9.4
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode10.1
- os: osx
osx_image: xcode11.3
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=core ..
- ctest --output-on-failure -R boost_core
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="assert;config;core" -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/core/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/headers
- git submodule init libs/assert
- git submodule init libs/config
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule init tools/cmake
- git submodule update
- cp -r $TRAVIS_BUILD_DIR/* libs/core
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
- ./b2 -j $BUILD_JOBS libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:
on_success: always

View File

@@ -17,13 +17,6 @@ target_link_libraries(boost_core
Boost::config
)
if(BOOST_SUPERPROJECT_VERSION)
include(BoostInstall)
boost_install(TARGETS boost_core HEADER_DIRECTORY include/)
endif()
if(BUILD_TESTING)
add_subdirectory(test)

View File

@@ -8,12 +8,12 @@ The criteria for inclusion is that the utility component be:
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core itself, Config, Assert, Static Assert, or Predef.
### CI Status
### Build Status
Branch | Travis | Appveyor
---------|--------|---------
Develop | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=develop)](https://travis-ci.org/boostorg/core) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/core)
Master | [![Build Status](https://travis-ci.org/boostorg/core.svg?branch=master)](https://travis-ci.org/boostorg/core) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/core)
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
---------|----------------|--------- | ----------- | ------------ |
Develop | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/filesystem/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/core) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/core.html)
Master | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/filesystem/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/core) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/core.html)
### Directories

88
doc/changes.qbk Normal file
View File

@@ -0,0 +1,88 @@
[/
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt)
]
[section Revision History]
[section Changes in 1.78.0]
* Added a generic implementation to `boost/core/cmath.hpp`, enabled when `BOOST_CORE_USE_GENERIC_CMATH`
is defined or when the platform does not provide the necessary facilities in `<cmath>`.
* Added `boost::core::type_name`.
[endsect]
[section Changes in 1.77.0]
* `boost/core/uncaught_exceptions.hpp` has been modified for compatibility with Mac OS 10.4 and older.
[endsect]
[section Changes in 1.76.0]
* Add implicit conversion between compatible reference wrappers.
* Add `boost/core/cmath.hpp`, a portable implementation of the floating point classification functions from `<cmath>`.
* Add `boost/core/bit.hpp`, a portable implementation of the C++20 standard header `<bit>`.
* Fix `BOOST_TEST_EQ`, `BOOST_TEST_NE` for character types under C++20.
* Revise allocator access utilities (now support VS2013, and no workarounds use `allocator_traits`.)
[endsect]
[section Changes in 1.74.0]
* Implemented the allocator access utilities which provide a replacement for `allocator_traits`
with individual traits and functions for each facility. They support the C++11 allocator model
when possible and provide a fallback for C++98 compatibility.
[endsect]
[section Changes in 1.71.0]
* Added functions `alloc_construct`, `alloc_construct_n`, `alloc_destroy`, and `alloc_destroy_n`
in `<boost/core/alloc_construct.hpp>` for allocator aware and exception safe construction and
destruction of objects and arrays.
* Added constexpr functions `first_scalar` in `<boost/core/first_scalar.hpp>` for obtaining a pointer
to the first scalar element of an array. Given a pointer of type `T*` they return a pointer of type
`remove_all_extents_t<T>*`.
* Added class template `noinit_adaptor` in `<boost/core/noinit_adaptor.hpp>` which is an allocator adaptor
that converts any allocator into one whose `construct(ptr)` performs default initialization via placement
`new`, and whose `destroy(ptr)` invokes the `value_type` destructor directly.
* Added class template `default_allocator` in `<boost/core/default_allocator.hpp>`, which can serve as a minimal
default allocator that has interface similar to C++20 `std::allocator`, supports configurations with disabled
exceptions and does not have `std` as an associated namespace. The allocator uses `operator new` and
`operator delete` for allocation.
* In `<boost/core/uncaught_exceptions.hpp>` header, added workarounds for better compatibility with QNX SDP 7.0
when libc++/libc++abi libraries are used.
* The `<boost/detail/sp_typeinfo.hpp>` header is now marked as deprecated and will be removed in a future release.
`<boost/core/typeinfo.hpp>` should be used instead.
[endsect]
[section Changes in 1.69.0]
* Implemented `boost::empty_value`, for library authors to conveniently leverage the Empty Base Optimization to
store objects of potentially empty types.
* Implemented `boost::quick_exit` to provide the C++11 standard library facility `std::quick_exit` functionality.
* Reduced the number of statics in Lightweight Test, and employ lighter abort behavior for MSVC compilers upon
failure to call `boost::report_errors`.
[endsect]
[section Changes in 1.67.0]
* Updated `to_address` and `pointer_traits` to reflect the design adopted for C++20 in
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r2.html P0653R2].
[endsect]
[section Changes in 1.65.0]
* Implemented `pointer_traits` for C++03 and higher, that implements
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r0.html P0653r0].
* Added `BOOST_TEST_GT` and `BOOST_TEST_GE` to Lightweight Test.
[endsect]
[endsect]

View File

@@ -38,6 +38,8 @@ criteria for inclusion is that the utility component be:
[endsect]
[include changes.qbk]
[include addressof.qbk]
[include allocator_access.qbk]
[include alloc_construct.qbk]
@@ -65,5 +67,6 @@ criteria for inclusion is that the utility component be:
[include scoped_enum.qbk]
[include swap.qbk]
[include typeinfo.qbk]
[include type_name.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]

77
doc/type_name.qbk Normal file
View File

@@ -0,0 +1,77 @@
[/
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:type_name type_name]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/type_name.hpp>]
The header `<boost/core/type_name.hpp>` defines the function
template `boost::core::type_name<T>()` that returns a string
representation of the name of `T`, suitable for logging or
diagnostic display purposes.
The result is similar to `boost::core::demangle( typeid(T).name() )`,
but it's made more regular by eliminating some of the platform-specific
differences and extra template parameters of the standard library
container types.
For example, `type_name< std::map<std::string, int> >()` returns
`"std::map<std::string, int>"` and not
```
std::map<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >, int, std::less<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, std::allocator<
std::pair<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const, int> > >
```
or
```
class std::map<class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> >,int,struct std::less<class std::basic_string<
char,struct std::char_traits<char>,class std::allocator<char> > >,class
std::allocator<struct std::pair<class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const ,int> > >
```
The return values aren't guaranteed to be stable across Boost releases.
Compilation with `-fno-rtti` is supported, but the returned type names aren't
guaranteed to be particularly useful or unique.
[section Synopsis]
``
namespace boost
{
namespace core
{
template<class T> std::string type_name();
} // namespace core
} // namespace boost
``
[endsect]
[section template<class T> std::string type_name();]
* *Returns:* A string representation of the name of `T`.
[endsect]
[endsect]
[endsect]

View File

@@ -12,11 +12,108 @@
// Floating point classification and sign manipulation functions
// Extracted from https://github.com/boostorg/lexical_cast/pull/37
//
// Copyright 2020 Peter Dimov
// Copyright 2020, 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <cmath>
#if defined(BOOST_CORE_USE_GENERIC_CMATH) || (!defined(_MSC_VER) && !defined(FP_SUBNORMAL))
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <limits>
#include <cstring>
namespace boost
{
namespace core
{
// fpclassify return values
int const fp_zero = 0;
int const fp_subnormal = 1;
int const fp_normal = 2;
int const fp_infinite = 3;
int const fp_nan = 4;
// Classification functions
template<class T> bool isfinite( T x )
{
return x <= (std::numeric_limits<T>::max)() && x >= -(std::numeric_limits<T>::max)();
}
template<class T> bool isinf( T x )
{
return x > (std::numeric_limits<T>::max)() || x < -(std::numeric_limits<T>::max)();
}
template<class T> bool isnan( T x )
{
return !isfinite( x ) && !isinf( x );
}
template<class T> bool isnormal( T x )
{
return isfinite( x ) && ( x >= (std::numeric_limits<T>::min)() || x <= -(std::numeric_limits<T>::min)() );
}
template<class T> int fpclassify( T x )
{
if( x == 0 ) return fp_zero;
if( x < 0 ) x = -x;
if( x > (std::numeric_limits<T>::max)() ) return fp_infinite;
if( x >= (std::numeric_limits<T>::min)() ) return fp_normal;
if( x < (std::numeric_limits<T>::min)() ) return fp_subnormal;
return fp_nan;
}
// Sign manipulation functions
inline bool signbit( float x )
{
boost::int32_t y;
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
std::memcpy( &y, &x, sizeof( y ) );
return y < 0;
}
inline bool signbit( double x )
{
boost::int64_t y;
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
std::memcpy( &y, &x, sizeof( y ) );
return y < 0;
}
inline bool signbit( long double x )
{
return signbit( static_cast<double>( x ) );
}
template<class T> T copysign( T x, T y )
{
return signbit( x ) == signbit( y )? x: -x;
}
} // namespace core
} // namespace boost
#else // defined(BOOST_CORE_USE_GENERIC_CMATH)
#if defined(_MSC_VER) && _MSC_VER < 1800
# include <float.h>
#endif
@@ -196,4 +293,6 @@ template<class T> T copysign( T x, T y )
} // namespace core
} // namespace boost
#endif // defined(BOOST_CORE_USE_GENERIC_CMATH)
#endif // #ifndef BOOST_CORE_CMATH_HPP_INCLUDED

View File

@@ -11,34 +11,64 @@
namespace boost {
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <typename... Ts>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts&& ...)
{}
#else
template <typename... Ts>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(Ts const& ...)
{}
#endif
template <typename... Ts>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused()
{}
#else
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <typename T1>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&)
{}
template <typename T1>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&)
{}
template <typename T1, typename T2>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&)
{}
template <typename T1, typename T2>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&)
{}
template <typename T1, typename T2, typename T3>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&)
{}
template <typename T1, typename T2, typename T3>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&)
{}
template <typename T1, typename T2, typename T3, typename T4>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&, T4&)
{}
template <typename T1, typename T2, typename T3, typename T4>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&)
{}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1&, T2&, T3&, T4&, T5&)
{}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&, T5 const&)
{}

View File

@@ -181,7 +181,13 @@ inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
inline int test_output_impl( signed char const& v ) { return v; }
inline unsigned test_output_impl( unsigned char const& v ) { return v; }
inline unsigned long test_output_impl( wchar_t const& v ) { return v; }
// Whether wchar_t is signed is implementation-defined
template<bool Signed> struct lwt_long_type {};
template<> struct lwt_long_type<true> { typedef long type; };
template<> struct lwt_long_type<false> { typedef unsigned long type; };
inline lwt_long_type<(static_cast<wchar_t>(-1) < static_cast<wchar_t>(0))>::type test_output_impl( wchar_t const& v ) { return v; }
#if !defined( BOOST_NO_CXX11_CHAR16_T )
inline unsigned long test_output_impl( char16_t const& v ) { return v; }

View File

@@ -0,0 +1,855 @@
#ifndef BOOST_CORE_TYPE_NAME_HPP_INCLUDED
#define BOOST_CORE_TYPE_NAME_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// std::string boost::core::type_name<T>()
//
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/demangle.hpp>
#include <boost/core/is_same.hpp>
#include <boost/config.hpp>
#include <string>
#include <functional>
#include <memory>
#include <utility>
#include <cstdio>
#include <cstddef>
#include <iosfwd>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
namespace boost
{
namespace core
{
namespace detail
{
// tn_identity
template<class T> struct tn_identity
{
typedef T type;
};
// tn_enable_if
template<bool C, class T> struct tn_enable_if
{
};
template<class T> struct tn_enable_if<true, T>
{
typedef T type;
};
// tn_is_reference
template<class T> struct tn_is_reference
{
static const bool value = false;
};
template<class T> struct tn_is_reference<T&>
{
static const bool value = true;
};
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T> struct tn_is_reference<T&&>
{
static const bool value = true;
};
#endif
// tn_remove_const
template<class T> struct tn_remove_const
{
typedef T type;
};
template<class T> struct tn_remove_const<T const>
{
typedef T type;
};
// tn_is_function (also catches references but that's OK)
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4180 4181)
#endif
template<class T, class U = typename tn_remove_const<T>::type> struct tn_is_function: core::is_same<U, U const>
{
};
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#if !defined(BOOST_NO_TYPEID)
// typeid_name
template<class T> std::string typeid_name()
{
std::string r = boost::core::demangle( typeid(T).name() );
#if defined(_MSC_VER)
if( r.substr( 0, 6 ) == "class " )
{
r = r.substr( 6 );
}
if( r.substr( 0, 7 ) == "struct " )
{
r = r.substr( 7 );
}
if( r.substr( 0, 5 ) == "enum " )
{
r = r.substr( 5 );
}
#endif
// libc++ inline namespace
if( r.substr( 0, 10 ) == "std::__1::" )
{
r = "std::" + r.substr( 10 );
}
// libstdc++ inline namespace
if( r.substr( 0, 14 ) == "std::__cxx11::" )
{
r = "std::" + r.substr( 14 );
}
#if defined(BOOST_MSVC) && BOOST_MSVC == 1600
// msvc-10.0 puts TR1 things in std::tr1
if( r.substr( 0, 10 ) == "std::tr1::" )
{
r = "std::" + r.substr( 10 );
}
#endif
return r;
}
// template names
template<class T> std::string class_template_name()
{
std::string r = typeid_name<T>();
return r.substr( 0, r.find( '<' ) );
}
template<class T> std::string sequence_template_name()
{
return class_template_name<T>();
}
template<class T> std::string set_template_name()
{
return class_template_name<T>();
}
template<class T> std::string map_template_name()
{
return class_template_name<T>();
}
template<class T> std::string array_template_name()
{
return class_template_name<T>();
}
#else // #if !defined(BOOST_NO_TYPEID)
template<class T> std::string typeid_name()
{
return "_Tp";
}
template<class T> std::string class_template_name()
{
return "_Tm";
}
template<class T> std::string sequence_template_name()
{
return "_Sq";
}
template<class T> std::string set_template_name()
{
return "_St";
}
template<class T> std::string map_template_name()
{
return "_Mp";
}
template<class T> std::string array_template_name()
{
return "_Ar";
}
#endif
// tn_to_string
#if defined(BOOST_MSVC)
# pragma warning( push )
# pragma warning( disable: 4996 )
#endif
inline std::string tn_to_string( std::size_t n )
{
char buffer[ 32 ];
std::sprintf( buffer, "%lu", static_cast< unsigned long >( n ) );
return buffer;
}
#if defined(BOOST_MSVC)
# pragma warning( pop )
#endif
// tn_add_each
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T> int tn_add_each_impl( std::string& st )
{
if( !st.empty() ) st += ", ";
st += type_name( tn_identity<T>(), "" );
return 0;
}
template<class... T> std::string tn_add_each()
{
std::string st;
typedef int A[ sizeof...(T) + 1 ];
(void)A{ 0, tn_add_each_impl<T>( st )... };
return st;
}
#endif
// primary
template<class T> std::string type_name( tn_identity<T>, std::string const& suffix )
{
return typeid_name<T>() + suffix;
}
// integrals
inline std::string type_name( tn_identity<unsigned>, std::string const& suffix )
{
return "unsigned" + suffix;
}
#if defined(_MSC_VER)
inline std::string type_name( tn_identity<long long>, std::string const& suffix )
{
return "long long" + suffix;
}
inline std::string type_name( tn_identity<unsigned long long>, std::string const& suffix )
{
return "unsigned long long" + suffix;
}
#endif
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
inline std::string type_name( tn_identity<char8_t>, std::string const& suffix )
{
return "char8_t" + suffix;
}
#endif
// cv
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
template<class T> std::string type_name( tn_identity<T const>, std::string const& suffix )
{
return type_name( tn_identity<T>(), " const" + suffix );
}
template<class T> std::string type_name( tn_identity<T volatile>, std::string const& suffix )
{
return type_name( tn_identity<T>(), " volatile" + suffix );
}
template<class T> std::string type_name( tn_identity<T const volatile>, std::string const& suffix )
{
return type_name( tn_identity<T>(), " const volatile" + suffix );
}
#else
template<class T>
typename tn_enable_if<!tn_is_function<T>::value, std::string>::type
type_name( tn_identity<T const>, std::string const& suffix )
{
return type_name( tn_identity<T>(), " const" + suffix );
}
template<class T>
typename tn_enable_if<!tn_is_function<T>::value, std::string>::type
type_name( tn_identity<T volatile>, std::string const& suffix )
{
return type_name( tn_identity<T>(), " volatile" + suffix );
}
template<class T>
typename tn_enable_if<!tn_is_function<T>::value, std::string>::type
type_name( tn_identity<T const volatile>, std::string const& suffix )
{
return type_name( tn_identity<T>(), " const volatile" + suffix );
}
#endif
// refs
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
template<class T> std::string type_name( tn_identity<T&>, std::string const& suffix )
{
return type_name( tn_identity<T>(), "&" + suffix );
}
#else
template<class T>
typename tn_enable_if<!tn_is_reference<T>::value, std::string>::type
type_name( tn_identity<T&>, std::string const& suffix )
{
return type_name( tn_identity<T>(), "&" + suffix );
}
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T> std::string type_name( tn_identity<T&&>, std::string const& suffix )
{
return type_name( tn_identity<T>(), "&&" + suffix );
}
#endif
// function types
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class R, class... A> std::string function_type_name( tn_identity<R(A...)>, std::string const& trailer, std::string const& suffix )
{
std::string r = type_name( tn_identity<R>(), "" );
if( !suffix.empty() )
{
r += '(';
if( suffix[ 0 ] == ' ' )
{
r += suffix.substr( 1 );
}
else
{
r += suffix;
}
r += ')';
}
r += '(' + tn_add_each<A...>() + ')';
r += trailer;
return r;
}
template<class R, class... A> std::string type_name( tn_identity<R(A...)>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), "", suffix );
}
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
template<class R, class... A> std::string type_name( tn_identity<R(A...) const>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile", suffix );
}
#endif
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
template<class R, class... A> std::string type_name( tn_identity<R(A...) &>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " &", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const &>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const &", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile &>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile &", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile &>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile &", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) &&>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " &&", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const &&>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const &&", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile &&>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile &&", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile &&>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile &&", suffix );
}
#endif
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
template<class R, class... A> std::string type_name( tn_identity<R(A...) noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) & noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " & noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const & noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const & noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile & noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile & noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile & noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile & noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) && noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " && noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const && noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const && noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) volatile && noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile && noexcept", suffix );
}
template<class R, class... A> std::string type_name( tn_identity<R(A...) const volatile && noexcept>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile && noexcept", suffix );
}
#endif
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
// pointers
template<class T> std::string type_name( tn_identity<T*>, std::string const& suffix )
{
return type_name( tn_identity<T>(), "*" + suffix );
}
// arrays
template<class T> std::pair<std::string, std::string> array_prefix_suffix( tn_identity<T> )
{
return std::pair<std::string, std::string>( type_name( tn_identity<T>(), "" ), "" );
}
template<class T, std::size_t N> std::pair<std::string, std::string> array_prefix_suffix( tn_identity<T[N]> )
{
std::pair<std::string, std::string> r = array_prefix_suffix( tn_identity<T>() );
r.second = '[' + tn_to_string( N ) + ']' + r.second;
return r;
}
template<class T> std::string array_type_name( tn_identity<T[]>, std::string const& suffix )
{
std::pair<std::string, std::string> r = array_prefix_suffix( tn_identity<T>() );
if( suffix.empty() )
{
return r.first + "[]" + r.second;
}
else
{
return r.first + '(' + suffix + ")[]" + r.second;
}
}
template<class T> std::string type_name( tn_identity<T[]>, std::string const& suffix )
{
return array_type_name( tn_identity<T[]>(), suffix );
}
template<class T> std::string type_name( tn_identity<T const[]>, std::string const& suffix )
{
return array_type_name( tn_identity<T const[]>(), suffix );
}
template<class T> std::string type_name( tn_identity<T volatile[]>, std::string const& suffix )
{
return array_type_name( tn_identity<T volatile[]>(), suffix );
}
template<class T> std::string type_name( tn_identity<T const volatile[]>, std::string const& suffix )
{
return array_type_name( tn_identity<T const volatile[]>(), suffix );
}
template<class T, std::size_t N> std::string array_type_name( tn_identity<T[N]>, std::string const& suffix )
{
std::pair<std::string, std::string> r = array_prefix_suffix( tn_identity<T[N]>() );
if( suffix.empty() )
{
return r.first + r.second;
}
else
{
return r.first + '(' + suffix + ")" + r.second;
}
}
template<class T, std::size_t N> std::string type_name( tn_identity<T[N]>, std::string const& suffix )
{
return array_type_name( tn_identity<T[N]>(), suffix );
}
template<class T, std::size_t N> std::string type_name( tn_identity<T const[N]>, std::string const& suffix )
{
return array_type_name( tn_identity<T const[N]>(), suffix );
}
template<class T, std::size_t N> std::string type_name( tn_identity<T volatile[N]>, std::string const& suffix )
{
return array_type_name( tn_identity<T volatile[N]>(), suffix );
}
template<class T, std::size_t N> std::string type_name( tn_identity<T const volatile[N]>, std::string const& suffix )
{
return array_type_name( tn_identity<T const volatile[N]>(), suffix );
}
// pointers to members
template<class R, class T> std::string type_name( tn_identity<R T::*>, std::string const& suffix )
{
return type_name( tn_identity<R>(), ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
}
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1900 && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class R, class T, class... A> std::string type_name( tn_identity<R(T::*)(A...) const>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const", ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
}
template<class R, class T, class... A> std::string type_name( tn_identity<R(T::*)(A...) volatile>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " volatile", ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
}
template<class R, class T, class... A> std::string type_name( tn_identity<R(T::*)(A...) const volatile>, std::string const& suffix )
{
return function_type_name( tn_identity<R(A...)>(), " const volatile", ' ' + type_name( tn_identity<T>(), "" ) + "::*" + suffix );
}
#endif
// nullptr_t
#if !defined(BOOST_NO_CXX11_NULLPTR)
inline std::string type_name( tn_identity<std::nullptr_t>, std::string const& suffix )
{
return "std::nullptr_t" + suffix;
}
#endif
// strings
template<template<class Ch, class Tr, class A> class L, class Ch> std::string type_name( tn_identity< L<Ch, std::char_traits<Ch>, std::allocator<Ch> > >, std::string const& suffix )
{
std::string tn = sequence_template_name< L<Ch, std::char_traits<Ch>, std::allocator<Ch> > >();
return tn + '<' + type_name( tn_identity<Ch>(), "" ) + '>' + suffix;
}
inline std::string type_name( tn_identity<std::string>, std::string const& suffix )
{
return "std::string" + suffix;
}
inline std::string type_name( tn_identity<std::wstring>, std::string const& suffix )
{
return "std::wstring" + suffix;
}
#if !defined(BOOST_NO_CXX11_CHAR16_T)
inline std::string type_name( tn_identity<std::u16string>, std::string const& suffix )
{
return "std::u16string" + suffix;
}
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
inline std::string type_name( tn_identity<std::u32string>, std::string const& suffix )
{
return "std::u32string" + suffix;
}
#endif
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
inline std::string type_name( tn_identity<std::basic_string<char8_t>>, std::string const& suffix )
{
return "std::u8string" + suffix;
}
#endif
// string views (et al)
template<template<class Ch, class Tr> class L, class Ch> std::string type_name( tn_identity< L<Ch, std::char_traits<Ch> > >, std::string const& suffix )
{
std::string tn = sequence_template_name< L<Ch, std::char_traits<Ch> > >();
return tn + '<' + type_name( tn_identity<Ch>(), "" ) + '>' + suffix;
}
// needed for libstdc++
inline std::string type_name( tn_identity<std::ostream>, std::string const& suffix )
{
return "std::ostream" + suffix;
}
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
inline std::string type_name( tn_identity<std::string_view>, std::string const& suffix )
{
return "std::string_view" + suffix;
}
inline std::string type_name( tn_identity<std::wstring_view>, std::string const& suffix )
{
return "std::wstring_view" + suffix;
}
#if !defined(BOOST_NO_CXX11_CHAR16_T)
inline std::string type_name( tn_identity<std::u16string_view>, std::string const& suffix )
{
return "std::u16string_view" + suffix;
}
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
inline std::string type_name( tn_identity<std::u32string_view>, std::string const& suffix )
{
return "std::u32string_view" + suffix;
}
#endif
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
inline std::string type_name( tn_identity<std::basic_string_view<char8_t>>, std::string const& suffix )
{
return "std::u8string_view" + suffix;
}
#endif
#endif
// class templates
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class...> class L, class... T> std::string type_name( tn_identity< L<T...> >, std::string const& suffix )
{
std::string tn = class_template_name< L<T...> >();
std::string st = tn_add_each<T...>();
return tn + '<' + st + '>' + suffix;
}
#else
template<template<class T1> class L, class T1> std::string type_name( tn_identity< L<T1> >, std::string const& suffix )
{
std::string tn = class_template_name< L<T1> >();
return tn + '<' + type_name( tn_identity<T1>(), "" ) + '>' + suffix;
}
template<template<class T1, class T2> class L, class T1, class T2> std::string type_name( tn_identity< L<T1, T2> >, std::string const& suffix )
{
std::string tn = class_template_name< L<T1, T2> >();
return tn + '<' + type_name( tn_identity<T1>(), "" ) + ", " + type_name( tn_identity<T2>(), "" ) + '>' + suffix;
}
#endif
// sequence containers
template<template<class T, class A> class L, class T> std::string type_name( tn_identity< L<T, std::allocator<T> > >, std::string const& suffix )
{
std::string tn = sequence_template_name< L<T, std::allocator<T> > >();
return tn + '<' + type_name( tn_identity<T>(), "" ) + '>' + suffix;
}
// set
template<template<class T, class Pr, class A> class L, class T> std::string type_name( tn_identity< L<T, std::less<T>, std::allocator<T> > >, std::string const& suffix )
{
std::string tn = set_template_name< L<T, std::less<T>, std::allocator<T> > >();
return tn + '<' + type_name( tn_identity<T>(), "" ) + '>' + suffix;
}
// map
template<template<class T, class U, class Pr, class A> class L, class T, class U> std::string type_name( tn_identity< L<T, U, std::less<T>, std::allocator<std::pair<T const, U> > > >, std::string const& suffix )
{
std::string tn = map_template_name< L<T, U, std::less<T>, std::allocator<std::pair<T const, U> > > >();
return tn + '<' + type_name( tn_identity<T>(), "" ) + ", " + type_name( tn_identity<U>(), "" ) + '>' + suffix;
}
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
// unordered_set
template<template<class T, class H, class Eq, class A> class L, class T> std::string type_name( tn_identity< L<T, std::hash<T>, std::equal_to<T>, std::allocator<T> > >, std::string const& suffix )
{
std::string tn = set_template_name< L<T, std::hash<T>, std::equal_to<T>, std::allocator<T> > >();
return tn + '<' + type_name( tn_identity<T>(), "" ) + '>' + suffix;
}
// unordered_map
template<template<class T, class U, class H, class Eq, class A> class L, class T, class U> std::string type_name( tn_identity< L<T, U, std::hash<T>, std::equal_to<T>, std::allocator<std::pair<T const, U> > > >, std::string const& suffix )
{
std::string tn = map_template_name< L<T, U, std::hash<T>, std::equal_to<T>, std::allocator<std::pair<T const, U> > > >();
return tn + '<' + type_name( tn_identity<T>(), "" ) + ", " + type_name( tn_identity<U>(), "" ) + '>' + suffix;
}
#endif
// array
template<template<class T, std::size_t N> class L, class T, std::size_t N> std::string type_name( tn_identity< L<T, N> >, std::string const& suffix )
{
std::string tn = array_template_name< L<T, N> >();
return tn + '<' + type_name( tn_identity<T>(), "" ) + ", " + tn_to_string( N ) + '>' + suffix;
}
} // namespace detail
template<class T> std::string type_name()
{
return core::detail::type_name( core::detail::tn_identity<T>(), "" );
}
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_TYPE_NAME_HPP_INCLUDED

View File

@@ -26,6 +26,7 @@
#pragma once
#endif
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411)
#if defined(__APPLE__)
#include <Availability.h>
// Apple systems only support std::uncaught_exceptions starting with specific versions:
@@ -34,16 +35,15 @@
// - tvOS >= 10.0
// - watchOS >= 3.0
// https://github.com/boostorg/core/issues/80
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) && \
( \
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) \
)
#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#endif
#else
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#endif // defined(__APPLE__)
// Visual Studio 14.0 supports N4152 std::uncaught_exceptions() but doesn't define __cpp_lib_uncaught_exceptions
#elif (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
(defined(_MSC_VER) && _MSC_VER >= 1900)
#elif (defined(_MSC_VER) && _MSC_VER >= 1900)
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
#endif

View File

@@ -96,7 +96,9 @@ run lightweight_test_test4.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test5.cpp
: : : $(pedantic-errors)
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare
;
run lightweight_test_test6.cpp
: : : $(pedantic-errors) ;
@@ -230,6 +232,7 @@ run no_exceptions_support_test.cpp ;
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;
run cmath_test.cpp ;
run cmath_test.cpp : : : <define>BOOST_CORE_USE_GENERIC_CMATH <toolset>msvc-8.0:<build>no : cmath_test_generic ;
run bit_cast_test.cpp ;
run bit_rotate_test.cpp ;
@@ -242,5 +245,7 @@ run bit_ceil_test.cpp ;
run bit_popcount_test.cpp ;
run bit_endian_test.cpp ;
run type_name_test.cpp ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View File

@@ -6,6 +6,8 @@
#include <boost/core/cmath.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <limits>
#include <cfloat>
@@ -63,10 +65,18 @@ template<class T> void test_negative_zero( T x )
BOOST_TEST_EQ( boost::core::fpclassify( x ), boost::core::fp_zero );
#if defined(BOOST_CORE_USE_GENERIC_CMATH) && BOOST_WORKAROUND(BOOST_GCC, < 40700)
// g++ 4.4, 4.6 fail these tests with optimizations on
#else
BOOST_TEST( boost::core::signbit( x ) );
BOOST_TEST_EQ( boost::core::copysign( T(+2), x ), T(-2) );
BOOST_TEST_EQ( boost::core::copysign( T(-2), x ), T(-2) );
#endif
}
template<class T> void test_positive_infinity( T x )

357
test/type_name_test.cpp Normal file
View File

@@ -0,0 +1,357 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/type_name.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <cstddef>
#include <iosfwd>
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
# include <unordered_set>
#endif
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP)
# include <unordered_map>
#endif
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
# include <array>
#endif
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
//
#define TEST(...) BOOST_TEST_EQ((boost::core::type_name<__VA_ARGS__>()), std::string(#__VA_ARGS__))
struct A
{
};
class B
{
};
template<class T1, class T2> struct X
{
};
enum E1
{
e1
};
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
enum class E2
{
e2
};
#endif
struct Ch
{
};
int main()
{
TEST(signed char);
TEST(unsigned char);
TEST(short);
TEST(unsigned short);
TEST(int);
TEST(unsigned);
TEST(long);
TEST(unsigned long);
TEST(long long);
TEST(unsigned long long);
TEST(char);
TEST(wchar_t);
#if !defined(BOOST_NO_CXX11_CHAR16_T)
TEST(char16_t);
#endif
#if !defined(BOOST_NO_CXX11_CHAR16_T)
TEST(char32_t);
#endif
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
TEST(char8_t);
#endif
#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
TEST(std::byte);
#endif
TEST(bool);
TEST(float);
TEST(double);
TEST(long double);
TEST(void);
TEST(void const);
TEST(void volatile);
TEST(void const volatile);
TEST(A);
TEST(B);
TEST(E1);
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
TEST(E2);
#endif
TEST(A const);
TEST(A volatile);
TEST(A const volatile);
TEST(B&);
TEST(B const&);
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
TEST(B&&);
TEST(B const&&);
#endif
TEST(A*);
TEST(B const* volatile*);
TEST(void*);
TEST(void const* volatile*);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
TEST(void());
TEST(int(float, A, B*));
TEST(void(*)());
TEST(void(**)());
TEST(void(***)());
TEST(void(* const* const*)());
TEST(void(* const* const&)());
TEST(void(&)());
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
TEST(void(&&)());
#endif
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
TEST(void() const);
TEST(void() volatile);
TEST(void() const volatile);
#endif
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
TEST(void() &);
TEST(void() const &);
TEST(void() volatile &);
TEST(void() const volatile &);
TEST(void() &&);
TEST(void() const &&);
TEST(void() volatile &&);
TEST(void() const volatile &&);
#endif
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
TEST(void() noexcept);
TEST(void() const noexcept);
TEST(void() volatile noexcept);
TEST(void() const volatile noexcept);
TEST(void() & noexcept);
TEST(void() const & noexcept);
TEST(void() volatile & noexcept);
TEST(void() const volatile & noexcept);
TEST(void() && noexcept);
TEST(void() const && noexcept);
TEST(void() volatile && noexcept);
TEST(void() const volatile && noexcept);
#endif
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
TEST(A[]);
TEST(A const[]);
TEST(A volatile[]);
TEST(A const volatile[]);
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1500
TEST(A(&)[]);
#endif
TEST(A const(***)[]);
TEST(B[1]);
TEST(B const[1]);
TEST(B volatile[1]);
TEST(B const volatile[1]);
TEST(B(&)[1]);
TEST(B const(***)[1]);
TEST(A[][2][3]);
TEST(A const[][2][3]);
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1500
TEST(A(&)[][2][3]);
#endif
TEST(A const(***)[][2][3]);
TEST(B[1][2][3]);
TEST(B const volatile[1][2][3]);
TEST(B(&)[1][2][3]);
TEST(B const volatile(***)[1][2][3]);
TEST(int A::*);
TEST(int const B::*);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
TEST(void(A::*)());
TEST(void(A::*)() const);
TEST(void(A::*)() volatile);
TEST(void(A::*)() const volatile);
#endif
#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
TEST(void(A::*)() &);
TEST(void(A::*)() const &&);
#endif
#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED )
TEST(void(A::*)() volatile & noexcept);
TEST(void(A::*)() const volatile && noexcept);
#endif
#if !defined(BOOST_NO_CXX11_NULLPTR)
TEST(std::nullptr_t);
#endif
TEST(std::pair<A, B>);
TEST(std::pair<A const*, B*> volatile&);
TEST(std::basic_string<Ch>);
TEST(std::string);
TEST(std::wstring);
#if BOOST_CXX_VERSION >= 201100L
TEST(std::u16string);
TEST(std::u32string);
#endif
#if BOOST_CXX_VERSION >= 202000L
TEST(std::u8string);
#endif
TEST(X<A, B>);
TEST(X<A const&, B&> volatile&);
TEST(std::vector<int>);
TEST(std::vector<A>);
TEST(std::vector<std::string>);
TEST(std::list<int>);
TEST(std::list<B>);
TEST(std::list<std::wstring>);
TEST(std::deque<int>);
TEST(std::deque<A>);
TEST(std::deque<std::string>);
TEST(std::set<int>);
TEST(std::set<B>);
TEST(std::set<std::string>);
TEST(std::map<int, A>);
TEST(std::map<std::string, B>);
TEST(std::map<std::wstring, std::vector<std::string> const*> const&);
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
TEST(std::unordered_set<int>);
TEST(std::unordered_set<std::string>);
#endif
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_MAP)
TEST(std::unordered_map<int, A>);
TEST(std::unordered_map<std::string, B>);
TEST(std::unordered_map<std::wstring, std::set<std::string>*>);
#endif
#if !defined(BOOST_NO_CXX11_HDR_ARRAY)
TEST(std::array<std::string, 7>);
TEST(std::array<std::wstring const*, 0> const&);
#endif
TEST(std::ostream);
TEST(std::basic_ostream<wchar_t>);
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
TEST(std::basic_string_view<Ch>);
TEST(std::string_view);
TEST(std::wstring_view);
#if BOOST_CXX_VERSION >= 201100L
TEST(std::u16string_view);
TEST(std::u32string_view);
#endif
#if BOOST_CXX_VERSION >= 202000L
TEST(std::u8string_view);
#endif
#endif
return boost::report_errors();
}