forked from boostorg/utility
Compare commits
52 Commits
boost-1.72
...
boost-1.78
Author | SHA1 | Date | |
---|---|---|---|
05e0d1688d | |||
dcaf2c0e3b | |||
71107238eb | |||
28c90abaf0 | |||
2cc83cc7d5 | |||
e8fc7cc2a1 | |||
09d24c0516 | |||
3f51807f24 | |||
a04a0d9531 | |||
449a03e13d | |||
dc59afafdb | |||
e845ae6752 | |||
375382e1e6 | |||
6cca23a63a | |||
9ad7e51912 | |||
601f80e8c1 | |||
c960bef6ef | |||
6ab27d5689 | |||
3e2f0199cf | |||
9c2aa8d193 | |||
601fc9371f | |||
7aafdf92a0 | |||
a7570d7608 | |||
37168a3f4b | |||
e56171989a | |||
f00a5bf0d3 | |||
a4feaf4f24 | |||
688628f764 | |||
8faf831bd1 | |||
25cb7aa122 | |||
0ae5cebc7f | |||
1caa002121 | |||
691f3238d7 | |||
8b6da499a3 | |||
6e6d0777e8 | |||
64fffa0f97 | |||
5da340a2a4 | |||
9a4cff038b | |||
0c059a50ad | |||
bdc5b5cf3a | |||
86e7caefea | |||
7953ba56ba | |||
46f72656b3 | |||
e3a2a06011 | |||
a4752e066d | |||
957aeba2e9 | |||
2b436d7d50 | |||
882c9c86c4 | |||
c81d8e3990 | |||
6b62dcc504 | |||
91ebdcd1dd | |||
e8d2b2ba76 |
424
.github/workflows/ci.yml
vendored
Normal file
424
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,424 @@
|
||||
# Copyright 2021 Andrey Semashev
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
name: CI
|
||||
|
||||
on:
|
||||
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.4
|
||||
cxxstd: "98,0x"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.6
|
||||
cxxstd: "03,0x"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.7
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-7
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- g++-9
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-11
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- name: UBSAN
|
||||
toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
ubsan: 1
|
||||
build_variant: debug
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-11
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-7
|
||||
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install:
|
||||
- clang-8
|
||||
- g++-7
|
||||
gcc_toolchain: 7
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
ubsan: 1
|
||||
build_variant: debug
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-12
|
||||
- libc++-12-dev
|
||||
- libc++abi-12-dev
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
|
||||
timeout-minutes: 60
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
steps:
|
||||
- name: Setup environment
|
||||
run: |
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
fi
|
||||
if [ -n "${{matrix.container}}" ]
|
||||
then
|
||||
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 git cmake
|
||||
fi
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
|
||||
SOURCES=(${{join(matrix.sources, ' ')}})
|
||||
for key in "${SOURCE_KEYS[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
wget -O - "$key" | sudo apt-key add - && break || sleep 2
|
||||
done
|
||||
done
|
||||
if [ ${#SOURCES[@]} -gt 0 ]
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS=("-y")
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS=0
|
||||
SOFTWARE_PROPERTIES_VERSION="$(dpkg-query --showformat='${Version}' --show software-properties-common)"
|
||||
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.96.24.20"
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS+=("-n")
|
||||
fi
|
||||
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.98.10"
|
||||
then
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS=1
|
||||
fi
|
||||
for source in "${SOURCES[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
|
||||
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
|
||||
then
|
||||
case "$source" in
|
||||
"ppa:"*)
|
||||
APT_ADD_REPO_ARGS+=("-P")
|
||||
;;
|
||||
"deb "*)
|
||||
APT_ADD_REPO_ARGS+=("-S")
|
||||
;;
|
||||
*)
|
||||
APT_ADD_REPO_ARGS+=("-U")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
APT_ADD_REPO_ARGS+=("$source")
|
||||
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
|
||||
done
|
||||
done
|
||||
fi
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
|
||||
|
||||
- name: Setup GCC Toolchain
|
||||
if: matrix.gcc_toolchain
|
||||
run: |
|
||||
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
|
||||
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
|
||||
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT"
|
||||
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
|
||||
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
|
||||
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
DEPINST_ARGS=()
|
||||
GIT_VERSION="$(git --version | sed -e 's/git version //')"
|
||||
GIT_HAS_JOBS=1
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
|
||||
then
|
||||
GIT_HAS_JOBS=0
|
||||
fi
|
||||
else
|
||||
declare -a GIT_VER=(${GIT_VERSION//./ })
|
||||
declare -a GIT_MIN_VER=(2 8 0)
|
||||
for ((i=0; i<${#GIT_VER[@]}; i++))
|
||||
do
|
||||
if [ -z "${GIT_MIN_VER[i]}" ]
|
||||
then
|
||||
GIT_MIN_VER[i]=0
|
||||
fi
|
||||
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
|
||||
then
|
||||
GIT_HAS_JOBS=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$GIT_HAS_JOBS" -ne 0 ]
|
||||
then
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
fi
|
||||
cd ..
|
||||
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
if [ -z "${{matrix.cmake_tests}}" ]
|
||||
then
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
|
||||
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
|
||||
fi
|
||||
echo " ;" >> ~/user-config.jam
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
if: matrix.cmake_tests == ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
B2_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[@]}"
|
356
.travis.yml
356
.travis.yml
@ -1,356 +0,0 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2019 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)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
# gcc, Linux
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: gcc-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
# clang, Linux
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.5 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.6 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.7 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-6-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.8 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-6-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-4
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
- libstdc++-6-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-5
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
- libstdc++-7-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-6
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- libstdc++-8-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
- libstdc++-8-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
- libstdc++-8-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
- libstdc++-9-dev
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
- libc++-9-dev
|
||||
- libc++abi-9-dev
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
# clang, OS X
|
||||
# OS X builds are slow on Travis CI
|
||||
# - os: osx
|
||||
# env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
# osx_image: xcode9.4
|
||||
#
|
||||
# - os: osx
|
||||
# env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
# osx_image: xcode10.3
|
||||
|
||||
- os: osx
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17
|
||||
osx_image: xcode11.2
|
||||
|
||||
install:
|
||||
- GIT_FETCH_JOBS=8
|
||||
- BOOST_BRANCH=develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
- 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/boost_install
|
||||
- git submodule init libs/headers
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/container_hash
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/detail
|
||||
- git submodule update --jobs $GIT_FETCH_JOBS
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/utility
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
|
||||
- ./b2 -j $BUILD_JOBS libs/utility/test toolset=$TOOLSET cxxstd=$CXXSTD ${CXXFLAGS:+cxxflags="$CXXFLAGS"} ${LINKFLAGS:+linkflags="$LINKFLAGS"}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
@ -3,12 +3,9 @@
|
||||
# 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
|
||||
|
||||
# Partial (add_subdirectory only) and experimental CMake support
|
||||
# Subject to change; please do not rely on the contents of this file yet.
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(BoostUtility LANGUAGES CXX)
|
||||
project(boost_utility VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_utility INTERFACE)
|
||||
add_library(Boost::utility ALIAS boost_utility)
|
||||
@ -18,8 +15,8 @@ target_include_directories(boost_utility INTERFACE include)
|
||||
target_link_libraries(boost_utility
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::io
|
||||
Boost::preprocessor
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
|
@ -16,8 +16,10 @@ Boost.Utility, part of collection of the [Boost C++ Libraries](https://github.co
|
||||
|
||||
### Build status
|
||||
|
||||
Master: [](https://travis-ci.org/boostorg/utility)
|
||||
Develop: [](https://travis-ci.org/boostorg/utility)
|
||||
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
|
||||
:-------------: | -------------- | -------- | ----------- | ------------ |
|
||||
[`master`](https://github.com/boostorg/utility/tree/master) | [](https://github.com/boostorg/utility/actions?query=branch%3Amaster) | [](https://ci.appveyor.com/project/Lastique/utility/branch/master) | [](http://www.boost.org/development/tests/master/developer/utility.html) | [](https://pdimov.github.io/boostdep-report/master/utility.html)
|
||||
[`develop`](https://github.com/boostorg/utility/tree/develop) | [](https://github.com/boostorg/utility/actions?query=branch%3Adevelop) | [](https://ci.appveyor.com/project/Lastique/utility/branch/develop) | [](http://www.boost.org/development/tests/develop/developer/utility.html) | [](https://pdimov.github.io/boostdep-report/develop/utility.html)
|
||||
|
||||
### License
|
||||
|
||||
|
23
appveyor.yml
23
appveyor.yml
@ -15,9 +15,10 @@ branches:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.0
|
||||
- TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: msvc-14.1
|
||||
@ -29,9 +30,15 @@ environment:
|
||||
CXXSTD: 14,17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: clang-win
|
||||
ADDRMD: 32,64
|
||||
ADDRMD: 32
|
||||
CXXSTD: 14,17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
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
|
||||
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: 03,11,14,1z
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
@ -49,9 +56,13 @@ environment:
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
CXXSTD: 03,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: 03,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
|
||||
@ -66,6 +77,7 @@ install:
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/io
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
@ -82,6 +94,7 @@ 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%
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/utility/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
|
@ -99,19 +99,6 @@ boostbook standalone_declval
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
;
|
||||
|
||||
xml ostream_string : ostream_string.qbk ;
|
||||
boostbook standalone_ostream_string
|
||||
:
|
||||
ostream_string
|
||||
:
|
||||
<xsl:param>root.filename=ostream_string
|
||||
<xsl:param>chunk.section.depth=0
|
||||
<xsl:param>chunk.first.sections=0
|
||||
<xsl:param>toc.section.depth=1
|
||||
<xsl:param>toc.max.depth=1
|
||||
<xsl:param>generate.section.toc.level=1
|
||||
;
|
||||
|
||||
xml string_ref : string_ref.qbk ;
|
||||
boostbook standalone_string_ref
|
||||
:
|
||||
@ -136,5 +123,5 @@ alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease :
|
||||
standalone_base_from_member standalone_compressed_pair
|
||||
standalone_declval standalone_ostream_string standalone_string_ref ;
|
||||
standalone_declval standalone_string_ref ;
|
||||
explicit boostrelease ;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[/
|
||||
/ Copyright (c) 2008 Howard Hinnant
|
||||
/ Copyright (c) 2009-20012 Vicente J. Botet Escriba
|
||||
/ Copyright (c) 2009-2012 Vicente J. Botet Escriba
|
||||
/
|
||||
/ 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)
|
||||
|
@ -1,78 +0,0 @@
|
||||
[/
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[article ostream_string
|
||||
[quickbook 1.5]
|
||||
[authors [Fernandes, Glen]]
|
||||
[copyright 2019 Glen Joseph Fernandes]
|
||||
[license Distributed under the Boost Software License, Version 1.0.]]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/utility/ostream_string.hpp> provides the function template
|
||||
`boost::ostream_string` for formatted output that satisfies the requirements of
|
||||
\[ostream.formatted.reqmts\].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The inserter for class template `basic_string_view` could be implemented as
|
||||
follows:
|
||||
|
||||
```
|
||||
template<class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os,
|
||||
const basic_string_view<charT, traits>& str)
|
||||
{
|
||||
return boost::ostream_string(os, str.data(), str.size());
|
||||
}
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
template<class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
ostream_string(std::basic_ostream<charT, traits>& os,
|
||||
const charT* data, std::size_t size);
|
||||
|
||||
} /* boost */
|
||||
```
|
||||
|
||||
[heading Free functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class charT, class traits> std::basic_ostream<charT, traits>&
|
||||
ostream_string(std::basic_ostream<charT, traits>& os, const charT* data,
|
||||
std::size_t size);`]
|
||||
[[variablelist
|
||||
[[Effects]
|
||||
[Behaves like a formatted inserter (as described in
|
||||
\[ostream.formatted.reqmts\]) of `os`. Creates a character sequence `seq` of
|
||||
`size` characters starting at `data`, each widened using `os.widen()`
|
||||
(\[basic.ios.members\]). Determines padding for `seq` as described in
|
||||
\[ostream.formatted.reqmts\]. Inserts `seq` into `os`. Calls `width(0)`.]]
|
||||
[[Returns][`os`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section History]
|
||||
|
||||
[heading boost 1.71]
|
||||
|
||||
* Glen Fernandes updated the implementation of the `basic_string_ref` and
|
||||
`basic_string_view` stream insertion operators to write directly to the
|
||||
`basic_streambuf` and refactored that functionality into this common utility.
|
||||
|
||||
[endsect]
|
@ -100,7 +100,7 @@ struct call_traits<T&>
|
||||
typedef T& param_type; // hh removed const
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 )
|
||||
#if BOOST_WORKAROUND( BOOST_BORLANDC, < 0x5A0 )
|
||||
// these are illegal specialisations; cv-qualifies applied to
|
||||
// references have no effect according to [8.3.2p1],
|
||||
// C++ Builder requires them though as it treats cv-qualified
|
||||
|
@ -109,6 +109,15 @@
|
||||
# pragma warning( disable : 4284 ) // complaint about return type of
|
||||
#endif // operator-> not begin a UDT
|
||||
|
||||
// Define BOOST_OPERATORS_CONSTEXPR to be like BOOST_CONSTEXPR but empty under MSVC < v19.22
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1922)
|
||||
#define BOOST_OPERATORS_CONSTEXPR
|
||||
#elif defined __sun
|
||||
#define BOOST_OPERATORS_CONSTEXPR
|
||||
#else
|
||||
#define BOOST_OPERATORS_CONSTEXPR BOOST_CONSTEXPR
|
||||
#endif
|
||||
|
||||
// In this section we supply the xxxx1 and xxxx2 forms of the operator
|
||||
// templates, which are explicitly targeted at the 1-type-argument and
|
||||
// 2-type-argument operator forms, respectively.
|
||||
@ -132,34 +141,34 @@ template <typename T> class empty_base {};
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct less_than_comparable2 : B
|
||||
{
|
||||
friend bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
|
||||
friend bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
|
||||
friend bool operator>(const U& x, const T& y) { return y < x; }
|
||||
friend bool operator<(const U& x, const T& y) { return y > x; }
|
||||
friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const U& x, const T& y) { return y < x; }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<(const U& x, const T& y) { return y > x; }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct less_than_comparable1 : B
|
||||
{
|
||||
friend bool operator>(const T& x, const T& y) { return y < x; }
|
||||
friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const T& x, const T& y) { return y < x; }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
|
||||
};
|
||||
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct equality_comparable2 : B
|
||||
{
|
||||
friend bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct equality_comparable1 : B
|
||||
{
|
||||
friend bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
// A macro which produces "name_2left" from "name".
|
||||
@ -362,7 +371,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> )
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct equivalent2 : B
|
||||
{
|
||||
friend bool operator==(const T& x, const U& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const T& x, const U& y)
|
||||
{
|
||||
return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
|
||||
}
|
||||
@ -371,7 +380,7 @@ struct equivalent2 : B
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct equivalent1 : B
|
||||
{
|
||||
friend bool operator==(const T&x, const T&y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const T&x, const T&y)
|
||||
{
|
||||
return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
|
||||
}
|
||||
@ -380,28 +389,28 @@ struct equivalent1 : B
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct partially_ordered2 : B
|
||||
{
|
||||
friend bool operator<=(const T& x, const U& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const U& y)
|
||||
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>=(const T& x, const U& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const U& y)
|
||||
{ return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>(const U& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const U& x, const T& y)
|
||||
{ return y < x; }
|
||||
friend bool operator<(const U& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<(const U& x, const T& y)
|
||||
{ return y > x; }
|
||||
friend bool operator<=(const U& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const U& x, const T& y)
|
||||
{ return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
|
||||
friend bool operator>=(const U& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const U& x, const T& y)
|
||||
{ return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct partially_ordered1 : B
|
||||
{
|
||||
friend bool operator>(const T& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const T& x, const T& y)
|
||||
{ return y < x; }
|
||||
friend bool operator<=(const T& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const T& y)
|
||||
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>=(const T& x, const T& y)
|
||||
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const T& y)
|
||||
{ return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: conditional<
|
||||
@ -151,7 +151,7 @@ struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
|
||||
|
||||
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||
: tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
|
||||
@ -177,7 +177,7 @@ struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), F
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||
struct tr1_result_of_impl<R (T0::*)
|
||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
||||
|
190
include/boost/utility/detail/result_of_variadic.hpp
Normal file
190
include/boost/utility/detail/result_of_variadic.hpp
Normal file
@ -0,0 +1,190 @@
|
||||
// Boost result_of library
|
||||
|
||||
// Copyright Douglas Gregor 2004. 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)
|
||||
|
||||
// Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012.
|
||||
// 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)
|
||||
|
||||
// For more information, see http://www.boost.org/libs/utility
|
||||
|
||||
#ifndef BOOST_RESULT_OF_HPP
|
||||
# error Boost result_of - do not include this file!
|
||||
#endif
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct tr1_result_of<F(Args...)>
|
||||
: conditional<
|
||||
is_pointer<F>::value || is_member_function_pointer<F>::value
|
||||
, boost::detail::tr1_result_of_impl<
|
||||
typename remove_cv<F>::type,
|
||||
typename remove_cv<F>::type(Args...),
|
||||
(boost::detail::result_of_has_result_type<F>::value)>
|
||||
, boost::detail::tr1_result_of_impl<
|
||||
F,
|
||||
F(Args...),
|
||||
(boost::detail::result_of_has_result_type<F>::value)> >::type { };
|
||||
|
||||
#ifdef BOOST_RESULT_OF_USE_DECLTYPE
|
||||
template<typename F, typename... Args>
|
||||
struct result_of<F(Args...)>
|
||||
: detail::cpp0x_result_of<F(Args...)> { };
|
||||
#endif // BOOST_RESULT_OF_USE_DECLTYPE
|
||||
|
||||
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
||||
template<typename F, typename... Args>
|
||||
struct result_of<F(Args...)>
|
||||
: conditional<detail::result_of_has_result_type<F>::value || detail::result_of_has_result<F>::value,
|
||||
tr1_result_of<F(Args...)>,
|
||||
detail::cpp0x_result_of<F(Args...)> >::type { };
|
||||
#endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
|
||||
|
||||
#if defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct cpp0x_result_of<F(Args...)>
|
||||
: conditional<
|
||||
is_member_function_pointer<F>::value
|
||||
, detail::tr1_result_of_impl<
|
||||
typename remove_cv<F>::type,
|
||||
typename remove_cv<F>::type(Args...), false
|
||||
>
|
||||
, detail::cpp0x_result_of_impl<
|
||||
F(Args...)
|
||||
>
|
||||
>::type
|
||||
{};
|
||||
|
||||
#ifdef BOOST_NO_SFINAE_EXPR
|
||||
|
||||
template<typename F>
|
||||
struct result_of_callable_fun_2;
|
||||
|
||||
template<typename R, typename... Args>
|
||||
struct result_of_callable_fun_2<R(Args...)> {
|
||||
R operator()(Args...) const;
|
||||
typedef result_of_private_type const &(*pfn_t)(...);
|
||||
operator pfn_t() const volatile;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
struct result_of_callable_fun
|
||||
: result_of_callable_fun_2<F>
|
||||
{};
|
||||
|
||||
template<typename F>
|
||||
struct result_of_callable_fun<F *>
|
||||
: result_of_callable_fun_2<F>
|
||||
{};
|
||||
|
||||
template<typename F>
|
||||
struct result_of_select_call_wrapper_type
|
||||
: conditional<
|
||||
is_class<typename remove_reference<F>::type>::value,
|
||||
result_of_wrap_callable_class<F>,
|
||||
type_identity<result_of_callable_fun<typename remove_cv<typename remove_reference<F>::type>::type> >
|
||||
>::type
|
||||
{};
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct result_of_is_callable {
|
||||
typedef typename result_of_select_call_wrapper_type<F>::type wrapper_t;
|
||||
static const bool value = (
|
||||
sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
|
||||
(boost::declval<wrapper_t>()(boost::declval<Args>()...), result_of_weird_type())
|
||||
))
|
||||
);
|
||||
typedef integral_constant<bool, value> type;
|
||||
};
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct cpp0x_result_of_impl<F(Args...), true>
|
||||
: lazy_enable_if<
|
||||
result_of_is_callable<F, Args...>
|
||||
, cpp0x_result_of_impl<F(Args...), false>
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct cpp0x_result_of_impl<F(Args...), false>
|
||||
{
|
||||
typedef decltype(
|
||||
boost::declval<F>()(
|
||||
boost::declval<Args>()...
|
||||
)
|
||||
) type;
|
||||
};
|
||||
|
||||
#else // BOOST_NO_SFINAE_EXPR
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct cpp0x_result_of_impl<F(Args...),
|
||||
typename result_of_always_void<decltype(
|
||||
boost::declval<F>()(
|
||||
boost::declval<Args>()...
|
||||
)
|
||||
)>::type> {
|
||||
typedef decltype(
|
||||
boost::declval<F>()(
|
||||
boost::declval<Args>()...
|
||||
)
|
||||
) type;
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_SFINAE_EXPR
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
|
||||
|
||||
template<typename F, typename... Args>
|
||||
struct result_of<F(Args...)>
|
||||
: tr1_result_of<F(Args...)> { };
|
||||
|
||||
#endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename R, typename FArgs, typename... Args>
|
||||
struct tr1_result_of_impl<R (*)(Args...), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs, typename... Args>
|
||||
struct tr1_result_of_impl<R (&)(Args...), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs, typename C, typename... Args>
|
||||
struct tr1_result_of_impl<R (C::*)(Args...), FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs, typename C, typename... Args>
|
||||
struct tr1_result_of_impl<R (C::*)(Args...) const, FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs, typename C, typename... Args>
|
||||
struct tr1_result_of_impl<R (C::*)(Args...) volatile, FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template<typename R, typename FArgs, typename C, typename... Args>
|
||||
struct tr1_result_of_impl<R (C::*)(Args...) const volatile, FArgs, false>
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_UTILITY_OSTREAM_STRING_HPP
|
||||
#define BOOST_UTILITY_OSTREAM_STRING_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template<class charT, class traits>
|
||||
inline std::size_t
|
||||
oss_put(std::basic_ostream<charT, traits>& os, const charT* data,
|
||||
std::size_t size)
|
||||
{
|
||||
return static_cast<std::size_t>(os.rdbuf()->sputn(data, size));
|
||||
}
|
||||
|
||||
template<class charT, class traits>
|
||||
inline bool
|
||||
oss_fill(std::basic_ostream<charT, traits>& os, std::size_t size)
|
||||
{
|
||||
charT c = os.fill();
|
||||
charT fill[] = { c, c, c, c, c, c, c, c };
|
||||
enum {
|
||||
chunk = sizeof fill / sizeof(charT)
|
||||
};
|
||||
for (; size > chunk; size -= chunk) {
|
||||
if (boost::detail::oss_put(os, fill, chunk) != chunk) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return boost::detail::oss_put(os, fill, size) == size;
|
||||
}
|
||||
|
||||
template<class charT, class traits>
|
||||
class oss_guard {
|
||||
public:
|
||||
explicit oss_guard(std::basic_ostream<charT, traits>& os) BOOST_NOEXCEPT
|
||||
: os_(&os) { }
|
||||
~oss_guard() BOOST_NOEXCEPT_IF(false) {
|
||||
if (os_) {
|
||||
os_->setstate(std::basic_ostream<charT, traits>::badbit);
|
||||
}
|
||||
}
|
||||
void release() BOOST_NOEXCEPT {
|
||||
os_ = 0;
|
||||
}
|
||||
private:
|
||||
oss_guard(const oss_guard&);
|
||||
oss_guard& operator=(const oss_guard&);
|
||||
std::basic_ostream<charT, traits>* os_;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class charT, class traits>
|
||||
inline std::basic_ostream<charT, traits>&
|
||||
ostream_string(std::basic_ostream<charT, traits>& os, const charT* data,
|
||||
std::size_t size)
|
||||
{
|
||||
typedef std::basic_ostream<charT, traits> stream;
|
||||
detail::oss_guard<charT, traits> guard(os);
|
||||
typename stream::sentry entry(os);
|
||||
if (entry) {
|
||||
std::size_t width = static_cast<std::size_t>(os.width());
|
||||
if (width <= size) {
|
||||
if (detail::oss_put(os, data, size) != size) {
|
||||
return os;
|
||||
}
|
||||
} else if ((os.flags() & stream::adjustfield) == stream::left) {
|
||||
if (detail::oss_put(os, data, size) != size ||
|
||||
!detail::oss_fill(os, width - size)) {
|
||||
return os;
|
||||
}
|
||||
} else if (!detail::oss_fill(os, width - size) ||
|
||||
detail::oss_put(os, data, size) != size) {
|
||||
return os;
|
||||
}
|
||||
os.width(0);
|
||||
}
|
||||
guard.release();
|
||||
return os;
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
@ -10,13 +10,6 @@
|
||||
#define BOOST_RESULT_OF_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/facilities/intercept.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
@ -29,6 +22,20 @@
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
|
||||
# undef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
|
||||
# define BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
|
||||
#endif
|
||||
#ifdef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/iteration/iterate.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||
# include <boost/preprocessor/facilities/intercept.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
||||
# define BOOST_RESULT_OF_NUM_ARGS 16
|
||||
#endif
|
||||
@ -217,8 +224,12 @@ struct tr1_result_of_impl<F, FArgs, false>
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
|
||||
#include BOOST_PP_ITERATE()
|
||||
#ifndef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
|
||||
# include <boost/utility/detail/result_of_variadic.hpp>
|
||||
#else
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// inform dependency trackers, as they can't see through macro includes
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/utility/ostream_string.hpp>
|
||||
#include <boost/io/ostream_put.hpp>
|
||||
#include <boost/utility/string_ref_fwd.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
@ -427,7 +427,7 @@ namespace boost {
|
||||
template<class charT, class traits>
|
||||
inline std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
|
||||
return boost::ostream_string(os, str.data(), str.size());
|
||||
return boost::io::ostream_put(os, str.data(), str.size());
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -20,10 +20,9 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/utility/ostream_string.hpp>
|
||||
#include <boost/io/ostream_put.hpp>
|
||||
#include <boost/utility/string_view_fwd.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
@ -578,7 +577,7 @@ namespace boost {
|
||||
inline std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os,
|
||||
const basic_string_view<charT,traits>& str) {
|
||||
return boost::ostream_string(os, str.data(), str.size());
|
||||
return boost::io::ostream_put(os, str.data(), str.size());
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -652,6 +651,9 @@ namespace boost {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Forward declaration of Boost.ContainerHash function
|
||||
template <class It> std::size_t hash_range(It, It);
|
||||
|
||||
template <class charT, class traits>
|
||||
std::size_t hash_value(basic_string_view<charT, traits> s) {
|
||||
return boost::hash_range(s.begin(), s.end());
|
||||
|
@ -1,4 +1,5 @@
|
||||
// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -21,15 +22,10 @@
|
||||
// issues, by clearing the bytes of T, before constructing the T object it
|
||||
// contains. More details on these issues are at libs/utility/value_init.htm
|
||||
|
||||
#include <boost/aligned_storage.hpp>
|
||||
#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/swap.hpp>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
@ -60,92 +56,58 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct zero_init
|
||||
{
|
||||
zero_init()
|
||||
{
|
||||
}
|
||||
|
||||
zero_init( void * p, std::size_t n )
|
||||
{
|
||||
std::memset( p, 0, n );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T>
|
||||
class initialized
|
||||
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
|
||||
: detail::zero_init
|
||||
#endif
|
||||
{
|
||||
private :
|
||||
struct wrapper
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
||||
typename
|
||||
#endif
|
||||
remove_const<T>::type data;
|
||||
private:
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
wrapper()
|
||||
:
|
||||
data()
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
wrapper(T const & arg)
|
||||
:
|
||||
data(arg)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
mutable
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
||||
typename
|
||||
#endif
|
||||
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
wrapper * wrapper_address() const
|
||||
{
|
||||
return static_cast<wrapper *>( static_cast<void*>(&x));
|
||||
}
|
||||
T data_;
|
||||
|
||||
public :
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
initialized()
|
||||
{
|
||||
initialized():
|
||||
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
|
||||
std::memset(&x, 0, sizeof(x));
|
||||
zero_init( &const_cast< char& >( reinterpret_cast<char const volatile&>( data_ ) ), sizeof( data_ ) ),
|
||||
#endif
|
||||
new (wrapper_address()) wrapper();
|
||||
data_()
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
initialized(initialized const & arg)
|
||||
explicit initialized(T const & arg): data_( arg )
|
||||
{
|
||||
new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
explicit initialized(T const & arg)
|
||||
{
|
||||
new (wrapper_address()) wrapper(arg);
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
initialized & operator=(initialized const & arg)
|
||||
{
|
||||
// Assignment is only allowed when T is non-const.
|
||||
BOOST_STATIC_ASSERT( ! is_const<T>::value );
|
||||
*wrapper_address() = static_cast<wrapper const &>(*(arg.wrapper_address()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
~initialized()
|
||||
{
|
||||
wrapper_address()->wrapper::~wrapper();
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
T const & data() const
|
||||
{
|
||||
return wrapper_address()->data;
|
||||
return data_;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
T& data()
|
||||
{
|
||||
return wrapper_address()->data;
|
||||
return data_;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
@ -157,13 +119,13 @@ class initialized
|
||||
BOOST_GPU_ENABLED
|
||||
operator T const &() const
|
||||
{
|
||||
return wrapper_address()->data;
|
||||
return data_;
|
||||
}
|
||||
|
||||
BOOST_GPU_ENABLED
|
||||
operator T&()
|
||||
{
|
||||
return wrapper_address()->data;
|
||||
return data_;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
49
index.html
49
index.html
@ -12,30 +12,31 @@
|
||||
<p>The Boost Utility Library isn't really a single library at all. It is just a
|
||||
collection for components too small to be called libraries in their own right.</p>
|
||||
<p>But that doesn't mean there isn't useful stuff here. Take a look:</p>
|
||||
<blockquote>
|
||||
<p>
|
||||
<a href="../core/doc/html/core/addressof.html">addressof</a> (moved to the Boost.Core library)<br>
|
||||
<a href="doc/html/base_from_member.html">base_from_member</a><br>
|
||||
<a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a><br>
|
||||
<a href="call_traits.htm">call_traits</a><br>
|
||||
<a href="../core/doc/html/core/checked_delete.html">checked_delete</a> (moved to the Boost.Core library)<br>
|
||||
<a href="doc/html/compressed_pair.html">compressed_pair</a><br>
|
||||
<a href="../type_traits/doc/html/boost_typetraits/reference/declval.html">declval</a> (moved to the Boost.TypeTraits library)<br>
|
||||
<a href="../core/doc/html/core/enable_if.html">enable_if</a> (moved to the Boost.Core library)<br>
|
||||
<a href="in_place_factories.html">in_place_factory</a><br>
|
||||
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
|
||||
<a href="../iterator/doc/generator_iterator.htm">generator iterator adaptors</a> (moved to the Boost.Iterator library)<br>
|
||||
<a href="../iterator/doc/html/iterator/algorithms/next_prior.html">next/prior</a> (moved to the Boost.Iterator library)<br>
|
||||
<a href="../core/doc/html/core/noncopyable.html">noncopyable</a> (moved to the Boost.Core library)<br>
|
||||
<a href="operators.htm">operators</a><br>
|
||||
<a href="utility.htm#result_of">result_of</a><br>
|
||||
<a href="throw_exception.html">throw_exception</a><br>
|
||||
<a href="utility.htm">utility</a><br>
|
||||
<a href="doc/html/ostream_string.html">ostream_string</a><br>
|
||||
<a href="doc/html/string_ref.html">string_ref</a><br>
|
||||
<a href="value_init.htm">value_init</a><br>
|
||||
</p>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li><a href="doc/html/base_from_member.html">base_from_member</a></li>
|
||||
<li><a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a></li>
|
||||
<li><a href="call_traits.htm">call_traits</a></li>
|
||||
<li><a href="doc/html/compressed_pair.html">compressed_pair</a></li>
|
||||
<li><a href="in_place_factories.html">in_place_factory</a></li>
|
||||
<li><a href="iterator_adaptors.htm">iterator_adaptors</a></li>
|
||||
<li><a href="operators.htm">operators</a></li>
|
||||
<li><a href="utility.htm#result_of">result_of</a></li>
|
||||
<li><a href="throw_exception.html">throw_exception</a></li>
|
||||
<li><a href="utility.htm">utility</a></li>
|
||||
<li><a href="doc/html/string_ref.html">string_ref</a></li>
|
||||
<li><a href="value_init.htm">value_init</a></li>
|
||||
</ul>
|
||||
<p>Over time useful stuff here has moved to more appropriate Boost libraries:</p>
|
||||
<ul>
|
||||
<li><a href="../core/doc/html/core/addressof.html">addressof</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../core/doc/html/core/checked_delete.html">checked_delete</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../type_traits/doc/html/boost_typetraits/reference/declval.html">declval</a> (moved to Boost.TypeTraits)</li>
|
||||
<li><a href="../core/doc/html/core/enable_if.html">enable_if</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../iterator/doc/generator_iterator.htm">generator iterator adaptors</a> (moved to Boost.Iterator)</li>
|
||||
<li><a href="../iterator/doc/html/iterator/algorithms/next_prior.html">next/prior</a> (moved to Boost.Iterator)</li>
|
||||
<li><a href="../core/doc/html/core/noncopyable.html">noncopyable</a> (moved to Boost.Core)</li>
|
||||
<li><a href="../io/doc/html/io.html">ostream_string</a> (moved to Boost.IO)</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See
|
||||
|
@ -13,7 +13,8 @@
|
||||
"Memory",
|
||||
"Miscellaneous",
|
||||
"Patterns"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/call_traits",
|
||||
@ -25,7 +26,8 @@
|
||||
"documentation": "call_traits.htm",
|
||||
"category": [
|
||||
"Generic"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/compressed_pair",
|
||||
@ -38,7 +40,8 @@
|
||||
"category": [
|
||||
"Data",
|
||||
"Patterns"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/identity_type",
|
||||
@ -53,7 +56,8 @@
|
||||
],
|
||||
"maintainers": [
|
||||
"Lorenzo Caminiti <lorcaminiti -at- gmail.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/in_place_factories",
|
||||
@ -65,7 +69,8 @@
|
||||
"documentation": "in_place_factories.html",
|
||||
"category": [
|
||||
"Generic"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/operators",
|
||||
@ -83,20 +88,8 @@
|
||||
],
|
||||
"maintainers": [
|
||||
"Daniel Frey <d.frey -at- gmx.de>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "utility/ostream_string",
|
||||
"name": "ostream_string",
|
||||
"description": "String formatted output function.",
|
||||
"documentation": "doc/html/ostream_string.html",
|
||||
"category": [
|
||||
"IO"
|
||||
],
|
||||
"authors": "Glen Fernandes",
|
||||
"maintainers": [
|
||||
"Glen Fernandes <glenjofe -at- gmail.com>"
|
||||
]
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/result_of",
|
||||
@ -109,7 +102,8 @@
|
||||
"authors": "",
|
||||
"maintainers": [
|
||||
"Daniel Walker <daniel.j.walker -at- gmail.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/string_ref",
|
||||
@ -122,7 +116,8 @@
|
||||
"authors": "Marshall Clow",
|
||||
"maintainers": [
|
||||
"Marshall Clow <marshall -at- idio.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
},
|
||||
{
|
||||
"key": "utility/value_initialized",
|
||||
@ -134,6 +129,7 @@
|
||||
"documentation": "value_init.htm",
|
||||
"category": [
|
||||
"Miscellaneous"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
]
|
||||
|
@ -454,7 +454,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
</caption>
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<td colspan="4">
|
||||
<table align="center" border="1">
|
||||
<caption>
|
||||
<em>Key</em>
|
||||
@ -482,6 +482,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<th>Supplied Operations</th>
|
||||
|
||||
<th>Requirements</th>
|
||||
|
||||
<th>Propagates <code>constexpr</code>?</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -496,6 +498,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>.<br>
|
||||
Return convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -513,6 +518,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < u</code>. <code>t > u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -524,6 +532,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>t == t1</code>.<br>
|
||||
Return convertible to <code>bool</code>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -537,6 +548,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>t == u</code>.<br>
|
||||
Return convertible to <code>bool</code>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -548,6 +562,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp += t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -560,6 +576,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp += u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -572,6 +590,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp -= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -584,6 +604,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp -= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -594,6 +616,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp -= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -606,6 +630,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp *= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -619,6 +645,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp *= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -630,6 +658,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp /= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -641,6 +671,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp /= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -651,6 +683,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp /= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -662,6 +696,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp %= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -673,6 +709,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp %= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -683,6 +721,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp %= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -694,6 +734,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp |= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -706,6 +748,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp |= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -717,6 +761,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp &= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -729,6 +775,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp &= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -740,6 +788,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp ^= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -752,6 +802,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp ^= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -762,6 +814,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(t); ++t</code><br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -772,6 +826,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(t); --t;</code><br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -784,6 +840,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp <<= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -796,6 +854,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp <<= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -808,6 +868,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp >>= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -820,6 +882,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp >>= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -831,6 +895,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>.<br>
|
||||
Return convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -842,6 +909,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < u</code>. <code>t > u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -856,6 +926,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>. <code>t == t1</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -874,6 +947,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code><br>
|
||||
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC < v19.22</a>)</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
@ -21,6 +21,7 @@ run compressed_pair_final_test.cpp ;
|
||||
run iterators_test.cpp ;
|
||||
|
||||
run operators_test.cpp ;
|
||||
compile operators_constexpr_test.cpp ;
|
||||
|
||||
compile result_of_test.cpp ;
|
||||
|
||||
@ -35,6 +36,8 @@ run string_view_test2.cpp ;
|
||||
run string_view_test_io.cpp ;
|
||||
|
||||
run value_init_test.cpp ;
|
||||
run value_init_test2.cpp ;
|
||||
run value_init_test3.cpp ;
|
||||
run value_init_workaround_test.cpp ;
|
||||
run initialized_test.cpp ;
|
||||
compile-fail value_init_test_fail1.cpp ;
|
||||
@ -42,5 +45,3 @@ compile-fail value_init_test_fail2.cpp ;
|
||||
compile-fail value_init_test_fail3.cpp ;
|
||||
compile-fail initialized_test_fail1.cpp ;
|
||||
compile-fail initialized_test_fail2.cpp ;
|
||||
|
||||
run ostream_string_test.cpp ;
|
||||
|
@ -376,7 +376,7 @@ void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>:
|
||||
reference r = t;
|
||||
const_reference cr = t;
|
||||
reference r2 = r;
|
||||
#ifndef __BORLANDC__
|
||||
#ifndef BOOST_BORLANDC
|
||||
// C++ Builder buglet:
|
||||
const_reference cr2 = r;
|
||||
#endif
|
||||
@ -393,7 +393,7 @@ void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>:
|
||||
unused_variable(v3);
|
||||
unused_variable(v4);
|
||||
unused_variable(v5);
|
||||
#ifndef __BORLANDC__
|
||||
#ifndef BOOST_BORLANDC
|
||||
unused_variable(r2);
|
||||
unused_variable(cr2);
|
||||
#endif
|
||||
|
59
test/operators_constexpr_test.cpp
Normal file
59
test/operators_constexpr_test.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && \
|
||||
(!defined(BOOST_MSVC) || (BOOST_MSVC >= 1922))
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
class Value
|
||||
: boost::operators<Value> {
|
||||
public:
|
||||
BOOST_OPERATORS_CONSTEXPR explicit Value(int v)
|
||||
: v_(v) { }
|
||||
|
||||
BOOST_OPERATORS_CONSTEXPR bool
|
||||
operator<(const Value& x) const {
|
||||
return v_ < x.v_;
|
||||
}
|
||||
|
||||
BOOST_OPERATORS_CONSTEXPR bool
|
||||
operator==(const Value& x) const {
|
||||
return v_ == x.v_;
|
||||
}
|
||||
|
||||
private:
|
||||
int v_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) == Value(2)));
|
||||
BOOST_STATIC_ASSERT(Value(1) != Value(2));
|
||||
BOOST_STATIC_ASSERT(Value(1) < Value(2));
|
||||
BOOST_STATIC_ASSERT(Value(1) <= Value(2));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) > Value(2)));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) >= Value(2)));
|
||||
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) == Value(1)));
|
||||
BOOST_STATIC_ASSERT(Value(2) != Value(1));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) < Value(1)));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) <= Value(1)));
|
||||
BOOST_STATIC_ASSERT(Value(2) > Value(1));
|
||||
BOOST_STATIC_ASSERT(Value(2) >= Value(1));
|
||||
|
||||
BOOST_STATIC_ASSERT(Value(1) == Value(1));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) != Value(1)));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) < Value(1)));
|
||||
BOOST_STATIC_ASSERT(Value(1) <= Value(1));
|
||||
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) > Value(1)));
|
||||
BOOST_STATIC_ASSERT(Value(1) >= Value(1));
|
||||
#endif
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include <iostream> // for std::cout (std::endl indirectly)
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
// avoiding a template version of true_value so as to not confuse VC++
|
||||
@ -50,9 +49,9 @@ namespace
|
||||
void operator!() const;
|
||||
|
||||
public:
|
||||
convertible_to_bool( const bool value ) : _value( value ) {}
|
||||
convertible_to_bool( const bool value ) : _value( value ) {}
|
||||
|
||||
operator unspecified_bool_type() const
|
||||
operator unspecified_bool_type() const
|
||||
{ return _value ? &convertible_to_bool::_value : 0; }
|
||||
};
|
||||
|
||||
@ -64,14 +63,14 @@ namespace
|
||||
, boost::shiftable<Wrapped1<T> >
|
||||
{
|
||||
public:
|
||||
explicit Wrapped1( T v = T() ) : _value(v) {}
|
||||
T value() const { return _value; }
|
||||
explicit Wrapped1( T v = T() ) : _value(v) {}
|
||||
T value() const { return _value; }
|
||||
|
||||
convertible_to_bool operator<(const Wrapped1& x) const
|
||||
convertible_to_bool operator<(const Wrapped1& x) const
|
||||
{ return _value < x._value; }
|
||||
convertible_to_bool operator==(const Wrapped1& x) const
|
||||
convertible_to_bool operator==(const Wrapped1& x) const
|
||||
{ return _value == x._value; }
|
||||
|
||||
|
||||
Wrapped1& operator+=(const Wrapped1& x)
|
||||
{ _value += x._value; return *this; }
|
||||
Wrapped1& operator-=(const Wrapped1& x)
|
||||
@ -92,14 +91,14 @@ namespace
|
||||
{ _value <<= x._value; return *this; }
|
||||
Wrapped1& operator>>=(const Wrapped1& x)
|
||||
{ _value >>= x._value; return *this; }
|
||||
Wrapped1& operator++() { ++_value; return *this; }
|
||||
Wrapped1& operator--() { --_value; return *this; }
|
||||
|
||||
Wrapped1& operator++() { ++_value; return *this; }
|
||||
Wrapped1& operator--() { --_value; return *this; }
|
||||
|
||||
private:
|
||||
T _value;
|
||||
};
|
||||
template <class T>
|
||||
T true_value(Wrapped1<T> x) { return x.value(); }
|
||||
T true_value(Wrapped1<T> x) { return x.value(); }
|
||||
|
||||
template <class T, class U>
|
||||
class Wrapped2
|
||||
@ -116,7 +115,7 @@ namespace
|
||||
{ return _value < x._value; }
|
||||
convertible_to_bool operator==(const Wrapped2& x) const
|
||||
{ return _value == x._value; }
|
||||
|
||||
|
||||
Wrapped2& operator+=(const Wrapped2& x)
|
||||
{ _value += x._value; return *this; }
|
||||
Wrapped2& operator-=(const Wrapped2& x)
|
||||
@ -139,7 +138,7 @@ namespace
|
||||
{ _value >>= x._value; return *this; }
|
||||
Wrapped2& operator++() { ++_value; return *this; }
|
||||
Wrapped2& operator--() { --_value; return *this; }
|
||||
|
||||
|
||||
convertible_to_bool operator<(U u) const
|
||||
{ return _value < u; }
|
||||
convertible_to_bool operator>(U u) const
|
||||
@ -163,7 +162,7 @@ namespace
|
||||
};
|
||||
template <class T, class U>
|
||||
T true_value(Wrapped2<T,U> x) { return x.value(); }
|
||||
|
||||
|
||||
template <class T>
|
||||
class Wrapped3
|
||||
: boost::equivalent<Wrapped3<T> >
|
||||
@ -176,12 +175,12 @@ namespace
|
||||
|
||||
convertible_to_bool operator<(const Wrapped3& x) const
|
||||
{ return _value < x._value; }
|
||||
|
||||
|
||||
private:
|
||||
T _value;
|
||||
};
|
||||
template <class T>
|
||||
T true_value(Wrapped3<T> x) { return x.value(); }
|
||||
T true_value(Wrapped3<T> x) { return x.value(); }
|
||||
|
||||
template <class T, class U>
|
||||
class Wrapped4
|
||||
@ -198,7 +197,7 @@ namespace
|
||||
|
||||
convertible_to_bool operator<(const Wrapped4& x) const
|
||||
{ return _value < x._value; }
|
||||
|
||||
|
||||
convertible_to_bool operator<(U u) const
|
||||
{ return _value < u; }
|
||||
convertible_to_bool operator>(U u) const
|
||||
@ -209,7 +208,7 @@ namespace
|
||||
};
|
||||
template <class T, class U>
|
||||
T true_value(Wrapped4<T,U> x) { return x.value(); }
|
||||
|
||||
|
||||
// U must be convertible to T
|
||||
template <class T, class U>
|
||||
class Wrapped5
|
||||
@ -249,7 +248,7 @@ namespace
|
||||
};
|
||||
template <class T, class U>
|
||||
T true_value(Wrapped5<T,U> x) { return x.value(); }
|
||||
|
||||
|
||||
// U must be convertible to T
|
||||
template <class T, class U>
|
||||
class Wrapped6
|
||||
@ -291,7 +290,7 @@ namespace
|
||||
};
|
||||
template <class T, class U>
|
||||
T true_value(Wrapped6<T,U> x) { return x.value(); }
|
||||
|
||||
|
||||
// MyInt uses only the single template-argument form of all_operators<>
|
||||
typedef Wrapped1<int> MyInt;
|
||||
|
||||
@ -320,7 +319,7 @@ namespace
|
||||
BOOST_TEST( static_cast<bool>(x1 >= y1) == static_cast<bool>(x2 >= y2) );
|
||||
BOOST_TEST( static_cast<bool>(x1 > y1) == static_cast<bool>(x2 > y2) );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_less_than_comparable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -335,7 +334,7 @@ namespace
|
||||
BOOST_TEST( static_cast<bool>(x1 == y1) == static_cast<bool>(x2 == y2) );
|
||||
BOOST_TEST( static_cast<bool>(x1 != y1) == static_cast<bool>(x2 != y2) );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_equality_comparable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -349,7 +348,7 @@ namespace
|
||||
{
|
||||
BOOST_TEST( (x1 * y1).value() == (x2 * y2) );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_multipliable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -358,21 +357,21 @@ namespace
|
||||
test_multipliable_aux( y1, x1, y2, x2 );
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void test_value_equality(A a, B b)
|
||||
{
|
||||
BOOST_TEST(a.value() == b);
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void test_value_equality(A a, B b)
|
||||
{
|
||||
BOOST_TEST(a.value() == b);
|
||||
}
|
||||
|
||||
#define TEST_OP_R(op) test_value_equality(x1 op y1, x2 op y2)
|
||||
#define TEST_OP_L(op) test_value_equality(y1 op x1, y2 op x2)
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_addable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
TEST_OP_R(+);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_addable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -402,7 +401,7 @@ namespace
|
||||
if ( y2 != 0 )
|
||||
TEST_OP_R(/);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_dividable_left(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -418,7 +417,7 @@ namespace
|
||||
if ( y2 != 0 )
|
||||
TEST_OP_R(%);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_modable_left(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -432,7 +431,7 @@ namespace
|
||||
{
|
||||
TEST_OP_R(^);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_xorable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -440,13 +439,13 @@ namespace
|
||||
test_xorable_aux( x1, y1, x2, y2 );
|
||||
test_xorable_aux( y1, x1, y2, x2 );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_andable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
TEST_OP_R(&);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_andable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -454,13 +453,13 @@ namespace
|
||||
test_andable_aux( x1, y1, x2, y2 );
|
||||
test_andable_aux( y1, x1, y2, x2 );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_orable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
TEST_OP_R(|);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_orable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -468,21 +467,21 @@ namespace
|
||||
test_orable_aux( x1, y1, x2, y2 );
|
||||
test_orable_aux( y1, x1, y2, x2 );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_left_shiftable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
sanity_check( x1, y1, x2, y2 );
|
||||
TEST_OP_R(<<);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_right_shiftable(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
sanity_check( x1, y1, x2, y2 );
|
||||
TEST_OP_R(>>);
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class X2>
|
||||
void test_incrementable(X1 x1, X2 x2)
|
||||
{
|
||||
@ -490,7 +489,7 @@ namespace
|
||||
BOOST_TEST( (x1++).value() == x2++ );
|
||||
BOOST_TEST( x1.value() == x2 );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class X2>
|
||||
void test_decrementable(X1 x1, X2 x2)
|
||||
{
|
||||
@ -498,7 +497,7 @@ namespace
|
||||
BOOST_TEST( (x1--).value() == x2-- );
|
||||
BOOST_TEST( x1.value() == x2 );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_all(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -517,7 +516,7 @@ namespace
|
||||
test_incrementable( x1, x2 );
|
||||
test_decrementable( x1, x2 );
|
||||
}
|
||||
|
||||
|
||||
template <class X1, class Y1, class X2, class Y2>
|
||||
void test_left(X1 x1, Y1 y1, X2 x2, Y2 y2)
|
||||
{
|
||||
@ -534,7 +533,7 @@ namespace
|
||||
Big b1 = Big( randomizer() );
|
||||
Big b2 = Big( randomizer() );
|
||||
Small s = Small( randomizer() );
|
||||
|
||||
|
||||
test_all( Wrapped1<Big>(b1), Wrapped1<Big>(b2), b1, b2 );
|
||||
test_all( Wrapped2<Big, Small>(b1), s, b1, s );
|
||||
}
|
||||
@ -547,7 +546,7 @@ namespace
|
||||
{
|
||||
Big b1 = Big( randomizer() );
|
||||
Small s = Small( randomizer() );
|
||||
|
||||
|
||||
test_left( Wrapped6<Big, Small>(b1), s, b1, s );
|
||||
}
|
||||
};
|
||||
@ -612,9 +611,11 @@ main()
|
||||
Point x;
|
||||
x = x + Point(3, 4);
|
||||
x = x - Point(3, 4);
|
||||
|
||||
|
||||
cout << "Created point, and operated on it." << endl;
|
||||
|
||||
|
||||
#if !defined(UBSAN)
|
||||
// Using random values produce UB in various tests, such as shifting by more than the left operand capacity or signed integer overflows
|
||||
for (int n = 0; n < 1000; ++n) // was 10,000 but took too long (Beman)
|
||||
{
|
||||
boost::detail::minstd_rand r;
|
||||
@ -623,7 +624,7 @@ main()
|
||||
tester<long, long>()(r);
|
||||
tester<int, int>()(r);
|
||||
tester<int, signed char>()(r);
|
||||
|
||||
|
||||
tester<unsigned long, unsigned int>()(r);
|
||||
tester<unsigned long, unsigned char>()(r);
|
||||
tester<unsigned long, unsigned long>()(r);
|
||||
@ -638,8 +639,9 @@ main()
|
||||
tester_left<unsigned long, unsigned char>()(r);
|
||||
tester_left<unsigned int, unsigned char>()(r);
|
||||
}
|
||||
|
||||
|
||||
cout << "Did random tester loop." << endl;
|
||||
#endif // !defined(UBSAN)
|
||||
|
||||
MyInt i1(1);
|
||||
MyInt i2(2);
|
||||
@ -691,7 +693,7 @@ main()
|
||||
cout << "Created MyLong objects.\n";
|
||||
|
||||
PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>(j2 == j) );
|
||||
BOOST_TEST( static_cast<bool>(2 == j) );
|
||||
BOOST_TEST( static_cast<bool>(j2 == 2) );
|
||||
@ -721,41 +723,41 @@ main()
|
||||
BOOST_TEST( static_cast<bool>((j1 + 2) == 3) );
|
||||
BOOST_TEST( static_cast<bool>((1 + j2) == 3) );
|
||||
PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((j + 2) == 5) );
|
||||
BOOST_TEST( static_cast<bool>((3 + j2) == 5) );
|
||||
PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((j - 1) == 4) );
|
||||
PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((j * 2) == 8) );
|
||||
BOOST_TEST( static_cast<bool>((4 * j2) == 8) );
|
||||
PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((j / 2) == 4) );
|
||||
PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((j % 3) == 1) );
|
||||
PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) );
|
||||
|
||||
|
||||
PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((1 | j2 | j) == 7) );
|
||||
BOOST_TEST( static_cast<bool>((j1 | 2 | j) == 7) );
|
||||
BOOST_TEST( static_cast<bool>((j1 | j2 | 4) == 7) );
|
||||
PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((7 & j2) == 2) );
|
||||
BOOST_TEST( static_cast<bool>((j & 2) == 2) );
|
||||
PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) );
|
||||
|
||||
|
||||
PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>((3 ^ j1) == 2) );
|
||||
BOOST_TEST( static_cast<bool>((j ^ 1) == 2) );
|
||||
PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) );
|
||||
|
||||
|
||||
PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) );
|
||||
|
||||
BOOST_TEST( static_cast<bool>((j1 << 2) == 4) );
|
||||
@ -765,7 +767,7 @@ main()
|
||||
BOOST_TEST( static_cast<bool>((j >> 2) == 1) );
|
||||
BOOST_TEST( static_cast<bool>((j2 >> 1) == 1) );
|
||||
PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) );
|
||||
|
||||
|
||||
cout << "Performed tests on MyLong objects.\n";
|
||||
|
||||
MyChar k1(1);
|
||||
@ -788,7 +790,7 @@ main()
|
||||
BOOST_TEST( static_cast<bool>(k2 > k1) );
|
||||
BOOST_TEST( static_cast<bool>(k2 >= k1) );
|
||||
BOOST_TEST( static_cast<bool>(k2 >= k) );
|
||||
|
||||
|
||||
cout << "Performed tests on MyChar objects.\n";
|
||||
|
||||
MyShort l1(1);
|
||||
@ -802,7 +804,7 @@ main()
|
||||
cout << "Created MyShort objects.\n";
|
||||
|
||||
PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>(l2 == l) );
|
||||
BOOST_TEST( static_cast<bool>(2 == l) );
|
||||
BOOST_TEST( static_cast<bool>(l2 == 2) );
|
||||
@ -828,9 +830,9 @@ main()
|
||||
BOOST_TEST( static_cast<bool>(l2 >= l) );
|
||||
BOOST_TEST( static_cast<bool>(2 >= l) );
|
||||
BOOST_TEST( static_cast<bool>(l2 >= 2) );
|
||||
|
||||
|
||||
cout << "Performed tests on MyShort objects.\n";
|
||||
|
||||
|
||||
MyDoubleInt di1(1);
|
||||
MyDoubleInt di2(2.);
|
||||
MyDoubleInt half(0.5);
|
||||
@ -845,7 +847,7 @@ main()
|
||||
cout << "Created MyDoubleInt objects.\n";
|
||||
|
||||
PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>(di2 == di) );
|
||||
BOOST_TEST( static_cast<bool>(2 == di) );
|
||||
BOOST_TEST( static_cast<bool>(di == 2) );
|
||||
@ -892,7 +894,7 @@ main()
|
||||
cout << "Created MyLongInt objects.\n";
|
||||
|
||||
PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) );
|
||||
|
||||
|
||||
BOOST_TEST( static_cast<bool>(li2 == li) );
|
||||
BOOST_TEST( static_cast<bool>(2 == li) );
|
||||
BOOST_TEST( static_cast<bool>(li == 2) );
|
||||
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/utility/ostream_string.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.width(1);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, "xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == "xy");
|
||||
}
|
||||
{
|
||||
std::wostringstream os;
|
||||
os.width(1);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, L"xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == L"xy");
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.width(1);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, "xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == "xy");
|
||||
}
|
||||
{
|
||||
std::wostringstream os;
|
||||
os.width(1);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, L"xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == L"xy");
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.width(4);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, "xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == "xy..");
|
||||
}
|
||||
{
|
||||
std::wostringstream os;
|
||||
os.width(4);
|
||||
os.fill(L'.');
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, L"xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == L"xy..");
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.width(4);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, "xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == "..xy");
|
||||
}
|
||||
{
|
||||
std::wostringstream os;
|
||||
os.width(4);
|
||||
os.fill(L'.');
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, L"xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == L"..xy");
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.width(12);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, "xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == "xy..........");
|
||||
}
|
||||
{
|
||||
std::wostringstream os;
|
||||
os.width(12);
|
||||
os.fill(L'.');
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, L"xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == L"xy..........");
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
os.width(12);
|
||||
os.fill('.');
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, "xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == "..........xy");
|
||||
}
|
||||
{
|
||||
std::wostringstream os;
|
||||
os.width(12);
|
||||
os.fill(L'.');
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
boost::ostream_string(os, L"xy", 2);
|
||||
BOOST_TEST(os.good());
|
||||
BOOST_TEST(os.width() == 0);
|
||||
BOOST_TEST(os.str() == L"..........xy");
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
#include <cstddef> // for NULL, std::size_t, std::ptrdiff_t
|
||||
#include <cstring> // for std::strchr and std::strcmp
|
||||
#include <cstdlib> // for std::malloc and std::free
|
||||
#include <cstdio> // for EOF
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/string_view.hpp>
|
||||
@ -19,11 +20,11 @@
|
||||
#if __cplusplus >= 201402L
|
||||
struct constexpr_char_traits
|
||||
{
|
||||
typedef char char_type;
|
||||
typedef int int_type;
|
||||
typedef std::streamoff off_type;
|
||||
typedef std::streampos pos_type;
|
||||
typedef std::mbstate_t state_type;
|
||||
typedef char char_type;
|
||||
typedef int int_type;
|
||||
typedef std::streamoff off_type;
|
||||
typedef std::streampos pos_type;
|
||||
typedef std::mbstate_t state_type;
|
||||
|
||||
static void assign(char_type& c1, const char_type& c2) noexcept { c1 = c2; }
|
||||
static constexpr bool eq(char_type c1, char_type c2) noexcept { return c1 == c2; }
|
||||
@ -43,11 +44,11 @@ struct constexpr_char_traits
|
||||
static constexpr int_type eof() noexcept { return EOF; }
|
||||
};
|
||||
|
||||
// yields:
|
||||
// 0 if for each i in [0,n), X::eq(s1[i],s2[i]) is true;
|
||||
// else, a negative value if, for some j in [0,n), X::lt(s1[j],s2[j]) is true and
|
||||
// for each i in [0,j) X::eq(s2[i],s2[i]) is true;
|
||||
// else a positive value.
|
||||
// yields:
|
||||
// 0 if for each i in [0,n), X::eq(s1[i],s2[i]) is true;
|
||||
// else, a negative value if, for some j in [0,n), X::lt(s1[j],s2[j]) is true and
|
||||
// for each i in [0,j) X::eq(s2[i],s2[i]) is true;
|
||||
// else a positive value.
|
||||
constexpr int constexpr_char_traits::compare(const char_type* s1, const char_type* s2, size_t n) noexcept
|
||||
{
|
||||
for (; n != 0; --n, ++s1, ++s2)
|
||||
@ -77,38 +78,38 @@ int main()
|
||||
constexpr string_view sv2{"abc", 3}; // ptr, len
|
||||
constexpr string_view sv3{"def"}; // ptr
|
||||
|
||||
constexpr const char *s1 = "";
|
||||
constexpr const char *s2 = "abc";
|
||||
|
||||
static_assert( (sv1 == sv1), "" );
|
||||
|
||||
static_assert(!(sv1 == sv2), "" );
|
||||
static_assert( (sv1 != sv2), "" );
|
||||
static_assert( (sv1 < sv2), "" );
|
||||
static_assert( (sv1 <= sv2), "" );
|
||||
static_assert(!(sv1 > sv2), "" );
|
||||
static_assert(!(sv1 >= sv2), "" );
|
||||
constexpr const char *s1 = "";
|
||||
constexpr const char *s2 = "abc";
|
||||
|
||||
static_assert(!(s1 == sv2), "" );
|
||||
static_assert( (s1 != sv2), "" );
|
||||
static_assert( (s1 < sv2), "" );
|
||||
static_assert( (s1 <= sv2), "" );
|
||||
static_assert(!(s1 > sv2), "" );
|
||||
static_assert(!(s1 >= sv2), "" );
|
||||
static_assert( (sv1 == sv1), "" );
|
||||
|
||||
static_assert(!(sv1 == s2), "" );
|
||||
static_assert( (sv1 != s2), "" );
|
||||
static_assert( (sv1 < s2), "" );
|
||||
static_assert( (sv1 <= s2), "" );
|
||||
static_assert(!(sv1 > s2), "" );
|
||||
static_assert(!(sv1 >= s2), "" );
|
||||
static_assert(!(sv1 == sv2), "" );
|
||||
static_assert( (sv1 != sv2), "" );
|
||||
static_assert( (sv1 < sv2), "" );
|
||||
static_assert( (sv1 <= sv2), "" );
|
||||
static_assert(!(sv1 > sv2), "" );
|
||||
static_assert(!(sv1 >= sv2), "" );
|
||||
|
||||
static_assert( sv1.compare(sv2) < 0, "" );
|
||||
static_assert( sv1.compare(sv1) == 0, "" );
|
||||
static_assert( sv3.compare(sv1) > 0, "" );
|
||||
static_assert(!(s1 == sv2), "" );
|
||||
static_assert( (s1 != sv2), "" );
|
||||
static_assert( (s1 < sv2), "" );
|
||||
static_assert( (s1 <= sv2), "" );
|
||||
static_assert(!(s1 > sv2), "" );
|
||||
static_assert(!(s1 >= sv2), "" );
|
||||
|
||||
static_assert( sv1.compare(s2) < 0, "" );
|
||||
static_assert( sv1.compare(s1) == 0, "" );
|
||||
static_assert( sv3.compare(s1) > 0, "" );
|
||||
static_assert(!(sv1 == s2), "" );
|
||||
static_assert( (sv1 != s2), "" );
|
||||
static_assert( (sv1 < s2), "" );
|
||||
static_assert( (sv1 <= s2), "" );
|
||||
static_assert(!(sv1 > s2), "" );
|
||||
static_assert(!(sv1 >= s2), "" );
|
||||
|
||||
static_assert( sv1.compare(sv2) < 0, "" );
|
||||
static_assert( sv1.compare(sv1) == 0, "" );
|
||||
static_assert( sv3.compare(sv1) > 0, "" );
|
||||
|
||||
static_assert( sv1.compare(s2) < 0, "" );
|
||||
static_assert( sv1.compare(s1) == 0, "" );
|
||||
static_assert( sv3.compare(s1) > 0, "" );
|
||||
}
|
||||
#endif
|
||||
|
@ -17,11 +17,12 @@
|
||||
|
||||
#include "boost/utility/value_init.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
//
|
||||
// Sample POD type
|
||||
@ -217,8 +218,8 @@ void check_initialized_value ( T const& y )
|
||||
BOOST_TEST ( y == initializedValue ) ;
|
||||
}
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#if __BORLANDC__ == 0x582
|
||||
#ifdef BOOST_BORLANDC
|
||||
#if BOOST_BORLANDC == 0x582
|
||||
void check_initialized_value( NonPOD const& )
|
||||
{
|
||||
// The initialized_value check is skipped for Borland 5.82
|
||||
|
169
test/value_init_test2.cpp
Normal file
169
test/value_init_test2.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
// Copyright 2010, Niels Dekker.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// Test program for the boost::value_initialized<T> workaround.
|
||||
//
|
||||
// 17 June 2010 (Created) Niels Dekker
|
||||
|
||||
#include <boost/utility/value_init.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct empty_struct
|
||||
{
|
||||
};
|
||||
|
||||
// A POD aggregate struct derived from an empty struct.
|
||||
// Similar to struct Foo1 from Microsoft Visual C++ bug report 484295,
|
||||
// "VC++ does not value-initialize members of derived classes without
|
||||
// user-declared constructor", reported in 2009 by Sylvester Hesp:
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/484295
|
||||
struct derived_struct: empty_struct
|
||||
{
|
||||
int data;
|
||||
};
|
||||
|
||||
bool is_value_initialized(const derived_struct& arg)
|
||||
{
|
||||
return arg.data == 0;
|
||||
}
|
||||
|
||||
|
||||
class virtual_destructor_holder
|
||||
{
|
||||
public:
|
||||
int i;
|
||||
virtual ~virtual_destructor_holder()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
bool is_value_initialized(const virtual_destructor_holder& arg)
|
||||
{
|
||||
return arg.i == 0;
|
||||
}
|
||||
|
||||
// Equivalent to the Stats class from GCC Bug 33916,
|
||||
// "Default constructor fails to initialize array members", reported in 2007 by
|
||||
// Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
|
||||
// and fixed for GCC 4.2.4.
|
||||
class private_int_array_pair
|
||||
{
|
||||
friend bool is_value_initialized(const private_int_array_pair& arg);
|
||||
private:
|
||||
int first[12];
|
||||
int second[12];
|
||||
};
|
||||
|
||||
bool is_value_initialized(const private_int_array_pair& arg)
|
||||
{
|
||||
for ( unsigned i = 0; i < 12; ++i)
|
||||
{
|
||||
if ( (arg.first[i] != 0) || (arg.second[i] != 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
struct int_pair_struct
|
||||
{
|
||||
int first;
|
||||
int second;
|
||||
};
|
||||
|
||||
typedef int int_pair_struct::*ptr_to_member_type;
|
||||
|
||||
struct ptr_to_member_struct
|
||||
{
|
||||
ptr_to_member_type data;
|
||||
};
|
||||
|
||||
bool is_value_initialized(const ptr_to_member_struct& arg)
|
||||
{
|
||||
return arg.data == 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool is_value_initialized(const T(& arg)[2])
|
||||
{
|
||||
return
|
||||
is_value_initialized(arg[0]) &&
|
||||
is_value_initialized(arg[1]);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool is_value_initialized(const boost::value_initialized<T>& arg)
|
||||
{
|
||||
return is_value_initialized(arg.data());
|
||||
}
|
||||
|
||||
// Returns zero when the specified object is value-initializated, and one otherwise.
|
||||
// Prints a message to standard output if the value-initialization has failed.
|
||||
template <class T>
|
||||
unsigned failed_to_value_initialized(const T& object, const char *const object_name)
|
||||
{
|
||||
if ( is_value_initialized(object) )
|
||||
{
|
||||
return 0u;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Note: Failed to value-initialize " << object_name << '.' << std::endl;
|
||||
return 1u;
|
||||
}
|
||||
}
|
||||
|
||||
// A macro that passed both the name and the value of the specified object to
|
||||
// the function above here.
|
||||
#define FAILED_TO_VALUE_INITIALIZE(value) failed_to_value_initialized(value, #value)
|
||||
|
||||
// Equivalent to the dirty_stack() function from GCC Bug 33916,
|
||||
// "Default constructor fails to initialize array members", reported in 2007 by
|
||||
// Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
|
||||
void dirty_stack()
|
||||
{
|
||||
unsigned char array_on_stack[4096];
|
||||
for (unsigned i = 0; i < sizeof(array_on_stack); ++i)
|
||||
{
|
||||
array_on_stack[i] = 0x11;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
|
||||
|
||||
std::cout << "BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED is defined.\n\n";
|
||||
|
||||
#endif
|
||||
|
||||
dirty_stack();
|
||||
|
||||
BOOST_TEST( is_value_initialized( boost::value_initialized<derived_struct>() ) );
|
||||
BOOST_TEST( is_value_initialized( boost::value_initialized<virtual_destructor_holder[2]>() ) );
|
||||
BOOST_TEST( is_value_initialized( boost::value_initialized<private_int_array_pair>() ) );
|
||||
|
||||
#if !BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1925) )
|
||||
|
||||
// Null pointers to data members are represented as -1 in MSVC, but
|
||||
// value initialization sets them to all zero. The workaround employed
|
||||
// by value_initialized<> is to memset the storage to all zero, which
|
||||
// doesn't help.
|
||||
|
||||
BOOST_TEST( is_value_initialized( boost::value_initialized<ptr_to_member_struct>() ) );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
40
test/value_init_test3.cpp
Normal file
40
test/value_init_test3.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/utility/value_init.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if __cplusplus >= 201103L || ( defined(BOOST_MSVC) && BOOST_MSVC >= 1900 )
|
||||
|
||||
struct X
|
||||
{
|
||||
int a;
|
||||
char b;
|
||||
};
|
||||
|
||||
struct Y: boost::value_initialized<X>
|
||||
{
|
||||
char c = 42;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST_EQ( y.data().a, 0 );
|
||||
BOOST_TEST_EQ( y.data().b, 0 );
|
||||
BOOST_TEST_EQ( y.c, 42 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because compiler doesn't support in-class member initializers" )
|
||||
|
||||
int main() {}
|
||||
|
||||
#endif
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "boost/utility/value_init.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "boost/utility/value_init.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "boost/utility/value_init.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user