mirror of
https://github.com/boostorg/detail.git
synced 2025-06-28 13:31:05 +02:00
Compare commits
110 Commits
boost-1.64
...
develop
Author | SHA1 | Date | |
---|---|---|---|
43238b75ce | |||
8651f245fe | |||
5628638ade | |||
d3a556f694 | |||
d533b69b87 | |||
1a28d9d60f | |||
002caaa54f | |||
f7fdaf08a3 | |||
5b10a0b9b5 | |||
a54b2619f8 | |||
804767983f | |||
a8a43b4778 | |||
080df0554b | |||
9c3a0022b2 | |||
6488652b08 | |||
8a0d14a862 | |||
845567f026 | |||
b75c261492 | |||
c6dac76110 | |||
15cc27d2bd | |||
f9888ad051 | |||
00efa0a0fb | |||
c22d18ee32 | |||
0583b51d35 | |||
90d5395868 | |||
8c603a1894 | |||
fc31e65e0d | |||
c5de1e6848 | |||
ab84a1cb11 | |||
2ca25f118d | |||
399a7a65b8 | |||
3986d6b7e6 | |||
b9f29ff43a | |||
3ec1c642f0 | |||
87489a4346 | |||
db4c8248c0 | |||
cc32906071 | |||
a01fe6d57b | |||
131208d8cc | |||
99fc546b78 | |||
5d285a2d5a | |||
d3da3ed070 | |||
4bb5ef3b38 | |||
e539c056f6 | |||
01c1bf1906 | |||
be1294c8a8 | |||
f26a04df65 | |||
5f456ffe33 | |||
63f2e170cb | |||
c281caa89f | |||
925c8ba02e | |||
f5bb480082 | |||
3e36eaf79e | |||
3b9267be46 | |||
52b610e32b | |||
116cc18560 | |||
8dbbfe372b | |||
d3c853eb08 | |||
fc781c8a5a | |||
7ce5543198 | |||
1e5a4ad35e | |||
313bc2a36b | |||
1b778d703b | |||
e529fca266 | |||
9439ae62d6 | |||
4c5f549c6e | |||
f86480f6eb | |||
d78dd02a90 | |||
622c7c4ee6 | |||
b29edf18cb | |||
9b95b29c59 | |||
1a9b7bccc3 | |||
83d7ee837d | |||
3fc08cca25 | |||
abfaa1443a | |||
121cbef225 | |||
be57f3c000 | |||
941fff4dc0 | |||
6172f9a30e | |||
adaa82e03e | |||
824721a753 | |||
bb0840b9c8 | |||
1631ba8134 | |||
40b75dae5f | |||
367c13fd20 | |||
ac88c3f24c | |||
d6f601b90e | |||
cf6808b26f | |||
aee87734a8 | |||
b47fccb4a4 | |||
15d8f9a59c | |||
9b2065c0ca | |||
13b49041e1 | |||
08bb964247 | |||
4da971f715 | |||
07fe4630f6 | |||
51baccb399 | |||
6e36d0d70a | |||
c0ced7e14d | |||
6adadccbde | |||
40d73a99e9 | |||
3db9d2e843 | |||
2c7b0fe600 | |||
bf772a322f | |||
4b233854aa | |||
5d2660f113 | |||
172a0a1062 | |||
ce79a887c4 | |||
782208b04d | |||
73c12230c3 |
594
.github/workflows/ci.yml
vendored
Normal file
594
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,594 @@
|
||||
# Copyright 2021-2025 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:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
concurrency:
|
||||
group: ${{format('{0}:{1}', github.repository, github.ref)}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
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.7
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-7
|
||||
- toolset: gcc-8
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- g++-9
|
||||
- toolset: gcc-10
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "11,14,17,20,23"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-11
|
||||
- toolset: gcc-12
|
||||
cxxstd: "11,14,17,20,23"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,23"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- g++-13
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- g++-14
|
||||
- toolset: gcc-15
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
install:
|
||||
- g++-15
|
||||
- name: UBSAN
|
||||
toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,23"
|
||||
ubsan: 1
|
||||
build_variant: debug
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- g++-13
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "11,14,17"
|
||||
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: "11,14,17,2a"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-8
|
||||
- g++-7
|
||||
gcc_toolchain: 7
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-12
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-13
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-14
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-15
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-16
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "11,14,17,20,23"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-17
|
||||
- g++-11
|
||||
gcc_toolchain: 11
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-18
|
||||
- g++-13
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-19
|
||||
- toolset: clang
|
||||
compiler: clang++-20
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
install:
|
||||
- clang-20
|
||||
- toolset: clang
|
||||
compiler: clang++-20
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
install:
|
||||
- clang-20
|
||||
- libc++-20-dev
|
||||
- libc++abi-20-dev
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
ubsan: 1
|
||||
build_variant: debug
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-18
|
||||
- libc++-18-dev
|
||||
- libc++abi-18-dev
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
|
||||
timeout-minutes: 15
|
||||
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
|
||||
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
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
declare -a SOURCE_KEYS SOURCES
|
||||
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
|
||||
then
|
||||
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
|
||||
fi
|
||||
if [ -n "${{join(matrix.sources, ' ')}}" ]
|
||||
then
|
||||
SOURCES=("${{join(matrix.sources, '" "')}}")
|
||||
fi
|
||||
for key in "${SOURCE_KEYS[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
echo "Adding key: $key"
|
||||
wget -O - "$key" | sudo apt-key add - && break || sleep 2
|
||||
done
|
||||
done
|
||||
if [ ${#SOURCES[@]} -gt 0 ]
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS=("-y")
|
||||
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
|
||||
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS+=("-n")
|
||||
fi
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
|
||||
for source in "${SOURCES[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
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")
|
||||
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
|
||||
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
|
||||
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
|
||||
mkdir -p snapshot
|
||||
cd snapshot
|
||||
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
|
||||
then
|
||||
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
cd ..
|
||||
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
|
||||
cd boost-root
|
||||
mkdir -p libs
|
||||
rm -rf "libs/$LIBRARY"
|
||||
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
|
||||
rm -rf "../snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
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_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[@]}"
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "11,14,17,20,23"
|
||||
addrmd: 64
|
||||
os: windows-2022
|
||||
|
||||
timeout-minutes: 15
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
mkdir snapshot
|
||||
cd snapshot
|
||||
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
|
||||
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
|
||||
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
|
||||
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
|
||||
dir
|
||||
exit /b 1
|
||||
)
|
||||
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
if not exist "libs\" mkdir libs
|
||||
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
|
||||
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd boost-root
|
||||
set BUILD_VARIANT=${{matrix.build_variant}}
|
||||
if "%BUILD_VARIANT%" == "" set BUILD_VARIANT=%DEFAULT_BUILD_VARIANT%
|
||||
b2 -j %NUMBER_OF_PROCESSORS% toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=%BUILD_VARIANT% embed-manifest-via=linker libs/%LIBRARY%/test
|
22
CMakeLists.txt
Normal file
22
CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Copyright 2018 Andrey Semashev
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
|
||||
project(boost_detail VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_detail INTERFACE)
|
||||
add_library(Boost::detail ALIAS boost_detail)
|
||||
|
||||
target_include_directories(boost_detail INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_detail
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::preprocessor
|
||||
Boost::static_assert
|
||||
Boost::type_traits
|
||||
)
|
88
appveyor.yml
Normal file
88
appveyor.yml
Normal file
@ -0,0 +1,88 @@
|
||||
# Copyright 2025 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)
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- TOOLSET: msvc-12.0
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
- TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17,20,latest
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: msvc-14.3
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17,20,latest
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||
- TOOLSET: clang-win
|
||||
ADDRMD: 32
|
||||
CXXSTD: 14,17,latest
|
||||
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 11,14,17
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 11,14,17,2a
|
||||
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
|
||||
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% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init tools/build
|
||||
- git submodule init tools/boostdep
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/config
|
||||
- git submodule update --jobs %GIT_FETCH_JOBS%
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\detail
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" detail
|
||||
- cmd /c bootstrap
|
||||
- b2 -d0 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%ENV_SCRIPT%" == "" call "%ENV_SCRIPT%"
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- if not "%THREADING%" == "" set THREADING=threading=%THREADING%
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/detail/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %THREADING%
|
27
build.jam
Normal file
27
build.jam
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/config//boost_config
|
||||
/boost/core//boost_core
|
||||
/boost/preprocessor//boost_preprocessor
|
||||
/boost/static_assert//boost_static_assert
|
||||
/boost/type_traits//boost_type_traits ;
|
||||
|
||||
project /boost/detail
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_detail : : : : <library>$(boost_dependencies) ]
|
||||
[ alias all : boost_detail test ]
|
||||
;
|
||||
|
||||
call-if : boost-library detail
|
||||
;
|
||||
|
@ -23,7 +23,7 @@ boostbook standalone
|
||||
<xsl:param>generate.section.toc.level=3
|
||||
<xsl:param>chunk.section.depth=2
|
||||
#<xsl:param>chunk.first.sections=1
|
||||
|
||||
|
||||
<dependency>images
|
||||
<dependency>callouts
|
||||
<dependency>css
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
<20> Copyright Beman Dawes, 2007
|
||||
Copyright (c) 2007 Beman Dawes
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
See www.boost.org/LICENSE_1_0.txt
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "boost/detail/templated_streams.hpp"
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/type_traits/integral_constant.hpp"
|
||||
#include "boost/type_traits/is_empty.hpp"
|
||||
#include "boost/type_traits/is_pod.hpp"
|
||||
#include "boost/type_traits/is_stateless.hpp"
|
||||
@ -36,19 +36,19 @@ struct blank
|
||||
|
||||
template <>
|
||||
struct is_pod< blank >
|
||||
: mpl::true_
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_empty< blank >
|
||||
: mpl::true_
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_stateless< blank >
|
||||
: mpl::true_
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/detail/select_type.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
@ -44,7 +44,7 @@ public:
|
||||
|
||||
typedef Type value_type;
|
||||
|
||||
partial_std_allocator_wrapper(){};
|
||||
partial_std_allocator_wrapper(){}
|
||||
|
||||
template<typename Other>
|
||||
partial_std_allocator_wrapper(const partial_std_allocator_wrapper<Other>&){}
|
||||
@ -52,7 +52,7 @@ public:
|
||||
partial_std_allocator_wrapper(const std::allocator<Type>& x):
|
||||
std::allocator<Type>(x)
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(BOOST_DINKUMWARE_STDLIB)
|
||||
/* Dinkumware guys didn't provide a means to call allocate() without
|
||||
@ -121,8 +121,13 @@ struct rebinder
|
||||
template<typename Type>
|
||||
struct result
|
||||
{
|
||||
typedef typename Allocator::BOOST_NESTED_TEMPLATE
|
||||
#ifdef BOOST_NO_CXX11_ALLOCATOR
|
||||
typedef typename Allocator::BOOST_NESTED_TEMPLATE
|
||||
rebind<Type>::other other;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Allocator>::BOOST_NESTED_TEMPLATE
|
||||
rebind_alloc<Type> other;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
@ -137,11 +142,12 @@ struct compliant_allocator_rebind_to
|
||||
|
||||
template<typename Allocator,typename Type>
|
||||
struct rebind_to:
|
||||
mpl::eval_if_c<
|
||||
is_partial_std_allocator<Allocator>::value,
|
||||
boost::detail::if_true<
|
||||
is_partial_std_allocator<Allocator>::value
|
||||
>::template then<
|
||||
partial_std_allocator_rebind_to<Allocator,Type>,
|
||||
compliant_allocator_rebind_to<Allocator,Type>
|
||||
>
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
@ -159,7 +165,7 @@ void construct(void* p,const Type& t)
|
||||
*/
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
template<typename Type>
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2000 David Abrahams.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// Copyright (c) 2000 David Abrahams.
|
||||
// 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)
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1994
|
||||
// Hewlett-Packard Company
|
||||
//
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
@ -13,10 +13,10 @@
|
||||
// in supporting documentation. Hewlett-Packard Company makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1996
|
||||
// Silicon Graphics Computer Systems, Inc.
|
||||
//
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
@ -24,22 +24,22 @@
|
||||
// in supporting documentation. Silicon Graphics makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
//
|
||||
#ifndef BINARY_SEARCH_DWA_122600_H_
|
||||
# define BINARY_SEARCH_DWA_122600_H_
|
||||
|
||||
# include <boost/detail/iterator.hpp>
|
||||
# include <utility>
|
||||
# include <iterator>
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
template <class ForwardIter, class Tp>
|
||||
ForwardIter lower_bound(ForwardIter first, ForwardIter last,
|
||||
const Tp& val)
|
||||
const Tp& val)
|
||||
{
|
||||
typedef detail::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = boost::detail::distance(first, last);
|
||||
typedef std::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = std::distance(first, last);
|
||||
typename traits::difference_type half;
|
||||
ForwardIter middle;
|
||||
|
||||
@ -62,9 +62,9 @@ template <class ForwardIter, class Tp, class Compare>
|
||||
ForwardIter lower_bound(ForwardIter first, ForwardIter last,
|
||||
const Tp& val, Compare comp)
|
||||
{
|
||||
typedef detail::iterator_traits<ForwardIter> traits;
|
||||
typedef std::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = boost::detail::distance(first, last);
|
||||
typename traits::difference_type len = std::distance(first, last);
|
||||
typename traits::difference_type half;
|
||||
ForwardIter middle;
|
||||
|
||||
@ -87,9 +87,9 @@ template <class ForwardIter, class Tp>
|
||||
ForwardIter upper_bound(ForwardIter first, ForwardIter last,
|
||||
const Tp& val)
|
||||
{
|
||||
typedef detail::iterator_traits<ForwardIter> traits;
|
||||
typedef std::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = boost::detail::distance(first, last);
|
||||
typename traits::difference_type len = std::distance(first, last);
|
||||
typename traits::difference_type half;
|
||||
ForwardIter middle;
|
||||
|
||||
@ -112,9 +112,9 @@ template <class ForwardIter, class Tp, class Compare>
|
||||
ForwardIter upper_bound(ForwardIter first, ForwardIter last,
|
||||
const Tp& val, Compare comp)
|
||||
{
|
||||
typedef detail::iterator_traits<ForwardIter> traits;
|
||||
typedef std::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = boost::detail::distance(first, last);
|
||||
typename traits::difference_type len = std::distance(first, last);
|
||||
typename traits::difference_type half;
|
||||
ForwardIter middle;
|
||||
|
||||
@ -137,9 +137,9 @@ template <class ForwardIter, class Tp>
|
||||
std::pair<ForwardIter, ForwardIter>
|
||||
equal_range(ForwardIter first, ForwardIter last, const Tp& val)
|
||||
{
|
||||
typedef detail::iterator_traits<ForwardIter> traits;
|
||||
typedef std::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = boost::detail::distance(first, last);
|
||||
typename traits::difference_type len = std::distance(first, last);
|
||||
typename traits::difference_type half;
|
||||
ForwardIter middle, left, right;
|
||||
|
||||
@ -169,9 +169,9 @@ std::pair<ForwardIter, ForwardIter>
|
||||
equal_range(ForwardIter first, ForwardIter last, const Tp& val,
|
||||
Compare comp)
|
||||
{
|
||||
typedef detail::iterator_traits<ForwardIter> traits;
|
||||
typedef std::iterator_traits<ForwardIter> traits;
|
||||
|
||||
typename traits::difference_type len = boost::detail::distance(first, last);
|
||||
typename traits::difference_type len = std::distance(first, last);
|
||||
typename traits::difference_type half;
|
||||
ForwardIter middle, left, right;
|
||||
|
||||
@ -194,7 +194,7 @@ equal_range(ForwardIter first, ForwardIter last, const Tp& val,
|
||||
}
|
||||
}
|
||||
return std::pair<ForwardIter, ForwardIter>(first, first);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ForwardIter, class Tp>
|
||||
bool binary_search(ForwardIter first, ForwardIter last,
|
||||
|
@ -1,47 +1,91 @@
|
||||
// boost/detail/bitmask.hpp ------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2006
|
||||
// Copyright Andrey Semashev 2025
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// Usage: enum foo { a=1, b=2, c=4 };
|
||||
// BOOST_BITMASK( foo );
|
||||
// BOOST_BITMASK( foo )
|
||||
//
|
||||
// void f( foo arg );
|
||||
// ...
|
||||
// f( a | c );
|
||||
//
|
||||
// See [bitmask.types] in the C++ standard for the formal specification
|
||||
|
||||
#ifndef BOOST_BITMASK_HPP
|
||||
#define BOOST_BITMASK_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#define BOOST_BITMASK(Bitmask) \
|
||||
\
|
||||
inline Bitmask operator| (Bitmask x , Bitmask y ) \
|
||||
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
|
||||
| static_cast<boost::int_least32_t>(y)); } \
|
||||
\
|
||||
inline Bitmask operator& (Bitmask x , Bitmask y ) \
|
||||
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
|
||||
& static_cast<boost::int_least32_t>(y)); } \
|
||||
\
|
||||
inline Bitmask operator^ (Bitmask x , Bitmask y ) \
|
||||
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
|
||||
^ static_cast<boost::int_least32_t>(y)); } \
|
||||
\
|
||||
inline Bitmask operator~ (Bitmask x ) \
|
||||
{ return static_cast<Bitmask>(~static_cast<boost::int_least32_t>(x)); } \
|
||||
\
|
||||
inline Bitmask & operator&=(Bitmask & x , Bitmask y) \
|
||||
{ x = x & y ; return x ; } \
|
||||
\
|
||||
inline Bitmask & operator|=(Bitmask & x , Bitmask y) \
|
||||
{ x = x | y ; return x ; } \
|
||||
\
|
||||
inline Bitmask & operator^=(Bitmask & x , Bitmask y) \
|
||||
{ x = x ^ y ; return x ; }
|
||||
#if defined(__has_builtin)
|
||||
#if __has_builtin(__underlying_type)
|
||||
#define BOOST_BITMASK_DETAIL_UNDERLYING_TYPE(enum_type) __underlying_type(enum_type)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_BITMASK_DETAIL_UNDERLYING_TYPE) && \
|
||||
((defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700)) || (defined(_MSC_VER) && (_MSC_VER >= 1700)))
|
||||
#define BOOST_BITMASK_DETAIL_UNDERLYING_TYPE(enum_type) __underlying_type(enum_type)
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_BITMASK_DETAIL_UNDERLYING_TYPE)
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace bitmask {
|
||||
|
||||
#if defined(BOOST_BITMASK_DETAIL_UNDERLYING_TYPE)
|
||||
template< typename Enum >
|
||||
using underlying_type_t = BOOST_BITMASK_DETAIL_UNDERLYING_TYPE(Enum);
|
||||
#elif (BOOST_CXX_VERSION >= 201402)
|
||||
using std::underlying_type_t;
|
||||
#else
|
||||
template< typename Enum >
|
||||
using underlying_type_t = typename std::underlying_type< Enum >::type;
|
||||
#endif
|
||||
|
||||
}}}
|
||||
|
||||
#undef BOOST_BITMASK_DETAIL_UNDERLYING_TYPE
|
||||
|
||||
#define BOOST_BITMASK(Bitmask) \
|
||||
\
|
||||
inline BOOST_CONSTEXPR Bitmask operator| (Bitmask x, Bitmask y) BOOST_NOEXCEPT \
|
||||
{ return static_cast< Bitmask >(static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x) \
|
||||
| static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(y)); } \
|
||||
\
|
||||
inline BOOST_CONSTEXPR Bitmask operator& (Bitmask x, Bitmask y) BOOST_NOEXCEPT \
|
||||
{ return static_cast< Bitmask >(static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x) \
|
||||
& static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(y)); } \
|
||||
\
|
||||
inline BOOST_CONSTEXPR Bitmask operator^ (Bitmask x, Bitmask y) BOOST_NOEXCEPT \
|
||||
{ return static_cast< Bitmask >(static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x) \
|
||||
^ static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(y)); } \
|
||||
\
|
||||
inline BOOST_CONSTEXPR Bitmask operator~ (Bitmask x) BOOST_NOEXCEPT \
|
||||
{ return static_cast< Bitmask >(~static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x)); } \
|
||||
\
|
||||
inline BOOST_CXX14_CONSTEXPR Bitmask& operator&=(Bitmask& x, Bitmask y) BOOST_NOEXCEPT \
|
||||
{ x = x & y; return x; } \
|
||||
\
|
||||
inline BOOST_CXX14_CONSTEXPR Bitmask& operator|=(Bitmask& x, Bitmask y) BOOST_NOEXCEPT \
|
||||
{ x = x | y; return x; } \
|
||||
\
|
||||
inline BOOST_CXX14_CONSTEXPR Bitmask& operator^=(Bitmask& x, Bitmask y) BOOST_NOEXCEPT \
|
||||
{ x = x ^ y; return x; } \
|
||||
\
|
||||
/* Boost extensions to [bitmask.types] */ \
|
||||
\
|
||||
inline BOOST_CONSTEXPR bool operator!(Bitmask x) BOOST_NOEXCEPT \
|
||||
{ return !static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x); } \
|
||||
\
|
||||
BOOST_DEPRECATED("bitmask_set(enum) is deprecated, use !!enum or comparison operators instead") \
|
||||
inline BOOST_CONSTEXPR bool bitmask_set(Bitmask x) BOOST_NOEXCEPT \
|
||||
{ return !!x; }
|
||||
|
||||
#endif // BOOST_BITMASK_HPP
|
||||
|
||||
|
@ -20,13 +20,14 @@
|
||||
// to reduce coupling to other boost libraries.
|
||||
#include <string> // for string
|
||||
#include <new> // for bad_alloc
|
||||
#include <ostream> // for ostream
|
||||
#include <typeinfo> // for bad_cast, bad_typeid
|
||||
#include <exception> // for exception, bad_exception
|
||||
#include <stdexcept> // for std exception hierarchy
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdlib.hpp> // for exit codes
|
||||
#include <ostream> // for ostream
|
||||
|
||||
# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x0551)
|
||||
# if defined(BOOST_BORLANDC) && (__BORLANDC__ <= 0x0551)
|
||||
# define BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT
|
||||
# endif
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef INDIRECT_TRAITS_DWA2002131_HPP
|
||||
# define INDIRECT_TRAITS_DWA2002131_HPP
|
||||
# include <boost/type_traits/integral_constant.hpp>
|
||||
# include <boost/type_traits/is_function.hpp>
|
||||
# include <boost/type_traits/is_reference.hpp>
|
||||
# include <boost/type_traits/is_pointer.hpp>
|
||||
@ -17,13 +18,7 @@
|
||||
# include <boost/type_traits/remove_pointer.hpp>
|
||||
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
# include <boost/mpl/eval_if.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/mpl/and.hpp>
|
||||
# include <boost/mpl/not.hpp>
|
||||
# include <boost/mpl/aux_/lambda_support.hpp>
|
||||
# include <boost/detail/select_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace detail {
|
||||
@ -31,24 +26,24 @@ namespace boost { namespace detail {
|
||||
namespace indirect_traits {
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_const : mpl::false_
|
||||
struct is_reference_to_const : boost::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_const<T const&> : mpl::true_
|
||||
struct is_reference_to_const<T const&> : boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
# if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
|
||||
template<class T>
|
||||
struct is_reference_to_const<T const volatile&> : mpl::true_
|
||||
struct is_reference_to_const<T const volatile&> : boost::true_type
|
||||
{
|
||||
};
|
||||
# endif
|
||||
# endif
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_function : mpl::false_
|
||||
struct is_reference_to_function : boost::false_type
|
||||
{
|
||||
};
|
||||
|
||||
@ -58,7 +53,7 @@ struct is_reference_to_function<T&> : is_function<T>
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_pointer_to_function : mpl::false_
|
||||
struct is_pointer_to_function : boost::false_type
|
||||
{
|
||||
};
|
||||
|
||||
@ -70,7 +65,7 @@ struct is_pointer_to_function<T*> : is_function<T>
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_member_function_pointer_impl : mpl::false_
|
||||
struct is_reference_to_member_function_pointer_impl : boost::false_type
|
||||
{
|
||||
};
|
||||
|
||||
@ -85,18 +80,17 @@ template <class T>
|
||||
struct is_reference_to_member_function_pointer
|
||||
: is_reference_to_member_function_pointer_impl<T>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_function_pointer_aux
|
||||
: mpl::and_<
|
||||
is_reference<T>
|
||||
, is_pointer_to_function<
|
||||
: boost::integral_constant<bool,
|
||||
is_reference<T>::value &&
|
||||
is_pointer_to_function<
|
||||
typename remove_cv<
|
||||
typename remove_reference<T>::type
|
||||
>::type
|
||||
>
|
||||
>::value
|
||||
>
|
||||
{
|
||||
// There's no such thing as a pointer-to-cv-function, so we don't need specializations for those
|
||||
@ -104,94 +98,91 @@ struct is_reference_to_function_pointer_aux
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_function_pointer
|
||||
: mpl::if_<
|
||||
is_reference_to_function<T>
|
||||
, mpl::false_
|
||||
: boost::detail::if_true<
|
||||
is_reference_to_function<T>::value
|
||||
>::template then<
|
||||
boost::false_type
|
||||
, is_reference_to_function_pointer_aux<T>
|
||||
>::type
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_non_const
|
||||
: mpl::and_<
|
||||
is_reference<T>
|
||||
, mpl::not_<
|
||||
is_reference_to_const<T>
|
||||
>
|
||||
: boost::integral_constant<bool,
|
||||
is_reference<T>::value &&
|
||||
!is_reference_to_const<T>::value
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_volatile : mpl::false_
|
||||
struct is_reference_to_volatile : boost::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_volatile<T volatile&> : mpl::true_
|
||||
struct is_reference_to_volatile<T volatile&> : boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
# if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
|
||||
template <class T>
|
||||
struct is_reference_to_volatile<T const volatile&> : mpl::true_
|
||||
struct is_reference_to_volatile<T const volatile&> : boost::true_type
|
||||
{
|
||||
};
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_pointer : mpl::false_
|
||||
struct is_reference_to_pointer : boost::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_pointer<T*&> : mpl::true_
|
||||
struct is_reference_to_pointer<T*&> : boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_pointer<T* const&> : mpl::true_
|
||||
struct is_reference_to_pointer<T* const&> : boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_pointer<T* volatile&> : mpl::true_
|
||||
struct is_reference_to_pointer<T* volatile&> : boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_pointer<T* const volatile&> : mpl::true_
|
||||
struct is_reference_to_pointer<T* const volatile&> : boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_reference_to_class
|
||||
: mpl::and_<
|
||||
is_reference<T>
|
||||
, is_class<
|
||||
: boost::integral_constant<bool,
|
||||
is_reference<T>::value &&
|
||||
is_class<
|
||||
typename remove_cv<
|
||||
typename remove_reference<T>::type
|
||||
>::type
|
||||
>
|
||||
>::value
|
||||
>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct is_pointer_to_class
|
||||
: mpl::and_<
|
||||
is_pointer<T>
|
||||
, is_class<
|
||||
: boost::integral_constant<bool,
|
||||
is_pointer<T>::value &&
|
||||
is_class<
|
||||
typename remove_cv<
|
||||
typename remove_pointer<T>::type
|
||||
>::type
|
||||
>
|
||||
>::value
|
||||
>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class,(T))
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
# include <boost/type_traits/integral_constant.hpp>
|
||||
# include <boost/type_traits/remove_cv.hpp>
|
||||
# include <boost/mpl/aux_/lambda_support.hpp>
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace detail {
|
||||
@ -106,14 +104,12 @@ template<typename T>
|
||||
struct is_incrementable :
|
||||
public boost::integral_constant<bool, boost::detail::is_incrementable_::impl<T>::value>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T))
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_postfix_incrementable :
|
||||
public boost::integral_constant<bool, boost::detail::is_incrementable_::postfix_impl<T>::value>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T))
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@ -8,8 +8,7 @@
|
||||
#ifndef BOOST_DETAIL_SORTED_HPP
|
||||
#define BOOST_DETAIL_SORTED_HPP
|
||||
|
||||
#include <boost/detail/iterator.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#include <functional>
|
||||
|
||||
namespace boost {
|
||||
@ -31,23 +30,23 @@ inline Iterator is_sorted_until (Iterator first, Iterator last, Comp c) {
|
||||
|
||||
template<class Iterator>
|
||||
inline Iterator is_sorted_until (Iterator first, Iterator last) {
|
||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type
|
||||
typedef typename std::iterator_traits<Iterator>::value_type
|
||||
value_type;
|
||||
|
||||
typedef std::less<value_type> c;
|
||||
typedef std::less<value_type> c;
|
||||
|
||||
return ::boost::detail::is_sorted_until(first, last, c());
|
||||
return ::boost::detail::is_sorted_until(first, last, c());
|
||||
}
|
||||
|
||||
template<class Iterator, class Comp>
|
||||
inline bool is_sorted (Iterator first, Iterator last, Comp c) {
|
||||
return ::boost::detail::is_sorted_until(first, last, c) == last;
|
||||
}
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
inline bool is_sorted (Iterator first, Iterator last) {
|
||||
return ::boost::detail::is_sorted_until(first, last) == last;
|
||||
}
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // boost
|
||||
|
@ -5,13 +5,13 @@
|
||||
# define BOOST_DETAIL_IS_XXX_DWA20051011_HPP
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/type_traits/integral_constant.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
|
||||
|
||||
# define BOOST_DETAIL_IS_XXX_DEF(name, qualified_name, nargs) \
|
||||
template <class T> \
|
||||
struct is_##name : mpl::false_ \
|
||||
struct is_##name : boost::false_type \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
@ -19,7 +19,7 @@ template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class T) > \
|
||||
struct is_##name< \
|
||||
qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) > \
|
||||
> \
|
||||
: mpl::true_ \
|
||||
: boost::true_type \
|
||||
{ \
|
||||
};
|
||||
|
||||
|
@ -53,4 +53,4 @@ int cpp_main(int argc, char* argv[])
|
||||
std::cout << std::endl;
|
||||
|
||||
return test_main(argc, argv);
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,10 @@
|
||||
#ifndef BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
|
||||
#define BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/conversion_traits.hpp>
|
||||
#include <boost/type_traits/composite_traits.hpp> // for is_reference
|
||||
#if defined(__BORLANDC__)
|
||||
#if defined(BOOST_BORLANDC)
|
||||
#include <boost/type_traits/ice.hpp>
|
||||
#endif
|
||||
|
||||
@ -57,7 +58,7 @@ namespace boost {
|
||||
};
|
||||
};
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#if defined(BOOST_BORLANDC)
|
||||
template <class UseDefault>
|
||||
struct choose_arg_or_default { typedef choose_arg type; };
|
||||
template <>
|
||||
@ -75,7 +76,7 @@ namespace boost {
|
||||
|
||||
template <class Arg, class DefaultGen, class Base, class Traits>
|
||||
class resolve_default {
|
||||
#if defined(__BORLANDC__)
|
||||
#if defined(BOOST_BORLANDC)
|
||||
typedef typename choose_arg_or_default<typename is_default<Arg>::type>::type Selector;
|
||||
#else
|
||||
// This usually works for Borland, but I'm seeing weird errors in
|
||||
|
@ -56,65 +56,39 @@
|
||||
// 21 Jan 2001 - Created (David Abrahams)
|
||||
|
||||
#ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901
|
||||
# define BOOST_NUMERIC_TRAITS_HPP_DWA20001901
|
||||
#define BOOST_NUMERIC_TRAITS_HPP_DWA20001901
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/cstdint.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/detail/select_type.hpp>
|
||||
# include <boost/limits.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
// Template class is_signed -- determine whether a numeric type is signed
|
||||
// Requires that T is constructable from the literals -1 and 0. Compile-time
|
||||
// error results if that requirement is not met (and thus signedness is not
|
||||
// likely to have meaning for that type).
|
||||
template <class Number>
|
||||
struct is_signed
|
||||
{
|
||||
#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS)
|
||||
BOOST_STATIC_CONSTANT(bool, value = (Number(-1) < Number(0)));
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<Number>::is_signed);
|
||||
#endif
|
||||
};
|
||||
|
||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
// digit_traits - compute the number of digits in a built-in integer
|
||||
// type. Needed for implementations on which numeric_limits is not specialized
|
||||
// for intmax_t (e.g. VC6).
|
||||
template <bool is_specialized> struct digit_traits_select;
|
||||
|
||||
// numeric_limits is specialized; just select that version of digits
|
||||
template <> struct digit_traits_select<true>
|
||||
// for some integer types, like __int128 in libstdc++ (gcc).
|
||||
template <class T, bool IsSpecialized = std::numeric_limits<T>::is_specialized>
|
||||
struct digit_traits
|
||||
{
|
||||
template <class T> struct traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits<T>::digits);
|
||||
};
|
||||
BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits<T>::digits);
|
||||
};
|
||||
|
||||
// numeric_limits is not specialized; compute digits from sizeof(T)
|
||||
template <> struct digit_traits_select<false>
|
||||
template <class T>
|
||||
struct digit_traits<T, false>
|
||||
{
|
||||
template <class T> struct traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, digits = (
|
||||
sizeof(T) * std::numeric_limits<unsigned char>::digits
|
||||
- (is_signed<T>::value ? 1 : 0))
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
// here's the "usable" template
|
||||
template <class T> struct digit_traits
|
||||
{
|
||||
typedef digit_traits_select<
|
||||
::std::numeric_limits<T>::is_specialized> selector;
|
||||
typedef typename selector::template traits<T> traits;
|
||||
BOOST_STATIC_CONSTANT(int, digits = traits::digits);
|
||||
BOOST_STATIC_CONSTANT(int, digits = (
|
||||
sizeof(T) * std::numeric_limits<unsigned char>::digits
|
||||
- (boost::is_signed<T>::value ? 1 : 0))
|
||||
);
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -124,44 +98,48 @@ namespace boost { namespace detail {
|
||||
template <class Integer>
|
||||
struct integer_traits
|
||||
{
|
||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
private:
|
||||
typedef Integer integer_type;
|
||||
typedef std::numeric_limits<integer_type> x;
|
||||
public:
|
||||
typedef typename
|
||||
if_true<(int(x::is_signed)
|
||||
&& (!int(x::is_bounded)
|
||||
// digits is the number of no-sign bits
|
||||
|| (int(x::digits) + 1 >= digit_traits<boost::intmax_t>::digits)))>::template then<
|
||||
typedef typename boost::conditional<
|
||||
(int(x::is_signed)
|
||||
&& (!int(x::is_bounded)
|
||||
// digits is the number of no-sign bits
|
||||
|| (int(x::digits) + 1 >= digit_traits<boost::intmax_t>::digits))),
|
||||
Integer,
|
||||
|
||||
typename if_true<(int(x::digits) + 1 < digit_traits<signed int>::digits)>::template then<
|
||||
signed int,
|
||||
|
||||
typename if_true<(int(x::digits) + 1 < digit_traits<signed long>::digits)>::template then<
|
||||
signed long,
|
||||
typename boost::conditional<
|
||||
(int(x::digits) + 1 < digit_traits<signed int>::digits),
|
||||
signed int,
|
||||
|
||||
// else
|
||||
intmax_t
|
||||
>::type>::type>::type difference_type;
|
||||
typename boost::conditional<
|
||||
(int(x::digits) + 1 < digit_traits<signed long>::digits),
|
||||
signed long,
|
||||
boost::intmax_t
|
||||
>::type
|
||||
>::type
|
||||
>::type difference_type;
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(boost::is_integral<Integer>::value);
|
||||
|
||||
typedef typename
|
||||
if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then<
|
||||
|
||||
typename if_true<(is_signed<Integer>::value)>::template then<
|
||||
Integer,
|
||||
intmax_t
|
||||
>::type,
|
||||
typedef typename boost::conditional<
|
||||
(sizeof(Integer) >= sizeof(intmax_t)),
|
||||
|
||||
typename if_true<(sizeof(Integer) < sizeof(std::ptrdiff_t))>::template then<
|
||||
boost::conditional<
|
||||
(boost::is_signed<Integer>::value),
|
||||
Integer,
|
||||
boost::intmax_t
|
||||
>,
|
||||
|
||||
boost::conditional<
|
||||
(sizeof(Integer) < sizeof(std::ptrdiff_t)),
|
||||
std::ptrdiff_t,
|
||||
intmax_t
|
||||
>::type
|
||||
>::type difference_type;
|
||||
# endif
|
||||
boost::intmax_t
|
||||
>
|
||||
>::type::type difference_type;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Right now, only supports integers, but should be expanded.
|
||||
@ -172,7 +150,7 @@ namespace boost { namespace detail {
|
||||
};
|
||||
|
||||
template <class Number>
|
||||
typename numeric_traits<Number>::difference_type numeric_distance(Number x, Number y)
|
||||
inline BOOST_CONSTEXPR typename numeric_traits<Number>::difference_type numeric_distance(Number x, Number y)
|
||||
{
|
||||
typedef typename numeric_traits<Number>::difference_type difference_type;
|
||||
return difference_type(y) - difference_type(x);
|
||||
|
@ -15,15 +15,15 @@
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
# include "boost/mpl/bool.hpp"
|
||||
# include "boost/type_traits/integral_constant.hpp"
|
||||
# include "boost/type_traits/has_nothrow_copy.hpp"
|
||||
|
||||
#include "boost/mpl/void.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct void_type {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class template reference_content
|
||||
//
|
||||
@ -71,7 +71,7 @@ public: // queries
|
||||
// Wraps with reference_content if specified type is reference.
|
||||
//
|
||||
|
||||
template <typename T = mpl::void_> struct make_reference_content;
|
||||
template <typename T = void_type> struct make_reference_content;
|
||||
|
||||
|
||||
template <typename T>
|
||||
@ -88,7 +88,7 @@ struct make_reference_content< T& >
|
||||
|
||||
|
||||
template <>
|
||||
struct make_reference_content< mpl::void_ >
|
||||
struct make_reference_content< void_type >
|
||||
{
|
||||
template <typename T>
|
||||
struct apply
|
||||
@ -96,7 +96,7 @@ struct make_reference_content< mpl::void_ >
|
||||
{
|
||||
};
|
||||
|
||||
typedef mpl::void_ type;
|
||||
typedef void_type type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@ -110,7 +110,7 @@ template <typename T>
|
||||
struct has_nothrow_copy<
|
||||
::boost::detail::reference_content< T& >
|
||||
>
|
||||
: mpl::true_
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// utf8_codecvt_facet.hpp
|
||||
|
||||
// This header defines class utf8_codecvt_facet, derived from
|
||||
// This header defines class utf8_codecvt_facet, derived from
|
||||
// std::codecvt<wchar_t, char>, which can be used to convert utf8 data in
|
||||
// files into wchar_t strings in the application.
|
||||
//
|
||||
@ -23,10 +23,10 @@
|
||||
// we want to avoid code duplication. It would be possible to create utf8
|
||||
// library, but:
|
||||
// - this requires review process first
|
||||
// - in the case, when linking the a library which uses utf8
|
||||
// - in the case, when linking the a library which uses utf8
|
||||
// (say 'program_options'), user should also link to the utf8 library.
|
||||
// This seems inconvenient, and asking a user to link to an unrevieved
|
||||
// library is strange.
|
||||
// This seems inconvenient, and asking a user to link to an unrevieved
|
||||
// library is strange.
|
||||
// Until the above points are fixed, a library which wants to use utf8 must:
|
||||
// - include this header in one of it's headers or sources
|
||||
// - include the corresponding boost/detail/utf8_codecvt_facet.ipp file in one
|
||||
@ -39,14 +39,14 @@
|
||||
// symbols.
|
||||
//
|
||||
// For example, program_options library might contain:
|
||||
// #define BOOST_UTF8_BEGIN_NAMESPACE <backslash character>
|
||||
// #define BOOST_UTF8_BEGIN_NAMESPACE <backslash character>
|
||||
// namespace boost { namespace program_options {
|
||||
// #define BOOST_UTF8_END_NAMESPACE }}
|
||||
// #define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL
|
||||
// #include <boost/detail/utf8_codecvt_facet.ipp>
|
||||
//
|
||||
// Essentially, each library will have its own copy of utf8 code, in
|
||||
// different namespaces.
|
||||
// different namespaces.
|
||||
|
||||
// Note:(Robert Ramey). I have made the following alterations in the original
|
||||
// code.
|
||||
@ -67,7 +67,7 @@
|
||||
// use two template parameters
|
||||
//
|
||||
// utf8_codecvt_facet
|
||||
// This is an implementation of a std::codecvt facet for translating
|
||||
// This is an implementation of a std::codecvt facet for translating
|
||||
// from UTF-8 externally to UCS-4. Note that this is not tied to
|
||||
// any specific types in order to allow customization on platforms
|
||||
// where wchar_t is not big enough.
|
||||
@ -110,27 +110,28 @@ BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#endif
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE utf8_codecvt_facet :
|
||||
public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
public:
|
||||
BOOST_UTF8_DECL explicit utf8_codecvt_facet(std::size_t no_locale_manage=0);
|
||||
virtual ~utf8_codecvt_facet(){}
|
||||
BOOST_UTF8_DECL explicit utf8_codecvt_facet(std::size_t no_locale_manage = 0);
|
||||
BOOST_UTF8_DECL virtual ~utf8_codecvt_facet();
|
||||
|
||||
protected:
|
||||
BOOST_UTF8_DECL virtual std::codecvt_base::result do_in(
|
||||
std::mbstate_t& state,
|
||||
std::mbstate_t& state,
|
||||
const char * from,
|
||||
const char * from_end,
|
||||
const char * from_end,
|
||||
const char * & from_next,
|
||||
wchar_t * to,
|
||||
wchar_t * to_end,
|
||||
wchar_t*& to_next
|
||||
wchar_t * to,
|
||||
wchar_t * to_end,
|
||||
wchar_t * & to_next
|
||||
) const;
|
||||
|
||||
BOOST_UTF8_DECL virtual std::codecvt_base::result do_out(
|
||||
std::mbstate_t & state,
|
||||
const wchar_t * from,
|
||||
const wchar_t * from_end,
|
||||
const wchar_t* & from_next,
|
||||
const wchar_t * & from_next,
|
||||
char * to,
|
||||
char * to_end,
|
||||
char * & to_next
|
||||
@ -140,7 +141,7 @@ protected:
|
||||
return (octet_1 < 0x80|| 0xbf< octet_1);
|
||||
}
|
||||
|
||||
bool invalid_leading_octet(unsigned char octet_1) const {
|
||||
bool invalid_leading_octet(unsigned char octet_1) const {
|
||||
return (0x7f < octet_1 && octet_1 < 0xc0) ||
|
||||
(octet_1 > 0xfd);
|
||||
}
|
||||
@ -154,7 +155,7 @@ protected:
|
||||
|
||||
// How many "continuing octets" will be needed for this word
|
||||
// == total octets - 1.
|
||||
BOOST_UTF8_DECL int get_cont_octet_out_count(wchar_t word) const ;
|
||||
BOOST_UTF8_DECL static int get_cont_octet_out_count(wchar_t word);
|
||||
|
||||
virtual bool do_always_noconv() const BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
return false;
|
||||
@ -162,7 +163,7 @@ protected:
|
||||
|
||||
// UTF-8 isn't really stateful since we rewind on partial conversions
|
||||
virtual std::codecvt_base::result do_unshift(
|
||||
std::mbstate_t&,
|
||||
std::mbstate_t &,
|
||||
char * from,
|
||||
char * /*to*/,
|
||||
char * & next
|
||||
@ -179,19 +180,21 @@ protected:
|
||||
// How many char objects can I process to get <= max_limit
|
||||
// wchar_t objects?
|
||||
BOOST_UTF8_DECL virtual int do_length(
|
||||
const std::mbstate_t &,
|
||||
std::mbstate_t &,
|
||||
const char * from,
|
||||
const char * from_end,
|
||||
const char * from_end,
|
||||
std::size_t max_limit
|
||||
) const
|
||||
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
|
||||
throw()
|
||||
#endif
|
||||
;
|
||||
|
||||
// Nonstandard override
|
||||
virtual int do_length(
|
||||
std::mbstate_t & s,
|
||||
const std::mbstate_t & s,
|
||||
const char * from,
|
||||
const char * from_end,
|
||||
const char * from_end,
|
||||
std::size_t max_limit
|
||||
) const
|
||||
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
|
||||
@ -199,12 +202,13 @@ protected:
|
||||
#endif
|
||||
{
|
||||
return do_length(
|
||||
const_cast<const std::mbstate_t &>(s),
|
||||
const_cast<std::mbstate_t &>(s),
|
||||
from,
|
||||
from_end,
|
||||
max_limit
|
||||
);
|
||||
}
|
||||
|
||||
// Largest possible value do_length(state,from,from_end,1) could return.
|
||||
virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
return 6; // largest UTF-8 encoding of a UCS-4 character
|
||||
|
@ -2,7 +2,7 @@
|
||||
// utf8_codecvt_facet.ipp
|
||||
|
||||
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
// Use, modification and distribution is subject to 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)
|
||||
@ -18,7 +18,7 @@
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// If we don't have wstring, then Unicode support
|
||||
// If we don't have wstring, then Unicode support
|
||||
// is not available anyway, so we don't need to even
|
||||
// compiler this file. This also fixes the problem
|
||||
// with mingw, which can compile this file, but will
|
||||
@ -30,105 +30,117 @@ BOOST_UTF8_BEGIN_NAMESPACE
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// implementation for wchar_t
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline const wchar_t * get_octet1_modifier_table() BOOST_NOEXCEPT
|
||||
{
|
||||
static const wchar_t octet1_modifier_table[] = {
|
||||
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
|
||||
};
|
||||
return octet1_modifier_table;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
BOOST_UTF8_DECL utf8_codecvt_facet::utf8_codecvt_facet(
|
||||
std::size_t no_locale_manage
|
||||
) :
|
||||
std::codecvt<wchar_t, char, std::mbstate_t>(no_locale_manage)
|
||||
{}
|
||||
|
||||
BOOST_UTF8_DECL utf8_codecvt_facet::~utf8_codecvt_facet()
|
||||
{}
|
||||
|
||||
// Translate incoming UTF-8 into UCS-4
|
||||
BOOST_UTF8_DECL std::codecvt_base::result utf8_codecvt_facet::do_in(
|
||||
std::mbstate_t& /*state*/,
|
||||
std::mbstate_t& /*state*/,
|
||||
const char * from,
|
||||
const char * from_end,
|
||||
const char * from_end,
|
||||
const char * & from_next,
|
||||
wchar_t * to,
|
||||
wchar_t * to_end,
|
||||
wchar_t * to,
|
||||
wchar_t * to_end,
|
||||
wchar_t * & to_next
|
||||
) const {
|
||||
// Basic algorithm: The first octet determines how many
|
||||
// octets total make up the UCS-4 character. The remaining
|
||||
// Basic algorithm: The first octet determines how many
|
||||
// octets total make up the UCS-4 character. The remaining
|
||||
// "continuing octets" all begin with "10". To convert, subtract
|
||||
// the amount that specifies the number of octets from the first
|
||||
// octet. Subtract 0x80 (1000 0000) from each continuing octet,
|
||||
// then mash the whole lot together. Note that each continuing
|
||||
// octet. Subtract 0x80 (1000 0000) from each continuing octet,
|
||||
// then mash the whole lot together. Note that each continuing
|
||||
// octet only uses 6 bits as unique values, so only shift by
|
||||
// multiples of 6 to combine.
|
||||
const wchar_t * const octet1_modifier_table = detail::get_octet1_modifier_table();
|
||||
while (from != from_end && to != to_end) {
|
||||
|
||||
// Error checking on the first octet
|
||||
if (invalid_leading_octet(*from)){
|
||||
// Error checking on the first octet
|
||||
if (invalid_leading_octet(*from)) {
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
return std::codecvt_base::error;
|
||||
}
|
||||
|
||||
// The first octet is adjusted by a value dependent upon
|
||||
// the number of "continuing octets" encoding the character
|
||||
const int cont_octet_count = get_cont_octet_count(*from);
|
||||
const wchar_t octet1_modifier_table[] = {
|
||||
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
|
||||
};
|
||||
// The first octet is adjusted by a value dependent upon
|
||||
// the number of "continuing octets" encoding the character
|
||||
const int cont_octet_count = get_cont_octet_count(*from);
|
||||
|
||||
// The unsigned char conversion is necessary in case char is
|
||||
// signed (I learned this the hard way)
|
||||
wchar_t ucs_result =
|
||||
// signed (I learned this the hard way)
|
||||
wchar_t ucs_result =
|
||||
(unsigned char)(*from++) - octet1_modifier_table[cont_octet_count];
|
||||
|
||||
// Invariants :
|
||||
// 1) At the start of the loop, 'i' continuing characters have been
|
||||
// processed
|
||||
// 2) *from points to the next continuing character to be processed.
|
||||
int i = 0;
|
||||
while(i != cont_octet_count && from != from_end) {
|
||||
// Invariants:
|
||||
// 1) At the start of the loop, 'i' continuing characters have been
|
||||
// processed
|
||||
// 2) *from points to the next continuing character to be processed.
|
||||
int i = 0;
|
||||
while (i != cont_octet_count && from != from_end) {
|
||||
|
||||
// Error checking on continuing characters
|
||||
if (invalid_continuing_octet(*from)) {
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
return std::codecvt_base::error;
|
||||
}
|
||||
|
||||
ucs_result *= (1 << 6);
|
||||
ucs_result *= (1 << 6);
|
||||
|
||||
// each continuing character has an extra (10xxxxxx)b attached to
|
||||
// each continuing character has an extra (10xxxxxx)b attached to
|
||||
// it that must be removed.
|
||||
ucs_result += (unsigned char)(*from++) - 0x80;
|
||||
++i;
|
||||
}
|
||||
|
||||
// If the buffer ends with an incomplete unicode character...
|
||||
if (from == from_end && i != cont_octet_count) {
|
||||
// If the buffer ends with an incomplete unicode character...
|
||||
if (from == from_end && i != cont_octet_count) {
|
||||
// rewind "from" to before the current character translation
|
||||
from_next = from - (i+1);
|
||||
from_next = from - (i + 1);
|
||||
to_next = to;
|
||||
return std::codecvt_base::partial;
|
||||
}
|
||||
*to++ = ucs_result;
|
||||
*to++ = ucs_result;
|
||||
}
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
// Were we done converting or did we run out of destination space?
|
||||
if(from == from_end) return std::codecvt_base::ok;
|
||||
else return std::codecvt_base::partial;
|
||||
if (from == from_end)
|
||||
return std::codecvt_base::ok;
|
||||
else
|
||||
return std::codecvt_base::partial;
|
||||
}
|
||||
|
||||
BOOST_UTF8_DECL std::codecvt_base::result utf8_codecvt_facet::do_out(
|
||||
std::mbstate_t& /*state*/,
|
||||
const wchar_t * from,
|
||||
const wchar_t * from_end,
|
||||
std::mbstate_t& /*state*/,
|
||||
const wchar_t * from,
|
||||
const wchar_t * from_end,
|
||||
const wchar_t * & from_next,
|
||||
char * to,
|
||||
char * to_end,
|
||||
char * to,
|
||||
char * to_end,
|
||||
char * & to_next
|
||||
) const
|
||||
{
|
||||
// RG - consider merging this table with the other one
|
||||
const wchar_t octet1_modifier_table[] = {
|
||||
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
|
||||
};
|
||||
|
||||
const wchar_t * const octet1_modifier_table = detail::get_octet1_modifier_table();
|
||||
wchar_t max_wchar = (std::numeric_limits<wchar_t>::max)();
|
||||
while (from != from_end && to != to_end) {
|
||||
|
||||
@ -141,75 +153,69 @@ BOOST_UTF8_DECL std::codecvt_base::result utf8_codecvt_facet::do_out(
|
||||
|
||||
int cont_octet_count = get_cont_octet_out_count(*from);
|
||||
|
||||
// RG - comment this formula better
|
||||
int shift_exponent = (cont_octet_count) * 6;
|
||||
// RG - comment this formula better
|
||||
int shift_exponent = cont_octet_count * 6;
|
||||
|
||||
// Process the first character
|
||||
*to++ = static_cast<char>(octet1_modifier_table[cont_octet_count] +
|
||||
(unsigned char)(*from / (1 << shift_exponent)));
|
||||
|
||||
// Process the continuation characters
|
||||
// Invariants: At the start of the loop:
|
||||
// 1) 'i' continuing octets have been generated
|
||||
// 2) '*to' points to the next location to place an octet
|
||||
// 3) shift_exponent is 6 more than needed for the next octet
|
||||
int i = 0;
|
||||
while (i != cont_octet_count && to != to_end) {
|
||||
// Process the continuation characters
|
||||
// Invariants: At the start of the loop:
|
||||
// 1) 'i' continuing octets have been generated
|
||||
// 2) '*to' points to the next location to place an octet
|
||||
// 3) shift_exponent is 6 more than needed for the next octet
|
||||
int i = 0;
|
||||
while (i != cont_octet_count && to != to_end) {
|
||||
shift_exponent -= 6;
|
||||
*to++ = static_cast<char>(0x80 + ((*from / (1 << shift_exponent)) % (1 << 6)));
|
||||
++i;
|
||||
}
|
||||
// If we filled up the out buffer before encoding the character
|
||||
if(to == to_end && i != cont_octet_count) {
|
||||
// If we filled up the out buffer before encoding the character
|
||||
if (to == to_end && i != cont_octet_count) {
|
||||
from_next = from;
|
||||
to_next = to - (i+1);
|
||||
to_next = to - (i + 1);
|
||||
return std::codecvt_base::partial;
|
||||
}
|
||||
++from;
|
||||
}
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
// Were we done or did we run out of destination space
|
||||
if(from == from_end) return std::codecvt_base::ok;
|
||||
else return std::codecvt_base::partial;
|
||||
if (from == from_end)
|
||||
return std::codecvt_base::ok;
|
||||
else
|
||||
return std::codecvt_base::partial;
|
||||
}
|
||||
|
||||
// How many char objects can I process to get <= max_limit
|
||||
// wchar_t objects?
|
||||
BOOST_UTF8_DECL int utf8_codecvt_facet::do_length(
|
||||
const std::mbstate_t &,
|
||||
std::mbstate_t &,
|
||||
const char * from,
|
||||
const char * from_end,
|
||||
const char * from_end,
|
||||
std::size_t max_limit
|
||||
) const
|
||||
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
|
||||
throw()
|
||||
#endif
|
||||
{
|
||||
// RG - this code is confusing! I need a better way to express it.
|
||||
// and test cases.
|
||||
|
||||
// Invariants:
|
||||
// 1) last_octet_count has the size of the last measured character
|
||||
// 2) char_count holds the number of characters shown to fit
|
||||
// within the bounds so far (no greater than max_limit)
|
||||
// 3) from_next points to the octet 'last_octet_count' before the
|
||||
// last measured character.
|
||||
int last_octet_count=0;
|
||||
std::size_t char_count = 0;
|
||||
const char* from_next = from;
|
||||
// Use "<" because the buffer may represent incomplete characters
|
||||
while (from_next+last_octet_count <= from_end && char_count <= max_limit) {
|
||||
from_next += last_octet_count;
|
||||
last_octet_count = (get_octet_count(*from_next));
|
||||
++char_count;
|
||||
{
|
||||
const char * from_next = from;
|
||||
for (std::size_t char_count = 0u; char_count < max_limit && from_next < from_end; ++char_count) {
|
||||
unsigned int octet_count = get_octet_count(*from_next);
|
||||
// The buffer may represent incomplete characters, so terminate early if one is found
|
||||
if (octet_count > static_cast<std::size_t>(from_end - from_next))
|
||||
break;
|
||||
from_next += octet_count;
|
||||
}
|
||||
return static_cast<int>(from_next-from);
|
||||
|
||||
return static_cast<int>(from_next - from);
|
||||
}
|
||||
|
||||
BOOST_UTF8_DECL unsigned int utf8_codecvt_facet::get_octet_count(
|
||||
unsigned char lead_octet
|
||||
){
|
||||
unsigned char lead_octet
|
||||
) {
|
||||
// if the 0-bit (MSB) is 0, then 1 character
|
||||
if (lead_octet <= 0x7f) return 1;
|
||||
|
||||
@ -226,7 +232,7 @@ BOOST_UTF8_DECL unsigned int utf8_codecvt_facet::get_octet_count(
|
||||
namespace detail {
|
||||
|
||||
template<std::size_t s>
|
||||
int get_cont_octet_out_count_impl(wchar_t word){
|
||||
inline int get_cont_octet_out_count_impl(wchar_t word) {
|
||||
if (word < 0x80) {
|
||||
return 0;
|
||||
}
|
||||
@ -237,7 +243,7 @@ int get_cont_octet_out_count_impl(wchar_t word){
|
||||
}
|
||||
|
||||
template<>
|
||||
int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
inline int get_cont_octet_out_count_impl<4>(wchar_t word) {
|
||||
if (word < 0x80) {
|
||||
return 0;
|
||||
}
|
||||
@ -249,7 +255,7 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
// where wchar_t is defined as UCS2. The warnings are superfluous as the
|
||||
// specialization is never instantitiated with such compilers, but this
|
||||
// can cause problems if warnings are being treated as errors, so we guard
|
||||
// against that. Including <boost/detail/utf8_codecvt_facet.hpp> as we do
|
||||
// against that. Including <boost/detail/utf8_codecvt_facet.hpp> as we do
|
||||
// should be enough to get WCHAR_MAX defined.
|
||||
#if !defined(WCHAR_MAX)
|
||||
# error WCHAR_MAX not defined!
|
||||
@ -258,8 +264,8 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1310 // 7.1 or earlier
|
||||
return 2;
|
||||
#elif WCHAR_MAX > 0x10000
|
||||
|
||||
if (word < 0x10000) {
|
||||
|
||||
if (word < 0x10000) {
|
||||
return 2;
|
||||
}
|
||||
if (word < 0x200000) {
|
||||
@ -269,7 +275,7 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
|
||||
|
||||
#else
|
||||
return 2;
|
||||
#endif
|
||||
@ -281,9 +287,10 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
// == total octets - 1.
|
||||
BOOST_UTF8_DECL int utf8_codecvt_facet::get_cont_octet_out_count(
|
||||
wchar_t word
|
||||
) const {
|
||||
) {
|
||||
return detail::get_cont_octet_out_count_impl<sizeof(wchar_t)>(word);
|
||||
}
|
||||
|
||||
BOOST_UTF8_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,6 @@
|
||||
"Miscellaneous"
|
||||
],
|
||||
"maintainers": [
|
||||
"Beman Dawes <bdawes -at- acm.org>",
|
||||
"Robert Ramey <ramey -at- rrsd.com>",
|
||||
"Rene Rivera <grafikrobot -at- gmail.com>",
|
||||
"Andrey Semashev <andrey.semashev -at- gmail.com>"
|
||||
|
30
test/Jamfile
30
test/Jamfile
@ -5,24 +5,34 @@
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
################################################################################
|
||||
|
||||
import testing ;
|
||||
import config : requires ;
|
||||
|
||||
build-project container_fwd ;
|
||||
|
||||
project detail/test
|
||||
project detail/test
|
||||
: requirements
|
||||
<library>/boost/detail//boost_detail
|
||||
<library>/boost/type_traits//boost_type_traits
|
||||
<c++-template-depth>300
|
||||
<toolset>clang:<cxxflags>-Wno-unused
|
||||
<toolset>clang:<cxxflags>-Wno-tautological-compare
|
||||
<toolset>clang:<cxxflags>-ftemplate-depth-300
|
||||
<toolset>gcc:<cxxflags>-ftemplate-depth-300
|
||||
<toolset>gcc:<define>_STLP_DEBUG
|
||||
<toolset>gcc:<define>_GLIBCXX_DEBUG
|
||||
<toolset>darwin:<cxxflags>-ftemplate-depth-300
|
||||
# Do not enable libstdc++ debug mode because of gcc 10.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95289
|
||||
# <toolset>gcc:<define>_GLIBCXX_DEBUG
|
||||
;
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
|
||||
run binary_search_test.cpp ;
|
||||
run is_sorted_test.cpp ;
|
||||
run test_utf8_codecvt.cpp : :
|
||||
: [ requires std_wstreambuf ]
|
||||
;
|
||||
run blank_test.cpp ;
|
||||
run bitmask_test.cpp : : : [ requires cxx11_scoped_enums ] ;
|
||||
run is_sorted_test.cpp /boost/array//boost_array ;
|
||||
run numeric_traits_test.cpp ;
|
||||
run is_xxx_test.cpp /boost/preprocessor//boost_preprocessor ;
|
||||
# run test_utf8_codecvt.cpp : : : [ requires std_wstreambuf ] ;
|
||||
run test_utf8_codecvt.cpp ;
|
||||
run allocator_utilities_test.cpp ;
|
||||
run reference_content_test.cpp ;
|
||||
|
46
test/allocator_utilities_test.cpp
Normal file
46
test/allocator_utilities_test.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
// Copyright 2018 Daniel James.
|
||||
// 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/detail/allocator_utilities.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <memory>
|
||||
|
||||
typedef std::allocator<int> std_int_allocator;
|
||||
typedef boost::detail::allocator::rebind_to<std_int_allocator, char>::type char_allocator;
|
||||
typedef boost::detail::allocator::rebind_to<char_allocator, int>::type int_allocator;
|
||||
typedef boost::detail::allocator::rebind_to<int_allocator, char>::type char_allocator2;
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_STATIC_ASSERT((!boost::is_same<char_allocator, int_allocator>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<char_allocator, char_allocator2>::value));
|
||||
|
||||
// Check the constructors works okay
|
||||
std_int_allocator a1;
|
||||
char_allocator a2(a1);
|
||||
char_allocator a2a(a2);
|
||||
int_allocator a3(a2);
|
||||
|
||||
// Check allocate works okay
|
||||
{
|
||||
boost::allocator_pointer<char_allocator>::type p = a2.allocate(10);
|
||||
BOOST_TEST(!!p);
|
||||
a2.deallocate(p, 10);
|
||||
}
|
||||
|
||||
// Try using the standalone construct/destroy
|
||||
{
|
||||
boost::allocator_pointer<int_allocator>::type p2 = a3.allocate(1);
|
||||
boost::detail::allocator::construct(p2, 25);
|
||||
BOOST_TEST(*p2 == 25);
|
||||
boost::detail::allocator::destroy(p2);
|
||||
a3.deallocate(p2, 1);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -3,18 +3,19 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/detail/binary_search.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <stdlib.h> // for rand(). Would use cstdlib but VC6.4 doesn't put it in std::
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <boost/detail/binary_search.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2)
|
||||
# define USE_SSTREAM
|
||||
@ -32,7 +33,7 @@ namespace {
|
||||
struct mystring : std::string
|
||||
{
|
||||
typedef std::string base;
|
||||
|
||||
|
||||
mystring(std::string const& x)
|
||||
: base(x) {}
|
||||
};
|
||||
@ -180,13 +181,13 @@ template <class Sequence, class Compare>
|
||||
void test_loop(Sequence& x, Compare cmp, unsigned long test_count)
|
||||
{
|
||||
typedef typename Sequence::const_iterator const_iterator;
|
||||
|
||||
|
||||
for (unsigned long i = 0; i < test_count; ++i)
|
||||
{
|
||||
random_sorted_sequence(x);
|
||||
const const_iterator start = x.begin();
|
||||
const const_iterator finish = x.end();
|
||||
|
||||
|
||||
unsigned key = random_number();
|
||||
const const_iterator l = searches<Compare>::lower_bound(start, finish, key, cmp);
|
||||
const const_iterator u = searches<Compare>::upper_bound(start, finish, key, cmp);
|
||||
@ -204,38 +205,40 @@ void test_loop(Sequence& x, Compare cmp, unsigned long test_count)
|
||||
|
||||
if (p == u)
|
||||
{
|
||||
assert(found_l);
|
||||
BOOST_TEST(found_l);
|
||||
found_u = true;
|
||||
}
|
||||
|
||||
unsigned value = to_int(*p);
|
||||
assert(value >= last_value);
|
||||
BOOST_TEST(value >= last_value);
|
||||
last_value = value;
|
||||
|
||||
if (!found_l)
|
||||
{
|
||||
++index;
|
||||
assert(to_int(*p) < key);
|
||||
BOOST_TEST(to_int(*p) < key);
|
||||
}
|
||||
else if (!found_u)
|
||||
{
|
||||
++count;
|
||||
assert(to_int(*p) == key);
|
||||
BOOST_TEST(to_int(*p) == key);
|
||||
}
|
||||
else
|
||||
assert(to_int(*p) > key);
|
||||
{
|
||||
BOOST_TEST(to_int(*p) > key);
|
||||
}
|
||||
}
|
||||
assert(found_l || l == finish);
|
||||
assert(found_u || u == finish);
|
||||
BOOST_TEST(found_l || l == finish);
|
||||
BOOST_TEST(found_u || u == finish);
|
||||
|
||||
std::pair<const_iterator, const_iterator>
|
||||
range = searches<Compare>::equal_range(start, finish, key, cmp);
|
||||
assert(range.first == l);
|
||||
assert(range.second == u);
|
||||
BOOST_TEST(range.first == l);
|
||||
BOOST_TEST(range.second == u);
|
||||
|
||||
bool found = searches<Compare>::binary_search(start, finish, key, cmp);
|
||||
(void)found;
|
||||
assert(found == (u != l));
|
||||
BOOST_TEST(found == (u != l));
|
||||
std::cout << "found " << count << " copies of " << key << " at index " << index << "\n";
|
||||
}
|
||||
}
|
||||
@ -256,5 +259,6 @@ int main()
|
||||
std::cout << "=== testing bidirectional iterators with compare: ===\n";
|
||||
test_loop(y, cmp(), 25);
|
||||
std::cerr << "******TEST PASSED******\n";
|
||||
return 0;
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
184
test/bitmask_test.cpp
Normal file
184
test/bitmask_test.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2025 Andrey Semashev
|
||||
*/
|
||||
|
||||
#include <boost/detail/bitmask.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
enum unscoped_enum
|
||||
{
|
||||
zero = 0,
|
||||
one = 1,
|
||||
two = 2,
|
||||
four = 4
|
||||
};
|
||||
|
||||
BOOST_BITMASK(unscoped_enum)
|
||||
|
||||
void test_unscoped_enum()
|
||||
{
|
||||
BOOST_TEST((one | two) == ((unscoped_enum)(1 | 2)));
|
||||
BOOST_TEST((one & two) == ((unscoped_enum)(1 & 2)));
|
||||
BOOST_TEST((one ^ two) == ((unscoped_enum)(1 ^ 2)));
|
||||
BOOST_TEST((one | one) == ((unscoped_enum)(1 | 1)));
|
||||
BOOST_TEST((one & one) == ((unscoped_enum)(1 & 1)));
|
||||
BOOST_TEST((one ^ one) == ((unscoped_enum)(1 ^ 1)));
|
||||
BOOST_TEST((~one) == ((unscoped_enum)(~1)));
|
||||
{
|
||||
unscoped_enum val = one;
|
||||
val |= two;
|
||||
BOOST_TEST(val == ((unscoped_enum)(1 | 2)));
|
||||
}
|
||||
{
|
||||
unscoped_enum val = one;
|
||||
val &= two;
|
||||
BOOST_TEST(val == ((unscoped_enum)(1 & 2)));
|
||||
}
|
||||
{
|
||||
unscoped_enum val = one;
|
||||
val ^= two;
|
||||
BOOST_TEST(val == ((unscoped_enum)(1 ^ 2)));
|
||||
}
|
||||
{
|
||||
unscoped_enum val = one;
|
||||
val |= one;
|
||||
BOOST_TEST(val == ((unscoped_enum)(1 | 1)));
|
||||
}
|
||||
{
|
||||
unscoped_enum val = one;
|
||||
val &= one;
|
||||
BOOST_TEST(val == ((unscoped_enum)(1 & 1)));
|
||||
}
|
||||
{
|
||||
unscoped_enum val = one;
|
||||
val ^= one;
|
||||
BOOST_TEST(val == ((unscoped_enum)(1 ^ 1)));
|
||||
}
|
||||
BOOST_TEST(!zero);
|
||||
BOOST_TEST(!!one);
|
||||
}
|
||||
|
||||
|
||||
enum class scoped_enum
|
||||
{
|
||||
none = 0,
|
||||
x = 8,
|
||||
y = 16,
|
||||
z = 32
|
||||
};
|
||||
|
||||
BOOST_BITMASK(scoped_enum)
|
||||
|
||||
void test_scoped_enum()
|
||||
{
|
||||
BOOST_TEST((scoped_enum::x | scoped_enum::y) == ((scoped_enum)(8 | 16)));
|
||||
BOOST_TEST((scoped_enum::x & scoped_enum::y) == ((scoped_enum)(8 & 16)));
|
||||
BOOST_TEST((scoped_enum::x ^ scoped_enum::y) == ((scoped_enum)(8 ^ 16)));
|
||||
BOOST_TEST((scoped_enum::x | scoped_enum::x) == ((scoped_enum)(8 | 8)));
|
||||
BOOST_TEST((scoped_enum::x & scoped_enum::x) == ((scoped_enum)(8 & 8)));
|
||||
BOOST_TEST((scoped_enum::x ^ scoped_enum::x) == ((scoped_enum)(8 ^ 8)));
|
||||
BOOST_TEST((~scoped_enum::x) == ((scoped_enum)(~8)));
|
||||
{
|
||||
scoped_enum val = scoped_enum::x;
|
||||
val |= scoped_enum::y;
|
||||
BOOST_TEST(val == ((scoped_enum)(8 | 16)));
|
||||
}
|
||||
{
|
||||
scoped_enum val = scoped_enum::x;
|
||||
val &= scoped_enum::y;
|
||||
BOOST_TEST(val == ((scoped_enum)(8 & 16)));
|
||||
}
|
||||
{
|
||||
scoped_enum val = scoped_enum::x;
|
||||
val ^= scoped_enum::y;
|
||||
BOOST_TEST(val == ((scoped_enum)(8 ^ 16)));
|
||||
}
|
||||
{
|
||||
scoped_enum val = scoped_enum::x;
|
||||
val |= scoped_enum::x;
|
||||
BOOST_TEST(val == ((scoped_enum)(8 | 8)));
|
||||
}
|
||||
{
|
||||
scoped_enum val = scoped_enum::x;
|
||||
val &= scoped_enum::x;
|
||||
BOOST_TEST(val == ((scoped_enum)(8 & 8)));
|
||||
}
|
||||
{
|
||||
scoped_enum val = scoped_enum::x;
|
||||
val ^= scoped_enum::x;
|
||||
BOOST_TEST(val == ((scoped_enum)(8 ^ 8)));
|
||||
}
|
||||
BOOST_TEST(!scoped_enum::none);
|
||||
BOOST_TEST(!!scoped_enum::x);
|
||||
}
|
||||
|
||||
|
||||
namespace my_namespace {
|
||||
|
||||
enum class namespaced_enum : unsigned int
|
||||
{
|
||||
empty = 0,
|
||||
a = 64,
|
||||
b = 128,
|
||||
c = 256
|
||||
};
|
||||
|
||||
BOOST_BITMASK(namespaced_enum)
|
||||
|
||||
} // namespace my_namespace
|
||||
|
||||
void test_namespaced_enum()
|
||||
{
|
||||
BOOST_TEST((my_namespace::namespaced_enum::a | my_namespace::namespaced_enum::b) == ((my_namespace::namespaced_enum)(64u | 128u)));
|
||||
BOOST_TEST((my_namespace::namespaced_enum::a & my_namespace::namespaced_enum::b) == ((my_namespace::namespaced_enum)(64u & 128u)));
|
||||
BOOST_TEST((my_namespace::namespaced_enum::a ^ my_namespace::namespaced_enum::b) == ((my_namespace::namespaced_enum)(64u ^ 128u)));
|
||||
BOOST_TEST((my_namespace::namespaced_enum::a | my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(64u | 64u)));
|
||||
BOOST_TEST((my_namespace::namespaced_enum::a & my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(64u & 64u)));
|
||||
BOOST_TEST((my_namespace::namespaced_enum::a ^ my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(64u ^ 64u)));
|
||||
BOOST_TEST((~my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(~64u)));
|
||||
{
|
||||
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
|
||||
val |= my_namespace::namespaced_enum::b;
|
||||
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u | 128u)));
|
||||
}
|
||||
{
|
||||
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
|
||||
val &= my_namespace::namespaced_enum::b;
|
||||
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u & 128u)));
|
||||
}
|
||||
{
|
||||
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
|
||||
val ^= my_namespace::namespaced_enum::b;
|
||||
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u ^ 128u)));
|
||||
}
|
||||
{
|
||||
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
|
||||
val |= my_namespace::namespaced_enum::a;
|
||||
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u | 64u)));
|
||||
}
|
||||
{
|
||||
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
|
||||
val &= my_namespace::namespaced_enum::a;
|
||||
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u & 64u)));
|
||||
}
|
||||
{
|
||||
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
|
||||
val ^= my_namespace::namespaced_enum::a;
|
||||
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u ^ 64u)));
|
||||
}
|
||||
BOOST_TEST(!my_namespace::namespaced_enum::empty);
|
||||
BOOST_TEST(!!my_namespace::namespaced_enum::a);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_unscoped_enum();
|
||||
test_scoped_enum();
|
||||
test_namespaced_enum();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
37
test/blank_test.cpp
Normal file
37
test/blank_test.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
// Copyright 2018 Daniel James.
|
||||
// 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/blank.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_pod.hpp>
|
||||
#include <boost/type_traits/is_empty.hpp>
|
||||
#include <boost/type_traits/is_stateless.hpp>
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::is_pod<boost::blank>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_empty<boost::blank>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_stateless<boost::blank>::value));
|
||||
|
||||
boost::blank b1,b2;
|
||||
BOOST_TEST(b1 == b2);
|
||||
BOOST_TEST(b1 <= b2);
|
||||
BOOST_TEST(b1 >= b2);
|
||||
BOOST_TEST(!(b1 != b2));
|
||||
BOOST_TEST(!(b1 < b2));
|
||||
BOOST_TEST(!(b1 > b2));
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
std::stringstream s;
|
||||
s << "(" << b1 << ")";
|
||||
BOOST_TEST(s.str() == "()");
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -9,9 +9,12 @@ project detail/test/container_fwd
|
||||
: requirements
|
||||
<warnings>all
|
||||
<toolset>intel:<warnings>on
|
||||
<toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
|
||||
<toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
|
||||
<toolset>clang:<cxxflags>"-pedantic -Wextra -Wmismatched-tags"
|
||||
<toolset>gcc:<warnings>pedantic
|
||||
<toolset>gcc:<cxxflags>"-Wstrict-aliasing -fstrict-aliasing -Wsign-promo -Wunused-parameter -Wconversion"
|
||||
<toolset>darwin:<warnings>pedantic
|
||||
<toolset>darwin:<cxxflags>"-Wstrict-aliasing -fstrict-aliasing -Wsign-promo -Wunused-parameter -Wconversion"
|
||||
<toolset>clang:<warnings>pedantic
|
||||
<toolset>clang:<cxxflags>"-Wmismatched-tags"
|
||||
<warnings-as-errors>on
|
||||
;
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/detail/is_sorted.hpp>
|
||||
#include <iostream>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/detail/is_sorted.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct tracking_less {
|
||||
|
23
test/is_xxx_test.cpp
Normal file
23
test/is_xxx_test.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
// Copyright 2018 Daniel James.
|
||||
// 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/detail/is_xxx.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace is_xxx_test {
|
||||
template <typename T> struct thing1 {};
|
||||
template <typename T1, typename T2 = int> struct thing2 {};
|
||||
}
|
||||
|
||||
BOOST_DETAIL_IS_XXX_DEF(thing1, is_xxx_test::thing1, 1);
|
||||
BOOST_DETAIL_IS_XXX_DEF(thing2, is_xxx_test::thing2, 2);
|
||||
|
||||
BOOST_STATIC_ASSERT((is_thing1<is_xxx_test::thing1<int> >::value));
|
||||
BOOST_STATIC_ASSERT((!is_thing1<is_xxx_test::thing2<int> >::value));
|
||||
BOOST_STATIC_ASSERT((!is_thing2<is_xxx_test::thing1<int> >::value));
|
||||
BOOST_STATIC_ASSERT((is_thing2<is_xxx_test::thing2<int> >::value));
|
||||
BOOST_STATIC_ASSERT((is_thing2<is_xxx_test::thing2<int, float> >::value));
|
||||
|
||||
int main() {}
|
422
test/numeric_traits_test.cpp
Normal file
422
test/numeric_traits_test.cpp
Normal file
@ -0,0 +1,422 @@
|
||||
// (C) Copyright David Abrahams 2001.
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 1 Apr 2001 Fixes for ICL; use BOOST_STATIC_CONSTANT
|
||||
// 11 Feb 2001 Fixes for Borland (David Abrahams)
|
||||
// 23 Jan 2001 Added test for wchar_t (David Abrahams)
|
||||
// 23 Jan 2001 Now statically selecting a test for signed numbers to avoid
|
||||
// warnings with fancy compilers. Added commentary and
|
||||
// additional dumping of traits data for tested types (David
|
||||
// Abrahams).
|
||||
// 21 Jan 2001 Initial version (David Abrahams)
|
||||
|
||||
#include <boost/detail/numeric_traits.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <climits>
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#ifndef BOOST_NO_LIMITS
|
||||
#include <limits>
|
||||
#endif
|
||||
|
||||
// =================================================================================
|
||||
// template class complement_traits<Number> --
|
||||
//
|
||||
// statically computes the max and min for 1s and 2s-complement binary
|
||||
// numbers. This helps on platforms without <limits> support. It also shows
|
||||
// an example of a recursive template that works with MSVC!
|
||||
//
|
||||
|
||||
template <unsigned size> struct complement; // forward
|
||||
|
||||
// The template complement, below, does all the real work, using "poor man's
|
||||
// partial specialization". We need complement_traits_aux<> so that MSVC doesn't
|
||||
// complain about undefined min/max as we're trying to recursively define them.
|
||||
template <class Number, unsigned size>
|
||||
struct complement_traits_aux
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, max = complement<size>::template traits<Number>::max);
|
||||
BOOST_STATIC_CONSTANT(Number, min = complement<size>::template traits<Number>::min);
|
||||
};
|
||||
|
||||
template <unsigned size>
|
||||
struct complement
|
||||
{
|
||||
template <class Number>
|
||||
struct traits
|
||||
{
|
||||
private:
|
||||
// indirection through complement_traits_aux necessary to keep MSVC happy
|
||||
typedef complement_traits_aux<Number, size - 1> prev;
|
||||
public:
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
|
||||
// GCC 4.0.2 ICEs on these C-style casts
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
Number((prev::max) << CHAR_BIT)
|
||||
+ Number(UCHAR_MAX));
|
||||
BOOST_STATIC_CONSTANT(Number, min = Number((prev::min) << CHAR_BIT));
|
||||
#else
|
||||
// Avoid left shifting negative integers, use multiplication instead
|
||||
BOOST_STATIC_CONSTANT(Number, shift = 1u << CHAR_BIT);
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
Number(Number(prev::max) * shift)
|
||||
+ Number(UCHAR_MAX));
|
||||
BOOST_STATIC_CONSTANT(Number, min = Number(Number(prev::min) * shift));
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
// Template class complement_base<> -- defines values for min and max for
|
||||
// complement<1>, at the deepest level of recursion. Uses "poor man's partial
|
||||
// specialization" again.
|
||||
template <bool is_signed> struct complement_base;
|
||||
|
||||
template <> struct complement_base<false>
|
||||
{
|
||||
template <class Number>
|
||||
struct values
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, min = 0);
|
||||
BOOST_STATIC_CONSTANT(Number, max = UCHAR_MAX);
|
||||
};
|
||||
};
|
||||
|
||||
template <> struct complement_base<true>
|
||||
{
|
||||
template <class Number>
|
||||
struct values
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, min = SCHAR_MIN);
|
||||
BOOST_STATIC_CONSTANT(Number, max = SCHAR_MAX);
|
||||
};
|
||||
};
|
||||
|
||||
// Base specialization of complement, puts an end to the recursion.
|
||||
template <>
|
||||
struct complement<1>
|
||||
{
|
||||
template <class Number>
|
||||
struct traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = boost::is_signed<Number>::value);
|
||||
BOOST_STATIC_CONSTANT(Number, min =
|
||||
complement_base<is_signed>::template values<Number>::min);
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
complement_base<is_signed>::template values<Number>::max);
|
||||
};
|
||||
};
|
||||
|
||||
// Now here's the "pretty" template you're intended to actually use.
|
||||
// complement_traits<Number>::min, complement_traits<Number>::max are the
|
||||
// minimum and maximum values of Number if Number is a built-in integer type.
|
||||
template <class Number>
|
||||
struct complement_traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(Number, max = (complement_traits_aux<Number, sizeof(Number)>::max));
|
||||
BOOST_STATIC_CONSTANT(Number, min = (complement_traits_aux<Number, sizeof(Number)>::min));
|
||||
};
|
||||
|
||||
// =================================================================================
|
||||
|
||||
// Support for streaming various numeric types in exactly the format I want. I
|
||||
// needed this in addition to all the assertions so that I could see exactly
|
||||
// what was going on.
|
||||
//
|
||||
// Numbers go through a 2-stage conversion process (by default, though, no real
|
||||
// conversion).
|
||||
//
|
||||
template <class T> struct stream_as {
|
||||
typedef T t1;
|
||||
typedef T t2;
|
||||
};
|
||||
|
||||
// char types first get converted to unsigned char, then to unsigned.
|
||||
template <> struct stream_as<char> {
|
||||
typedef unsigned char t1;
|
||||
typedef unsigned t2;
|
||||
};
|
||||
template <> struct stream_as<unsigned char> {
|
||||
typedef unsigned char t1; typedef unsigned t2;
|
||||
};
|
||||
template <> struct stream_as<signed char> {
|
||||
typedef unsigned char t1; typedef unsigned t2;
|
||||
};
|
||||
|
||||
// C++20 ostream has deleted operator<< for wchar_t
|
||||
template <> struct stream_as<wchar_t> {
|
||||
typedef unsigned int t1;
|
||||
typedef unsigned int t2;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
|
||||
|
||||
// With this library implementation, __int64 and __uint64 get streamed as strings
|
||||
template <> struct stream_as<boost::uintmax_t> {
|
||||
typedef std::string t1;
|
||||
typedef std::string t2;
|
||||
};
|
||||
|
||||
template <> struct stream_as<boost::intmax_t> {
|
||||
typedef std::string t1;
|
||||
typedef std::string t2;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Standard promotion process for streaming
|
||||
template <class T> struct promote
|
||||
{
|
||||
static typename stream_as<T>::t1 from(T x) {
|
||||
typedef typename stream_as<T>::t1 t1;
|
||||
return t1(x);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
|
||||
|
||||
// On this platform, stream them as long/unsigned long if they fit.
|
||||
// Otherwise, write a string.
|
||||
template <> struct promote<boost::uintmax_t> {
|
||||
std::string static from(const boost::uintmax_t x) {
|
||||
if (x > ULONG_MAX)
|
||||
return std::string("large unsigned value");
|
||||
else {
|
||||
std::ostringstream strm;
|
||||
strm << (unsigned long)x;
|
||||
return strm.str();
|
||||
}
|
||||
}
|
||||
};
|
||||
template <> struct promote<boost::intmax_t> {
|
||||
std::string static from(const boost::intmax_t x) {
|
||||
if (x > boost::intmax_t(ULONG_MAX))
|
||||
return std::string("large positive signed value");
|
||||
else if (x >= 0) {
|
||||
std::ostringstream strm;
|
||||
strm << (unsigned long)x;
|
||||
return strm.str();
|
||||
}
|
||||
|
||||
if (x < boost::intmax_t(LONG_MIN))
|
||||
return std::string("large negative signed value");
|
||||
else {
|
||||
std::ostringstream strm;
|
||||
strm << (long)x;
|
||||
return strm.str();
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// This is the function which converts types to the form I want to stream them in.
|
||||
template <class T>
|
||||
typename stream_as<T>::t2 stream_number(T x)
|
||||
{
|
||||
return promote<T>::from(x);
|
||||
}
|
||||
// =================================================================================
|
||||
|
||||
//
|
||||
// Tests for built-in signed and unsigned types
|
||||
//
|
||||
|
||||
// Tag types for selecting tests
|
||||
struct unsigned_tag {};
|
||||
struct signed_tag {};
|
||||
|
||||
// Tests for unsigned numbers. The extra default Number parameter works around
|
||||
// an MSVC bug.
|
||||
template <class Number>
|
||||
void test_aux(unsigned_tag, Number*)
|
||||
{
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
BOOST_STATIC_ASSERT(!boost::is_signed<Number>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
(sizeof(Number) < sizeof(boost::intmax_t))
|
||||
| (boost::is_same<difference_type, boost::intmax_t>::value));
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
|
||||
// GCC 4.0.2 ICEs on this C-style cases
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::min) == Number(0));
|
||||
#else
|
||||
// Force casting to Number here to work around the fact that it's an enum on MSVC
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::min) == Number(0));
|
||||
#endif
|
||||
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
const Number test_max = (sizeof(Number) < sizeof(boost::intmax_t))
|
||||
? max
|
||||
: max / 2 - 1;
|
||||
|
||||
std::cout << std::hex << "(unsigned) min = " << stream_number(min) << ", max = "
|
||||
<< stream_number(max) << "..." << std::flush;
|
||||
std::cout << "difference_type = " << typeid(difference_type).name() << "..."
|
||||
<< std::flush;
|
||||
|
||||
difference_type d1 = boost::detail::numeric_distance(Number(0), test_max);
|
||||
difference_type d2 = boost::detail::numeric_distance(test_max, Number(0));
|
||||
|
||||
std::cout << "0->" << stream_number(test_max) << "==" << std::dec << stream_number(d1) << "; "
|
||||
<< std::hex << stream_number(test_max) << "->0==" << std::dec << stream_number(d2) << "..." << std::flush;
|
||||
|
||||
assert(d1 == difference_type(test_max));
|
||||
assert(d2 == -difference_type(test_max));
|
||||
}
|
||||
|
||||
// Tests for signed numbers. The extra default Number parameter works around an
|
||||
// MSVC bug.
|
||||
struct out_of_range_tag {};
|
||||
struct in_range_tag {};
|
||||
|
||||
// This test morsel gets executed for numbers whose difference will always be
|
||||
// representable in intmax_t
|
||||
template <class Number>
|
||||
void signed_test(in_range_tag, Number*)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(boost::is_signed<Number>::value);
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
difference_type d1 = boost::detail::numeric_distance(min, max);
|
||||
difference_type d2 = boost::detail::numeric_distance(max, min);
|
||||
|
||||
std::cout << stream_number(min) << "->" << stream_number(max) << "==";
|
||||
std::cout << std::dec << stream_number(d1) << "; ";
|
||||
std::cout << std::hex << stream_number(max) << "->" << stream_number(min)
|
||||
<< "==" << std::dec << stream_number(d2) << "..." << std::flush;
|
||||
assert(d1 == difference_type(max) - difference_type(min));
|
||||
assert(d2 == difference_type(min) - difference_type(max));
|
||||
}
|
||||
|
||||
// This test morsel gets executed for numbers whose difference may exceed the
|
||||
// capacity of intmax_t.
|
||||
template <class Number>
|
||||
void signed_test(out_of_range_tag, Number*)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(boost::is_signed<Number>::value);
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
difference_type min_distance = complement_traits<difference_type>::min;
|
||||
difference_type max_distance = complement_traits<difference_type>::max;
|
||||
|
||||
const Number n1 = Number(min + max_distance);
|
||||
const Number n2 = Number(max + min_distance);
|
||||
difference_type d1 = boost::detail::numeric_distance(min, n1);
|
||||
difference_type d2 = boost::detail::numeric_distance(max, n2);
|
||||
|
||||
std::cout << stream_number(min) << "->" << stream_number(n1) << "==";
|
||||
std::cout << std::dec << stream_number(d1) << "; ";
|
||||
std::cout << std::hex << stream_number(max) << "->" << stream_number(n2)
|
||||
<< "==" << std::dec << stream_number(d2) << "..." << std::flush;
|
||||
assert(d1 == max_distance);
|
||||
assert(d2 == min_distance);
|
||||
}
|
||||
|
||||
template <class Number>
|
||||
void test_aux(signed_tag, Number*)
|
||||
{
|
||||
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
|
||||
BOOST_STATIC_ASSERT(boost::is_signed<Number>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
(sizeof(Number) < sizeof(boost::intmax_t))
|
||||
| (boost::is_same<difference_type, Number>::value));
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
|
||||
// GCC 4.0.2 ICEs on this cast
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT((complement_traits<Number>::min) < Number(0));
|
||||
#else
|
||||
// Force casting to Number here to work around the fact that it's an enum on MSVC
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::max) > Number(0));
|
||||
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::min) < Number(0));
|
||||
#endif
|
||||
const Number max = complement_traits<Number>::max;
|
||||
const Number min = complement_traits<Number>::min;
|
||||
|
||||
std::cout << std::hex << "min = " << stream_number(min) << ", max = "
|
||||
<< stream_number(max) << "..." << std::flush;
|
||||
std::cout << "difference_type = " << typeid(difference_type).name() << "..."
|
||||
<< std::flush;
|
||||
|
||||
typedef typename boost::conditional<
|
||||
(sizeof(Number) < sizeof(boost::intmax_t)),
|
||||
in_range_tag,
|
||||
out_of_range_tag
|
||||
>::type range_tag;
|
||||
signed_test<Number>(range_tag(), 0);
|
||||
}
|
||||
|
||||
|
||||
// Test for all numbers. The extra default Number parameter works around an MSVC
|
||||
// bug.
|
||||
template <class Number>
|
||||
void test(Number* = 0)
|
||||
{
|
||||
std::cout << "testing " << typeid(Number).name() << ":\n"
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
<< "is_signed: " << (std::numeric_limits<Number>::is_signed ? "true\n" : "false\n")
|
||||
<< "is_bounded: " << (std::numeric_limits<Number>::is_bounded ? "true\n" : "false\n")
|
||||
<< "digits: " << std::numeric_limits<Number>::digits << "\n"
|
||||
#endif
|
||||
<< "..." << std::flush;
|
||||
|
||||
// factoring out difference_type for the assert below confused Borland :(
|
||||
typedef boost::is_signed<
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
typename
|
||||
#endif
|
||||
boost::detail::numeric_traits<Number>::difference_type
|
||||
> is_signed;
|
||||
BOOST_STATIC_ASSERT(is_signed::value);
|
||||
|
||||
typedef typename boost::conditional<
|
||||
boost::is_signed<Number>::value,
|
||||
signed_tag,
|
||||
unsigned_tag
|
||||
>::type signedness;
|
||||
|
||||
test_aux<Number>(signedness(), 0);
|
||||
std::cout << "passed" << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<unsigned char>();
|
||||
test<signed char>();
|
||||
test<wchar_t>();
|
||||
test<short>();
|
||||
test<unsigned short>();
|
||||
test<int>();
|
||||
test<unsigned int>();
|
||||
test<long>();
|
||||
test<unsigned long>();
|
||||
#if defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T)
|
||||
test< ::boost::long_long_type>();
|
||||
test< ::boost::ulong_long_type>();
|
||||
#elif defined(BOOST_MSVC)
|
||||
// The problem of not having compile-time static class constants other than
|
||||
// enums prevents this from working, since values get truncated.
|
||||
// test<boost::uintmax_t>();
|
||||
// test<boost::intmax_t>();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
16
test/reference_content_test.cpp
Normal file
16
test/reference_content_test.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
// Copyright 2018 Daniel James.
|
||||
// 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/detail/reference_content.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<int, boost::detail::make_reference_content<int>::type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<boost::detail::reference_content<int&>, boost::detail::make_reference_content<int&>::type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<int, boost::detail::make_reference_content<>::apply<int>::type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<boost::detail::reference_content<int&>, boost::detail::make_reference_content<>::apply<int&>::type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::has_nothrow_copy<boost::detail::make_reference_content<int&>::type>::value));
|
||||
|
||||
int main() {}
|
@ -17,6 +17,11 @@
|
||||
#include <cstddef> // size_t
|
||||
#include <cwchar>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE namespace boost { namespace detail {
|
||||
#define BOOST_UTF8_END_NAMESPACE } }
|
||||
@ -46,6 +51,9 @@ namespace std{
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
// Directory of the test executable
|
||||
std::string executable_dir;
|
||||
|
||||
template<std::size_t s>
|
||||
struct test_data
|
||||
{
|
||||
@ -133,7 +141,7 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
// Send our test UTF-8 data to file
|
||||
{
|
||||
std::ofstream ofs;
|
||||
ofs.open("test.dat");
|
||||
ofs.open((executable_dir + "test.dat").c_str());
|
||||
std::copy(
|
||||
td::utf8_encoding,
|
||||
td::utf8_encoding + sizeof(td::utf8_encoding) / sizeof(unsigned char),
|
||||
@ -146,7 +154,7 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
{
|
||||
std::wifstream ifs;
|
||||
ifs.imbue(utf8_locale);
|
||||
ifs.open("test.dat");
|
||||
ifs.open((executable_dir + "test.dat").c_str());
|
||||
|
||||
std::wint_t item = 0;
|
||||
// note can't use normal vector from iterator constructor because
|
||||
@ -168,7 +176,7 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
{
|
||||
std::wofstream ofs;
|
||||
ofs.imbue(utf8_locale);
|
||||
ofs.open("test2.dat");
|
||||
ofs.open((executable_dir + "test2.dat").c_str());
|
||||
std::copy(
|
||||
from_file.begin(),
|
||||
from_file.end(),
|
||||
@ -181,21 +189,21 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
typedef std::istream_iterator<utf8_t> is_iter;
|
||||
is_iter end_iter;
|
||||
|
||||
std::ifstream ifs1("test.dat");
|
||||
std::ifstream ifs1((executable_dir + "test.dat").c_str());
|
||||
is_iter it1(ifs1);
|
||||
std::vector<utf8_t> data1;
|
||||
std::copy(it1, end_iter, std::back_inserter(data1));
|
||||
|
||||
std::ifstream ifs2("test2.dat");
|
||||
std::ifstream ifs2((executable_dir + "test2.dat").c_str());
|
||||
is_iter it2(ifs2);
|
||||
std::vector<utf8_t> data2;
|
||||
std::copy(it2, end_iter, std::back_inserter(data2));
|
||||
|
||||
BOOST_TEST(data1 == data2);
|
||||
BOOST_TEST_ALL_EQ(data1.begin(), data1.end(), data2.begin(), data2.end());
|
||||
}
|
||||
|
||||
// some libraries have trouble that only shows up with longer strings
|
||||
|
||||
|
||||
const wchar_t * test3_data = L"\
|
||||
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
|
||||
<!DOCTYPE boost_serialization>\
|
||||
@ -223,13 +231,13 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
</a>\
|
||||
</boost_serialization>\
|
||||
";
|
||||
|
||||
|
||||
// Send the UCS4_data back out, converting to UTF-8
|
||||
std::size_t l = std::wcslen(test3_data);
|
||||
{
|
||||
std::wofstream ofs;
|
||||
ofs.imbue(utf8_locale);
|
||||
ofs.open("test3.dat");
|
||||
ofs.open((executable_dir + "test3.dat").c_str());
|
||||
std::copy(
|
||||
test3_data,
|
||||
test3_data + l,
|
||||
@ -241,7 +249,7 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
{
|
||||
std::wifstream ifs;
|
||||
ifs.imbue(utf8_locale);
|
||||
ifs.open("test3.dat");
|
||||
ifs.open((executable_dir + "test3.dat").c_str());
|
||||
ifs >> std::noskipws;
|
||||
BOOST_TEST(
|
||||
std::equal(
|
||||
@ -261,29 +269,48 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
BOOST_TEST_EQ(utf8_len, res);
|
||||
}
|
||||
|
||||
// Test that length calculation detects character boundaries
|
||||
{
|
||||
std::codecvt<wchar_t, char, std::mbstate_t> const& fac = std::use_facet< std::codecvt<wchar_t, char, std::mbstate_t> >(utf8_locale);
|
||||
std::mbstate_t mbs = std::mbstate_t();
|
||||
// The first 5 bytes of utf8_encoding contain 3 complete UTF-8 characters (taking 4 bytes in total) and 1 byte of an incomplete character.
|
||||
// This last byte should not be accounted by length().
|
||||
const int input_len = 5;
|
||||
const int utf8_len = 4;
|
||||
int res = fac.length(mbs, reinterpret_cast< const char* >(td::utf8_encoding), reinterpret_cast< const char* >(td::utf8_encoding + input_len), ~static_cast< std::size_t >(0u));
|
||||
BOOST_TEST_EQ(utf8_len, res);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char * argv[]){
|
||||
main(int argc, char * argv[]) {
|
||||
if (argc > 0) {
|
||||
// We need to save the path to executable to create test files in the same directory.
|
||||
// This allows running different configurations of the test (release/debug, different C++ versions, etc.) in parallel.
|
||||
std::string exec_name = argv[0];
|
||||
std::string::size_type last_dir_sep_pos = exec_name.find_last_of("/\\");
|
||||
if (last_dir_sep_pos != std::string::npos)
|
||||
executable_dir = exec_name.substr(0, last_dir_sep_pos + 1); // include the trailing directory separator
|
||||
}
|
||||
|
||||
int retval = 1;
|
||||
BOOST_TRY{
|
||||
retval = test_main(argc, argv);
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||
BOOST_CATCH(const std::exception & e){
|
||||
BOOST_ERROR(e.what());
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||
BOOST_CATCH(const std::exception & e){
|
||||
BOOST_ERROR(e.what());
|
||||
}
|
||||
#endif
|
||||
BOOST_CATCH(...){
|
||||
BOOST_ERROR("failed with uncaught exception:");
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
int error_count = boost::report_errors();
|
||||
if(error_count > 0)
|
||||
if (error_count > 0)
|
||||
retval = error_count;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user