Compare commits

...

23 Commits

Author SHA1 Message Date
05e0d1688d Re-enabled 32-bit clang-win AppVeyor job on VS2019 image.
32-bit clang does not fail with the mspdb error on the VS2019 image.
Apply the same env script workaround as for the 64-bit clang.
2021-10-10 13:59:26 +03:00
dcaf2c0e3b Fixed a typo in AppVeyor config. 2021-10-10 00:18:35 +03:00
71107238eb Call env setup script to work around missing msvcrt.lib errors with clang-win. 2021-10-10 00:08:03 +03:00
28c90abaf0 Try switching clang-win to VS2019 image.
This is an attempt to work around the missing msvcrt(d).lib linking errors.
2021-10-09 20:32:03 +03:00
2cc83cc7d5 Added MinGW-w64 gcc 8.1 job to AppVeyor. 2021-10-09 20:31:48 +03:00
e8fc7cc2a1 Disabled 32-bit clang-win in AppVeyor because of "unable to load mspdbcore.dll" errors. 2021-10-09 11:18:24 +03:00
09d24c0516 Fixed git version check on Mac OS. 2021-09-26 20:43:44 +03:00
3f51807f24 Disabled random operators tests under UBSAN.
The tests use random input to various arithmetic and bitwise operators,
which cause undefined behavior, such as shifting by more than the left
operand capacity or signed integer overflows.
2021-09-16 02:12:41 +03:00
a04a0d9531 Updated link to AppVeyor badge. 2021-09-15 22:18:17 +03:00
449a03e13d Updated README.md to replace Travis CI with GHA and add other links. 2021-09-15 21:43:31 +03:00
dc59afafdb Added GitHub Actions config. 2021-09-15 21:40:04 +03:00
e845ae6752 Removed Travis CI config.
Since Travis CI no longer runs free jobs for open source projects,
we are migrating to GitHub Actions instead.
2021-09-15 21:38:55 +03:00
375382e1e6 Merge pull request #67 from Kojoley/patch-1
Cease dependence on ContainerHash
2021-06-23 07:42:12 -07:00
6cca23a63a Cease dependence on ContainerHash
by local `hash_range` forward declaration
2021-06-20 19:34:05 +03:00
9ad7e51912 Update CMakeLists.txt 2021-06-10 00:45:51 +03:00
601f80e8c1 Merge pull request #75 from Kojoley/feature/result_of-variadic-templates
Use variadic templates in result_of
2021-04-22 23:12:34 +03:00
c960bef6ef Merge pull request #76 from vahtis/develop
Workaround for Oracle Developer Studio
2021-03-25 16:58:37 +01:00
6ab27d5689 Workaround for Oracle Developer Studio
Oracle Developer Studio needs same workaround as VIsual Studio
2021-03-25 11:32:37 +02:00
3e2f0199cf Use variadic templates in result_of 2021-03-08 04:25:46 +03:00
9c2aa8d193 Revert "Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73"
This reverts commit 601fc9371f.
2021-03-01 16:50:14 -08:00
601fc9371f Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73 2021-03-01 06:52:49 -08:00
7aafdf92a0 [skip ci] Merge pull request #71 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 11:18:10 +03:00
a7570d7608 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 22:19:49 -05:00
11 changed files with 741 additions and 474 deletions

424
.github/workflows/ci.yml vendored Normal file
View 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[@]}"

View File

@ -1,382 +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"
- os: linux
dist: bionic
compiler: gcc-10
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20
addons:
apt:
packages:
- g++-10
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-10
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20
addons:
apt:
packages:
- clang-10
- libstdc++-9-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
- os: linux
dist: xenial
compiler: clang-libc++
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,20 CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
addons:
apt:
packages:
- clang-10
- libc++-10-dev
- libc++abi-10-dev
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 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/io
- 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

View File

@ -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,7 +15,6 @@ target_include_directories(boost_utility INTERFACE include)
target_link_libraries(boost_utility
INTERFACE
Boost::config
Boost::container_hash
Boost::core
Boost::io
Boost::preprocessor

View File

@ -16,8 +16,10 @@ Boost.Utility, part of collection of the [Boost C++ Libraries](https://github.co
### Build status
Master: [![Travis CI](https://travis-ci.org/boostorg/utility.svg?branch=master)](https://travis-ci.org/boostorg/utility)
Develop: [![Travis CI](https://travis-ci.org/boostorg/utility.svg?branch=develop)](https://travis-ci.org/boostorg/utility)
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
:-------------: | -------------- | -------- | ----------- | ------------ |
[`master`](https://github.com/boostorg/utility/tree/master) | [![GitHub Actions](https://github.com/boostorg/utility/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/utility/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/g09ehuy2o6aq42th/branch/master?svg=true)](https://ci.appveyor.com/project/Lastique/utility/branch/master) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/utility.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/utility.html)
[`develop`](https://github.com/boostorg/utility/tree/develop) | [![GitHub Actions](https://github.com/boostorg/utility/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/utility/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/g09ehuy2o6aq42th/branch/develop?svg=true)](https://ci.appveyor.com/project/Lastique/utility/branch/develop) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/utility.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/utility.html)
### License

View File

@ -30,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;
@ -50,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
@ -84,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

View File

@ -112,6 +112,8 @@
// 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

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

View File

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

View File

@ -23,7 +23,6 @@
#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>
@ -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());

View File

@ -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,7 +88,8 @@
],
"maintainers": [
"Daniel Frey <d.frey -at- gmx.de>"
]
],
"cxxstd": "03"
},
{
"key": "utility/result_of",
@ -96,7 +102,8 @@
"authors": "",
"maintainers": [
"Daniel Walker <daniel.j.walker -at- gmail.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/string_ref",
@ -109,7 +116,8 @@
"authors": "Marshall Clow",
"maintainers": [
"Marshall Clow <marshall -at- idio.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/value_initialized",
@ -121,6 +129,7 @@
"documentation": "value_init.htm",
"category": [
"Miscellaneous"
]
],
"cxxstd": "03"
}
]

View File

@ -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++
@ -71,7 +70,7 @@ namespace
{ return _value < x._value; }
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)
@ -94,12 +93,12 @@ namespace
{ _value >>= x._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) );