mirror of
https://github.com/boostorg/variant2.git
synced 2025-07-29 19:57:18 +02:00
Compare commits
80 Commits
boost-1.72
...
feature/is
Author | SHA1 | Date | |
---|---|---|---|
f39a71ed2f | |||
06dde96400 | |||
8be0a4a5fe | |||
90cda5339f | |||
afb0aafd64 | |||
f586dc8848 | |||
20b9175932 | |||
fb3ce863ff | |||
8ec0bf448a | |||
6d19e6be68 | |||
d8552b23ae | |||
f44aba09a2 | |||
99cc1db385 | |||
6d848c5af6 | |||
3c9f4e56bf | |||
3015e56bcb | |||
7c37053950 | |||
60995edb41 | |||
84a2c175d0 | |||
ea3268feb4 | |||
6de876954a | |||
efc1d5acca | |||
453b00dec8 | |||
c6186e0a95 | |||
24ccee2104 | |||
93b8618e94 | |||
1ebc29aa02 | |||
d3db874762 | |||
5586ebaa64 | |||
bede3777a8 | |||
b302dd5912 | |||
2ad6fed07a | |||
84ea994325 | |||
465e5bac3d | |||
41829b0fb1 | |||
b57d75ff80 | |||
03019860df | |||
8ec4720d2d | |||
75f574fc48 | |||
1d79adfca0 | |||
fa92e40b35 | |||
a403f82691 | |||
a7d0da59ad | |||
fa872cb835 | |||
93204676f5 | |||
772ef0d312 | |||
f3b3b533aa | |||
4b60dee4b6 | |||
76c67c9b21 | |||
308bd731a5 | |||
719c43316f | |||
d6680df4e5 | |||
8cf72527a6 | |||
b649a39776 | |||
37f6efab5d | |||
5259bdd5fc | |||
9964e77dd2 | |||
57ab36bd95 | |||
fac5992e45 | |||
972280e59f | |||
ef2ef292b9 | |||
3b2fb1a48a | |||
4f81882bfd | |||
17bc06b090 | |||
c4cad3e96a | |||
83ff667813 | |||
5e76451843 | |||
c2b5d101eb | |||
a92185a86d | |||
a795f9cf01 | |||
f6e2e78d7d | |||
1f05cdfb17 | |||
1203aa97c0 | |||
b3229d48b7 | |||
be11d94adc | |||
fece11142c | |||
58b4a21deb | |||
5192a345ab | |||
74e6a04a60 | |||
2af66dd815 |
197
.github/workflows/ci.yml
vendored
Normal file
197
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.1
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2016
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
126
.travis.yml
126
.travis.yml
@ -1,12 +1,10 @@
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Copyright 2016-2021 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
dist: trusty
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
@ -25,8 +23,14 @@ matrix:
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=11
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
@ -89,12 +93,13 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
- g++-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
@ -108,7 +113,6 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
@ -119,7 +123,6 @@ matrix:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
@ -130,7 +133,6 @@ matrix:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
@ -141,7 +143,6 @@ matrix:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
@ -152,7 +153,6 @@ matrix:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
@ -163,9 +163,9 @@ matrix:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=11,14,1z
|
||||
addons:
|
||||
@ -174,9 +174,9 @@ matrix:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=11,14,17
|
||||
addons:
|
||||
@ -185,9 +185,9 @@ matrix:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
@ -196,9 +196,10 @@ matrix:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
- llvm-toolchain-bionic-7
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
@ -207,20 +208,62 @@ matrix:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-8
|
||||
- llvm-toolchain-bionic-8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
dist: bionic
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-11
|
||||
env: TOOLSET=clang COMPILER=clang++-11 CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-11
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-12
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-12 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-12
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=11,14,1z
|
||||
addons:
|
||||
@ -229,8 +272,9 @@ matrix:
|
||||
- libc++-dev
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -238,24 +282,46 @@ matrix:
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
env: CMAKE_TEST=1
|
||||
script:
|
||||
- cd libs/variant2/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=variant2 ..
|
||||
- ctest --output-on-failure -R boost_variant2
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/mp11.git ../mp11
|
||||
script:
|
||||
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- cmake ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_INSTALL_TEST=1
|
||||
script:
|
||||
- pip install --user cmake
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=variant2 -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build . --target install
|
||||
- cd ../libs/variant2/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- mkdir -p libs/variant2
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/variant2
|
||||
|
@ -2,12 +2,9 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# http://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.16)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(BoostVariant2 LANGUAGES CXX)
|
||||
project(boost_variant2 VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_variant2 INTERFACE)
|
||||
add_library(Boost::variant2 ALIAS boost_variant2)
|
||||
@ -15,7 +12,13 @@ add_library(Boost::variant2 ALIAS boost_variant2)
|
||||
target_include_directories(boost_variant2 INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_variant2
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::mp11
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::mp11
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
16
appveyor.yml
16
appveyor.yml
@ -1,4 +1,4 @@
|
||||
# Copyright 2016-2018 Peter Dimov
|
||||
# Copyright 2016-2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@ -20,7 +20,15 @@ environment:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
CXXSTD: 14,17,latest
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17,latest
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
@ -28,8 +36,6 @@ install:
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\variant2\
|
||||
- python tools/boostdep/depinst/depinst.py variant2
|
||||
@ -41,4 +47,4 @@ build: off
|
||||
test_script:
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
- b2 -j3 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
|
@ -1,5 +1,5 @@
|
||||
////
|
||||
Copyright 2019 Peter Dimov
|
||||
Copyright 2019-2021 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@ -11,6 +11,23 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix: changelog_
|
||||
|
||||
## Changes in 1.76.0
|
||||
|
||||
* Improved generated code for the double buffered case.
|
||||
|
||||
## Changes in 1.74.0
|
||||
|
||||
* Added support for derived types in `visit`
|
||||
* Improved compilation performance for many (hundreds of) alternatives.
|
||||
* Added support for `visit<R>`
|
||||
|
||||
## Changes in 1.73.0
|
||||
|
||||
* Added support for `std::hash`, `boost::hash`.
|
||||
* `variant<T...>` is now trivial when all types in `T...` are trivial.
|
||||
This improves performance by enabling it to be passed to, and returned
|
||||
from, functions in registers.
|
||||
|
||||
## Changes in 1.71.0
|
||||
|
||||
After the Boost formal review, the implementation has been
|
||||
|
@ -169,8 +169,6 @@ The main differences between this implementation and `std::variant` are:
|
||||
`variant<int, float>` is provided as the member function `subset<U...>`.
|
||||
(This operation can throw if the current state of the variant cannot be
|
||||
represented.)
|
||||
* `variant<T...>` is not (yet) trivial when all contained types are trivial,
|
||||
as mandated by {cpp}17.
|
||||
* The {cpp}20 additions and changes to `std::variant` have not yet been
|
||||
implemented.
|
||||
|
||||
|
@ -134,7 +134,7 @@ template<class... T>
|
||||
|
||||
// visit
|
||||
|
||||
template<class F, class... V>
|
||||
template<class R = /*unspecified*/, class F, class... V>
|
||||
constexpr /*see below*/ visit(F&& f, V&&... v);
|
||||
|
||||
// monostate
|
||||
@ -490,8 +490,8 @@ template<size_t I, class... A>
|
||||
+
|
||||
Requires: :: `I < sizeof...(T)`.
|
||||
Effects: ::
|
||||
Destroys the currently contained value, then initializes a new contained
|
||||
value as if using the expression `Ti(std::forward<A>(a)...)`.
|
||||
Initializes a new contained value as if using the expression
|
||||
`Ti(std::forward<A>(a)...)`, then destroys the currently contained value.
|
||||
Ensures: :: `index() == I`.
|
||||
Returns: :: A reference to the new contained value.
|
||||
Throws: ::
|
||||
@ -511,8 +511,8 @@ template<size_t I, class V, class... A>
|
||||
+
|
||||
Requires: :: `I < sizeof...(T)`.
|
||||
Effects: ::
|
||||
Destroys the currently contained value, then initializes a new contained
|
||||
value as if using the expression `Ti(il, std::forward<A>(a)...)`.
|
||||
Initializes a new contained value as if using the expression
|
||||
`Ti(il, std::forward<A>(a)...)`, then destroys the currently contained value.
|
||||
Ensures: :: `index() == I`.
|
||||
Returns: :: A reference to the new contained value.
|
||||
Throws: ::
|
||||
@ -838,7 +838,7 @@ Returns: ::
|
||||
### visit
|
||||
|
||||
```
|
||||
template<class F, class... V>
|
||||
template<class R = /*unspecified*/, class F, class... V>
|
||||
constexpr /*see below*/ visit(F&& f, V&&... v);
|
||||
```
|
||||
[none]
|
||||
@ -846,6 +846,10 @@ template<class F, class... V>
|
||||
+
|
||||
Returns: :: `std::forward<F>(f)(get<I>(std::forward<V>(v))...)`, where
|
||||
`I...` is `v.index()...`.
|
||||
Remarks: :: If `R` is given explicitly, as in `visit<int>`, the return
|
||||
type is `R`. Otherwise, it's deduced from `F`. All possible applications
|
||||
of `F` to the variant alternatives must have the same return type for
|
||||
this deduction to succeed.
|
||||
|
||||
### swap
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,10 +5,11 @@
|
||||
"Peter Dimov"
|
||||
],
|
||||
"maintainers": [
|
||||
"Peter Dimov <pdimov -at- pdimov.com>"
|
||||
"Peter Dimov <pdimov -at- gmail.com>"
|
||||
],
|
||||
"description": "A never-valueless, strong guarantee implementation of std::variant.",
|
||||
"category": [
|
||||
"Containers", "Data"
|
||||
]
|
||||
],
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
11
test/CMakeLists.txt
Normal file
11
test/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::variant2 Boost::core Boost::container_hash)
|
||||
|
||||
endif()
|
38
test/Jamfile
38
test/Jamfile
@ -12,7 +12,7 @@ import ../../config/checks/config : requires ;
|
||||
project
|
||||
: default-build
|
||||
|
||||
<warnings>all
|
||||
<warnings>extra
|
||||
|
||||
: requirements
|
||||
|
||||
@ -23,20 +23,22 @@ project
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
;
|
||||
|
||||
run quick.cpp ;
|
||||
|
||||
run variant_size.cpp ;
|
||||
run variant_alternative.cpp ;
|
||||
|
||||
run variant_holds_alternative.cpp ;
|
||||
compile variant_holds_alternative_cx.cpp ;
|
||||
compile variant_holds_alternative_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_get_by_index.cpp ;
|
||||
compile variant_get_by_index_cx.cpp ;
|
||||
compile variant_get_by_index_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_get_by_type.cpp ;
|
||||
compile variant_get_by_type_cx.cpp ;
|
||||
compile variant_get_by_type_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_default_construct.cpp ;
|
||||
compile variant_default_construct_cx.cpp ;
|
||||
compile variant_default_construct_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_copy_construct.cpp ;
|
||||
compile variant_copy_construct_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
@ -45,13 +47,13 @@ run variant_move_construct.cpp ;
|
||||
compile variant_move_construct_cx.cpp : [ requires cxx14_constexpr ] ;
|
||||
|
||||
run variant_value_construct.cpp ;
|
||||
compile variant_value_construct_cx.cpp ;
|
||||
compile variant_value_construct_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_in_place_index_construct.cpp ;
|
||||
compile variant_in_place_index_construct_cx.cpp ;
|
||||
compile variant_in_place_index_construct_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_in_place_type_construct.cpp ;
|
||||
compile variant_in_place_type_construct_cx.cpp ;
|
||||
compile variant_in_place_type_construct_cx.cpp : <toolset>msvc-14.0:<build>no ;
|
||||
|
||||
run variant_copy_assign.cpp ;
|
||||
compile variant_copy_assign_cx.cpp : [ requires cxx14_constexpr ] ;
|
||||
@ -97,9 +99,25 @@ local NX =
|
||||
;
|
||||
|
||||
run variant_get_by_index.cpp throw_exception.cpp : : : $(NX) : variant_get_by_index_nx ;
|
||||
compile variant_get_by_index_cx.cpp : $(NX) : variant_get_by_index_cx_nx ;
|
||||
compile variant_get_by_index_cx.cpp : $(NX) <toolset>msvc-14.0:<build>no : variant_get_by_index_cx_nx ;
|
||||
|
||||
run variant_get_by_type.cpp throw_exception.cpp : : : $(NX) : variant_get_by_type_nx ;
|
||||
compile variant_get_by_type_cx.cpp : $(NX) : variant_get_by_type_cx_nx ;
|
||||
compile variant_get_by_type_cx.cpp : $(NX) <toolset>msvc-14.0:<build>no : variant_get_by_type_cx_nx ;
|
||||
|
||||
run variant_subset.cpp throw_exception.cpp : : : $(NX) : variant_subset_nx ;
|
||||
|
||||
run variant_hash.cpp ;
|
||||
|
||||
run variant_trivial.cpp ;
|
||||
run variant_special.cpp ;
|
||||
|
||||
run variant_visit_derived.cpp ;
|
||||
|
||||
run variant_many_types.cpp ;
|
||||
|
||||
run variant_visit_r.cpp : : :
|
||||
<toolset>gcc,<target-os>windows:<variant>release
|
||||
<toolset>gcc,<target-os>cygwin:<variant>release
|
||||
;
|
||||
|
||||
compile variant_derived_construct.cpp ;
|
||||
|
17
test/cmake_install_test/CMakeLists.txt
Normal file
17
test/cmake_install_test/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(boost_variant2 REQUIRED)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::variant2)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
@ -2,7 +2,7 @@
|
||||
# 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
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
@ -10,7 +10,7 @@ add_subdirectory(../.. boostorg/variant2)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
add_subdirectory(../../../mp11 boostorg/mp11)
|
||||
|
||||
add_executable(quick quick.cpp)
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::variant2)
|
||||
|
||||
enable_testing()
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
@ -48,12 +50,21 @@ struct Y
|
||||
Y( Y const& ) = delete;
|
||||
};
|
||||
|
||||
struct D
|
||||
{
|
||||
~D() {}
|
||||
};
|
||||
|
||||
inline bool operator==( D, D ) { return true; }
|
||||
|
||||
template<class V> static void test( V const & v )
|
||||
{
|
||||
V v2( v );
|
||||
|
||||
BOOST_TEST_EQ( v.index(), v2.index() );
|
||||
BOOST_TEST( v == v2 );
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible<V>));
|
||||
}
|
||||
|
||||
int main()
|
||||
@ -115,6 +126,12 @@ int main()
|
||||
test( v );
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND( __GNUC__, < 5 )
|
||||
|
||||
test( variant<D>() );
|
||||
|
||||
#endif
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_copy_constructible<variant<int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_nothrow_copy_constructible<variant<int const>>));
|
||||
|
33
test/variant_derived_construct.cpp
Normal file
33
test/variant_derived_construct.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
template<class... T> class X: variant<T...>
|
||||
{
|
||||
using base = variant<T...>;
|
||||
using base::base;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
Y( Y const& rhs ) = default;
|
||||
|
||||
template<class T> Y( T const& t )
|
||||
{
|
||||
t.bar();
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
using W = X<int, double, Y>;
|
||||
|
||||
W a( 1 );
|
||||
W b( a );
|
||||
|
||||
(void)b;
|
||||
}
|
@ -57,6 +57,60 @@ STATIC_ASSERT( !std::is_nothrow_move_constructible<X2>::value );
|
||||
STATIC_ASSERT( !std::is_nothrow_copy_assignable<X2>::value );
|
||||
STATIC_ASSERT( !std::is_nothrow_move_assignable<X2>::value );
|
||||
|
||||
struct Y1
|
||||
{
|
||||
int v = 1;
|
||||
|
||||
Y1() = default;
|
||||
Y1(Y1 const&) = delete;
|
||||
Y1(Y1&&) = delete;
|
||||
};
|
||||
|
||||
STATIC_ASSERT( !std::is_copy_constructible<Y1>::value );
|
||||
STATIC_ASSERT( !std::is_move_constructible<Y1>::value );
|
||||
|
||||
struct Y2
|
||||
{
|
||||
int v = 2;
|
||||
|
||||
Y2() = default;
|
||||
Y2(Y2 const&) = delete;
|
||||
Y2(Y2&&) = delete;
|
||||
};
|
||||
|
||||
STATIC_ASSERT( !std::is_copy_constructible<Y2>::value );
|
||||
STATIC_ASSERT( !std::is_move_constructible<Y2>::value );
|
||||
|
||||
struct Z1
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v = 1;
|
||||
|
||||
Z1() { ++instances; }
|
||||
~Z1() { --instances; }
|
||||
|
||||
Z1(Z1 const&) = delete;
|
||||
Z1(Z1&&) = delete;
|
||||
};
|
||||
|
||||
int Z1::instances = 0;
|
||||
|
||||
struct Z2
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v = 2;
|
||||
|
||||
Z2() { ++instances; }
|
||||
~Z2() { --instances; }
|
||||
|
||||
Z2(Z2 const&) = delete;
|
||||
Z2(Z2&&) = delete;
|
||||
};
|
||||
|
||||
int Z2::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -177,5 +231,62 @@ int main()
|
||||
BOOST_TEST_EQ( get<0>(v).v, 4 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<Y1, Y2> v;
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<Z1, Z2> v;
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
BOOST_TEST_EQ( Z1::instances, 1 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
BOOST_TEST_EQ( Z1::instances, 1 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
BOOST_TEST_EQ( Z1::instances, 0 );
|
||||
BOOST_TEST_EQ( Z2::instances, 1 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
BOOST_TEST_EQ( Z1::instances, 0 );
|
||||
BOOST_TEST_EQ( Z2::instances, 1 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
BOOST_TEST_EQ( Z1::instances, 1 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( Z1::instances, 0 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -88,5 +88,12 @@ int main()
|
||||
BOOST_TEST_NOT( v1 != v2 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<monostate> v1, v2;
|
||||
|
||||
BOOST_TEST( v1 == v2 );
|
||||
BOOST_TEST_NOT( v1 != v2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -93,6 +93,13 @@ int main()
|
||||
STATIC_ASSERT( !(v1 == v2) );
|
||||
STATIC_ASSERT( !(v1 != v2) );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr variant<monostate> v1, v2;
|
||||
|
||||
STATIC_ASSERT( v1 == v2 );
|
||||
STATIC_ASSERT( !(v1 != v2) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,12 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined( __clang__ ) && defined( __has_warning )
|
||||
# if __has_warning( "-Wdeprecated-volatile" )
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-volatile"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
@ -6,6 +6,12 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined( __clang__ ) && defined( __has_warning )
|
||||
# if __has_warning( "-Wdeprecated-volatile" )
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-volatile"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
73
test/variant_hash.cpp
Normal file
73
test/variant_hash.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4244 ) // conversion from int to float, possible loss of data
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
template<template<class...> class Hash, class T1, class T2, class T3> void test()
|
||||
{
|
||||
variant<T1, T2, T3> v1( in_place_index_t<0>{} );
|
||||
std::size_t h1 = Hash<decltype(v1)>()( v1 );
|
||||
|
||||
variant<T1, T2, T3> v2( in_place_index_t<1>{} );
|
||||
std::size_t h2 = Hash<decltype(v2)>()( v2 );
|
||||
|
||||
variant<T1, T2, T3> v3( in_place_index_t<2>{} );
|
||||
std::size_t h3 = Hash<decltype(v3)>()( v3 );
|
||||
|
||||
BOOST_TEST_NE( h1, h2 );
|
||||
BOOST_TEST_NE( h1, h3 );
|
||||
BOOST_TEST_NE( h2, h3 );
|
||||
}
|
||||
|
||||
template<template<class...> class Hash, class T> void test2()
|
||||
{
|
||||
variant<T> v1( 0 );
|
||||
std::size_t h1 = Hash<decltype(v1)>()( v1 );
|
||||
|
||||
variant<T> v2( 1 );
|
||||
std::size_t h2 = Hash<decltype(v2)>()( v2 );
|
||||
|
||||
variant<T> v3( 2 );
|
||||
std::size_t h3 = Hash<decltype(v3)>()( v3 );
|
||||
|
||||
BOOST_TEST_NE( h1, h2 );
|
||||
BOOST_TEST_NE( h1, h3 );
|
||||
BOOST_TEST_NE( h2, h3 );
|
||||
}
|
||||
|
||||
struct X {};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::hash, monostate, monostate, monostate>();
|
||||
test<std::hash, int, int, float>();
|
||||
|
||||
test<boost::hash, monostate, monostate, monostate>();
|
||||
test<boost::hash, int, int, float>();
|
||||
|
||||
test2<std::hash, int>();
|
||||
test2<std::hash, float>();
|
||||
|
||||
test2<boost::hash, int>();
|
||||
test2<boost::hash, float>();
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910) && ( !defined(_LIBCPP_STD_VER) || _LIBCPP_STD_VER > 11 )
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( detail::is_hash_enabled<X> ));
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -7,11 +7,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
@ -108,9 +105,17 @@ int main()
|
||||
STATIC_ASSERT( v.index() == 4 );
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, >= 100000 && BOOST_GCC < 110000)
|
||||
|
||||
// no idea why this fails on g++ 10
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
constexpr variant<int, int, float, float, X, X> v( in_place_index_t<5>{}, 0, 0 );
|
||||
|
||||
STATIC_ASSERT( v.index() == 5 );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
@ -100,6 +102,12 @@ int main()
|
||||
STATIC_ASSERT( holds_alternative<X>(v) );
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, >= 100000 && BOOST_GCC < 110000)
|
||||
|
||||
// no idea why this fails on g++ 10
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
constexpr variant<int, int, float, float, X> v( in_place_type_t<X>{}, 0, 0 );
|
||||
|
||||
@ -107,4 +115,6 @@ int main()
|
||||
|
||||
STATIC_ASSERT( holds_alternative<X>(v) );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -81,5 +81,14 @@ int main()
|
||||
BOOST_TEST_NOT( v1 >= v2 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<monostate> v1, v2;
|
||||
|
||||
BOOST_TEST_NOT( v1 < v2 );
|
||||
BOOST_TEST_NOT( v1 > v2 );
|
||||
BOOST_TEST( v1 <= v2 );
|
||||
BOOST_TEST( v1 >= v2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -86,6 +86,15 @@ int main()
|
||||
STATIC_ASSERT( !(v1 <= v2) );
|
||||
STATIC_ASSERT( !(v1 >= v2) );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr variant<monostate> v1, v2;
|
||||
|
||||
STATIC_ASSERT( !(v1 < v2) );
|
||||
STATIC_ASSERT( !(v1 > v2) );
|
||||
STATIC_ASSERT( v1 <= v2 );
|
||||
STATIC_ASSERT( v1 >= v2 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
109
test/variant_many_types.cpp
Normal file
109
test/variant_many_types.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4503 ) // decorated name length exceeded
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/mp11.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::mp11;
|
||||
|
||||
template<class I> struct X
|
||||
{
|
||||
static int const value = I::value;
|
||||
int v_;
|
||||
};
|
||||
|
||||
template<class I> int const X<I>::value;
|
||||
|
||||
template<class I> struct Y
|
||||
{
|
||||
static int const value = I::value;
|
||||
int v_;
|
||||
|
||||
Y() = default;
|
||||
Y( Y const& ) = default;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
|
||||
Y& operator=( Y const& ) noexcept = default;
|
||||
|
||||
Y& operator=( Y&& r ) noexcept
|
||||
{
|
||||
v_ = r.v_;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class I> int const Y<I>::value;
|
||||
|
||||
template<class I> struct Z
|
||||
{
|
||||
static int const value = I::value;
|
||||
int v_;
|
||||
|
||||
~Z() {}
|
||||
};
|
||||
|
||||
template<class I> int const Z<I>::value;
|
||||
|
||||
template<class V> struct F1
|
||||
{
|
||||
template<class T> void operator()( T ) const
|
||||
{
|
||||
int const i = T::value;
|
||||
|
||||
T t{ i * 2 };
|
||||
|
||||
using boost::variant2::get;
|
||||
|
||||
{
|
||||
V v( t );
|
||||
|
||||
BOOST_TEST_EQ( v.index(), i );
|
||||
BOOST_TEST_EQ( get<i>( v ).v_, t.v_ );
|
||||
BOOST_TEST_EQ( get<T>( v ).v_, t.v_ );
|
||||
}
|
||||
|
||||
{
|
||||
V const v( t );
|
||||
|
||||
BOOST_TEST_EQ( v.index(), i );
|
||||
BOOST_TEST_EQ( get<i>( v ).v_, t.v_ );
|
||||
BOOST_TEST_EQ( get<T>( v ).v_, t.v_ );
|
||||
}
|
||||
|
||||
{
|
||||
V v;
|
||||
|
||||
v = t;
|
||||
|
||||
BOOST_TEST_EQ( v.index(), i );
|
||||
BOOST_TEST_EQ( get<i>( v ).v_, t.v_ );
|
||||
BOOST_TEST_EQ( get<T>( v ).v_, t.v_ );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class V> void test()
|
||||
{
|
||||
mp_for_each<V>( F1<V>() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int const N = 32;
|
||||
|
||||
using V = mp_rename<mp_iota_c<N>, boost::variant2::variant>;
|
||||
|
||||
test< mp_transform<X, V> >();
|
||||
test< mp_transform<Y, V> >();
|
||||
test< mp_transform<Z, V> >();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
103
test/variant_special.cpp
Normal file
103
test/variant_special.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||
# pragma warning(disable: 4503) // decorated name length exceeded
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
using namespace boost::mp11;
|
||||
|
||||
//
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
struct D
|
||||
{
|
||||
~D() noexcept {}
|
||||
};
|
||||
|
||||
struct CC1
|
||||
{
|
||||
CC1( CC1 const& ) {}
|
||||
};
|
||||
|
||||
struct CC2
|
||||
{
|
||||
CC2( CC2 const& ) = delete;
|
||||
};
|
||||
|
||||
struct MC1
|
||||
{
|
||||
MC1( MC1 && ) {}
|
||||
};
|
||||
|
||||
struct MC2
|
||||
{
|
||||
MC2( MC2 && ) = delete;
|
||||
};
|
||||
|
||||
struct CA1
|
||||
{
|
||||
CA1& operator=( CA1 const& ) { return *this; }
|
||||
};
|
||||
|
||||
struct CA2
|
||||
{
|
||||
CA2& operator=( CA2 const& ) = delete;
|
||||
};
|
||||
|
||||
struct MA1
|
||||
{
|
||||
MA1& operator=( MA1 && ) { return *this; }
|
||||
};
|
||||
|
||||
struct MA2
|
||||
{
|
||||
MA2& operator=( MA2 && ) = delete;
|
||||
};
|
||||
|
||||
struct test
|
||||
{
|
||||
template<class... T> void operator()( mp_list<T...> ) const noexcept
|
||||
{
|
||||
using U = mp_inherit<T...>;
|
||||
|
||||
#if !BOOST_WORKAROUND( __GNUC__, < 5 )
|
||||
|
||||
BOOST_TEST_EQ( std::is_copy_constructible<variant<U>>::value, std::is_copy_constructible<U>::value );
|
||||
BOOST_TEST_EQ( std::is_nothrow_copy_constructible<variant<U>>::value, std::is_nothrow_copy_constructible<U>::value );
|
||||
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
|
||||
BOOST_TEST_EQ( std::is_move_constructible<variant<U>>::value, std::is_move_constructible<U>::value );
|
||||
|
||||
#else
|
||||
|
||||
BOOST_TEST_GE( std::is_move_constructible<variant<U>>::value, std::is_move_constructible<U>::value );
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( std::is_nothrow_move_constructible<variant<U>>::value, std::is_nothrow_move_constructible<U>::value );
|
||||
|
||||
BOOST_TEST_EQ( std::is_copy_assignable<variant<U>>::value, std::is_copy_constructible<U>::value && std::is_copy_assignable<U>::value );
|
||||
BOOST_TEST_EQ( std::is_nothrow_copy_assignable<variant<U>>::value, std::is_nothrow_copy_constructible<U>::value && std::is_copy_assignable<U>::value );
|
||||
|
||||
BOOST_TEST_EQ( std::is_move_assignable<variant<U>>::value, std::is_move_constructible<U>::value && std::is_move_assignable<U>::value );
|
||||
BOOST_TEST_EQ( std::is_nothrow_move_assignable<variant<U>>::value, std::is_nothrow_move_constructible<U>::value && std::is_move_assignable<U>::value );
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
mp_for_each< mp_power_set< mp_list<D, CC1, CC2, MC1, MC2, CA1, CA2, MA1, MA2> > >( test() );
|
||||
return boost::report_errors();
|
||||
}
|
95
test/variant_trivial.cpp
Normal file
95
test/variant_trivial.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||
# pragma warning(disable: 4503) // decorated name length exceeded
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
using namespace boost::mp11;
|
||||
|
||||
//
|
||||
|
||||
struct D
|
||||
{
|
||||
~D() noexcept {}
|
||||
};
|
||||
|
||||
struct CC1
|
||||
{
|
||||
CC1( CC1 const& ) noexcept {}
|
||||
};
|
||||
|
||||
struct CC2
|
||||
{
|
||||
CC2( CC2 const& ) = delete;
|
||||
};
|
||||
|
||||
struct MC1
|
||||
{
|
||||
MC1( MC1 && ) noexcept {}
|
||||
};
|
||||
|
||||
struct MC2
|
||||
{
|
||||
MC2( MC2 && ) = delete;
|
||||
};
|
||||
|
||||
struct CA1
|
||||
{
|
||||
CA1& operator=( CA1 const& ) noexcept { return *this; }
|
||||
};
|
||||
|
||||
struct CA2
|
||||
{
|
||||
CA2& operator=( CA2 const& ) = delete;
|
||||
};
|
||||
|
||||
struct MA1
|
||||
{
|
||||
MA1& operator=( MA1 && ) noexcept { return *this; }
|
||||
};
|
||||
|
||||
struct MA2
|
||||
{
|
||||
MA2& operator=( MA2 && ) = delete;
|
||||
};
|
||||
|
||||
using namespace boost::variant2;
|
||||
namespace v2d = boost::variant2::detail;
|
||||
|
||||
struct test
|
||||
{
|
||||
template<class... T> void operator()( mp_list<T...> ) const noexcept
|
||||
{
|
||||
using U = mp_inherit<T...>;
|
||||
|
||||
#if !BOOST_WORKAROUND( __GNUC__, < 5 )
|
||||
|
||||
BOOST_TEST_EQ( v2d::is_trivially_copy_constructible<variant<U>>::value, v2d::is_trivially_copy_constructible<U>::value );
|
||||
BOOST_TEST_EQ( v2d::is_trivially_copy_assignable<variant<U>>::value, std::is_trivially_destructible<U>::value && v2d::is_trivially_copy_constructible<U>::value && v2d::is_trivially_copy_assignable<U>::value );
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( std::is_trivially_destructible<variant<U>>::value, std::is_trivially_destructible<U>::value );
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_LIBSTDCXX_VERSION, < 50000)
|
||||
|
||||
BOOST_TEST_EQ( v2d::is_trivially_move_constructible<variant<U>>::value, v2d::is_trivially_move_constructible<U>::value );
|
||||
BOOST_TEST_EQ( v2d::is_trivially_move_assignable<variant<U>>::value, std::is_trivially_destructible<U>::value && v2d::is_trivially_move_constructible<U>::value && v2d::is_trivially_move_assignable<U>::value );
|
||||
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
mp_for_each< mp_power_set< mp_list<D, CC1, CC2, MC1, MC2, CA1, CA2, MA1, MA2> > >( test() );
|
||||
return boost::report_errors();
|
||||
}
|
@ -37,6 +37,10 @@ struct F
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
BOOST_TEST_EQ( (visit( []{ return 5; } )), 5 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int> v( 1 );
|
||||
|
||||
|
57
test/variant_visit_derived.cpp
Normal file
57
test/variant_visit_derived.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
// Copyright 2017, 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4244 ) // conversion from float to int, possible loss of data
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <utility>
|
||||
|
||||
struct X: boost::variant2::variant<int, float>
|
||||
{
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, < 1930 )
|
||||
|
||||
template<class T> explicit X( T&& t ): variant( std::forward<T>( t ) ) {};
|
||||
|
||||
#else
|
||||
|
||||
using variant::variant;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class... T> struct Y: boost::variant2::variant<T...>
|
||||
{
|
||||
using boost::variant2::variant<T...>::variant;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
X v1( 1 );
|
||||
X const v2( 3.14f );
|
||||
|
||||
BOOST_TEST_EQ( (visit( []( int x1, float x2 ){ return (int)(x1 * 1000) + (int)(x2 * 100); }, v1, v2 )), 1314 );
|
||||
|
||||
visit( []( int x1, float x2 ){ BOOST_TEST_EQ( x1, 1 ); BOOST_TEST_EQ( x2, 3.14f ); }, v1, v2 );
|
||||
visit( []( int x1, float x2 ){ BOOST_TEST_EQ( x1, 1 ); BOOST_TEST_EQ( x2, 3.14f ); }, std::move(v1), std::move(v2) );
|
||||
}
|
||||
|
||||
{
|
||||
Y<int, float> v1( 1 );
|
||||
Y<int, float> const v2( 3.14f );
|
||||
|
||||
BOOST_TEST_EQ( (visit( []( int x1, float x2 ){ return (int)(x1 * 1000) + (int)(x2 * 100); }, v1, v2 )), 1314 );
|
||||
|
||||
visit( []( int x1, float x2 ){ BOOST_TEST_EQ( x1, 1 ); BOOST_TEST_EQ( x2, 3.14f ); }, v1, v2 );
|
||||
visit( []( int x1, float x2 ){ BOOST_TEST_EQ( x1, 1 ); BOOST_TEST_EQ( x2, 3.14f ); }, std::move(v1), std::move(v2) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
98
test/variant_visit_r.cpp
Normal file
98
test/variant_visit_r.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
|
||||
// Copyright 2017 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4244 ) // conversion from float to int, possible loss of data
|
||||
#endif
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
struct F1
|
||||
{
|
||||
template<class T1> T1 operator()( T1 t1 ) const
|
||||
{
|
||||
return t1;
|
||||
}
|
||||
};
|
||||
|
||||
struct F2
|
||||
{
|
||||
template<class T1, class T2> auto operator()( T1 t1, T2 t2 ) const -> decltype( t1 + t2 )
|
||||
{
|
||||
return t1 + t2;
|
||||
}
|
||||
};
|
||||
|
||||
struct F3
|
||||
{
|
||||
template<class T1, class T2, class T3> auto operator()( T1 t1, T2 t2, T3 t3 ) const -> decltype( t1 + t2 + t3 )
|
||||
{
|
||||
return t1 + t2 + t3;
|
||||
}
|
||||
};
|
||||
|
||||
struct F4
|
||||
{
|
||||
template<class T1, class T2, class T3, class T4> auto operator()( T1 t1, T2 t2, T3 t3, T4 t4 ) const -> decltype( t1 + t2 + t3 + t4 )
|
||||
{
|
||||
return t1 + t2 + t3 + t4;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
BOOST_TEST_EQ( (visit<int>( []{ return 3.14f; } )), 3 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float> v( 1 );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F1(), v ), 1 );
|
||||
BOOST_TEST_EQ( visit<float>( F1(), v ), 1.0f );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float> const v( 3.14f );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F1(), v ), 3 );
|
||||
BOOST_TEST_EQ( visit<float>( F1(), v ), 3.14f );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float> v1( 1 );
|
||||
variant<int, float> const v2( 3.14f );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F2(), v1, v2 ), 4 );
|
||||
BOOST_TEST_EQ( visit<float>( F2(), v1, v2 ), 1 + 3.14f );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float, double> v1( 1 );
|
||||
variant<int, float, double> const v2( 3.14f );
|
||||
variant<int, float, double> v3( 6.28 );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F3(), v1, v2, v3 ), 10 );
|
||||
BOOST_TEST_EQ( visit<float>( F3(), v1, v2, v3 ), static_cast<float>( 1 + 3.14f + 6.28 ) );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float, double, char> v1( 1 );
|
||||
variant<int, float, double, char> const v2( 3.14f );
|
||||
variant<int, float, double, char> v3( 6.28 );
|
||||
variant<int, float, double, char> const v4( 'A' );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F4(), v1, v2, v3, v4 ), 10 + 'A' );
|
||||
BOOST_TEST_EQ( visit<float>( F4(), v1, v2, v3, v4 ), static_cast<float>( 1 + 3.14f + 6.28 + 'A' ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user