mirror of
https://github.com/boostorg/variant.git
synced 2026-07-21 13:43:36 +00:00
Compare commits
170 Commits
boost-1.65.0
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| e8cb128f99 | |||
| 5e1fe395b6 | |||
| fdf2c0f646 | |||
| 0d822a9b73 | |||
| cf72f05cef | |||
| 9738f5733b | |||
| a803f3f1dd | |||
| 1fd7271d2e | |||
| 36fc992f51 | |||
| 0fd179fbd8 | |||
| b33ff4f811 | |||
| e37df948d7 | |||
| 9d1e62f33c | |||
| 7b45064ed8 | |||
| d48711fb84 | |||
| a3368f0cf8 | |||
| e4447e892f | |||
| db54469549 | |||
| 8bad74942d | |||
| 78856c049d | |||
| 738e53c83b | |||
| 40621b1256 | |||
| bab78044e4 | |||
| 73753b3d9e | |||
| a104ef5f8a | |||
| edec2ffb3b | |||
| 70ff3706c5 | |||
| 281c1791b1 | |||
| d2fdf2384b | |||
| 18853a6bfb | |||
| 2d490e74bf | |||
| 445d790b2f | |||
| 39d38baf29 | |||
| fce20c67fb | |||
| a8e42245e1 | |||
| afe0914af5 | |||
| 15f2eefbc4 | |||
| 4962a5307c | |||
| d80cb48f02 | |||
| 95ddf424e5 | |||
| 2969e124bc | |||
| 3a46150c0f | |||
| 8942489244 | |||
| 5f90f71e1b | |||
| 4c9b00be1a | |||
| 945331a312 | |||
| dcaa5ba5ef | |||
| 9221b1513c | |||
| 688a7db652 | |||
| 8da93b3259 | |||
| 5e989572ae | |||
| b948c1a486 | |||
| 03035b2f6b | |||
| 5bd7870560 | |||
| 9bd4ae5684 | |||
| 619d3dcc0f | |||
| 351b812267 | |||
| 2605aa4bff | |||
| 167b5ff373 | |||
| 1fa5aa0e0a | |||
| 5cbe9b7e19 | |||
| 38bc003df0 | |||
| a816eb6202 | |||
| 1ba33a580e | |||
| a3f266706b | |||
| 74a9d7691c | |||
| bee77d42a8 | |||
| 206d1d2bb2 | |||
| 93c21189e6 | |||
| c401edba70 | |||
| f34376e115 | |||
| 15a846fba0 | |||
| 8f52f879b5 | |||
| 3ed28d2cc5 | |||
| b18c22a8ff | |||
| 0e122c38fe | |||
| 31ed2a3b70 | |||
| 7331d648f4 | |||
| 2e32903579 | |||
| 5be655d46f | |||
| cbdb354a27 | |||
| b1d66215e1 | |||
| 66ef97f655 | |||
| dd9b0c9b84 | |||
| 74ea828cde | |||
| 7cc18f356c | |||
| dcbfeb9892 | |||
| 055487c5bb | |||
| 31dcc43faf | |||
| c80759d265 | |||
| e20f5eb7b8 | |||
| 3cc73fe162 | |||
| 7ecf721f2b | |||
| 90e7fbae48 | |||
| dd728220b0 | |||
| 98e2674467 | |||
| 5c10399096 | |||
| 11d03f3b51 | |||
| df4e29cf1e | |||
| 32794c2340 | |||
| 754eaf824f | |||
| af07139502 | |||
| 3e93fd428c | |||
| 1364d3ff5f | |||
| d069511e31 | |||
| ba0746fc9d | |||
| 46d8b92f73 | |||
| b4acbdf3e8 | |||
| 3850c195d6 | |||
| 06b643df31 | |||
| 3c5a67e48f | |||
| 500778bd7b | |||
| c4370b2da2 | |||
| 6900641f4f | |||
| 7c1171a8dd | |||
| a0ad527fce | |||
| 9af72f37bc | |||
| 4b37f9b804 | |||
| 4addd1022a | |||
| 283bff8e21 | |||
| 7d865cc369 | |||
| 1725a7f2a1 | |||
| 2cd28cdd9c | |||
| 9b13f1cb11 | |||
| edfb83b342 | |||
| 1c4d882685 | |||
| 4a448b2bf7 | |||
| 50e7df744a | |||
| e5a75bb8e1 | |||
| d972192e54 | |||
| 98b5d42e6d | |||
| b8149a3a77 | |||
| 65477fa1ae | |||
| 3f849aae1f | |||
| b91d4aa40b | |||
| 9dc4f7d697 | |||
| c11d5a3365 | |||
| 8b073bc92f | |||
| 30f57614d3 | |||
| 8c043e1135 | |||
| 6f66a90b47 | |||
| 33784034b7 | |||
| 7a756bc773 | |||
| b0852f6e60 | |||
| 85416b5182 | |||
| 2d09012977 | |||
| 6caaa65563 | |||
| bdccd8d90e | |||
| f132ca7591 | |||
| be54a19e1b | |||
| f87445832e | |||
| 28f8707515 | |||
| 49e4f90e74 | |||
| 1cf3d885bc | |||
| 3cab439be0 | |||
| ec3c0964f1 | |||
| d933b7cf01 | |||
| 61c3872905 | |||
| c15f85475e | |||
| 51f5b50dc9 | |||
| 6d0566898e | |||
| 09bbcadbc1 | |||
| bb9473dfd0 | |||
| d4202b8a3f | |||
| 18fb1d3d7f | |||
| ce556f3371 | |||
| 86142eccda | |||
| ea73f3fb81 | |||
| 18bf0a18f3 | |||
| 6c2c2fd506 |
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,168 @@
|
||||
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-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
|
||||
linkflags: "linkflags=--coverage -lasan -lubsan"
|
||||
gcov_tool: "gcov-12"
|
||||
launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8"
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
|
||||
linkflags: "linkflags=--coverage -lasan -lubsan"
|
||||
gcov_tool: "gcov-11"
|
||||
launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.7"
|
||||
- toolset: clang
|
||||
compiler: clang++
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-24.04
|
||||
cxxflags: "cxxflags=-fsanitize=address,undefined,integer -fno-sanitize-recover=undefined"
|
||||
linkflags: "linkflags=-fsanitize=address,undefined,integer"
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- 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 10 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init --depth 10 --jobs 2 tools/boostdep tools/inspect libs/filesystem
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 3" filesystem
|
||||
rm -rf libs/$LIBRARY/*
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
./b2 -j4 variant=debug tools/inspect
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release "${{matrix.cxxflags}}" "${{matrix.linkflags}}" "${{matrix.launcher}}"
|
||||
dist/bin/inspect libs/$LIBRARY
|
||||
|
||||
- name: Prepare coverage data
|
||||
if: matrix.gcov_tool
|
||||
run: |
|
||||
mkdir -p $GITHUB_WORKSPACE/coveralls
|
||||
|
||||
echo -e "#!/bin/bash\nexec ${{matrix.gcov_tool}} \"\$@\"" > $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
|
||||
chmod +x $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
|
||||
wget https://github.com/linux-test-project/lcov/archive/v1.16.zip
|
||||
unzip v1.16.zip
|
||||
LCOV="`pwd`/lcov-1.16/bin/lcov --gcov-tool $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh"
|
||||
|
||||
echo "$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory `pwd`/libs/$LIBRARY/test --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info"
|
||||
$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory ../boost-root/ --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info
|
||||
$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info "/usr*" "*/$LIBRARY/test/*" ${{matrix.ignore_coverage}} "*/$LIBRARY/tests/*" "*/$LIBRARY/examples/*" "*/$LIBRARY/example/*" -o $GITHUB_WORKSPACE/coveralls/coverage.info
|
||||
|
||||
cd ../boost-root
|
||||
OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$LIBRARY\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
|
||||
echo $OTHER_LIBS
|
||||
eval "$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info $OTHER_LIBS -o $GITHUB_WORKSPACE/coveralls/coverage.info"
|
||||
|
||||
- name: Coveralls
|
||||
uses: coverallsapp/github-action@master
|
||||
if: matrix.gcov_tool
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: ./coveralls/coverage.info
|
||||
parallel: true
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: msvc
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2025
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- 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 10 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 --include benchmark --include example --include examples --include tools --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
|
||||
|
||||
finish:
|
||||
needs: posix
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Coveralls Finished
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
parallel-finished: true
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
# Use, modification, and distribution are
|
||||
# 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 Antony Polukhin 2014-2016.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
# and how it can be used with Boost libraries.
|
||||
#
|
||||
# File revision #7
|
||||
|
||||
sudo: false
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
# - clang
|
||||
|
||||
os:
|
||||
- linux
|
||||
|
||||
env:
|
||||
global:
|
||||
# Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=$TRAVIS_BRANCH
|
||||
# or just directly specify it
|
||||
- BRANCH_TO_TEST=$TRAVIS_BRANCH
|
||||
|
||||
# Files, which coverage results must be ignored (files from other projects).
|
||||
# Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/*'
|
||||
- IGNORE_COVERAGE=''
|
||||
|
||||
# Explicitly remove the following library from Boost. This may be usefull, if you're for example running Travis
|
||||
# from `Boost.DLL` repo, while Boost already has `dll`.
|
||||
#
|
||||
# By default is eaual to - BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
|
||||
# This will force to use local repo content, instead of the Boost's default.
|
||||
- BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
|
||||
|
||||
matrix:
|
||||
# Note that "--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD" are added automatically lower in code
|
||||
- CXX_FLAGS="-std=c++98" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
- CXX_FLAGS="-std=c++11" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
- CXX_FLAGS="-std=c++1y" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
#- CXX_FLAGS="-std=c++11 -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
|
||||
#- CXX_FLAGS="-std=c++1y -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
|
||||
|
||||
###############################################################################################################
|
||||
# From this point and below code is same for all the Boost libs
|
||||
###############################################################################################################
|
||||
|
||||
|
||||
# Installing additional tools
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- git-core
|
||||
packages:
|
||||
- git
|
||||
- python-yaml
|
||||
- gcc-6
|
||||
- g++-6
|
||||
- clang
|
||||
- libc++-dev
|
||||
|
||||
before_install:
|
||||
# Set this to the name of the library
|
||||
- PROJECT_TO_TEST=`basename $TRAVIS_BUILD_DIR`
|
||||
# Cloning Boost libraries (fast nondeep cloning)
|
||||
- BOOST=$HOME/boost-local
|
||||
- echo "Testing $PROJECT_TO_TEST, to remove $BOOST/libs/$BOOST_REMOVE, testing branch $BRANCH_TO_TEST"
|
||||
- git init $BOOST
|
||||
- cd $BOOST
|
||||
- git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git
|
||||
- git fetch --depth=1
|
||||
- git checkout $BRANCH_TO_TEST
|
||||
- git submodule update --jobs=3 --init --merge
|
||||
- git remote set-branches --add origin $BRANCH_TO_TEST
|
||||
- git pull --recurse-submodules
|
||||
- git status
|
||||
- rm -rf $BOOST/libs/$BOOST_REMOVE
|
||||
- mv $TRAVIS_BUILD_DIR $BOOST/libs/$PROJECT_TO_TEST
|
||||
- TRAVIS_BUILD_DIR=$BOOST/libs/$PROJECT_TO_TEST
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
- cd $BOOST/libs/$PROJECT_TO_TEST/test/
|
||||
|
||||
script:
|
||||
# `--coverage` flags required to generate coverage info for Coveralls
|
||||
- ../../../b2 "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.3 " address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD $CXX_FLAGS" linkflags="$LINK_FLAGS --coverage -lasan -lubsan"
|
||||
|
||||
after_success:
|
||||
# Copying Coveralls data to a separate folder
|
||||
- mkdir -p $TRAVIS_BUILD_DIR/coverals
|
||||
- find ../../../bin.v2/ -name "*.gcda" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- find ../../../bin.v2/ -name "*.gcno" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- find ../../../bin.v2/ -name "*.da" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- find ../../../bin.v2/ -name "*.no" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- wget https://github.com/linux-test-project/lcov/archive/v1.12.zip
|
||||
- unzip v1.12.zip
|
||||
- LCOV="`pwd`/lcov-1.12/bin/lcov --gcov-tool gcov-6"
|
||||
|
||||
# Preparing Coveralls data by changind data format to a readable one
|
||||
- echo "$LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info"
|
||||
- $LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info
|
||||
|
||||
# ... erasing /test/ /example/ folder data
|
||||
- cd $BOOST
|
||||
- $LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info "/usr*" "*/$PROJECT_TO_TEST/test/*" $IGNORE_COVERAGE "*/$PROJECT_TO_TEST/tests/*" "*/$PROJECT_TO_TEST/examples/*" "*/$PROJECT_TO_TEST/example/*" -o $TRAVIS_BUILD_DIR/coverals/coverage.info
|
||||
|
||||
# ... erasing data that is not related to this project directly
|
||||
- OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$PROJECT_TO_TEST\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
|
||||
- echo $OTHER_LIBS
|
||||
- eval "$LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info $OTHER_LIBS -o $TRAVIS_BUILD_DIR/coverals/coverage.info"
|
||||
|
||||
# Sending data to Coveralls
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- gem install coveralls-lcov
|
||||
- coveralls-lcov coverals/coverage.info
|
||||
@@ -0,0 +1,27 @@
|
||||
# Copyright 2019 Mike Dev
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required( VERSION 3.5...3.20 )
|
||||
project( boost_variant VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
|
||||
|
||||
add_library( boost_variant INTERFACE )
|
||||
add_library( Boost::variant ALIAS boost_variant )
|
||||
|
||||
target_include_directories( boost_variant INTERFACE include )
|
||||
|
||||
target_link_libraries( boost_variant
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::detail
|
||||
Boost::integer
|
||||
Boost::mpl
|
||||
Boost::preprocessor
|
||||
Boost::throw_exception
|
||||
Boost::type_index
|
||||
Boost::type_traits
|
||||
Boost::utility
|
||||
)
|
||||
@@ -1,16 +1,16 @@
|
||||
# [Boost.Variant](http://boost.org/libs/variant)
|
||||
Boost.Variant, part of collection of the [Boost C++ Libraries](http://github.com/boostorg). It is a safe, generic, stack-based discriminated union container, offering a simple solution for manipulating an object from a heterogeneous set of types in a uniform manner.
|
||||
# [Boost.Variant](https://boost.org/libs/variant)
|
||||
Boost.Variant, part of collection of the [Boost C++ Libraries](https://github.com/boostorg). It is a safe, generic, stack-based discriminated union container, offering a simple solution for manipulating an object from a heterogeneous set of types in a uniform manner.
|
||||
|
||||
### Test results
|
||||
|
||||
@ | Build | Tests coverage | More info
|
||||
----------------|-------------- | -------------- |-----------
|
||||
Develop branch: | [](https://travis-ci.org/apolukhin/variant) [](https://ci.appveyor.com/project/apolukhin/variant/branch/develop) | [](https://coveralls.io/r/apolukhin/variant?branch=develop) | [details...](http://www.boost.org/development/tests/develop/developer/variant.html)
|
||||
Master branch: | [](https://travis-ci.org/apolukhin/variant) [](https://ci.appveyor.com/project/apolukhin/variant/branch/master) | [](https://coveralls.io/r/apolukhin/variant?branch=master) | [details...](http://www.boost.org/development/tests/master/developer/variant.html)
|
||||
Develop branch: | [](https://github.com/boostorg/variant/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/apolukhin/variant-ykfti/branch/develop) | [](https://coveralls.io/r/apolukhin/variant?branch=develop) | [details...](https://regression.boost.io/develop/developer/variant.html)
|
||||
Master branch: | [](https://github.com/boostorg/variant/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/apolukhin/variant-ykfti/branch/master) | [](https://coveralls.io/r/apolukhin/variant?branch=master) | [details...](https://regression.boost.io/master/developer/variant.html)
|
||||
|
||||
|
||||
[Open Issues](https://svn.boost.org/trac/boost/query?status=!closed&component=variant)
|
||||
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/variant.html)
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
|
||||
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/container_hash//boost_container_hash
|
||||
/boost/core//boost_core
|
||||
/boost/detail//boost_detail
|
||||
/boost/integer//boost_integer
|
||||
/boost/mpl//boost_mpl
|
||||
/boost/preprocessor//boost_preprocessor
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/type_index//boost_type_index
|
||||
/boost/type_traits//boost_type_traits
|
||||
/boost/utility//boost_utility ;
|
||||
|
||||
project /boost/variant
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_variant : : : : <library>$(boost_dependencies) ]
|
||||
[ alias all : boost_variant test ]
|
||||
;
|
||||
|
||||
call-if : boost-library variant
|
||||
;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<!--
|
||||
Copyright 2003, Eric Friedman, Itay Maman.
|
||||
Copyright 2013-2014 Antony Polukhin.
|
||||
Copyright 2013-2026 Antony Polukhin.
|
||||
|
||||
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)
|
||||
@@ -91,8 +91,6 @@
|
||||
<code><functionname>apply_visitor</functionname></code> on the
|
||||
stored visitor using the given operands.</simpara>
|
||||
</description>
|
||||
<notes>Version with variadic templates is used by default if
|
||||
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined.</notes>
|
||||
</overloaded-method>
|
||||
</method-group>
|
||||
</class>
|
||||
@@ -111,8 +109,7 @@
|
||||
<simpara>See <code><classname>apply_visitor_delayed_t</classname></code>
|
||||
which is used when <code>Visitor</code> has <code>result_type</code>
|
||||
typedef.</simpara>
|
||||
<simpara>Available only if macro
|
||||
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined and
|
||||
<simpara>Available only if
|
||||
compiler supports <code>decltype(auto)</code> and <code>decltype(some-expression)</code>.</simpara>
|
||||
</description>
|
||||
|
||||
@@ -167,7 +164,7 @@
|
||||
<paramtype>Visitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand">
|
||||
<paramtype>Variant &</paramtype>
|
||||
<paramtype>Variant&&</paramtype>
|
||||
</parameter>
|
||||
</signature>
|
||||
|
||||
@@ -183,7 +180,7 @@
|
||||
<paramtype>const Visitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand">
|
||||
<paramtype>Variant &</paramtype>
|
||||
<paramtype>Variant&&</paramtype>
|
||||
</parameter>
|
||||
</signature>
|
||||
|
||||
@@ -200,10 +197,10 @@
|
||||
<paramtype>BinaryVisitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand1">
|
||||
<paramtype>Variant1 &</paramtype>
|
||||
<paramtype>Variant1&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand2">
|
||||
<paramtype>Variant2 &</paramtype>
|
||||
<paramtype>Variant2&&</paramtype>
|
||||
</parameter>
|
||||
</signature>
|
||||
|
||||
@@ -220,10 +217,10 @@
|
||||
<paramtype>const BinaryVisitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand1">
|
||||
<paramtype>Variant1 &</paramtype>
|
||||
<paramtype>Variant1&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand2">
|
||||
<paramtype>Variant2 &</paramtype>
|
||||
<paramtype>Variant2&&</paramtype>
|
||||
</parameter>
|
||||
</signature>
|
||||
|
||||
@@ -241,13 +238,13 @@
|
||||
<paramtype>MultiVisitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand1">
|
||||
<paramtype>Variant1 &</paramtype>
|
||||
<paramtype>Variant1&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand2">
|
||||
<paramtype>Variant2 &</paramtype>
|
||||
<paramtype>Variant2&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand3">
|
||||
<paramtype>Variant3 &</paramtype>
|
||||
<paramtype>Variant3&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="other_operands">
|
||||
<paramtype>...</paramtype>
|
||||
@@ -268,13 +265,13 @@
|
||||
<paramtype>const MultiVisitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand1">
|
||||
<paramtype>Variant1 &</paramtype>
|
||||
<paramtype>Variant1&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand2">
|
||||
<paramtype>Variant2 &</paramtype>
|
||||
<paramtype>Variant2&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand3">
|
||||
<paramtype>Variant3 &</paramtype>
|
||||
<paramtype>Variant3&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="other_operands">
|
||||
<paramtype>...</paramtype>
|
||||
@@ -315,7 +312,8 @@
|
||||
<description>
|
||||
<simpara>The behavior of <code>apply_visitor</code> is dependent on
|
||||
the number of arguments on which it operates (i.e., other than the
|
||||
visitor). The function behaves as follows:
|
||||
visitor). If your compiler does not support the rvalue references or reference qualifiers then all the
|
||||
forwarding references from above degrade to non const lvalue reference. The function behaves as follows:
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>Overloads accepting one operand invoke the unary function
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE header PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<!--
|
||||
Copyright 2013-2014, Antony Polukhin.
|
||||
Copyright 2013-2026 Antony Polukhin.
|
||||
|
||||
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)
|
||||
@@ -13,22 +13,6 @@
|
||||
<para>Provides declarations of <functionname>apply_visitor</functionname> for three or more
|
||||
<code><classname>variant</classname></code> parameters.</para>
|
||||
|
||||
<macro name="BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS">
|
||||
<purpose>
|
||||
<simpara>Controls maximum amount of <code><classname>variant</classname></code>
|
||||
parameters for multi visistors. Not used when <code>std::tuple</code> is available and
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined.</simpara>
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para><emphasis role="bold">Note</emphasis>: Default amount is 4. Define it
|
||||
to bigger value before including <boost/variant/multivisitors.hpp> to
|
||||
increase maximum amount of <code><classname>variant</classname></code>
|
||||
parameters for <functionname>apply_visitor</functionname>.</para>
|
||||
</description>
|
||||
</macro>
|
||||
|
||||
<namespace name="boost">
|
||||
<overloaded-function name="apply_visitor /*three or more variant parameters*/">
|
||||
<description>
|
||||
@@ -52,13 +36,13 @@
|
||||
<paramtype>MultiVisitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand1">
|
||||
<paramtype>Variant1 &</paramtype>
|
||||
<paramtype>Variant1&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand2">
|
||||
<paramtype>Variant2 &</paramtype>
|
||||
<paramtype>Variant2&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand3">
|
||||
<paramtype>Variant3 &</paramtype>
|
||||
<paramtype>Variant3&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="other_operands">
|
||||
<paramtype>...</paramtype>
|
||||
@@ -79,13 +63,13 @@
|
||||
<paramtype>const MultiVisitor &</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand1">
|
||||
<paramtype>Variant1 &</paramtype>
|
||||
<paramtype>Variant1&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand2">
|
||||
<paramtype>Variant2 &</paramtype>
|
||||
<paramtype>Variant2&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="operand3">
|
||||
<paramtype>Variant3 &</paramtype>
|
||||
<paramtype>Variant3&&</paramtype>
|
||||
</parameter>
|
||||
<parameter name="other_operands">
|
||||
<paramtype>...</paramtype>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE header PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<!--
|
||||
Copyright 2013-20014, Antony Polukhin.
|
||||
Copyright 2013-2026 Antony Polukhin.
|
||||
|
||||
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)
|
||||
|
||||
@@ -104,11 +104,6 @@
|
||||
<listitem><code>Sequence</code> must meet the requirements of
|
||||
<libraryname>MPL</libraryname>'s <emphasis>Sequence</emphasis>
|
||||
concept.</listitem>
|
||||
<listitem>Due to standard conformance problems in several compilers,
|
||||
<code>make_recursive_variant_over</code> may not be supported on
|
||||
your compiler. See
|
||||
<code><macroname>BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT</macroname></code>
|
||||
for more information.</listitem>
|
||||
</itemizedlist>
|
||||
</description>
|
||||
</class>
|
||||
|
||||
@@ -951,11 +951,6 @@
|
||||
<listitem><code>Sequence</code> must meet the requirements of
|
||||
<libraryname>MPL</libraryname>'s <emphasis>Sequence</emphasis>
|
||||
concept.</listitem>
|
||||
<listitem>Due to standard conformance problems in several compilers,
|
||||
<code>make_variant_over</code> may not be supported on your
|
||||
compiler. See
|
||||
<code><macroname>BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT</macroname></code>
|
||||
for more information.</listitem>
|
||||
</itemizedlist>
|
||||
</description>
|
||||
</class>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<!--
|
||||
Copyright 2003, Eric Friedman, Itay Maman.
|
||||
Copyright 2016, Antony Polukhin.
|
||||
Copyright 2016-2026 Antony Polukhin.
|
||||
|
||||
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)
|
||||
@@ -19,36 +19,6 @@
|
||||
class templates and the <code>boost::recursive_variant_</code> tag type.
|
||||
Also defines several preprocessor symbols, as described below.</para>
|
||||
|
||||
<macro name="BOOST_VARIANT_LIMIT_TYPES">
|
||||
<purpose>
|
||||
<simpara>Expands to the length of the
|
||||
template parameter list for
|
||||
<code><classname>variant</classname></code>. Not used if
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined.
|
||||
</simpara>
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para><emphasis role="bold">Note</emphasis>: Conforming
|
||||
implementations of <code>variant</code> must allow at least ten
|
||||
template arguments. That is, BOOST_VARIANT_LIMIT_TYPES must be greater
|
||||
or equal to <code>10</code>.</para>
|
||||
</description>
|
||||
</macro>
|
||||
|
||||
<macro name="BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES">
|
||||
<purpose>
|
||||
<simpara>If this macro is defined, then library won't use C++11 variadic templates.
|
||||
Users may define this macro to make
|
||||
<code><macroname>BOOST_VARIANT_ENUM_PARAMS</macroname></code>
|
||||
and <code><macroname>BOOST_VARIANT_ENUM_SHIFTED_PARAMS</macroname></code> expand
|
||||
to a comma-separated sequence instead of variadic templates. Define this macro if
|
||||
your compiler has problems with compilation of variadic templates.
|
||||
</simpara>
|
||||
</purpose>
|
||||
</macro>
|
||||
|
||||
<macro name="BOOST_VARIANT_ENUM_PARAMS" kind="functionlike">
|
||||
<macro-parameter name="param"/>
|
||||
|
||||
@@ -58,9 +28,7 @@
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para> When variadic templates are available and
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined, expands to variadic template list in the following manner:
|
||||
<para> Expands to variadic template list in the following manner:
|
||||
<code><programlisting>
|
||||
BOOST_VARIANT_ENUM_PARAMS(T) => T0, TN...
|
||||
BOOST_VARIANT_ENUM_PARAMS(class T) => class T0, class... TN
|
||||
@@ -97,9 +65,7 @@
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para> When variadic templates are available and
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined, expands to variadic template list in the following manner:
|
||||
<para> Expands to variadic template list in the following manner:
|
||||
<code><programlisting>
|
||||
BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T) => TN...
|
||||
BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class T) => class... TN
|
||||
@@ -125,19 +91,11 @@
|
||||
</description>
|
||||
</macro>
|
||||
|
||||
<macro name="BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT">
|
||||
<macro name="BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH">
|
||||
<purpose>
|
||||
<simpara>Indicates absence of support for specifying the bounded types
|
||||
of a <code><classname>variant</classname></code> by the elements of a
|
||||
type sequence.</simpara>
|
||||
<simpara>Define this macro if you do not wish to have a <code><classname>std::hash</classname></code> specialization for
|
||||
<code><classname>boost::variant</classname></code>.</simpara>
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para>Defined only if
|
||||
<code><classname>make_variant_over</classname></code> and
|
||||
<code><classname>make_recursive_variant_over</classname></code>
|
||||
are not supported for some reason on the target compiler.</para>
|
||||
</description>
|
||||
</macro>
|
||||
|
||||
<macro name="BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<!--
|
||||
Copyright 2003, Eric Friedman, Itay Maman.
|
||||
Copyright 2013-2014, Antony Polukhin.
|
||||
Copyright 2013-2026 Antony Polukhin.
|
||||
|
||||
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)
|
||||
@@ -90,13 +90,6 @@ typedef <classname>mpl::push_front</classname>< types_initial, int >::type
|
||||
|
||||
</para>
|
||||
|
||||
<para><emphasis role="bold">Portability</emphasis>: Unfortunately, due to
|
||||
standard conformance issues in several compilers,
|
||||
<code>make_variant_over</code> is not universally available. On these
|
||||
compilers the library indicates its lack of support for the syntax via the
|
||||
definition of the preprocessor symbol
|
||||
<code><macroname>BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT</macroname></code>.</para>
|
||||
|
||||
</section>
|
||||
|
||||
<section id="variant.tutorial.recursive">
|
||||
@@ -407,12 +400,6 @@ assert(
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>Finally, we must note that multi visitation does not support
|
||||
"delayed" form of
|
||||
<code><functionname>apply_visitor</functionname> if
|
||||
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is defined</code>.
|
||||
</para>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
<holder>Itay Maman</holder>
|
||||
</copyright>
|
||||
|
||||
<copyright>
|
||||
<year>2014-2026</year>
|
||||
<holder>Antony Polukhin</holder>
|
||||
</copyright>
|
||||
<legalnotice>
|
||||
<para>Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#ifndef BOOST_VARIANT_BAD_VISIT_HPP
|
||||
#define BOOST_VARIANT_BAD_VISIT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace boost {
|
||||
@@ -23,12 +25,12 @@ namespace boost {
|
||||
// Exception thrown when a visitation attempt via apply_visitor fails due
|
||||
// to invalid visited subtype or contents.
|
||||
//
|
||||
struct bad_visit
|
||||
struct BOOST_SYMBOL_VISIBLE bad_visit
|
||||
: std::exception
|
||||
{
|
||||
public: // std::exception interface
|
||||
|
||||
virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
|
||||
{
|
||||
return "boost::bad_visit: "
|
||||
"failed visitation using boost::apply_visitor";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,22 +14,18 @@
|
||||
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/variant/detail/generic_result_type.hpp>
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/variant/detail/has_result_type.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -42,7 +38,7 @@ namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <typename Visitor, typename Value1>
|
||||
template <typename Visitor, typename Value1, bool MoveSemantics>
|
||||
class apply_visitor_binary_invoke
|
||||
{
|
||||
public: // visitor typedefs
|
||||
@@ -66,17 +62,24 @@ public: // structors
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value2>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Value2& value2)
|
||||
typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
|
||||
operator()(Value2&& value2)
|
||||
{
|
||||
return visitor_(value1_, value2);
|
||||
return visitor_(std::move(value1_), std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
template <typename Value2>
|
||||
typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
|
||||
operator()(Value2&& value2)
|
||||
{
|
||||
return visitor_(value1_, std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_binary_invoke& operator=(const apply_visitor_binary_invoke&);
|
||||
};
|
||||
|
||||
template <typename Visitor, typename Visitable2>
|
||||
template <typename Visitor, typename Visitable2, bool MoveSemantics>
|
||||
class apply_visitor_binary_unwrap
|
||||
{
|
||||
public: // visitor typedefs
|
||||
@@ -100,12 +103,26 @@ public: // structors
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value1>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Value1& value1)
|
||||
typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
|
||||
operator()(Value1&& value1)
|
||||
{
|
||||
apply_visitor_binary_invoke<
|
||||
Visitor
|
||||
, Value1
|
||||
, ! ::boost::is_lvalue_reference<Value1>::value
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, std::move(visitable2_));
|
||||
}
|
||||
|
||||
template <typename Value1>
|
||||
typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
|
||||
operator()(Value1&& value1)
|
||||
{
|
||||
apply_visitor_binary_invoke<
|
||||
Visitor
|
||||
, Value1
|
||||
, ! ::boost::is_lvalue_reference<Value1>::value
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, visitable2_);
|
||||
@@ -122,59 +139,31 @@ private:
|
||||
// nonconst-visitor version:
|
||||
//
|
||||
|
||||
#if !BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
|
||||
|
||||
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
|
||||
/**/
|
||||
|
||||
#else // EDG-based compilers
|
||||
|
||||
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
|
||||
typename enable_if< \
|
||||
mpl::not_< is_const< V > > \
|
||||
, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
|
||||
>::type \
|
||||
/**/
|
||||
|
||||
#endif // EDG-based compilers workaround
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
|
||||
apply_visitor(
|
||||
Visitor& visitor
|
||||
, Visitable1& visitable1, Visitable2& visitable2
|
||||
)
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap<
|
||||
Visitor, Visitable2
|
||||
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
|
||||
|
||||
//
|
||||
// const-visitor version:
|
||||
//
|
||||
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
|
||||
typename Visitor::result_type
|
||||
)
|
||||
apply_visitor(
|
||||
const Visitor& visitor
|
||||
, Visitable1& visitable1, Visitable2& visitable2
|
||||
)
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor( const Visitor& visitor , Visitable1&& visitable1 , Visitable2&& visitable2)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap<
|
||||
const Visitor, Visitable2
|
||||
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +177,7 @@ apply_visitor(
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <typename Visitor, typename Value1>
|
||||
template <typename Visitor, typename Value1, bool MoveSemantics>
|
||||
class apply_visitor_binary_invoke_cpp14
|
||||
{
|
||||
Visitor& visitor_;
|
||||
@@ -205,16 +194,22 @@ public: // structors
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value2>
|
||||
decltype(auto) operator()(Value2& value2)
|
||||
decltype(auto) operator()(Value2&& value2, typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, bool>::type = true)
|
||||
{
|
||||
return visitor_(value1_, value2);
|
||||
return visitor_(std::move(value1_), std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
template <typename Value2>
|
||||
decltype(auto) operator()(Value2&& value2, typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, bool>::type = true)
|
||||
{
|
||||
return visitor_(value1_, std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_binary_invoke_cpp14& operator=(const apply_visitor_binary_invoke_cpp14&);
|
||||
};
|
||||
|
||||
template <typename Visitor, typename Visitable2>
|
||||
template <typename Visitor, typename Visitable2, bool MoveSemantics>
|
||||
class apply_visitor_binary_unwrap_cpp14
|
||||
{
|
||||
Visitor& visitor_;
|
||||
@@ -231,11 +226,24 @@ public: // structors
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value1>
|
||||
decltype(auto) operator()(Value1& value1)
|
||||
decltype(auto) operator()(Value1&& value1, typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, bool>::type = true)
|
||||
{
|
||||
apply_visitor_binary_invoke_cpp14<
|
||||
Visitor
|
||||
, Value1
|
||||
, ! ::boost::is_lvalue_reference<Value1>::value
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, std::move(visitable2_));
|
||||
}
|
||||
|
||||
template <typename Value1>
|
||||
decltype(auto) operator()(Value1&& value1, typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value, bool>::type = true)
|
||||
{
|
||||
apply_visitor_binary_invoke_cpp14<
|
||||
Visitor
|
||||
, Value1
|
||||
, ! ::boost::is_lvalue_reference<Value1>::value
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, visitable2_);
|
||||
@@ -248,31 +256,34 @@ private:
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2,
|
||||
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
bool
|
||||
>::type = true)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
|
||||
Visitor, Visitable2
|
||||
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2,
|
||||
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
bool
|
||||
>::type = true)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
|
||||
const Visitor, Visitable2
|
||||
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -13,11 +13,9 @@
|
||||
#ifndef BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP
|
||||
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP
|
||||
|
||||
#include <boost/variant/detail/generic_result_type.hpp>
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
#include <boost/variant/detail/apply_visitor_binary.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
|
||||
#include <boost/variant/detail/has_result_type.hpp>
|
||||
@@ -59,38 +57,13 @@ public: // structors
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
public: // N-ary visitor interface
|
||||
template <typename... Visitables>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Visitables&... visitables) const
|
||||
result_type operator()(Visitables&... visitables) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitables...);
|
||||
}
|
||||
|
||||
#else // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
public: // unary visitor interface
|
||||
|
||||
template <typename Visitable>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Visitable& visitable) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitable);
|
||||
}
|
||||
|
||||
public: // binary visitor interface
|
||||
|
||||
template <typename Visitable1, typename Visitable2>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Visitable1& visitable1, Visitable2& visitable2) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitable1, visitable2);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
private:
|
||||
apply_visitor_delayed_t& operator=(const apply_visitor_delayed_t&);
|
||||
|
||||
@@ -105,8 +78,7 @@ inline typename boost::enable_if<
|
||||
return apply_visitor_delayed_t<Visitor>(visitor);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276) \
|
||||
&& !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)
|
||||
|
||||
template <typename Visitor>
|
||||
class apply_visitor_delayed_cpp14_t
|
||||
@@ -142,8 +114,7 @@ inline typename boost::disable_if<
|
||||
return apply_visitor_delayed_cpp14_t<Visitor>(visitor);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
// && !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,14 +14,7 @@
|
||||
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/variant/detail/generic_result_type.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#endif
|
||||
#include <utility>
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/mpl/distance.hpp>
|
||||
@@ -30,6 +23,8 @@
|
||||
# include <boost/mpl/size.hpp>
|
||||
# include <boost/utility/declval.hpp>
|
||||
# include <boost/core/enable_if.hpp>
|
||||
# include <boost/type_traits/copy_cv_ref.hpp>
|
||||
# include <boost/type_traits/remove_reference.hpp>
|
||||
# include <boost/variant/detail/has_result_type.hpp>
|
||||
#endif
|
||||
|
||||
@@ -45,47 +40,27 @@ namespace boost {
|
||||
// nonconst-visitor version:
|
||||
//
|
||||
|
||||
#if !BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
|
||||
|
||||
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
|
||||
/**/
|
||||
|
||||
#else // EDG-based compilers
|
||||
|
||||
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
|
||||
typename enable_if< \
|
||||
mpl::not_< is_const< V > > \
|
||||
, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
|
||||
>::type \
|
||||
/**/
|
||||
|
||||
#endif // EDG-based compilers workaround
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
|
||||
apply_visitor(Visitor& visitor, Visitable& visitable)
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor, Visitable&& visitable)
|
||||
{
|
||||
return visitable.apply_visitor(visitor);
|
||||
return std::forward<Visitable>(visitable).apply_visitor(visitor);
|
||||
}
|
||||
|
||||
#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
|
||||
|
||||
//
|
||||
// const-visitor version:
|
||||
//
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
apply_visitor(const Visitor& visitor, Visitable& visitable)
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(const Visitor& visitor, Visitable&& visitable)
|
||||
{
|
||||
return visitable.apply_visitor(visitor);
|
||||
return std::forward<Visitable>(visitable).apply_visitor(visitor);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
#define BOOST_VARIANT_HAS_DECLTYPE_APPLY_VISITOR_RETURN_TYPE
|
||||
|
||||
// C++14
|
||||
namespace detail { namespace variant {
|
||||
@@ -93,77 +68,56 @@ namespace detail { namespace variant {
|
||||
// This class serves only metaprogramming purposes. none of its methods must be called at runtime!
|
||||
template <class Visitor, class Variant>
|
||||
struct result_multideduce1 {
|
||||
typedef typename Variant::types types;
|
||||
typedef typename remove_reference<Variant>::type::types types;
|
||||
typedef typename boost::mpl::begin<types>::type begin_it;
|
||||
typedef typename boost::mpl::advance<
|
||||
begin_it, boost::mpl::int_<boost::mpl::size<types>::type::value - 1>
|
||||
>::type last_it;
|
||||
|
||||
// For metaprogramming purposes ONLY! Do not use this method (and class) at runtime!
|
||||
static Visitor& vis() BOOST_NOEXCEPT {
|
||||
// Functions that work with lambdas must be defined in same translation unit.
|
||||
// Because of that, we can not use `boost::decval<Visitor&>()` here.
|
||||
Visitor&(*f)() = 0; // pointer to function
|
||||
return f();
|
||||
}
|
||||
|
||||
static decltype(auto) deduce_impl(last_it, unsigned /*helper*/) {
|
||||
typedef typename boost::mpl::deref<last_it>::type value_t;
|
||||
return vis()( boost::declval< value_t& >() );
|
||||
}
|
||||
|
||||
template <class It>
|
||||
static decltype(auto) deduce_impl(It, unsigned helper) {
|
||||
template <class It, class Dummy = void> // avoid explicit specialization in class scope
|
||||
struct deduce_impl {
|
||||
typedef typename boost::mpl::next<It>::type next_t;
|
||||
typedef typename boost::mpl::deref<It>::type value_t;
|
||||
if (helper == boost::mpl::distance<begin_it, It>::type::value) {
|
||||
return deduce_impl(next_t(), ++helper);
|
||||
}
|
||||
typedef decltype(true ? boost::declval< Visitor& >()( boost::declval< copy_cv_ref_t< value_t, Variant > >() )
|
||||
: boost::declval< typename deduce_impl<next_t>::type >()) type;
|
||||
};
|
||||
|
||||
return vis()( boost::declval< value_t& >() );
|
||||
}
|
||||
template <class Dummy>
|
||||
struct deduce_impl<last_it, Dummy> {
|
||||
typedef typename boost::mpl::deref<last_it>::type value_t;
|
||||
typedef decltype(boost::declval< Visitor& >()( boost::declval< copy_cv_ref_t< value_t, Variant > >() )) type;
|
||||
};
|
||||
|
||||
static decltype(auto) deduce() {
|
||||
return deduce_impl(begin_it(), 0);
|
||||
}
|
||||
typedef typename deduce_impl<begin_it>::type type;
|
||||
};
|
||||
|
||||
template <class Visitor, class Variant>
|
||||
struct result_wrapper1
|
||||
{
|
||||
typedef decltype(result_multideduce1<Visitor, Variant>::deduce()) result_type;
|
||||
typedef typename result_multideduce1<Visitor, Variant>::type result_type;
|
||||
|
||||
Visitor& visitor_;
|
||||
explicit result_wrapper1(Visitor& visitor) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
Visitor&& visitor_;
|
||||
explicit result_wrapper1(Visitor&& visitor) BOOST_NOEXCEPT
|
||||
: visitor_(std::forward<Visitor>(visitor))
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
result_type operator()(T& val) const {
|
||||
return visitor_(val);
|
||||
result_type operator()(T&& val) const {
|
||||
return visitor_(std::forward<T>(val));
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable& visitable,
|
||||
inline decltype(auto) apply_visitor(Visitor&& visitor, Visitable&& visitable,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
bool
|
||||
>::type = true)
|
||||
{
|
||||
boost::detail::variant::result_wrapper1<Visitor, Visitable> cpp14_vis(visitor);
|
||||
return visitable.apply_visitor(cpp14_vis);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable& visitable,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
{
|
||||
boost::detail::variant::result_wrapper1<const Visitor, Visitable> cpp14_vis(visitor);
|
||||
return visitable.apply_visitor(cpp14_vis);
|
||||
boost::detail::variant::result_wrapper1<Visitor, Visitable> cpp14_vis(std::forward<Visitor>(visitor));
|
||||
return std::forward<Visitable>(visitable).apply_visitor(cpp14_vis);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2016 Antony Polukhin
|
||||
// Copyright (c) 2016-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2015 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -36,42 +36,10 @@
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
# define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(T,Dest,Source) \
|
||||
substitute< T , Dest , Source > \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class template rebind1
|
||||
//
|
||||
// Limited workaround in case 'substitute' metafunction unavailable.
|
||||
//
|
||||
|
||||
template <typename T, typename U1>
|
||||
struct rebind1
|
||||
{
|
||||
private:
|
||||
typedef typename mpl::lambda<
|
||||
mpl::identity<T>
|
||||
>::type le_;
|
||||
|
||||
public:
|
||||
typedef typename mpl::eval_if<
|
||||
is_same< le_, mpl::identity<T> >
|
||||
, le_ // identity<T>
|
||||
, mpl::apply1<le_, U1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
# define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(T,Dest,Source) \
|
||||
rebind1< T , Dest > \
|
||||
/**/
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction enable_recursive
|
||||
//
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2015-2016 Antony Polukhin
|
||||
// Copyright (c) 2015-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,9 +14,7 @@
|
||||
#define BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/variant/detail/generic_result_type.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstdlib> // std::abort
|
||||
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
@@ -26,12 +24,6 @@
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
BOOST_NORETURN inline void forced_return_no_return() { // fixes `must return a value` warnings
|
||||
using namespace std;
|
||||
abort(); // some implementations have no std::abort
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) function template forced_return
|
||||
//
|
||||
@@ -39,19 +31,15 @@ BOOST_NORETURN inline void forced_return_no_return() { // fixes `must return a v
|
||||
// compile-time requirement of returning a result value.
|
||||
//
|
||||
template <typename T>
|
||||
BOOST_NORETURN inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T)
|
||||
BOOST_NORETURN inline T
|
||||
forced_return()
|
||||
{
|
||||
// logical error: should never be here! (see above)
|
||||
BOOST_ASSERT(false);
|
||||
|
||||
forced_return_no_return();
|
||||
|
||||
#ifdef BOOST_NO_NORETURN
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) (*dummy)() = 0;
|
||||
return dummy();
|
||||
#endif
|
||||
T (*dummy)() = 0;
|
||||
(void)dummy;
|
||||
BOOST_UNREACHABLE_RETURN(dummy());
|
||||
}
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/generic_result_type.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_GENERIC_RESULT_TYPE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_GENERIC_RESULT_TYPE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// (workaround) macro BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE
|
||||
//
|
||||
// On compilers with BOOST_NO_VOID_RETURNS, this macro provides a route
|
||||
// to a single syntax for dealing with template functions that may (but
|
||||
// not necessarily) return nothing (i.e. void).
|
||||
//
|
||||
// BOOST_VARIANT_AUX_RETURN_VOID provided for compilers w/ (erroneous?)
|
||||
// warnings about non-void functions not returning a value.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
#define BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) \
|
||||
T \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_RETURN_VOID \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_RETURN_VOID_TYPE \
|
||||
void \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
struct fake_return_void
|
||||
{
|
||||
fake_return_void()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
fake_return_void(const T&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct no_void_returns_helper
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct no_void_returns_helper<void>
|
||||
{
|
||||
typedef fake_return_void type;
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) \
|
||||
BOOST_DEDUCED_TYPENAME \
|
||||
::boost::detail::variant::no_void_returns_helper< T >::type \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_RETURN_VOID \
|
||||
return ::boost::detail::variant::fake_return_void() \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_RETURN_VOID_TYPE \
|
||||
::boost::detail::variant::fake_return_void
|
||||
|
||||
#endif // BOOST_NO_VOID_RETURNS workaround
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_GENERIC_RESULT_TYPE_HPP
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2015 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2011
|
||||
// Antony Polukhin
|
||||
// Copyright (c) 2011-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <boost/variant/recursive_wrapper_fwd.hpp>
|
||||
#include <boost/variant/detail/move.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
# include <boost/mpl/aux_/value_wknd.hpp>
|
||||
# include <boost/mpl/int.hpp>
|
||||
# include <boost/mpl/iter_fold.hpp>
|
||||
@@ -30,12 +29,7 @@
|
||||
# include <boost/mpl/deref.hpp>
|
||||
# include <boost/mpl/pair.hpp>
|
||||
# include <boost/mpl/protect.hpp>
|
||||
#else
|
||||
# include <boost/variant/variant_fwd.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/enum.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
@@ -53,8 +47,6 @@ namespace detail { namespace variant {
|
||||
// size of the variant's psuedo-variadic template parameter list.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
// (detail) quoted metafunction make_initializer_node
|
||||
//
|
||||
// Exposes a pair whose first type is a node in the initializer hierarchy.
|
||||
@@ -81,7 +73,6 @@ struct make_initializer_node
|
||||
typedef typename unwrap_recursive<recursive_enabled_T>::type
|
||||
public_T;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
typedef boost::is_reference<public_T>
|
||||
is_reference_content_t;
|
||||
|
||||
@@ -92,10 +83,6 @@ struct make_initializer_node
|
||||
|
||||
typedef typename boost::mpl::if_<is_reference_content_t, disable_overload<public_T>, public_T&& >::type
|
||||
param2_T;
|
||||
#else
|
||||
typedef typename call_traits<public_T>::param_type
|
||||
param_T;
|
||||
#endif
|
||||
|
||||
public: // static functions
|
||||
|
||||
@@ -111,7 +98,6 @@ struct make_initializer_node
|
||||
return BOOST_MPL_AUX_VALUE_WKND(index)::value; // which
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
static int initialize(void* dest, param2_T operand)
|
||||
{
|
||||
// This assert must newer trigger, because all the reference contents are
|
||||
@@ -122,7 +108,6 @@ struct make_initializer_node
|
||||
new(dest) value_T( boost::detail::variant::move(operand) );
|
||||
return BOOST_MPL_AUX_VALUE_WKND(index)::value; // which
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
friend class initializer_node;
|
||||
@@ -150,61 +135,6 @@ public: // static functions
|
||||
|
||||
};
|
||||
|
||||
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
// Obsolete. Remove.
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS \
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) \
|
||||
/**/
|
||||
|
||||
// Obsolete. Remove.
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_PARAM_T(N) \
|
||||
typedef typename unwrap_recursive< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type BOOST_PP_CAT(public_T,N); \
|
||||
typedef typename call_traits< \
|
||||
BOOST_PP_CAT(public_T,N) \
|
||||
>::param_type BOOST_PP_CAT(param_T,N); \
|
||||
/**/
|
||||
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) >
|
||||
struct preprocessor_list_initializer
|
||||
{
|
||||
public: // static functions
|
||||
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION(z,N,_) \
|
||||
typedef typename unwrap_recursive< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type BOOST_PP_CAT(public_T,N); \
|
||||
typedef typename call_traits< \
|
||||
BOOST_PP_CAT(public_T,N) \
|
||||
>::param_type BOOST_PP_CAT(param_T,N); \
|
||||
static int initialize( \
|
||||
void* dest \
|
||||
, BOOST_PP_CAT(param_T,N) operand \
|
||||
) \
|
||||
{ \
|
||||
typedef typename boost::detail::make_reference_content< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type internal_T; \
|
||||
\
|
||||
new(dest) internal_T(operand); \
|
||||
return (N); /*which*/ \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
@@ -216,8 +146,6 @@ public: // static functions
|
||||
// most appropriate to the current compiler.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
#define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
|
||||
::boost::mpl::iter_fold< \
|
||||
mpl_seq \
|
||||
@@ -231,19 +159,4 @@ public: // static functions
|
||||
>::type::first \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
// Obsolete. Remove.
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename_base) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
|
||||
::boost::detail::variant::preprocessor_list_initializer< \
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename_base) \
|
||||
> \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_INITIALIZER_HPP
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -19,8 +19,7 @@
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/enum.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction make_variant_list
|
||||
@@ -32,42 +31,12 @@ namespace detail { namespace variant {
|
||||
// declaration workaround (below).
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
template < typename... T >
|
||||
struct make_variant_list
|
||||
{
|
||||
typedef typename mpl::list< T... >::type type;
|
||||
};
|
||||
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
struct make_variant_list
|
||||
{
|
||||
public: // metafunction result
|
||||
|
||||
// [Define a macro to convert any void(NN) tags to mpl::void...]
|
||||
# define BOOST_VARIANT_AUX_CONVERT_VOID(z, N,_) \
|
||||
typename convert_void< BOOST_PP_CAT(T,N) >::type
|
||||
|
||||
// [...so that the specified types can be passed to mpl::list...]
|
||||
typedef typename mpl::list<
|
||||
BOOST_PP_ENUM(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_CONVERT_VOID
|
||||
, _
|
||||
)
|
||||
>::type type;
|
||||
|
||||
// [...and, finally, the conversion macro can be undefined:]
|
||||
# undef BOOST_VARIANT_AUX_CONVERT_VOID
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman
|
||||
// Copyright (c) 2002 by Andrei Alexandrescu
|
||||
// Copyright (c) 2013-2014 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
@@ -20,17 +20,13 @@
|
||||
#ifndef BOOST_VARIANT_DETAIL_MOVE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MOVE_HPP
|
||||
|
||||
#include <iterator> // for iterator_traits
|
||||
#include <new> // for placement new
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
using boost::move;
|
||||
using std::move;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template move_swap
|
||||
@@ -42,7 +38,8 @@ using boost::move;
|
||||
template <typename T>
|
||||
inline void move_swap(T& lhs, T& rhs)
|
||||
{
|
||||
::boost::adl_move_swap(lhs, rhs);
|
||||
using std::swap;
|
||||
swap(lhs, rhs);
|
||||
}
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2014.
|
||||
// Copyright Antony Polukhin, 2013-2024.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -17,11 +17,9 @@
|
||||
#endif
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
#if defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
# error "This file requires <tuple> and variadic templates support"
|
||||
#endif
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
@@ -41,10 +39,34 @@ namespace detail { namespace variant {
|
||||
: index_sequence<I...>
|
||||
{};
|
||||
|
||||
template <class... Types>
|
||||
std::tuple<Types&...> forward_as_tuple_simple(Types&... args) BOOST_NOEXCEPT
|
||||
template <typename T_, bool MoveSemantics_>
|
||||
struct MoveableWrapper //Just a reference with some metadata
|
||||
{
|
||||
return std::tuple<Types&...>(args...);
|
||||
typedef T_ T;
|
||||
static constexpr bool MoveSemantics = MoveSemantics_;
|
||||
|
||||
T& v;
|
||||
};
|
||||
|
||||
template <typename Tp, bool MoveSemantics>
|
||||
MoveableWrapper<Tp, MoveSemantics>
|
||||
wrap(Tp& t)
|
||||
{
|
||||
return MoveableWrapper<Tp, MoveSemantics>{t};
|
||||
}
|
||||
|
||||
template <typename Wrapper>
|
||||
typename enable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type
|
||||
unwrap(Wrapper& w)
|
||||
{
|
||||
return std::move(w.v);
|
||||
}
|
||||
|
||||
template <typename Wrapper>
|
||||
typename disable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type &
|
||||
unwrap(Wrapper& w)
|
||||
{
|
||||
return w.v;
|
||||
}
|
||||
|
||||
// Implementing some of the helper tuple methods
|
||||
@@ -64,7 +86,6 @@ namespace detail { namespace variant {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Forward declaration
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer;
|
||||
@@ -72,7 +93,7 @@ namespace detail { namespace variant {
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
inline one_by_one_visitor_and_value_referer<Visitor, Visitables, Values... >
|
||||
make_one_by_one_visitor_and_value_referer(
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
|
||||
)
|
||||
{
|
||||
return one_by_one_visitor_and_value_referer<Visitor, Visitables, Values... > (
|
||||
@@ -84,12 +105,12 @@ namespace detail { namespace variant {
|
||||
class one_by_one_visitor_and_value_referer
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
std::tuple<Values...> values_;
|
||||
Visitables visitables_;
|
||||
|
||||
public: // structors
|
||||
one_by_one_visitor_and_value_referer(
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
@@ -100,15 +121,15 @@ namespace detail { namespace variant {
|
||||
typedef typename Visitor::result_type result_type;
|
||||
|
||||
template <typename Value>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()(Value& value) const
|
||||
result_type operator()(Value&& value) const
|
||||
{
|
||||
return ::boost::apply_visitor(
|
||||
make_one_by_one_visitor_and_value_referer(
|
||||
visitor_,
|
||||
tuple_tail(visitables_),
|
||||
std::tuple_cat(values_, std::tuple<Value&>(value))
|
||||
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value)))
|
||||
)
|
||||
, std::get<0>(visitables_) // getting Head element
|
||||
, unwrap(std::get<0>(visitables_)) // getting Head element
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,11 +141,11 @@ namespace detail { namespace variant {
|
||||
class one_by_one_visitor_and_value_referer<Visitor, std::tuple<>, Values...>
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
std::tuple<Values...> values_;
|
||||
|
||||
public:
|
||||
one_by_one_visitor_and_value_referer(
|
||||
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values&...> values
|
||||
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
@@ -133,15 +154,15 @@ namespace detail { namespace variant {
|
||||
typedef typename Visitor::result_type result_type;
|
||||
|
||||
template <class Tuple, std::size_t... I>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) do_call(Tuple t, index_sequence<I...>) const {
|
||||
return visitor_(std::get<I>(t)...);
|
||||
result_type do_call(Tuple t, index_sequence<I...>) const {
|
||||
return visitor_(unwrap(std::get<I>(t))...);
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()(Value& value) const
|
||||
result_type operator()(Value&& value) const
|
||||
{
|
||||
return do_call(
|
||||
std::tuple_cat(values_, std::tuple<Value&>(value)),
|
||||
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value))),
|
||||
make_index_sequence<sizeof...(Values) + 1>()
|
||||
);
|
||||
}
|
||||
@@ -150,31 +171,39 @@ namespace detail { namespace variant {
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <class Visitor, class T1, class T2, class T3, class... TN>
|
||||
inline BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
apply_visitor(const Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn)
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(const Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn)
|
||||
{
|
||||
return ::boost::apply_visitor(
|
||||
::boost::detail::variant::make_one_by_one_visitor_and_value_referer(
|
||||
visitor,
|
||||
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
|
||||
std::make_tuple(
|
||||
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
|
||||
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
|
||||
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
v1
|
||||
);
|
||||
),
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
template <class Visitor, class T1, class T2, class T3, class... TN>
|
||||
inline BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
apply_visitor(Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn)
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn)
|
||||
{
|
||||
return ::boost::apply_visitor(
|
||||
::boost::detail::variant::make_one_by_one_visitor_and_value_referer(
|
||||
visitor,
|
||||
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
|
||||
std::make_tuple(
|
||||
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
|
||||
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
|
||||
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
v1
|
||||
);
|
||||
),
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant/detail/multivisitors_cpp14_based.hpp>
|
||||
#include <tuple>
|
||||
|
||||
namespace boost {
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace detail { namespace variant {
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
inline one_by_one_visitor_and_value_referer_cpp14<Visitor, Visitables, Values... >
|
||||
make_one_by_one_visitor_and_value_referer_cpp14(
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
|
||||
)
|
||||
{
|
||||
return one_by_one_visitor_and_value_referer_cpp14<Visitor, Visitables, Values... > (
|
||||
@@ -42,12 +42,12 @@ namespace detail { namespace variant {
|
||||
class one_by_one_visitor_and_value_referer_cpp14
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
std::tuple<Values...> values_;
|
||||
Visitables visitables_;
|
||||
|
||||
public: // structors
|
||||
one_by_one_visitor_and_value_referer_cpp14(
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
@@ -56,15 +56,15 @@ namespace detail { namespace variant {
|
||||
|
||||
public: // visitor interfaces
|
||||
template <typename Value>
|
||||
decltype(auto) operator()(Value& value) const
|
||||
decltype(auto) operator()(Value&& value) const
|
||||
{
|
||||
return ::boost::apply_visitor(
|
||||
make_one_by_one_visitor_and_value_referer_cpp14(
|
||||
visitor_,
|
||||
tuple_tail(visitables_),
|
||||
std::tuple_cat(values_, std::tuple<Value&>(value))
|
||||
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value)))
|
||||
)
|
||||
, std::get<0>(visitables_) // getting Head element
|
||||
, unwrap(std::get<0>(visitables_)) // getting Head element
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ namespace detail { namespace variant {
|
||||
class one_by_one_visitor_and_value_referer_cpp14<Visitor, std::tuple<>, Values...>
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
std::tuple<Values...> values_;
|
||||
|
||||
public:
|
||||
one_by_one_visitor_and_value_referer_cpp14(
|
||||
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values&...> values
|
||||
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
@@ -88,14 +88,14 @@ namespace detail { namespace variant {
|
||||
|
||||
template <class Tuple, std::size_t... I>
|
||||
decltype(auto) do_call(Tuple t, index_sequence<I...>) const {
|
||||
return visitor_(std::get<I>(t)...);
|
||||
return visitor_(unwrap(std::get<I>(t))...);
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
decltype(auto) operator()(Value& value) const
|
||||
decltype(auto) operator()(Value&& value) const
|
||||
{
|
||||
return do_call(
|
||||
std::tuple_cat(values_, std::tuple<Value&>(value)),
|
||||
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value))),
|
||||
make_index_sequence<sizeof...(Values) + 1>()
|
||||
);
|
||||
}
|
||||
@@ -104,35 +104,45 @@ namespace detail { namespace variant {
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <class Visitor, class T1, class T2, class T3, class... TN>
|
||||
inline decltype(auto) apply_visitor(const Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn,
|
||||
inline decltype(auto) apply_visitor(const Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
bool
|
||||
>::type = true)
|
||||
{
|
||||
return boost::apply_visitor(
|
||||
::boost::detail::variant::make_one_by_one_visitor_and_value_referer_cpp14(
|
||||
visitor,
|
||||
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
|
||||
std::make_tuple(
|
||||
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
|
||||
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
|
||||
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
v1
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class Visitor, class T1, class T2, class T3, class... TN>
|
||||
inline decltype(auto) apply_visitor(Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn,
|
||||
inline decltype(auto) apply_visitor(Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
bool
|
||||
>::type = true)
|
||||
{
|
||||
return ::boost::apply_visitor(
|
||||
::boost::detail::variant::make_one_by_one_visitor_and_value_referer_cpp14(
|
||||
visitor,
|
||||
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
|
||||
std::make_tuple(
|
||||
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
|
||||
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
|
||||
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
v1
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
// Boost.Varaint
|
||||
// Contains multivisitors that are implemented via preprocessor magic
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2014.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_MULTIVISITORS_PREPROCESSOR_BASED_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MULTIVISITORS_PREPROCESSOR_BASED_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition.hpp>
|
||||
#include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||
#include <boost/preprocessor/arithmetic/add.hpp>
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
|
||||
#ifndef BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS
|
||||
# define BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS 4
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <class VisitorT, class Visitable1T, class Visitable2T>
|
||||
struct two_variables_holder {
|
||||
private:
|
||||
VisitorT& visitor_;
|
||||
Visitable1T& visitable1_;
|
||||
Visitable2T& visitable2_;
|
||||
|
||||
// required to suppress warnings and ensure that we do not copy
|
||||
// this visitor
|
||||
two_variables_holder& operator=(const two_variables_holder&);
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME VisitorT::result_type result_type;
|
||||
|
||||
explicit two_variables_holder(VisitorT& visitor, Visitable1T& visitable1, Visitable2T& visitable2) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, visitable1_(visitable1)
|
||||
, visitable2_(visitable2)
|
||||
{}
|
||||
|
||||
#define BOOST_VARIANT_OPERATOR_BEG() \
|
||||
return ::boost::apply_visitor( \
|
||||
::boost::bind<result_type>(boost::ref(visitor_), _1, _2 \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_OPERATOR_END() \
|
||||
), visitable1_, visitable2_); \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARANT_VISITORS_VARIABLES_PRINTER(z, n, data) \
|
||||
BOOST_PP_COMMA() boost::ref( BOOST_PP_CAT(vis, n) ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_VISIT(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(n, 1), class VisitableUnwrapped)> \
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ADD(n, 1), VisitableUnwrapped, & vis) \
|
||||
) const \
|
||||
{ \
|
||||
BOOST_VARIANT_OPERATOR_BEG() \
|
||||
BOOST_PP_REPEAT(BOOST_PP_ADD(n, 1), BOOST_VARANT_VISITORS_VARIABLES_PRINTER, ~) \
|
||||
BOOST_VARIANT_OPERATOR_END() \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_VARIANT_VISIT, ~)
|
||||
#undef BOOST_VARIANT_OPERATOR_BEG
|
||||
#undef BOOST_VARIANT_OPERATOR_END
|
||||
#undef BOOST_VARANT_VISITORS_VARIABLES_PRINTER
|
||||
#undef BOOST_VARIANT_VISIT
|
||||
|
||||
};
|
||||
|
||||
template <class VisitorT, class Visitable1T, class Visitable2T>
|
||||
inline two_variables_holder<VisitorT, Visitable1T, Visitable2T> make_two_variables_holder(
|
||||
VisitorT& visitor, Visitable1T& visitable1, Visitable2T& visitable2
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
return two_variables_holder<VisitorT, Visitable1T, Visitable2T>(visitor, visitable1, visitable2);
|
||||
}
|
||||
|
||||
template <class VisitorT, class Visitable1T, class Visitable2T>
|
||||
inline two_variables_holder<const VisitorT, Visitable1T, Visitable2T> make_two_variables_holder(
|
||||
const VisitorT& visitor, Visitable1T& visitable1, Visitable2T& visitable2
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
return two_variables_holder<const VisitorT, Visitable1T, Visitable2T>(visitor, visitable1, visitable2);
|
||||
}
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
#define BOOST_VARIANT_APPLY_VISITOR_BEG() \
|
||||
return ::boost::apply_visitor( \
|
||||
boost::detail::variant::make_two_variables_holder(visitor, var0 , var1), \
|
||||
var2 \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_APPLY_VISITOR_END() \
|
||||
); \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARANT_VISITORS_VARIABLES_PRINTER(z, n, data) \
|
||||
BOOST_PP_COMMA() BOOST_PP_CAT(var, BOOST_PP_ADD(n, 3)) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_VISIT(z, n, data) \
|
||||
template <class Visitor BOOST_PP_COMMA() BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(n, 3), class T)> \
|
||||
inline BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(BOOST_DEDUCED_TYPENAME Visitor::result_type) apply_visitor( \
|
||||
data BOOST_PP_COMMA() BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ADD(n, 3), T, & var) \
|
||||
) \
|
||||
{ \
|
||||
BOOST_VARIANT_APPLY_VISITOR_BEG() \
|
||||
BOOST_PP_REPEAT(n, BOOST_VARANT_VISITORS_VARIABLES_PRINTER, ~) \
|
||||
BOOST_VARIANT_APPLY_VISITOR_END() \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_VARIANT_VISIT, const Visitor& visitor)
|
||||
BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_VARIANT_VISIT, Visitor& visitor)
|
||||
|
||||
#undef BOOST_VARIANT_APPLY_VISITOR_BEG
|
||||
#undef BOOST_VARIANT_APPLY_VISITOR_END
|
||||
#undef BOOST_VARANT_VISITORS_VARIABLES_PRINTER
|
||||
#undef BOOST_VARIANT_VISIT
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MULTIVISITORS_PREPROCESSOR_BASED_HPP
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/std_hash.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018-2026 Antony Polukhin
|
||||
//
|
||||
// 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)
|
||||
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_STD_HASH_HPP
|
||||
#define BOOST_VARIANT_DETAIL_STD_HASH_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/detail/hash_variant.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH
|
||||
//
|
||||
// Define this macro if you do not wish to have a std::hash specialization for
|
||||
// boost::variant.
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||
|
||||
#include <functional> // for std::hash
|
||||
|
||||
namespace std {
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
struct hash<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) > > {
|
||||
std::size_t operator()(const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& val) const {
|
||||
return ::boost::hash_value(val);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // #if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_STD_HASH_HPP
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
///// header body
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/substitute.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
@@ -21,22 +16,17 @@
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
#include <boost/variant/detail/substitute_fwd.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/mpl/aux_/lambda_arity_param.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/repeat.hpp>
|
||||
#include <boost/mpl/int_fwd.hpp>
|
||||
#include <boost/mpl/limits/arity.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction substitute
|
||||
//
|
||||
@@ -126,7 +116,6 @@ struct substitute<
|
||||
// template expression (i.e., F<...>) specializations
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
template <
|
||||
template <typename...> class F
|
||||
, typename... Ts
|
||||
@@ -145,96 +134,18 @@ struct substitute<
|
||||
Ts, Dest, Source
|
||||
>::type...> type;
|
||||
};
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL(N) \
|
||||
typedef typename substitute< \
|
||||
BOOST_PP_CAT(U,N), Dest, Source \
|
||||
>::type BOOST_PP_CAT(u,N); \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF(z, N, _) \
|
||||
BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL( BOOST_PP_INC(N) ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_PP_ITERATION_LIMITS (0,BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
|
||||
#define BOOST_PP_FILENAME_1 <boost/variant/detail/substitute.hpp>
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL
|
||||
#undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
|
||||
|
||||
///// iteration, depth == 1
|
||||
|
||||
#elif BOOST_PP_ITERATION_DEPTH() == 1
|
||||
#define i BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
#if i > 0
|
||||
|
||||
//
|
||||
// template specializations
|
||||
//
|
||||
template <
|
||||
template < BOOST_MPL_PP_PARAMS(i,typename P) > class T
|
||||
, BOOST_MPL_PP_PARAMS(i,typename U)
|
||||
, typename Dest
|
||||
, typename Source
|
||||
>
|
||||
struct substitute<
|
||||
T< BOOST_MPL_PP_PARAMS(i,U) >
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<( i )>)
|
||||
>
|
||||
{
|
||||
private:
|
||||
BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _)
|
||||
|
||||
public:
|
||||
typedef T< BOOST_MPL_PP_PARAMS(i,u) > type;
|
||||
};
|
||||
|
||||
//
|
||||
// function specializations
|
||||
//
|
||||
template <
|
||||
typename R
|
||||
, BOOST_MPL_PP_PARAMS(i,typename U)
|
||||
, typename... A
|
||||
, typename Dest
|
||||
, typename Source
|
||||
>
|
||||
struct substitute<
|
||||
R (*)( BOOST_MPL_PP_PARAMS(i,U) )
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef typename substitute< R, Dest, Source >::type r;
|
||||
BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _)
|
||||
|
||||
public:
|
||||
typedef r (*type)( BOOST_MPL_PP_PARAMS(i,u) );
|
||||
};
|
||||
|
||||
#elif i == 0
|
||||
|
||||
//
|
||||
// zero-arg function specialization
|
||||
//
|
||||
template <
|
||||
typename R, typename Dest, typename Source
|
||||
>
|
||||
struct substitute<
|
||||
R (*)( void )
|
||||
R (*)(A...)
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
|
||||
@@ -244,10 +155,12 @@ private:
|
||||
typedef typename substitute< R, Dest, Source >::type r;
|
||||
|
||||
public:
|
||||
typedef r (*type)( void );
|
||||
typedef r (*type)(typename substitute<
|
||||
A, Dest, Source
|
||||
>::type...);
|
||||
};
|
||||
|
||||
#endif // i
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#undef i
|
||||
#endif // BOOST_PP_IS_ITERATING
|
||||
#endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
|
||||
|
||||
@@ -18,25 +18,12 @@
|
||||
#include <boost/mpl/int_fwd.hpp>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// BOOST_VARIANT_DETAIL_NO_SUBSTITUTE
|
||||
//
|
||||
// Defined if 'substitute' is not implementable on the current compiler.
|
||||
//
|
||||
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
#include <boost/mpl/aux_/config/ttp.hpp>
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_TEMPLATE_PARAMETERS) \
|
||||
&& !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
# define BOOST_VARIANT_DETAIL_NO_SUBSTITUTE
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction substitute
|
||||
//
|
||||
@@ -50,8 +37,6 @@ template <
|
||||
>
|
||||
struct substitute;
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include <iosfwd> // for std::basic_ostream forward declare
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/detail/templated_streams.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -29,14 +27,9 @@ namespace boost {
|
||||
//
|
||||
|
||||
// forward declare (allows output of embedded variant< variant< ... >, ... >)
|
||||
template <
|
||||
BOOST_TEMPLATED_STREAM_ARGS(E,T)
|
||||
BOOST_TEMPLATED_STREAM_COMMA
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename U)
|
||||
>
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
, const variant< BOOST_VARIANT_ENUM_PARAMS(U) >& rhs
|
||||
template <class CharT, class Trait, typename... U>
|
||||
inline std::basic_ostream<CharT, Trait>& operator<<(
|
||||
std::basic_ostream<CharT, Trait>& out, const variant<U...>& rhs
|
||||
);
|
||||
|
||||
namespace detail { namespace variant {
|
||||
@@ -71,18 +64,13 @@ private:
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <
|
||||
BOOST_TEMPLATED_STREAM_ARGS(E,T)
|
||||
BOOST_TEMPLATED_STREAM_COMMA
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename U)
|
||||
>
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
, const variant< BOOST_VARIANT_ENUM_PARAMS(U) >& rhs
|
||||
template <class CharT, class Trait, typename... U>
|
||||
inline std::basic_ostream<CharT, Trait>& operator<<(
|
||||
std::basic_ostream<CharT, Trait>& out, const variant<U...>& rhs
|
||||
)
|
||||
{
|
||||
detail::variant::printer<
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)
|
||||
std::basic_ostream<CharT, Trait>
|
||||
> visitor(out);
|
||||
|
||||
rhs.apply_visitor(visitor);
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
#include <boost/variant/detail/backup_holder.hpp>
|
||||
#include <boost/variant/detail/cast_storage.hpp>
|
||||
#include <boost/variant/detail/forced_return.hpp>
|
||||
#include <boost/variant/detail/generic_result_type.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
@@ -35,9 +34,9 @@
|
||||
#include <boost/type_traits/has_nothrow_copy.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable : 4702) //unreachable code
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable : 4702) //unreachable code
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -48,14 +47,9 @@
|
||||
//
|
||||
#if !defined(BOOST_VARIANT_VISITATION_UNROLLING_LIMIT)
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# include <boost/mpl/limits/list.hpp>
|
||||
# define BOOST_VARIANT_VISITATION_UNROLLING_LIMIT \
|
||||
BOOST_MPL_LIMIT_LIST_SIZE
|
||||
#else
|
||||
# define BOOST_VARIANT_VISITATION_UNROLLING_LIMIT \
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,8 +96,7 @@ struct visitation_impl_step< LastIter,LastIter >
|
||||
//
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename T>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
inline typename Visitor::result_type
|
||||
visitation_impl_invoke_impl(
|
||||
int, Visitor& visitor, VoidPtrCV storage, T*
|
||||
, mpl::true_// never_uses_backup
|
||||
@@ -115,8 +108,7 @@ visitation_impl_invoke_impl(
|
||||
}
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename T>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
inline typename Visitor::result_type
|
||||
visitation_impl_invoke_impl(
|
||||
int internal_which, Visitor& visitor, VoidPtrCV storage, T*
|
||||
, mpl::false_// never_uses_backup
|
||||
@@ -137,8 +129,7 @@ visitation_impl_invoke_impl(
|
||||
}
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename T, typename NoBackupFlag>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
inline typename Visitor::result_type
|
||||
visitation_impl_invoke(
|
||||
int internal_which, Visitor& visitor, VoidPtrCV storage, T* t
|
||||
, NoBackupFlag
|
||||
@@ -158,8 +149,7 @@ visitation_impl_invoke(
|
||||
}
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename NBF>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
inline typename Visitor::result_type
|
||||
visitation_impl_invoke(int, Visitor&, VoidPtrCV, apply_visitor_unrolled*, NBF, long)
|
||||
{
|
||||
// should never be here at runtime!
|
||||
@@ -178,12 +168,11 @@ template <
|
||||
, typename Visitor, typename VPCV
|
||||
, typename NBF
|
||||
>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
inline typename Visitor::result_type
|
||||
visitation_impl(
|
||||
int, int, Visitor&, VPCV
|
||||
, mpl::true_ // is_apply_visitor_unrolled
|
||||
, NBF, W* = 0, S* = 0
|
||||
, NBF, W* = nullptr, S* = nullptr
|
||||
)
|
||||
{
|
||||
// should never be here at runtime!
|
||||
@@ -196,14 +185,13 @@ template <
|
||||
, typename Visitor, typename VoidPtrCV
|
||||
, typename NoBackupFlag
|
||||
>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
BOOST_FORCEINLINE typename Visitor::result_type
|
||||
visitation_impl(
|
||||
const int internal_which, const int logical_which
|
||||
, Visitor& visitor, VoidPtrCV storage
|
||||
, mpl::false_ // is_apply_visitor_unrolled
|
||||
, NoBackupFlag no_backup_flag
|
||||
, Which* = 0, step0* = 0
|
||||
, Which* = nullptr, step0* = nullptr
|
||||
)
|
||||
{
|
||||
// Typedef apply_visitor_unrolled steps and associated types...
|
||||
@@ -270,8 +258,8 @@ visitation_impl(
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_VISITATION_IMPL_HPP
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,10 +16,10 @@
|
||||
#include <exception>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/detail/element_index.hpp>
|
||||
#include <boost/variant/detail/move.hpp>
|
||||
@@ -44,7 +44,7 @@ class BOOST_SYMBOL_VISIBLE bad_get
|
||||
{
|
||||
public: // std::exception implementation
|
||||
|
||||
virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
|
||||
{
|
||||
return "boost::bad_get: "
|
||||
"failed value get using boost::get";
|
||||
@@ -99,11 +99,16 @@ public: // visitor interfaces
|
||||
}} // namespace detail::variant
|
||||
|
||||
#ifndef BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
# if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0551))
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# else
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = 0
|
||||
# if defined(BOOST_NO_CXX11_NULLPTR)
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = 0
|
||||
# else
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = nullptr
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -173,6 +178,12 @@ relaxed_get(
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#if defined(BOOST_MSVC) && (_MSC_VER < 1900) // MSVC-2014 has fixed the incorrect diagnostics.
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4172) // returning address of local variable or temporary
|
||||
#endif
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
U&&
|
||||
@@ -188,6 +199,11 @@ relaxed_get(
|
||||
boost::throw_exception(bad_get());
|
||||
return static_cast<U&&>(*result);
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) && (_MSC_VER < 1900)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2014.
|
||||
// Copyright (c) 2013-2026 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -17,15 +17,11 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
# include <boost/variant/detail/multivisitors_cpp11_based.hpp>
|
||||
# if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/variant/detail/multivisitors_cpp14_based.hpp>
|
||||
# endif
|
||||
#else
|
||||
# include <boost/variant/detail/multivisitors_preprocessor_based.hpp>
|
||||
#include <boost/variant/detail/multivisitors_cpp11_based.hpp>
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/variant/detail/multivisitors_cpp14_based.hpp>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_MULTIVISITORS_HPP
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2013-2017 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -15,10 +15,10 @@
|
||||
#include <exception>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/get.hpp>
|
||||
|
||||
@@ -132,11 +132,16 @@ public: // visitor interfaces
|
||||
}} // namespace detail::variant
|
||||
|
||||
#ifndef BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
# if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0551))
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# else
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = 0
|
||||
# if defined(BOOST_NO_CXX11_NULLPTR)
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = 0
|
||||
# else
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = nullptr
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -45,8 +45,6 @@ namespace detail { namespace variant {
|
||||
// Handles embedded variant types when substituting for recursive_variant_.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
template <
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
, typename RecursiveVariant
|
||||
@@ -115,9 +113,7 @@ struct substitute<
|
||||
, ::boost::recursive_variant_
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
|
||||
>
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
{
|
||||
typedef ::boost::variant<
|
||||
typename enable_recursive<
|
||||
T0
|
||||
@@ -130,41 +126,8 @@ struct substitute<
|
||||
, mpl::true_
|
||||
>::type...
|
||||
> type;
|
||||
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
private: // helpers, for metafunction result (below)
|
||||
|
||||
#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS(z,N,_) \
|
||||
typedef typename enable_recursive< \
|
||||
BOOST_PP_CAT(T,N) \
|
||||
, RecursiveVariant \
|
||||
, mpl::true_ \
|
||||
>::type BOOST_PP_CAT(wknd_T,N); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS
|
||||
|
||||
public: // metafunction result
|
||||
|
||||
typedef ::boost::variant< BOOST_VARIANT_ENUM_PARAMS(wknd_T) > type;
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
};
|
||||
|
||||
#else // defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
//
|
||||
// no specializations: embedded variants unsupported on these compilers!
|
||||
//
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <boost/variant/recursive_wrapper_fwd.hpp>
|
||||
#include <boost/variant/detail/move.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2016-2017 Antony Polukhin
|
||||
// Copyright (c) 2016-2026 Antony Polukhin
|
||||
//
|
||||
// Portions Copyright (C) 2002 David Abrahams
|
||||
//
|
||||
|
||||
@@ -50,10 +50,8 @@ public: // typedefs
|
||||
protected: // for use as base class only
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
||||
static_visitor() = default;
|
||||
~static_visitor() = default;
|
||||
#else
|
||||
static_visitor() BOOST_NOEXCEPT { }
|
||||
~static_visitor() BOOST_NOEXCEPT { }
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -84,7 +82,7 @@ struct is_static_visitor_impl
|
||||
} // namespace detail
|
||||
|
||||
template< typename T > struct is_static_visitor
|
||||
: public ::boost::integral_constant<bool,(::boost::detail::is_static_visitor_impl<T>::value)>
|
||||
: public ::boost::integral_constant<bool,(::boost::detail::is_static_visitor_impl<T>::value)>
|
||||
{
|
||||
public:
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_static_visitor,(T))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2012-2016 Antony Polukhin
|
||||
// Copyright (c) 2012-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -32,18 +32,15 @@
|
||||
#include <boost/variant/detail/over_sequence.hpp>
|
||||
#include <boost/variant/detail/visitation_impl.hpp>
|
||||
#include <boost/variant/detail/hash_variant.hpp>
|
||||
#include <boost/variant/detail/std_hash.hpp>
|
||||
|
||||
#include <boost/variant/detail/generic_result_type.hpp>
|
||||
#include <boost/variant/detail/move.hpp>
|
||||
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <boost/detail/reference_content.hpp>
|
||||
#include <boost/aligned_storage.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
#include <boost/math/common_factor_ct.hpp>
|
||||
#include <boost/integer/common_factor_ct.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/has_nothrow_constructor.hpp>
|
||||
@@ -55,8 +52,9 @@
|
||||
#include <boost/type_traits/is_rvalue_reference.hpp>
|
||||
#include <boost/type_traits/is_constructible.hpp>
|
||||
#include <boost/type_traits/add_lvalue_reference.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
#include <boost/type_traits/declval.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/variant/recursive_wrapper_fwd.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
@@ -130,7 +128,7 @@ private: // helpers, for metafunction result (below)
|
||||
|
||||
typedef typename mpl::transform1<Sequence, F>::type transformed_;
|
||||
typedef typename mpl::max_element<transformed_
|
||||
|
||||
|
||||
>::type max_it;
|
||||
|
||||
public: // metafunction result
|
||||
@@ -145,7 +143,7 @@ struct add_alignment
|
||||
template <typename State, typename Item>
|
||||
struct apply
|
||||
: mpl::size_t<
|
||||
::boost::math::static_lcm<
|
||||
::boost::integer::static_lcm<
|
||||
BOOST_MPL_AUX_VALUE_WKND(State)::value
|
||||
, ::boost::alignment_of<Item>::value
|
||||
>::value
|
||||
@@ -221,7 +219,6 @@ public: // metafunction result
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction is_variant_move_noexcept_constructible
|
||||
//
|
||||
@@ -255,7 +252,6 @@ struct is_variant_move_noexcept_assignable {
|
||||
iterator_t, end_t
|
||||
>::type type;
|
||||
};
|
||||
#endif // BOOST_NO_CXX11_NOEXCEPT
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction is_variant_constructible_from
|
||||
@@ -308,8 +304,6 @@ struct is_variant_constructible_from< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T
|
||||
is_variant_constructible_from<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Types >
|
||||
{};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T), class Types>
|
||||
struct is_variant_constructible_from< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>&& , Types >:
|
||||
is_variant_constructible_from<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Types >
|
||||
@@ -320,8 +314,6 @@ struct is_variant_constructible_from< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T
|
||||
is_variant_constructible_from<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Types >
|
||||
{};
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction make_storage
|
||||
@@ -347,7 +339,7 @@ private: // helpers, for metafunction result (below)
|
||||
types, mpl::sizeof_<mpl::_1>
|
||||
>::type max_size;
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0551))
|
||||
|
||||
typedef typename mpl::fold<
|
||||
types
|
||||
@@ -381,17 +373,14 @@ struct destroyer
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(T& operand, int) const BOOST_NOEXCEPT
|
||||
void internal_visit(T& operand, int) const BOOST_NOEXCEPT
|
||||
{
|
||||
operand.~T(); // must be noexcept
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551)) || \
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0551)) || \
|
||||
BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
|
||||
(void)operand; // suppresses warnings
|
||||
#endif
|
||||
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -445,27 +434,21 @@ public: // structors
|
||||
public: // internal visitor interface
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
|
||||
void internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
|
||||
{
|
||||
new(storage_) T( operand.get() );
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
|
||||
void internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
|
||||
{
|
||||
new(storage_) T( operand.get() );
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(const T& operand, int) const
|
||||
void internal_visit(const T& operand, int) const
|
||||
{
|
||||
new(storage_) T(operand);
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -475,7 +458,6 @@ public: // internal visitor interface
|
||||
//
|
||||
// Internal visitor that moves the value it visits into the given buffer.
|
||||
//
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
class move_into
|
||||
: public static_visitor<>
|
||||
{
|
||||
@@ -493,22 +475,17 @@ public: // structors
|
||||
public: // internal visitor interface
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
|
||||
void internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
|
||||
{
|
||||
new(storage_) T( ::boost::detail::variant::move(operand.get()) );
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(T& operand, int) const BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T(boost::declval<T>())))
|
||||
void internal_visit(T& operand, int) const BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T(boost::declval<T>())))
|
||||
{
|
||||
new(storage_) T(::boost::detail::variant::move(operand));
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class assign_storage
|
||||
@@ -533,26 +510,21 @@ public: // structors
|
||||
public: // internal visitor interfaces
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(backup_holder<T>& lhs_content, long) const
|
||||
void internal_visit(backup_holder<T>& lhs_content, long) const
|
||||
{
|
||||
lhs_content.get()
|
||||
= static_cast< const backup_holder<T>* >(rhs_storage_)->get();
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(const backup_holder<T>& lhs_content, long) const
|
||||
void internal_visit(const backup_holder<T>& lhs_content, long) const
|
||||
{
|
||||
lhs_content.get()
|
||||
= static_cast< const backup_holder<T>* >(rhs_storage_)->get();
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(T& lhs_content, int) const
|
||||
void internal_visit(T& lhs_content, int) const
|
||||
{
|
||||
// NOTE TO USER :
|
||||
// Compile error here indicates one of variant's bounded types does
|
||||
@@ -562,7 +534,6 @@ public: // internal visitor interfaces
|
||||
// Hint: Are any of the bounded types const-qualified or references?
|
||||
//
|
||||
lhs_content = *static_cast< const T* >(rhs_storage_);
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -590,26 +561,21 @@ public: // structors
|
||||
public: // internal visitor interfaces
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(backup_holder<T>& lhs_content, long) const
|
||||
void internal_visit(backup_holder<T>& lhs_content, long) const
|
||||
{
|
||||
lhs_content.get()
|
||||
= ::boost::detail::variant::move(static_cast<backup_holder<T>* >(rhs_storage_)->get());
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(const backup_holder<T>& lhs_content, long) const
|
||||
void internal_visit(const backup_holder<T>& lhs_content, long) const
|
||||
{
|
||||
lhs_content.get()
|
||||
= ::boost::detail::variant::move(static_cast<backup_holder<T>* >(rhs_storage_)->get());
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(T& lhs_content, int) const
|
||||
void internal_visit(T& lhs_content, int) const
|
||||
{
|
||||
// NOTE TO USER :
|
||||
// Compile error here indicates one of variant's bounded types does
|
||||
@@ -619,7 +585,6 @@ public: // internal visitor interfaces
|
||||
// Hint: Are any of the bounded types const-qualified or references?
|
||||
//
|
||||
lhs_content = ::boost::detail::variant::move(*static_cast<T* >(rhs_storage_));
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -866,15 +831,12 @@ private: // helpers, for visitor interface (below)
|
||||
public: // visitor interface
|
||||
|
||||
template <typename LhsT>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(LhsT& lhs_content, int)
|
||||
void internal_visit(LhsT& lhs_content, int)
|
||||
{
|
||||
typedef typename is_nothrow_move_constructible<LhsT>::type
|
||||
nothrow_move;
|
||||
|
||||
backup_assign_impl( lhs_content, nothrow_move(), 1L);
|
||||
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
|
||||
@@ -1019,7 +981,7 @@ struct less_comp
|
||||
// * for wrappers (e.g., recursive_wrapper), the wrapper's held value.
|
||||
// * for all other values, the value itself.
|
||||
//
|
||||
template <typename Visitor>
|
||||
template <typename Visitor, bool MoveSemantics>
|
||||
class invoke_visitor
|
||||
{
|
||||
private: // representation
|
||||
@@ -1038,97 +1000,56 @@ public: // structors
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
public: // internal visitor interfaces
|
||||
|
||||
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
|
||||
template <typename T>
|
||||
result_type internal_visit(T& operand, int)
|
||||
typename enable_if_c<MoveSemantics && is_same<T, T>::value, result_type>::type internal_visit(T&& operand, int)
|
||||
{
|
||||
return visitor_(std::move(operand));
|
||||
}
|
||||
|
||||
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
|
||||
template <typename T>
|
||||
typename disable_if_c<MoveSemantics && is_same<T, T>::value, result_type>::type internal_visit(T&& operand, int)
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564))
|
||||
template <typename T>
|
||||
result_type internal_visit(const T& operand, int)
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
# endif
|
||||
|
||||
#else // defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
private: // helpers, for internal visitor interfaces (below)
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
visit_impl(T& operand, mpl::false_)
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
visit_impl(T& operand, mpl::true_)
|
||||
{
|
||||
visitor_(operand);
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
public: // internal visitor interfaces
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(T& operand, int)
|
||||
{
|
||||
typedef typename is_same<result_type, void>::type
|
||||
has_void_result_type;
|
||||
|
||||
return visit_impl(operand, has_void_result_type());
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_VOID_RETURNS) workaround
|
||||
|
||||
public: // internal visitor interfaces, cont.
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(boost::recursive_wrapper<T>& operand, long)
|
||||
result_type internal_visit(boost::recursive_wrapper<T>& operand, long)
|
||||
{
|
||||
return internal_visit( operand.get(), 1L );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(const boost::recursive_wrapper<T>& operand, long)
|
||||
result_type internal_visit(const boost::recursive_wrapper<T>& operand, long)
|
||||
{
|
||||
return internal_visit( operand.get(), 1L );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(boost::detail::reference_content<T>& operand, long)
|
||||
result_type internal_visit(boost::detail::reference_content<T>& operand, long)
|
||||
{
|
||||
return internal_visit( operand.get(), 1L );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(const boost::detail::reference_content<T>& operand, long)
|
||||
result_type internal_visit(const boost::detail::reference_content<T>& operand, long)
|
||||
{
|
||||
return internal_visit( operand.get(), 1L );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(boost::detail::variant::backup_holder<T>& operand, long)
|
||||
result_type internal_visit(boost::detail::variant::backup_holder<T>& operand, long)
|
||||
{
|
||||
return internal_visit( operand.get(), 1L );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
internal_visit(const boost::detail::variant::backup_holder<T>& operand, long)
|
||||
result_type internal_visit(const boost::detail::variant::backup_holder<T>& operand, long)
|
||||
{
|
||||
return internal_visit( operand.get(), 1L );
|
||||
}
|
||||
@@ -1173,8 +1094,6 @@ private: // helpers, for typedefs (below)
|
||||
{
|
||||
};
|
||||
|
||||
#if !defined(BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
|
||||
|
||||
private: // helpers, for typedefs (below)
|
||||
|
||||
typedef typename mpl::eval_if<
|
||||
@@ -1218,82 +1137,6 @@ private: // internal typedefs
|
||||
internal_types
|
||||
>::type internal_T0;
|
||||
|
||||
#else // defined(BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
|
||||
|
||||
private: // helpers, for typedefs (below)
|
||||
|
||||
typedef unwrapped_T0_ T0;
|
||||
|
||||
#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS(z,N,_) \
|
||||
typedef typename mpl::eval_if< \
|
||||
is_recursive_ \
|
||||
, detail::variant::enable_recursive< \
|
||||
BOOST_PP_CAT(T,N) \
|
||||
, wknd_self_t \
|
||||
> \
|
||||
, mpl::identity< BOOST_PP_CAT(T,N) > \
|
||||
>::type BOOST_PP_CAT(recursive_enabled_T,N); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS
|
||||
|
||||
#define BOOST_VARIANT_AUX_UNWRAP_RECURSIVE_TYPEDEFS(z,N,_) \
|
||||
typedef typename unwrap_recursive< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type BOOST_PP_CAT(public_T,N); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_UNWRAP_RECURSIVE_TYPEDEFS
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_UNWRAP_RECURSIVE_TYPEDEFS
|
||||
|
||||
public: // public typedefs
|
||||
|
||||
typedef typename detail::variant::make_variant_list<
|
||||
BOOST_VARIANT_ENUM_PARAMS(public_T)
|
||||
>::type types;
|
||||
|
||||
private: // helpers, for internal typedefs (below)
|
||||
|
||||
#define BOOST_VARIANT_AUX_MAKE_REFERENCE_CONTENT_TYPEDEFS(z,N,_) \
|
||||
typedef detail::make_reference_content< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type BOOST_PP_CAT(internal_T,N); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_MAKE_REFERENCE_CONTENT_TYPEDEFS
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_MAKE_REFERENCE_CONTENT_TYPEDEFS
|
||||
|
||||
private: // internal typedefs
|
||||
|
||||
typedef typename detail::variant::make_variant_list<
|
||||
BOOST_VARIANT_ENUM_PARAMS(internal_T)
|
||||
>::type internal_types;
|
||||
|
||||
private: // static precondition assertions
|
||||
|
||||
// NOTE TO USER :
|
||||
// variant< type-sequence > syntax is not supported on this compiler!
|
||||
//
|
||||
BOOST_MPL_ASSERT_NOT(( is_sequence_based_ ));
|
||||
|
||||
#endif // BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT workaround
|
||||
|
||||
private: // helpers, for representation (below)
|
||||
|
||||
typedef typename detail::variant::find_fallback_type<
|
||||
@@ -1319,7 +1162,6 @@ private: // helpers, for representation (below)
|
||||
internal_types, never_uses_backup_flag
|
||||
>::type storage_t;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
typedef typename detail::variant::is_variant_move_noexcept_constructible<
|
||||
internal_types
|
||||
> variant_move_noexcept_constructible;
|
||||
@@ -1328,8 +1170,6 @@ private: // helpers, for representation (below)
|
||||
internal_types
|
||||
> variant_move_noexcept_assignable;
|
||||
|
||||
#endif
|
||||
|
||||
private: // helpers, for representation (below)
|
||||
|
||||
// which_ on:
|
||||
@@ -1421,15 +1261,15 @@ public: // structors
|
||||
destroy_content();
|
||||
}
|
||||
|
||||
variant()
|
||||
variant()
|
||||
#if !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130))
|
||||
BOOST_NOEXCEPT_IF(boost::has_nothrow_constructor<internal_T0>::value)
|
||||
#endif
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( push )
|
||||
// behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
|
||||
#pragma warning( disable : 4345 )
|
||||
// behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
|
||||
#pragma warning( disable : 4345 )
|
||||
#endif
|
||||
// NOTE TO USER :
|
||||
// Compile error from here indicates that the first bound
|
||||
@@ -1465,14 +1305,14 @@ private: // helpers, for structors, cont. (below)
|
||||
int internal_visit(T& operand, int) const
|
||||
{
|
||||
// NOTE TO USER :
|
||||
// Compile error here indicates one of the source variant's types
|
||||
// Compile error here indicates one of the source variant's types
|
||||
// cannot be unambiguously converted to the destination variant's
|
||||
// types (or that no conversion exists).
|
||||
//
|
||||
return initializer::initialize(storage_, operand);
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564))
|
||||
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0564))
|
||||
template <typename T>
|
||||
result_type internal_visit(const T& operand, int) const
|
||||
{
|
||||
@@ -1520,7 +1360,6 @@ private: // helpers, for structors, cont. (below)
|
||||
|
||||
friend class convert_copy_into;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
class convert_move_into
|
||||
: public static_visitor<int>
|
||||
{
|
||||
@@ -1541,7 +1380,7 @@ private: // helpers, for structors, cont. (below)
|
||||
int internal_visit(T& operand, int) const
|
||||
{
|
||||
// NOTE TO USER :
|
||||
// Compile error here indicates one of the source variant's types
|
||||
// Compile error here indicates one of the source variant's types
|
||||
// cannot be unambiguously converted to the destination variant's
|
||||
// types (or that no conversion exists).
|
||||
//
|
||||
@@ -1586,9 +1425,8 @@ private: // helpers, for structors, cont. (below)
|
||||
};
|
||||
|
||||
friend class convert_move_into;
|
||||
#endif
|
||||
|
||||
private: // helpers, for structors, below
|
||||
private: // helpers, for structors, below
|
||||
|
||||
template <typename T>
|
||||
void convert_construct(
|
||||
@@ -1598,7 +1436,7 @@ private: // helpers, for structors, below
|
||||
)
|
||||
{
|
||||
// NOTE TO USER :
|
||||
// Compile error here indicates that the given type is not
|
||||
// Compile error here indicates that the given type is not
|
||||
// unambiguously convertible to one of the variant's types
|
||||
// (or that no conversion exists).
|
||||
//
|
||||
@@ -1610,7 +1448,6 @@ private: // helpers, for structors, below
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
typename boost::enable_if<boost::is_rvalue_reference<T&&> >::type convert_construct(
|
||||
T&& operand
|
||||
@@ -1619,7 +1456,7 @@ private: // helpers, for structors, below
|
||||
)
|
||||
{
|
||||
// NOTE TO USER :
|
||||
// Compile error here indicates that the given type is not
|
||||
// Compile error here indicates that the given type is not
|
||||
// unambiguously convertible to one of the variant's types
|
||||
// (or that no conversion exists).
|
||||
//
|
||||
@@ -1630,7 +1467,6 @@ private: // helpers, for structors, below
|
||||
)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Variant>
|
||||
void convert_construct(
|
||||
@@ -1645,7 +1481,6 @@ private: // helpers, for structors, below
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename Variant>
|
||||
typename boost::enable_if<boost::is_rvalue_reference<Variant&&> >::type convert_construct(
|
||||
Variant&& operand
|
||||
@@ -1658,7 +1493,6 @@ private: // helpers, for structors, below
|
||||
operand.internal_apply_visitor(visitor)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Variant>
|
||||
void convert_construct_variant(Variant& operand)
|
||||
@@ -1687,7 +1521,6 @@ private: // helpers, for structors, below
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename Variant>
|
||||
typename boost::enable_if<boost::is_rvalue_reference<Variant&&> >::type convert_construct_variant(Variant&& operand)
|
||||
{
|
||||
@@ -1714,7 +1547,6 @@ private: // helpers, for structors, below
|
||||
, is_foreign_variant()
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename U)>
|
||||
typename boost::enable_if<mpl::or_<
|
||||
@@ -1737,10 +1569,9 @@ private: // helpers, for structors, below
|
||||
, long
|
||||
)
|
||||
{
|
||||
convert_construct_variant(operand);
|
||||
convert_construct_variant(operand);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename U)>
|
||||
typename boost::enable_if<mpl::or_<
|
||||
boost::is_same<boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>, variant>,
|
||||
@@ -1750,9 +1581,8 @@ private: // helpers, for structors, below
|
||||
, long
|
||||
)
|
||||
{
|
||||
convert_construct_variant( detail::variant::move(operand) );
|
||||
convert_construct_variant( detail::variant::move(operand) );
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // structors, cont.
|
||||
|
||||
@@ -1762,8 +1592,9 @@ public: // structors, cont.
|
||||
mpl::and_<
|
||||
mpl::not_< boost::is_same<T, variant> >,
|
||||
boost::detail::variant::is_variant_constructible_from<const T&, internal_types>
|
||||
>,
|
||||
boost::is_same<T, boost::recursive_variant_> > >::type* = 0)
|
||||
>,
|
||||
boost::is_same<T, boost::recursive_variant_> >,
|
||||
bool >::type = true)
|
||||
{
|
||||
convert_construct(operand, 1L);
|
||||
}
|
||||
@@ -1777,13 +1608,13 @@ public: // structors, cont.
|
||||
mpl::not_< boost::is_same<T, variant> >,
|
||||
boost::detail::variant::is_variant_constructible_from<T&, internal_types>
|
||||
>,
|
||||
boost::is_same<T, boost::recursive_variant_> > >::type* = 0
|
||||
boost::is_same<T, boost::recursive_variant_> >,
|
||||
bool >::type = true
|
||||
)
|
||||
{
|
||||
convert_construct(operand, 1L);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class T>
|
||||
variant(T&& operand,
|
||||
typename boost::enable_if<mpl::or_<
|
||||
@@ -1793,11 +1624,11 @@ public: // structors, cont.
|
||||
mpl::not_< boost::is_same<T, variant> >,
|
||||
boost::detail::variant::is_variant_constructible_from<T&&, internal_types>
|
||||
>,
|
||||
boost::is_same<T, boost::recursive_variant_> > >::type* = 0)
|
||||
boost::is_same<T, boost::recursive_variant_> >,
|
||||
bool >::type = true)
|
||||
{
|
||||
convert_construct( detail::variant::move(operand), 1L);
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // structors, cont.
|
||||
|
||||
@@ -1812,7 +1643,6 @@ public: // structors, cont.
|
||||
indicate_which(operand.which());
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
variant(variant&& operand) BOOST_NOEXCEPT_IF(variant_move_noexcept_constructible::type::value)
|
||||
{
|
||||
// Move the value of operand into *this...
|
||||
@@ -1822,14 +1652,11 @@ public: // structors, cont.
|
||||
// ...and activate the *this's primary storage on success:
|
||||
indicate_which(operand.which());
|
||||
}
|
||||
#endif
|
||||
|
||||
private: // helpers, for modifiers (below)
|
||||
|
||||
# if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
template <typename Variant>
|
||||
friend class detail::variant::backup_assigner;
|
||||
# endif
|
||||
|
||||
// class assigner
|
||||
//
|
||||
@@ -1953,8 +1780,7 @@ private: // helpers, for modifiers (below)
|
||||
public: // internal visitor interfaces
|
||||
|
||||
template <typename RhsT>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(const RhsT& rhs_content, int) const
|
||||
void internal_visit(const RhsT& rhs_content, int) const
|
||||
{
|
||||
typedef typename has_nothrow_copy<RhsT>::type
|
||||
nothrow_copy;
|
||||
@@ -1969,8 +1795,6 @@ private: // helpers, for modifiers (below)
|
||||
, nothrow_move_constructor()
|
||||
, has_fallback_type_()
|
||||
);
|
||||
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
|
||||
@@ -1979,10 +1803,9 @@ private: // helpers, for modifiers (below)
|
||||
assigner& operator= (assigner const&);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
friend class assigner;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
// class move_assigner
|
||||
//
|
||||
// Internal visitor that "move assigns" the visited value to the given variant
|
||||
@@ -2000,7 +1823,7 @@ private: // helpers, for modifiers (below)
|
||||
}
|
||||
|
||||
private: // helpers, for internal visitor interface (below)
|
||||
|
||||
|
||||
template <typename RhsT, typename B2>
|
||||
void assign_impl(
|
||||
RhsT& rhs_content
|
||||
@@ -2060,7 +1883,7 @@ private: // helpers, for modifiers (below)
|
||||
// In the event of success, indicate new content type:
|
||||
assigner::lhs_.indicate_which(assigner::rhs_which_); // nothrow
|
||||
}
|
||||
|
||||
|
||||
template <typename RhsT>
|
||||
void assign_impl(
|
||||
RhsT& rhs_content
|
||||
@@ -2075,8 +1898,7 @@ private: // helpers, for modifiers (below)
|
||||
public: // internal visitor interfaces
|
||||
|
||||
template <typename RhsT>
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
internal_visit(RhsT& rhs_content, int) const
|
||||
void internal_visit(RhsT& rhs_content, int) const
|
||||
{
|
||||
typedef typename is_nothrow_move_constructible<RhsT>::type
|
||||
nothrow_move_constructor;
|
||||
@@ -2091,8 +1913,6 @@ private: // helpers, for modifiers (below)
|
||||
, nothrow_move_constructor()
|
||||
, has_fallback_type_()
|
||||
);
|
||||
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
|
||||
@@ -2103,7 +1923,6 @@ private: // helpers, for modifiers (below)
|
||||
};
|
||||
|
||||
friend class move_assigner;
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
void variant_assign(const variant& rhs)
|
||||
{
|
||||
@@ -2118,11 +1937,10 @@ private: // helpers, for modifiers (below)
|
||||
{
|
||||
// Otherwise, perform general (copy-based) variant assignment:
|
||||
assigner visitor(*this, rhs.which());
|
||||
rhs.internal_apply_visitor(visitor);
|
||||
rhs.internal_apply_visitor(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
void variant_assign(variant&& rhs)
|
||||
{
|
||||
// If the contained types are EXACTLY the same...
|
||||
@@ -2136,10 +1954,9 @@ private: // helpers, for modifiers (below)
|
||||
{
|
||||
// Otherwise, perform general (move-based) variant assignment:
|
||||
move_assigner visitor(*this, rhs.which());
|
||||
rhs.internal_apply_visitor(visitor);
|
||||
rhs.internal_apply_visitor(visitor);
|
||||
}
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
private: // helpers, for modifiers (below)
|
||||
|
||||
@@ -2161,7 +1978,6 @@ private: // helpers, for modifiers (below)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
void move_assign(T&& rhs)
|
||||
{
|
||||
@@ -2179,11 +1995,10 @@ private: // helpers, for modifiers (below)
|
||||
variant_assign( detail::variant::move(temp) );
|
||||
}
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
public: // modifiers
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#if !BOOST_WORKAROUND(BOOST_CLANG_VERSION, BOOST_TESTED_AT(150000)) || BOOST_CXX_VERSION <= 202002L
|
||||
template <class T>
|
||||
typename boost::enable_if<
|
||||
boost::mpl::and_<
|
||||
@@ -2192,12 +2007,12 @@ public: // modifiers
|
||||
boost::detail::variant::is_variant_constructible_from<T&&, internal_types>
|
||||
>,
|
||||
variant&
|
||||
>::type operator=(T&& rhs)
|
||||
>::type operator=(T&& rhs)
|
||||
{
|
||||
move_assign( detail::variant::move(rhs) );
|
||||
return *this;
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
typename boost::enable_if<
|
||||
@@ -2219,8 +2034,7 @@ public: // modifiers
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
variant& operator=(variant&& rhs)
|
||||
variant& operator=(variant&& rhs)
|
||||
#if !defined(__GNUC__) || (__GNUC__ != 4) || (__GNUC_MINOR__ > 6) || defined(__clang__)
|
||||
BOOST_NOEXCEPT_IF(variant_move_noexcept_constructible::type::value && variant_move_noexcept_assignable::type::value)
|
||||
#endif
|
||||
@@ -2228,7 +2042,6 @@ public: // modifiers
|
||||
variant_assign( detail::variant::move(rhs) );
|
||||
return *this;
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
void swap(variant& rhs)
|
||||
{
|
||||
@@ -2370,10 +2183,7 @@ public:
|
||||
#endif// !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV>
|
||||
static
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
|
||||
typename Visitor::result_type
|
||||
)
|
||||
BOOST_FORCEINLINE static typename Visitor::result_type
|
||||
internal_apply_visitor_impl(
|
||||
int internal_which
|
||||
, int logical_which
|
||||
@@ -2398,9 +2208,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
|
||||
typename Visitor::result_type
|
||||
)
|
||||
BOOST_FORCEINLINE typename Visitor::result_type
|
||||
internal_apply_visitor(Visitor& visitor)
|
||||
{
|
||||
return internal_apply_visitor_impl(
|
||||
@@ -2409,9 +2217,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
|
||||
typename Visitor::result_type
|
||||
)
|
||||
BOOST_FORCEINLINE typename Visitor::result_type
|
||||
internal_apply_visitor(Visitor& visitor) const
|
||||
{
|
||||
return internal_apply_visitor_impl(
|
||||
@@ -2422,22 +2228,34 @@ public:
|
||||
public: // visitation support
|
||||
|
||||
template <typename Visitor>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
|
||||
typename Visitor::result_type
|
||||
)
|
||||
apply_visitor(Visitor& visitor)
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor) &&
|
||||
{
|
||||
detail::variant::invoke_visitor<Visitor> invoker(visitor);
|
||||
detail::variant::invoke_visitor<Visitor, true> invoker(visitor);
|
||||
return this->internal_apply_visitor(invoker);
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
|
||||
typename Visitor::result_type
|
||||
)
|
||||
apply_visitor(Visitor& visitor) const
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor) const&&
|
||||
{
|
||||
detail::variant::invoke_visitor<Visitor> invoker(visitor);
|
||||
detail::variant::invoke_visitor<Visitor, true> invoker(visitor);
|
||||
return this->internal_apply_visitor(invoker);
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor) &
|
||||
{
|
||||
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
|
||||
return this->internal_apply_visitor(invoker);
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor) const &
|
||||
{
|
||||
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
|
||||
return this->internal_apply_visitor(invoker);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2013-2016 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -25,15 +25,6 @@
|
||||
#include <boost/preprocessor/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT
|
||||
//
|
||||
// Defined if variant does not support make_variant_over (see below).
|
||||
//
|
||||
#if defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
# define BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
|
||||
//
|
||||
@@ -45,37 +36,6 @@
|
||||
|
||||
#include <boost/variant/detail/substitute_fwd.hpp>
|
||||
|
||||
#if defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE) \
|
||||
&& !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
|
||||
# define BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
//
|
||||
|
||||
/*
|
||||
GCC before 4.0 had no variadic tempaltes;
|
||||
GCC 4.6 has incomplete implementation of variadic templates.
|
||||
|
||||
MSVC2015 Update 1 has variadic templates, but they have issues.
|
||||
|
||||
NOTE: Clang compiler defines __GNUC__
|
||||
*/
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \
|
||||
|| (!defined(__clang__) && defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) \
|
||||
|| (defined(_MSC_VER) && (_MSC_VER <= 1900)) \
|
||||
|| defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE) \
|
||||
|| defined (BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# define BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
|
||||
#define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_class class)(
|
||||
@@ -108,9 +68,6 @@
|
||||
// Rationale: Cleaner, simpler code for clients of variant library. Minimal
|
||||
// code modifications to move from C++03 to C++11.
|
||||
//
|
||||
// With BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES defined
|
||||
// will be used BOOST_VARIANT_ENUM_PARAMS and BOOST_VARIANT_ENUM_SHIFTED_PARAMS from below `#else`
|
||||
//
|
||||
|
||||
#define BOOST_VARIANT_ENUM_PARAMS(x) \
|
||||
x ## 0, \
|
||||
@@ -121,49 +78,6 @@
|
||||
BOOST_VARIANT_MAKE_VARIADIC( (BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_ ## x), x) \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_LIMIT_TYPES
|
||||
//
|
||||
// Implementation-defined preprocessor symbol describing the actual
|
||||
// length of variant's pseudo-variadic template parameter list.
|
||||
//
|
||||
#include <boost/mpl/limits/list.hpp>
|
||||
#define BOOST_VARIANT_LIMIT_TYPES \
|
||||
BOOST_MPL_LIMIT_LIST_SIZE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_RECURSIVE_VARIANT_MAX_ARITY
|
||||
//
|
||||
// Exposes maximum allowed arity of class templates with recursive_variant
|
||||
// arguments. That is,
|
||||
// make_recursive_variant< ..., T<[1], recursive_variant_, ... [N]> >.
|
||||
//
|
||||
#include <boost/mpl/limits/arity.hpp>
|
||||
#define BOOST_VARIANT_RECURSIVE_VARIANT_MAX_ARITY \
|
||||
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_ENUM_PARAMS
|
||||
//
|
||||
// Convenience macro for enumeration of BOOST_VARIANT_LIMIT_TYPES params.
|
||||
//
|
||||
// Rationale: Cleaner, simpler code for clients of variant library.
|
||||
//
|
||||
#define BOOST_VARIANT_ENUM_PARAMS( param ) \
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_VARIANT_LIMIT_TYPES, param)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_ENUM_SHIFTED_PARAMS
|
||||
//
|
||||
// Convenience macro for enumeration of BOOST_VARIANT_LIMIT_TYPES-1 params.
|
||||
//
|
||||
#define BOOST_VARIANT_ENUM_SHIFTED_PARAMS( param ) \
|
||||
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_VARIANT_LIMIT_TYPES, param)
|
||||
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -195,75 +109,9 @@ struct convert_void< void_ >
|
||||
typedef mpl::na type;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (workaround) BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE
|
||||
//
|
||||
// Needed to work around compilers that don't support using-declaration
|
||||
// overloads. (See the variant::initializer workarounds below.)
|
||||
//
|
||||
|
||||
#if defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
// (detail) tags voidNN -- NN defined on [0, BOOST_VARIANT_LIMIT_TYPES)
|
||||
//
|
||||
// Defines void types that are each unique and specializations of
|
||||
// convert_void that yields mpl::na for each voidNN type.
|
||||
//
|
||||
|
||||
#define BOOST_VARIANT_DETAIL_DEFINE_VOID_N(z,N,_) \
|
||||
struct BOOST_PP_CAT(void,N); \
|
||||
\
|
||||
template <> \
|
||||
struct convert_void< BOOST_PP_CAT(void,N) > \
|
||||
{ \
|
||||
typedef mpl::na type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_DETAIL_DEFINE_VOID_N
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_DETAIL_DEFINE_VOID_N
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
# define BOOST_VARIANT_AUX_DECLARE_PARAMS BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) macro BOOST_VARIANT_AUX_DECLARE_PARAM
|
||||
//
|
||||
// Template parameter list for variant and recursive_variant declarations.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
# define BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL(z, N, T) \
|
||||
typename BOOST_PP_CAT(T,N) = detail::variant::void_ \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
# define BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL(z, N, T) \
|
||||
typename BOOST_PP_CAT(T,N) = BOOST_PP_CAT(detail::variant::void,N) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
#define BOOST_VARIANT_AUX_DECLARE_PARAMS \
|
||||
BOOST_PP_ENUM( \
|
||||
BOOST_VARIANT_LIMIT_TYPES \
|
||||
, BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL \
|
||||
, T \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
#define BOOST_VARIANT_AUX_DECLARE_PARAMS BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class template variant (concept inspired by Andrei Alexandrescu)
|
||||
|
||||
@@ -68,8 +68,6 @@ public: // static visitor interfaces
|
||||
boost::throw_exception(bad_visit());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
public: // static visitor interfaces, cont.
|
||||
|
||||
result_type operator()(argument_fwd_type operand) const
|
||||
@@ -77,33 +75,6 @@ public: // static visitor interfaces, cont.
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
#else // defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
private: // helpers, for static visitor interfaces (below)
|
||||
|
||||
result_type execute_impl(argument_fwd_type operand, mpl::false_) const
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
|
||||
execute_impl(argument_fwd_type operand, mpl::true_) const
|
||||
{
|
||||
visitor_(operand);
|
||||
BOOST_VARIANT_AUX_RETURN_VOID;
|
||||
}
|
||||
|
||||
public: // static visitor interfaces, cont.
|
||||
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(argument_fwd_type operand) const
|
||||
{
|
||||
typedef typename is_void<result_type>::type has_void_result;
|
||||
return execute_impl(operand, has_void_result());
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_VOID_RETURNS workaround
|
||||
|
||||
};
|
||||
|
||||
template <typename R, typename T>
|
||||
|
||||
+28
-2
@@ -1,9 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2014-2026 Antony Polukhin
|
||||
antoshkka at gmail dot com
|
||||
|
||||
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)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/variant.html">
|
||||
<title>Boost.Variant</title>
|
||||
<style>
|
||||
body {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
a {
|
||||
color: #00f;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../../doc/html/variant.html">../../doc/html/variant.html</a>
|
||||
<p>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../../doc/html/variant.html">../../doc/html/variant.html</a>
|
||||
</p>
|
||||
<p>
|
||||
© 2014-2024 Antony Polukhin
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-1
@@ -13,5 +13,6 @@
|
||||
"maintainers": [
|
||||
"Antony Polukhin <antoshkka -at- gmail.com>",
|
||||
"Eric Friedman <ericbrandon -at- gmail.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#==============================================================================
|
||||
# Copyright (c) 2012 Antony Polukhin
|
||||
# Copyright (c) 2012-2026 Antony Polukhin
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Antony Polukhin 2012-2014.
|
||||
// (C) Copyright Antony Polukhin 2012-2021.
|
||||
// Use, modification and distribution are 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)
|
||||
|
||||
+24
-9
@@ -1,15 +1,25 @@
|
||||
# Boost.Variant Library test Jamfile
|
||||
#
|
||||
# Copyright (C) 2003, Eric Friedman, Itay Maman.
|
||||
# Copyright (C) 2013, Antony Polukhin.
|
||||
# Copyright (C) 2013-2026 Antony Polukhin.
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
|
||||
require-b2 5.0.1 ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
import testing ;
|
||||
|
||||
local below_cpp14 = 98 03 0x 11 ;
|
||||
local since_cpp20 = 2a 20 latest ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
#<dependency>/boost/test//minimal
|
||||
<library>/boost/variant//boost_variant
|
||||
[ requires cxx11_rvalue_references ]
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
;
|
||||
test-suite variant
|
||||
@@ -18,19 +28,21 @@ test-suite variant
|
||||
[ run test2.cpp : : : : variant_test2 ]
|
||||
[ run test3.cpp : : : : variant_test3 ]
|
||||
[ run test3.cpp : : : <rtti>off <define>BOOST_NO_RTTI <define>BOOST_NO_TYPEID : variant_test3_no_rtti ]
|
||||
[ run test4.cpp class_a.cpp
|
||||
: : : : variant_test4 ]
|
||||
[ run test4.cpp class_a.cpp : : : : variant_test4 ]
|
||||
[ run test5.cpp : : : : variant_test5 ]
|
||||
[ run test6.cpp : : : : variant_test6 ]
|
||||
[ run test7.cpp : : : : variant_test7 ]
|
||||
[ run test8.cpp : : : : variant_test8 ]
|
||||
[ run test9.cpp : : : : variant_test9 ]
|
||||
[ run test9.cpp : : : <library>/boost/fusion//boost_fusion : variant_test9 ]
|
||||
[ run recursive_variant_test.cpp ]
|
||||
[ run variant_reference_test.cpp ]
|
||||
[ run variant_comparison_test.cpp ]
|
||||
[ run variant_visit_internal_linkage.cpp : : : "<cxxstd>$(below_cpp14)"\:<build>no ]
|
||||
[ run variant_visit_test.cpp ]
|
||||
[ run variant_get_test.cpp ]
|
||||
[ compile-fail variant_rvalue_get_with_ampersand_test.cpp ]
|
||||
[ compile-fail no_rvalue_to_nonconst_visitation.cpp ]
|
||||
[ compile fusion_interop.cpp : <library>/boost/fusion//boost_fusion ]
|
||||
[ run variant_polymorphic_get_test.cpp ]
|
||||
[ run variant_multivisit_test.cpp ]
|
||||
[ run hash_variant_test.cpp ]
|
||||
@@ -49,10 +61,13 @@ test-suite variant
|
||||
[ run recursive_variant_test.cpp : : : <rtti>off <define>BOOST_NO_RTTI <define>BOOST_NO_TYPEID : variant_no_rtti_test ]
|
||||
[ run hash_recursive_variant_test.cpp ]
|
||||
[ run variant_swap_test.cpp ]
|
||||
[ run auto_visitors.cpp ]
|
||||
[ run overload_selection.cpp ]
|
||||
[ run recursive_wrapper_move_test.cpp ]
|
||||
[ run auto_visitors.cpp : : : <library>/boost/lexical_cast//boost_lexical_cast ]
|
||||
[ run issue42.cpp ]
|
||||
[ compile issue53.cpp : <library>/boost/thread//boost_thread ]
|
||||
[ run overload_selection.cpp : : : "<cxxstd>$(since_cpp20)"\:<build>no ]
|
||||
[ run recursive_wrapper_move_test.cpp : : : <library>/boost/array//boost_array ]
|
||||
[ run variant_over_joint_view_test.cpp ]
|
||||
;
|
||||
[ run const_ref_apply_visitor.cpp : : : <library>/boost/lexical_cast//boost_lexical_cast ]
|
||||
;
|
||||
|
||||
|
||||
|
||||
+51
-19
@@ -2,23 +2,26 @@
|
||||
# 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 Antony Polukhin 2016-2017.
|
||||
# Copyright Antony Polukhin 2016-2021.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
# and how it can be used with Boost libraries.
|
||||
#
|
||||
# File revision #5
|
||||
# File revision #7
|
||||
|
||||
init:
|
||||
- set BRANCH_TO_TEST=%APPVEYOR_REPO_BRANCH% # Change to branch you wish to test. Use %APPVEYOR_REPO_BRANCH% for current branch.
|
||||
- set BOOST_REMOVE=variant # Remove this folder from lib from full clone of Boost. If you are testing `any` repo, write here `any`.
|
||||
# boost-local/libs/ folder to put this library into. This may be useful, if you're for example running Travis
|
||||
# from `Boost.DLL` repo while Boost already has `dll` and with to replace `dll` with content of`Boost.DLL`.
|
||||
#
|
||||
# Otherwise just leave the default value - set BOOST_LIBS_FOLDER=%APPVEYOR_PROJECT_NAME%
|
||||
- set BOOST_LIBS_FOLDER=%APPVEYOR_PROJECT_NAME%
|
||||
|
||||
###############################################################################################################
|
||||
# From this point and below code is same for all the Boost libs
|
||||
###############################################################################################################
|
||||
|
||||
version: 1.64.{build}-{branch}
|
||||
version: 1.71.{build}-{branch}
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
@@ -27,32 +30,61 @@ branches:
|
||||
|
||||
skip_tags: true
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1,clang-win
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
VARIANT: release # "variant_get_test.o: File too big" errors in debug
|
||||
# MinGW 32-bit is not supported by Boost.System any more
|
||||
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
# ADDPATH: C:\mingw\bin;
|
||||
# TOOLSET: gcc
|
||||
# CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
VARIANT: release # "variant_get_test.o: File too big" errors in debug
|
||||
|
||||
before_build:
|
||||
- set PATH=%PATH%;C:\\MinGW\\bin
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- echo "Testing %APPVEYOR_PROJECT_NAME%"
|
||||
# Cloning Boost libraries (fast nondeep cloning)
|
||||
- set BOOST=C:/boost-local
|
||||
- git init %BOOST%
|
||||
- git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git %BOOST%
|
||||
- cd %BOOST%
|
||||
- git remote add --no-tags -t %BRANCH_TO_TEST% origin https://github.com/boostorg/boost.git
|
||||
- git fetch --depth=1
|
||||
- git checkout %BRANCH_TO_TEST%
|
||||
- git submodule update --init --merge --jobs 16
|
||||
- git remote set-branches --add origin %BRANCH_TO_TEST%
|
||||
#- git pull --recurse-submodules # Updaes submodules to most recent version. Not required
|
||||
- rm -rf %BOOST%/libs/%BOOST_REMOVE%
|
||||
- mv %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%APPVEYOR_PROJECT_NAME%
|
||||
- git submodule update --init --depth 10 tools/build tools/boostdep
|
||||
|
||||
- rm -rf %BOOST%/libs/%BOOST_LIBS_FOLDER%
|
||||
- mv -f %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%BOOST_LIBS_FOLDER%
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" %BOOST_LIBS_FOLDER%
|
||||
|
||||
build_script:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
|
||||
- bootstrap.bat
|
||||
- cmd /c bootstrap
|
||||
- b2.exe headers
|
||||
- cd %BOOST%/libs/%APPVEYOR_PROJECT_NAME%/test
|
||||
- cd %BOOST%/libs/%BOOST_LIBS_FOLDER%/test
|
||||
|
||||
after_build:
|
||||
before_test:
|
||||
test_script:
|
||||
- ..\..\..\b2.exe address-model=32 architecture=x86 toolset=msvc,gcc cxxflags="-DBOOST_TRAVISCI_BUILD" -sBOOST_BUILD_PATH=.
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- if "%VARIANT%"== "" set VARIANT=debug,release
|
||||
- set VARIANT=variant=%VARIANT%
|
||||
- echo "Running command ..\..\..\b2 -j3 toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release"
|
||||
- ..\..\..\b2.exe -j3 toolset=%TOOLSET% %CXXSTD% %ADDRMD% %VARIANT% cxxflags="-DBOOST_TRAVISCI_BUILD"
|
||||
|
||||
after_test:
|
||||
on_success:
|
||||
|
||||
+60
-70
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2015 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/variant/multivisitors.hpp"
|
||||
#include "boost/lexical_cast.hpp"
|
||||
@@ -50,24 +50,24 @@ void test_has_result_type_triat() {
|
||||
using namespace has_result_type_tests;
|
||||
using boost::detail::variant::has_result_type;
|
||||
|
||||
BOOST_CHECK(has_result_type<s1>::value);
|
||||
BOOST_CHECK(has_result_type<s2>::value);
|
||||
BOOST_CHECK(has_result_type<s3>::value);
|
||||
BOOST_CHECK(!has_result_type<s4>::value);
|
||||
BOOST_CHECK(has_result_type<s5>::value);
|
||||
BOOST_CHECK(has_result_type<s6>::value);
|
||||
BOOST_CHECK(has_result_type<s7>::value);
|
||||
BOOST_CHECK(has_result_type<s8>::value);
|
||||
BOOST_CHECK(has_result_type<s9>::value);
|
||||
BOOST_TEST(has_result_type<s1>::value);
|
||||
BOOST_TEST(has_result_type<s2>::value);
|
||||
BOOST_TEST(has_result_type<s3>::value);
|
||||
BOOST_TEST(!has_result_type<s4>::value);
|
||||
BOOST_TEST(has_result_type<s5>::value);
|
||||
BOOST_TEST(has_result_type<s6>::value);
|
||||
BOOST_TEST(has_result_type<s7>::value);
|
||||
BOOST_TEST(has_result_type<s8>::value);
|
||||
BOOST_TEST(has_result_type<s9>::value);
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_CHECK(has_result_type<s10>::value);
|
||||
BOOST_TEST(has_result_type<s10>::value);
|
||||
#endif
|
||||
BOOST_CHECK(has_result_type<s11>::value);
|
||||
BOOST_CHECK(has_result_type<s12>::value);
|
||||
BOOST_CHECK(has_result_type<s13>::value);
|
||||
BOOST_CHECK(has_result_type<s14>::value);
|
||||
BOOST_CHECK(has_result_type<s15>::value);
|
||||
BOOST_CHECK(has_result_type<s16>::value);
|
||||
BOOST_TEST(has_result_type<s11>::value);
|
||||
BOOST_TEST(has_result_type<s12>::value);
|
||||
BOOST_TEST(has_result_type<s13>::value);
|
||||
BOOST_TEST(has_result_type<s14>::value);
|
||||
BOOST_TEST(has_result_type<s15>::value);
|
||||
BOOST_TEST(has_result_type<s16>::value);
|
||||
}
|
||||
|
||||
struct lex_streamer_explicit: boost::static_visitor<std::string> {
|
||||
@@ -91,8 +91,8 @@ void run_explicit()
|
||||
lex_streamer_explicit visitor_ref;
|
||||
|
||||
// Must return instance of std::string
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2).c_str() == std::string("10"));
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2, v1).c_str() == std::string("100"));
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2).c_str() == std::string("10"));
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2, v1).c_str() == std::string("100"));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,18 +102,18 @@ void run_explicit()
|
||||
|
||||
void run()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void run2()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
void run3()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -151,18 +151,18 @@ struct lex_streamer2 {
|
||||
std::string res;
|
||||
|
||||
template <class T>
|
||||
const char* operator()(const T& val) const {
|
||||
const char* operator()(const T& /*val*/) const {
|
||||
return "fail";
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
const char* operator()(const T1& v1, const T2& v2) const {
|
||||
const char* operator()(const T1& /*v1*/, const T2& /*v2*/) const {
|
||||
return "fail2";
|
||||
}
|
||||
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
const char* operator()(const T1& v1, const T2& v2, const T3& v3) const {
|
||||
const char* operator()(const T1& /*v1*/, const T2& /*v2*/, const T3& /*v3*/) const {
|
||||
return "fail3";
|
||||
}
|
||||
|
||||
@@ -188,48 +188,42 @@ struct lex_streamer2 {
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# define BOOST_CHECK_IF_HAS_VARIADIC(x) BOOST_CHECK(x)
|
||||
#else
|
||||
# define BOOST_CHECK_IF_HAS_VARIADIC(x) /**/
|
||||
#endif
|
||||
|
||||
void run()
|
||||
{
|
||||
typedef boost::variant<int, std::string, double> variant_type;
|
||||
variant_type v1(1), v2("10"), v3(100.0);
|
||||
lex_streamer lex_streamer_visitor;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lex_streamer(), v1) == "1");
|
||||
BOOST_CHECK_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v1) == "1");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_streamer(), v2) == "10");
|
||||
BOOST_CHECK_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer(), v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer_visitor)(v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer(), v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer_visitor)(v2) == "10");
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_CHECK(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v1) == "1");
|
||||
BOOST_CHECK(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v2) == "10");
|
||||
|
||||
// Retun type must be the same in all instances, so this code does not compile
|
||||
//boost::variant<int, short, unsigned> v_diff_types(1);
|
||||
//BOOST_CHECK(boost::apply_visitor([](auto v) { return v; }, v_diff_types) == 1);
|
||||
//BOOST_TEST(boost::apply_visitor([](auto v) { return v; }, v_diff_types) == 1);
|
||||
|
||||
boost::apply_visitor([](auto v) { std::cout << v << std::endl; }, v1);
|
||||
boost::apply_visitor([](auto v) { std::cout << v << std::endl; }, v2);
|
||||
#endif
|
||||
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v1) == "1");
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2) == "10");
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2) == "10");
|
||||
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref, v1);
|
||||
BOOST_CHECK(ref_to_string == "1");
|
||||
#endif
|
||||
BOOST_TEST(ref_to_string == "1");
|
||||
|
||||
lex_streamer_void lex_streamer_void_visitor;
|
||||
boost::apply_visitor(lex_streamer_void(), v1);
|
||||
boost::apply_visitor(lex_streamer_void(), v2);
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
boost::apply_visitor(lex_streamer_void_visitor)(v2);
|
||||
#endif
|
||||
|
||||
|
||||
boost::ignore_unused(lex_streamer_visitor, visitor_ref, lex_streamer_void_visitor);
|
||||
}
|
||||
@@ -256,13 +250,13 @@ void run2()
|
||||
variant_type v1(1), v2("10"), v3(100.0);
|
||||
lex_combine lex_combine_visitor;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v1, v2) == "1+10");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v2, v1) == "10+1");
|
||||
BOOST_CHECK_IF_HAS_VARIADIC(boost::apply_visitor(lex_combine_visitor)(v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine_visitor)(v2, v1) == "10+1");
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -272,7 +266,7 @@ void run2()
|
||||
, v2
|
||||
) == "1+10"
|
||||
);
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -289,12 +283,11 @@ void run2()
|
||||
|
||||
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v2, v1) == "10+1");
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2, v1) == "10+1");
|
||||
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref)(v1, v2);
|
||||
BOOST_CHECK(ref_to_string == "1+10");
|
||||
#endif
|
||||
BOOST_TEST(ref_to_string == "1+10");
|
||||
|
||||
boost::apply_visitor(lex_streamer_void(), v1, v2);
|
||||
boost::apply_visitor(lex_streamer_void(), v2, v1);
|
||||
@@ -302,22 +295,19 @@ void run2()
|
||||
boost::ignore_unused(lex_combine_visitor, visitor_ref);
|
||||
}
|
||||
|
||||
#undef BOOST_CHECK_IF_HAS_VARIADIC
|
||||
|
||||
void run3()
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
typedef boost::variant<int, std::string, double> variant_type;
|
||||
variant_type v1(1), v2("10"), v3(100);
|
||||
lex_combine lex_combine_visitor;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v1, v2, v3) == "1+10+100");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine(), v2, v1, v3) == "10+1+100");
|
||||
BOOST_CHECK(boost::apply_visitor(lex_combine_visitor)(v2, v1, v3) == "10+1+100");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v1, v2, v3) == "1+10+100");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v2, v1, v3) == "10+1+100");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine_visitor)(v2, v1, v3) == "10+1+100");
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2, auto v3) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -329,7 +319,7 @@ void run3()
|
||||
, v3
|
||||
) == "1+10+100"
|
||||
);
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(
|
||||
[](auto v1, auto v2, auto v3) {
|
||||
return boost::lexical_cast<std::string>(v1) + "+"
|
||||
@@ -354,21 +344,21 @@ void run3()
|
||||
|
||||
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_CHECK(boost::apply_visitor(visitor_ref)(v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref)(v2, v1) == "10+1");
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref, v1, v2);
|
||||
BOOST_CHECK(ref_to_string == "1+10");
|
||||
BOOST_TEST(ref_to_string == "1+10");
|
||||
|
||||
lex_streamer_void lex_streamer_void_visitor;
|
||||
boost::apply_visitor(lex_streamer_void(), v1, v2, v1);
|
||||
boost::apply_visitor(lex_streamer_void(), v2, v1, v1);
|
||||
boost::apply_visitor(lex_streamer_void_visitor)(v2, v1, v1);
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run_explicit();
|
||||
run();
|
||||
@@ -376,5 +366,5 @@ int test_main(int , char* [])
|
||||
run3();
|
||||
test_has_result_type_triat();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+3
-2
@@ -13,7 +13,8 @@
|
||||
#include <algorithm> // for std::swap
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include "class_a.h"
|
||||
|
||||
@@ -22,7 +23,7 @@ using namespace std;
|
||||
|
||||
class_a::~class_a()
|
||||
{
|
||||
assert(self_p_ == this);
|
||||
BOOST_ASSERT(self_p_ == this);
|
||||
}
|
||||
|
||||
class_a::class_a(int n)
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
// Copyright (c) 2017 Levon Tarakchyan
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/variant/apply_visitor.hpp"
|
||||
#include "boost/variant/multivisitors.hpp"
|
||||
#include "boost/lexical_cast.hpp"
|
||||
|
||||
#define lcs(val) boost::lexical_cast<std::string>(val)
|
||||
|
||||
struct construction_logger
|
||||
{
|
||||
int val_;
|
||||
|
||||
construction_logger(int val) : val_(val)
|
||||
{
|
||||
std::cout << val_ << " constructed\n";
|
||||
}
|
||||
|
||||
construction_logger(const construction_logger& cl) :
|
||||
val_(cl.val_)
|
||||
{
|
||||
std::cout << val_ << " copy constructed\n";
|
||||
}
|
||||
|
||||
construction_logger(construction_logger&& cl) :
|
||||
val_(cl.val_)
|
||||
{
|
||||
std::cout << val_ << " move constructed\n";
|
||||
}
|
||||
|
||||
friend std::ostream& operator << (std::ostream& os, const construction_logger& cl)
|
||||
{
|
||||
return os << cl.val_;
|
||||
}
|
||||
|
||||
friend std::istream& operator << (std::istream& is, construction_logger& cl)
|
||||
{
|
||||
return is >> cl.val_;
|
||||
}
|
||||
};
|
||||
|
||||
struct lex_streamer_explicit : boost::static_visitor<std::string>
|
||||
{
|
||||
template <class T>
|
||||
std::string operator()(const T& val) const
|
||||
{
|
||||
return lcs(val);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
std::string operator()(const T& val, const V& val2) const
|
||||
{
|
||||
return lcs(val) + '+' + lcs(val2);
|
||||
}
|
||||
|
||||
template <class T, class V, class P, class S>
|
||||
std::string operator()(const T& val, const V& val2, const P& val3, const S& val4) const
|
||||
{
|
||||
return lcs(val) + '+' + lcs(val2) + '+' + lcs(val3) + '+' + lcs(val4);
|
||||
}
|
||||
};
|
||||
|
||||
struct lvalue_rvalue_detector : boost::static_visitor<std::string>
|
||||
{
|
||||
template <class T>
|
||||
std::string operator()(T&&) const
|
||||
{
|
||||
return std::is_lvalue_reference<T>::value ? "lvalue reference"
|
||||
: "rvalue reference";
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
std::string operator()(T&& t, V&& v) const
|
||||
{
|
||||
return operator()(std::forward<T>(t)) + ", " + operator()(std::forward<V>(v));
|
||||
}
|
||||
|
||||
template <class T, class V, class P>
|
||||
std::string operator()(T&& t, V&& v, P&& p) const
|
||||
{
|
||||
return operator()(std::forward<T>(t), std::forward<V>(v)) + ", " + operator()(std::forward<P>(p));
|
||||
}
|
||||
|
||||
template <class T, class V, class P, class S>
|
||||
std::string operator()(T&& t, V&& v, P&& p, S&& s) const
|
||||
{
|
||||
return operator()(std::forward<T>(t), std::forward<V>(v), std::forward<P>(p)) + ", " + operator()(std::forward<S>(s));
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<construction_logger, std::string> variant_type;
|
||||
|
||||
void test_const_ref_parameter(const variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing const lvalue reference visitable\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_const_ref_parameter2(const variant_type& test_var, const variant_type& test_var2)
|
||||
{
|
||||
std::cout << "Testing const lvalue reference visitable\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), test_var, test_var2) == "lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_const_ref_parameter4(const variant_type& test_var, const variant_type& test_var2, const variant_type& test_var3, const variant_type& test_var4)
|
||||
{
|
||||
std::cout << "Testing const lvalue reference visitable with multivisitor\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), test_var, test_var2, test_var3, test_var4)
|
||||
== "lvalue reference, lvalue reference, lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_rvalue_parameter(variant_type&& test_var)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable\n";
|
||||
|
||||
const auto expected_val = lcs(test_var);
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var)) == "rvalue reference");
|
||||
}
|
||||
|
||||
void test_rvalue_parameter2(variant_type&& test_var, variant_type&& test_var2)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var), std::move(test_var2)) == "rvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
void test_rvalue_parameter4(variant_type&& test_var, variant_type&& test_var2, variant_type&& test_var3, variant_type&& test_var4)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable with multivisitor\n";
|
||||
|
||||
auto result = boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var), std::move(test_var2), std::move(test_var3), std::move(test_var4));
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "rvalue reference, rvalue reference, rvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
|
||||
#define FORWARD(x) std::forward<decltype(x)>(x)
|
||||
|
||||
void test_cpp14_visitor(const variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v) { return lvalue_rvalue_detector()(FORWARD(v)); }, test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_mutable_visitor(const variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14 with inline mutable lambda\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v) mutable -> auto { return lvalue_rvalue_detector()(FORWARD(v)); }, test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(const variant_type& test_var, const variant_type& test_var2)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& vv) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(vv)); }, test_var, test_var2)
|
||||
== "lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(const variant_type& test_var, const variant_type& test_var2, const variant_type& test_var3)
|
||||
{
|
||||
std::cout << "Testing const lvalue visitable for c++14\n";
|
||||
|
||||
auto result = boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
test_var, test_var2, test_var3);
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "lvalue reference, lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing lvalue visitable for c++14\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto& v) { return lvalue_rvalue_detector()(v); }, test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_mutable_visitor(variant_type& test_var)
|
||||
{
|
||||
std::cout << "Testing lvalue visitable for c++14 with inline mutable lambda\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto& v) mutable -> auto { return lvalue_rvalue_detector()(v); }, test_var) == "lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type& test_var, variant_type& test_var2)
|
||||
{
|
||||
std::cout << "Testing lvalue visitable for c++14\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto& v, auto& vv) { return lvalue_rvalue_detector()(v, vv); }, test_var, test_var2)
|
||||
== "lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type& test_var, variant_type& test_var2, variant_type& test_var3)
|
||||
{
|
||||
std::cout << "Testing lvalue visitable for c++14\n";
|
||||
|
||||
auto result = boost::apply_visitor([](auto& v, auto& t, auto& p) { return lvalue_rvalue_detector()(v, t, p); },
|
||||
test_var, test_var2, test_var3);
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "lvalue reference, lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type&& test_var)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable for c++14\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v) { return lvalue_rvalue_detector()(FORWARD(v)); }, std::move(test_var)) == "rvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type&& test_var, variant_type&& test_var2)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable for c++14\n";
|
||||
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& vv) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(vv)); }, std::move(test_var), std::move(test_var2))
|
||||
== "rvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type&& test_var, variant_type&& test_var2, variant_type&& test_var3)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable for c++14\n";
|
||||
|
||||
auto result = boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
std::move(test_var), std::move(test_var2), std::move(test_var3));
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "rvalue reference, rvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
|
||||
void run_const_lvalue_ref_tests()
|
||||
{
|
||||
const variant_type v1(1), v2(2), v3(3), v4(4);
|
||||
test_const_ref_parameter(v1);
|
||||
test_const_ref_parameter2(v1, v2);
|
||||
test_const_ref_parameter4(v1, v2, v3, v4);
|
||||
}
|
||||
|
||||
void run_rvalue_ref_tests()
|
||||
{
|
||||
variant_type v1(10), v2(20), v3(30);
|
||||
test_rvalue_parameter(std::move(v1));
|
||||
test_rvalue_parameter2(std::move(v2), std::move(v3));
|
||||
|
||||
variant_type vv1(100), vv2(200), vv3(300), vv4(400);
|
||||
test_rvalue_parameter4(std::move(vv1), std::move(vv2), std::move(vv3), std::move(vv4));
|
||||
}
|
||||
|
||||
void run_mixed_tests()
|
||||
{
|
||||
variant_type v1(1), v2(2);
|
||||
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10)) == "lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1, variant_type(20)) == "rvalue reference, lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10), v2, variant_type(20)) == "lvalue reference, rvalue reference, lvalue reference, rvalue reference");
|
||||
}
|
||||
|
||||
void run_cpp14_mixed_tests()
|
||||
{
|
||||
#ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
variant_type v1(1), v2(2);
|
||||
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
v1, variant_type(10)) == "lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
variant_type(10), v1, v2) == "rvalue reference, lvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
v1, variant_type(10), v2) == "lvalue reference, rvalue reference, lvalue reference");
|
||||
#endif // #ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
}
|
||||
|
||||
void run_cpp14_tests()
|
||||
{
|
||||
#ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
variant_type const c1(10), c2(20), c3(30);
|
||||
variant_type v1(10), v2(20), v3(30);
|
||||
|
||||
test_cpp14_visitor(c1);
|
||||
test_cpp14_mutable_visitor(c1);
|
||||
test_cpp14_visitor(c2, c3);
|
||||
test_cpp14_visitor(c1, c2, c3);
|
||||
|
||||
test_cpp14_visitor(v1);
|
||||
test_cpp14_mutable_visitor(v1);
|
||||
test_cpp14_visitor(v2, v3);
|
||||
test_cpp14_visitor(v1, v2, v3);
|
||||
|
||||
test_cpp14_visitor(std::move(v1));
|
||||
test_cpp14_visitor(std::move(v2), std::move(v3));
|
||||
|
||||
variant_type vv1(100), vv2(200), vv3(300);
|
||||
test_cpp14_visitor(std::move(vv1), std::move(vv2), std::move(vv3));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
run_const_lvalue_ref_tests();
|
||||
run_rvalue_ref_tests();
|
||||
run_mixed_tests();
|
||||
run_cpp14_mixed_tests();
|
||||
run_cpp14_tests();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2021-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Test case from https://svn.boost.org/trac10/ticket/8721
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <boost/fusion/include/vector.hpp>
|
||||
|
||||
struct emptyList {};
|
||||
|
||||
typedef boost::make_recursive_variant
|
||||
< emptyList
|
||||
, boost::fusion::vector
|
||||
< int
|
||||
, boost::recursive_variant_
|
||||
>
|
||||
>::type IntList;
|
||||
|
||||
const emptyList el = emptyList();
|
||||
const IntList nil( el );
|
||||
|
||||
IntList cons( int head, IntList tail )
|
||||
{
|
||||
return IntList( boost::fusion::vector<int, IntList>( head, tail ) );
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
|
||||
// Test is based on reported issues:
|
||||
@@ -28,15 +28,15 @@ template <typename T>
|
||||
using basic_set_t = std::unordered_set<T, hash>;
|
||||
|
||||
using value_t = boost::make_recursive_variant<
|
||||
int_t,
|
||||
basic_set_t<boost::recursive_variant_>
|
||||
int_t,
|
||||
basic_set_t<boost::recursive_variant_>
|
||||
>::type;
|
||||
|
||||
using set_t = basic_set_t<value_t>;
|
||||
|
||||
struct hash
|
||||
{
|
||||
size_t operator()(const value_t& value) const
|
||||
size_t operator()(const value_t&) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -48,15 +48,15 @@ void run()
|
||||
int_t i = 3;
|
||||
value_t v = i;
|
||||
auto emplace_result = s.emplace(v); // raises error above
|
||||
BOOST_CHECK(emplace_result.second);
|
||||
BOOST_TEST(emplace_result.second);
|
||||
v = s;
|
||||
const set_t& check_set = boost::get<set_t>(v);
|
||||
BOOST_CHECK(!check_set.empty());
|
||||
BOOST_TEST(!check_set.empty());
|
||||
for (const auto& check_v : check_set) {
|
||||
BOOST_CHECK(s.find(check_v) != s.end());
|
||||
BOOST_TEST(s.find(check_v) != s.end());
|
||||
}
|
||||
for (const auto& check_v : s) {
|
||||
BOOST_CHECK(check_set.find(check_v) != check_set.end());
|
||||
BOOST_TEST(check_set.find(check_v) != check_set.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ void run()
|
||||
void run() {}
|
||||
#endif
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+32
-16
@@ -1,16 +1,32 @@
|
||||
// Copyright (c) 2011-2014
|
||||
// Antony Polukhin
|
||||
// Copyright (c) 2011-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/functional/hash/hash.hpp"
|
||||
|
||||
void run()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET) && !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH)
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
void test_std_hash() {
|
||||
std::unordered_set<boost::variant<int, bool> > us;
|
||||
us.insert(1);
|
||||
us.insert(true);
|
||||
BOOST_TEST(us.size() == 2);
|
||||
}
|
||||
|
||||
#else
|
||||
void test_std_hash() {}
|
||||
#endif
|
||||
|
||||
|
||||
void run() {
|
||||
typedef boost::variant<bool, int, unsigned int, char> variant_type;
|
||||
boost::hash<variant_type> hasher;
|
||||
|
||||
@@ -21,18 +37,18 @@ void run()
|
||||
variant_type char_variant2 = '\2';
|
||||
variant_type uint_variant = static_cast<unsigned int>(1);
|
||||
|
||||
BOOST_CHECK(hasher(bool_variant1) != hasher(bool_variant2));
|
||||
BOOST_CHECK(hasher(bool_variant1) == hasher(bool_variant1));
|
||||
BOOST_CHECK(hasher(int_variant) != hasher(uint_variant));
|
||||
BOOST_CHECK(hasher(char_variant1) != hasher(uint_variant));
|
||||
BOOST_CHECK(hasher(char_variant1) != hasher(char_variant2));
|
||||
BOOST_CHECK(hasher(char_variant1) == hasher(char_variant1));
|
||||
BOOST_CHECK(hasher(char_variant2) == hasher(char_variant2));
|
||||
BOOST_TEST(hasher(bool_variant1) != hasher(bool_variant2));
|
||||
BOOST_TEST(hasher(bool_variant1) == hasher(bool_variant1));
|
||||
BOOST_TEST(hasher(int_variant) != hasher(uint_variant));
|
||||
BOOST_TEST(hasher(char_variant1) != hasher(uint_variant));
|
||||
BOOST_TEST(hasher(char_variant1) != hasher(char_variant2));
|
||||
BOOST_TEST(hasher(char_variant1) == hasher(char_variant1));
|
||||
BOOST_TEST(hasher(char_variant2) == hasher(char_variant2));
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
int main() {
|
||||
run();
|
||||
test_std_hash();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost-libs variant/test/issue42.cpp source file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Test case from https://github.com/boostorg/variant/issues/42
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
#ifdef BOOST_NO_CXX11_SMART_PTR
|
||||
template <class T> struct shared_ptr_like {};
|
||||
typedef shared_ptr_like<boost::recursive_variant_> ptr_t;
|
||||
#else
|
||||
typedef std::shared_ptr<boost::recursive_variant_> ptr_t;
|
||||
#endif
|
||||
|
||||
template <class F>
|
||||
class func{};
|
||||
|
||||
int main() {
|
||||
typedef boost::make_recursive_variant<
|
||||
int,
|
||||
ptr_t
|
||||
>::type node;
|
||||
|
||||
node x = 1;
|
||||
(void)x;
|
||||
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
std::string, int, double, bool,
|
||||
ptr_t,
|
||||
std::map<const std::string, boost::recursive_variant_>,
|
||||
std::vector<boost::recursive_variant_>
|
||||
>::type node2;
|
||||
|
||||
node2 x2 = 1;
|
||||
(void)x2;
|
||||
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
int,
|
||||
func<boost::recursive_variant_(*)(boost::recursive_variant_&, const boost::recursive_variant_&)>,
|
||||
boost::recursive_variant_&(*)(boost::recursive_variant_, boost::recursive_variant_*),
|
||||
ptr_t
|
||||
>::type node3;
|
||||
|
||||
node3 x3 = func<node3(*)(node3&, const node3&)>();
|
||||
(void)x3;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost-libs variant/test/issue53.cpp source file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2019-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Test case from https://github.com/boostorg/variant/issues/53
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/thread/lock_guard.hpp> // this line was causing problems on MSVC
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
struct spanac {};
|
||||
|
||||
struct ceapa{
|
||||
double a,b;
|
||||
};
|
||||
|
||||
typedef boost::variant<spanac, ceapa> var_t;
|
||||
|
||||
struct visitor_t : public boost::static_visitor<bool> {
|
||||
bool operator() (const spanac&) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator() (const ceapa&) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
double a, b;
|
||||
};
|
||||
|
||||
var_t get(int k) {
|
||||
if (k)
|
||||
return spanac();
|
||||
else
|
||||
return ceapa();
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
visitor_t v;
|
||||
|
||||
bool result = boost::apply_visitor(v, get(argc - 1));
|
||||
(void)result;
|
||||
}
|
||||
|
||||
#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main() {}
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
+11
-11
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "boost/type_index.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0551))
|
||||
# pragma warn -lvc
|
||||
#endif
|
||||
|
||||
@@ -244,14 +244,14 @@ inline void verify(VariantType& var, spec<S>, std::string str = "")
|
||||
{
|
||||
const VariantType& cvar = var;
|
||||
|
||||
BOOST_CHECK(boost::apply_visitor(total_sizeof(), cvar) == sizeof(S));
|
||||
BOOST_CHECK(cvar.type() == boost::typeindex::type_id<S>());
|
||||
BOOST_TEST(boost::apply_visitor(total_sizeof(), cvar) == sizeof(S));
|
||||
BOOST_TEST(cvar.type() == boost::typeindex::type_id<S>());
|
||||
|
||||
//
|
||||
// Check get<>()
|
||||
//
|
||||
BOOST_CHECK(boost::get<S>(&var));
|
||||
BOOST_CHECK(boost::get<S>(&cvar));
|
||||
BOOST_TEST(boost::get<S>(&var));
|
||||
BOOST_TEST(boost::get<S>(&cvar));
|
||||
|
||||
const S* ptr1 = 0;
|
||||
const S* ptr2 = 0;
|
||||
@@ -275,7 +275,7 @@ inline void verify(VariantType& var, spec<S>, std::string str = "")
|
||||
BOOST_ERROR( "get<S> const failed unexpectedly" );
|
||||
}
|
||||
|
||||
BOOST_CHECK(ptr1 != 0 && ptr2 == ptr1);
|
||||
BOOST_TEST(ptr1 != 0 && ptr2 == ptr1);
|
||||
|
||||
//
|
||||
// Check string content
|
||||
@@ -284,7 +284,7 @@ inline void verify(VariantType& var, spec<S>, std::string str = "")
|
||||
{
|
||||
std::string temp = boost::apply_visitor(to_text(), cvar);
|
||||
std::cout << "temp = " << temp << ", str = " << str << std::endl;
|
||||
BOOST_CHECK(temp == str);
|
||||
BOOST_TEST(temp == str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,13 +294,13 @@ inline void verify_not(VariantType& var, spec<S>)
|
||||
{
|
||||
const VariantType& cvar = var;
|
||||
|
||||
BOOST_CHECK(cvar.type() != boost::typeindex::type_id<S>());
|
||||
BOOST_TEST(cvar.type() != boost::typeindex::type_id<S>());
|
||||
|
||||
//
|
||||
// Check get<>()
|
||||
//
|
||||
BOOST_CHECK(!boost::get<S>(&var));
|
||||
BOOST_CHECK(!boost::get<S>(&cvar));
|
||||
BOOST_TEST(!boost::get<S>(&var));
|
||||
BOOST_TEST(!boost::get<S>(&cvar));
|
||||
|
||||
const S* ptr1 = 0;
|
||||
const S* ptr2 = 0;
|
||||
@@ -328,7 +328,7 @@ inline void verify_not(VariantType& var, spec<S>)
|
||||
// do nothing except pass-through
|
||||
}
|
||||
|
||||
BOOST_CHECK(ptr1 == 0 && ptr2 == 0);
|
||||
BOOST_TEST(ptr1 == 0 && ptr2 == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2017-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
struct foo {};
|
||||
|
||||
struct some_user_provided_visitor_for_lvalues: boost::static_visitor<void> {
|
||||
void operator()(foo& ) const {}
|
||||
void operator()(int ) const {}
|
||||
};
|
||||
|
||||
int main() {
|
||||
boost::apply_visitor(
|
||||
some_user_provided_visitor_for_lvalues(),
|
||||
boost::variant<int, foo>(foo())
|
||||
);
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ < 5 && __GNUC_MINOR__ < 8
|
||||
# error This test does not pass on GCC < 4.8 because of the incomplete C++11 support
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# error Temporaries/rvalues could bind to non-const lvalues on MSVC compilers
|
||||
#endif
|
||||
}
|
||||
+30
-30
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016 Antony Polukhin
|
||||
// Copyright (c) 2016-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/recursive_variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@@ -37,10 +37,10 @@ bool foo(const boost::variant<C, D>& ) {
|
||||
|
||||
void test_overload_selection_variant_constructor() {
|
||||
D d;
|
||||
BOOST_CHECK(foo(d));
|
||||
BOOST_TEST(foo(d));
|
||||
|
||||
boost::variant<B, A> v;
|
||||
BOOST_CHECK(!foo(v));
|
||||
BOOST_TEST(!foo(v));
|
||||
}
|
||||
|
||||
// Pre msvc-14.0 could not dustinguish between multiple assignment operators:
|
||||
@@ -51,7 +51,7 @@ void test_overload_selection_variant_constructor() {
|
||||
#if (defined(__GNUC__) && (__GNUC__ < 4)) || (defined(_MSC_VER) && _MSC_VER < 1900)
|
||||
|
||||
void test_overload_selection_variant_assignment() {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -66,13 +66,13 @@ void test_overload_selection_variant_assignment() {
|
||||
assignment_tester tester;
|
||||
tester = a;
|
||||
const int which0 = static_cast< boost::variant<B, A>& >(tester).which();
|
||||
BOOST_CHECK(which0 == 1);
|
||||
BOOST_TEST(which0 == 1);
|
||||
|
||||
boost::variant<A, B> b;
|
||||
b = B();
|
||||
tester = b;
|
||||
const int which1 = static_cast< boost::variant<B, A>& >(tester).which();
|
||||
BOOST_CHECK(which1 == 0);
|
||||
BOOST_TEST(which1 == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -88,7 +88,7 @@ struct convertible {
|
||||
void test_implicit_conversion_operator() {
|
||||
// https://svn.boost.org/trac/boost/ticket/8555
|
||||
my_variant y = convertible();
|
||||
BOOST_CHECK(y.which() == 0);
|
||||
BOOST_TEST(y.which() == 0);
|
||||
}
|
||||
|
||||
struct X: boost::variant< int > {};
|
||||
@@ -100,27 +100,27 @@ void test_derived_from_variant_construction() {
|
||||
// https://svn.boost.org/trac/boost/ticket/7120
|
||||
X x;
|
||||
boost::variant<X> y(x);
|
||||
BOOST_CHECK(y.which() == 0);
|
||||
BOOST_TEST(y.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/10278
|
||||
boost::variant<V1, std::string> v2 = V1();
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/12155
|
||||
AB ab;
|
||||
boost::variant<AB, C> ab_c(ab);
|
||||
BOOST_CHECK(ab_c.which() == 0);
|
||||
BOOST_TEST(ab_c.which() == 0);
|
||||
|
||||
boost::variant<A, B> a_b(ab);
|
||||
BOOST_CHECK(a_b.which() == 0);
|
||||
BOOST_TEST(a_b.which() == 0);
|
||||
|
||||
boost::variant<B, C, A> b_c_a1(static_cast<boost::variant<A, B>& >(ab));
|
||||
BOOST_CHECK(b_c_a1.which() == 2);
|
||||
BOOST_TEST(b_c_a1.which() == 2);
|
||||
|
||||
|
||||
// Following conversion seems harmful as it may lead to slicing:
|
||||
// boost::variant<B, C, A> b_c_a(ab);
|
||||
// BOOST_CHECK(b_c_a.which() == 2);
|
||||
// BOOST_TEST(b_c_a.which() == 2);
|
||||
}
|
||||
|
||||
void test_derived_from_variant_assignment() {
|
||||
@@ -128,32 +128,32 @@ void test_derived_from_variant_assignment() {
|
||||
X x;
|
||||
boost::variant<X> y;
|
||||
y = x;
|
||||
BOOST_CHECK(y.which() == 0);
|
||||
BOOST_TEST(y.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/10278
|
||||
boost::variant<V1, std::string> v2;
|
||||
v2 = V1();
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/12155
|
||||
AB ab;
|
||||
boost::variant<AB, C> ab_c;
|
||||
ab_c = ab;
|
||||
BOOST_CHECK(ab_c.which() == 0);
|
||||
BOOST_TEST(ab_c.which() == 0);
|
||||
|
||||
boost::variant<A, B> a_b;
|
||||
a_b = ab;
|
||||
BOOST_CHECK(a_b.which() == 0);
|
||||
BOOST_TEST(a_b.which() == 0);
|
||||
|
||||
boost::variant<B, C, A> b_c_a1;
|
||||
b_c_a1 = static_cast<boost::variant<A, B>& >(ab);
|
||||
BOOST_CHECK(b_c_a1.which() == 2);
|
||||
BOOST_TEST(b_c_a1.which() == 2);
|
||||
|
||||
|
||||
// Following conversion seems harmful as it may lead to slicing:
|
||||
// boost::variant<B, C, A> b_c_a;
|
||||
// b_c_a = ab;
|
||||
// BOOST_CHECK(b_c_a.which() == 2);
|
||||
// BOOST_TEST(b_c_a.which() == 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,34 +175,34 @@ struct info {
|
||||
inline void test_on_incomplete_types() {
|
||||
info i0;
|
||||
i0.v = "Hello";
|
||||
BOOST_CHECK(i0.v.which() == 1);
|
||||
BOOST_TEST(i0.v.which() == 1);
|
||||
|
||||
info::value_type v0 = "Hello";
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
|
||||
info::value_type v1("Hello");
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
info::value_type v2 = i0;
|
||||
BOOST_CHECK(v2.which() == 2);
|
||||
BOOST_TEST(v2.which() == 2);
|
||||
|
||||
info::value_type v3(i0);
|
||||
BOOST_CHECK(v3.which() == 2);
|
||||
BOOST_TEST(v3.which() == 2);
|
||||
|
||||
v0 = v3;
|
||||
BOOST_CHECK(v0.which() == 2);
|
||||
BOOST_TEST(v0.which() == 2);
|
||||
|
||||
v3 = v1;
|
||||
BOOST_CHECK(v3.which() == 1);
|
||||
BOOST_TEST(v3.which() == 1);
|
||||
|
||||
v3 = nil_();
|
||||
BOOST_CHECK(v3.which() == 0);
|
||||
BOOST_TEST(v3.which() == 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_overload_selection_variant_constructor();
|
||||
test_overload_selection_variant_assignment();
|
||||
@@ -211,5 +211,5 @@ int test_main(int , char* [])
|
||||
test_derived_from_variant_assignment();
|
||||
info().test_on_incomplete_types();
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,27 +18,8 @@
|
||||
// 2) variant_noexcept_test that tests Boost.Variant ability to compile
|
||||
// and work with disabled exceptions
|
||||
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
// `boost/test/minimal.hpp` cannot work with exceptions disabled,
|
||||
// so we need the following workarounds for that case:
|
||||
namespace boost {
|
||||
int exit_success = 0;
|
||||
}
|
||||
|
||||
int test_main(int , char* []);
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
return test_main(argc, argv);
|
||||
}
|
||||
|
||||
#include <stdlib.h>
|
||||
#define BOOST_CHECK(exp) if (!(exp)) exit(EXIT_FAILURE)
|
||||
|
||||
#else // BOOST_NO_EXCEPTIONS
|
||||
# include "boost/test/minimal.hpp"
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/mpl/vector.hpp"
|
||||
@@ -48,9 +29,9 @@ int main( int argc, char* argv[] )
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
#include <tuple>
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
struct Nil {};
|
||||
|
||||
struct printer
|
||||
: boost::static_visitor<std::string>
|
||||
@@ -78,7 +59,6 @@ struct printer
|
||||
return ost.str();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
template <int...> struct indices {};
|
||||
template <typename... Ts, int... Is>
|
||||
std::string operator()(const std::tuple<Ts...>& tup, indices<Is...>) const
|
||||
@@ -100,7 +80,6 @@ struct printer
|
||||
{
|
||||
return printer()(tup, make_indices<sizeof...(Ts)>());
|
||||
}
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
template <typename T>
|
||||
std::string operator()(const T& operand) const
|
||||
@@ -128,7 +107,7 @@ void test_recursive_variant()
|
||||
std::string result1( printer()(var1) );
|
||||
|
||||
std::cout << "result1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
|
||||
std::vector<var1_t> vec1_copy = vec1;
|
||||
vec1_copy.erase(vec1_copy.begin() + 2);
|
||||
@@ -136,7 +115,7 @@ void test_recursive_variant()
|
||||
var1 = vec1_copy;
|
||||
result1 = printer()(var1);
|
||||
std::cout << "result1+: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
// Uses move construction on compilers with rvalue references support
|
||||
result1 = printer()(
|
||||
@@ -145,7 +124,7 @@ void test_recursive_variant()
|
||||
)
|
||||
);
|
||||
std::cout << "result1++: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
|
||||
var1_t vec1_another_copy(vec1_copy);
|
||||
@@ -154,18 +133,18 @@ void test_recursive_variant()
|
||||
var1_t(vec1_copy)
|
||||
);
|
||||
std::cout << "result1+++1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
|
||||
result1 = printer()(vec1_another_copy);
|
||||
std::cout << "result1++2: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 7 ) ");
|
||||
|
||||
vec1_copy[2].swap(vec1_copy[2]);
|
||||
result1 = printer()(
|
||||
var1_t(vec1_copy)
|
||||
);
|
||||
std::cout << "result1.2: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
boost::variant<int, double>
|
||||
@@ -182,7 +161,7 @@ void test_recursive_variant()
|
||||
std::string result2( printer()(var2) );
|
||||
|
||||
std::cout << "result2: " << result2 << '\n';
|
||||
BOOST_CHECK(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
BOOST_TEST(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
int
|
||||
@@ -209,7 +188,7 @@ void test_recursive_variant()
|
||||
std::string result3( printer()(var4) );
|
||||
|
||||
std::cout << "result2: " << result3 << '\n';
|
||||
BOOST_CHECK(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
BOOST_TEST(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
double,
|
||||
@@ -224,7 +203,7 @@ void test_recursive_variant()
|
||||
std::string result5( printer()(vec5) );
|
||||
|
||||
std::cout << "result5: " << result5 << '\n';
|
||||
BOOST_CHECK(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
BOOST_TEST(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
int,
|
||||
@@ -232,7 +211,6 @@ void test_recursive_variant()
|
||||
>::type var6_t;
|
||||
var6_t var6;
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
typedef boost::make_recursive_variant<
|
||||
int,
|
||||
std::tuple<int, boost::recursive_variant_>
|
||||
@@ -244,8 +222,7 @@ void test_recursive_variant()
|
||||
std::string result7( printer()(var7) );
|
||||
|
||||
std::cout << "result7: " << result7 << '\n';
|
||||
BOOST_CHECK(result7 == "( 2 ( 1 0 ) ) ");
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
BOOST_TEST(result7 == "( 2 ( 1 0 ) ) ");
|
||||
}
|
||||
|
||||
void test_recursive_variant_over()
|
||||
@@ -267,7 +244,7 @@ void test_recursive_variant_over()
|
||||
std::string result1( printer()(var1) );
|
||||
|
||||
std::cout << "result1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ) 7 ) ");
|
||||
|
||||
std::vector<var1_t> vec1_copy = vec1;
|
||||
vec1_copy.erase(vec1_copy.begin() + 2);
|
||||
@@ -275,7 +252,7 @@ void test_recursive_variant_over()
|
||||
var1 = vec1_copy;
|
||||
result1 = printer()(var1);
|
||||
std::cout << "result1+: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
// Uses move construction on compilers with rvalue references support
|
||||
result1 = printer()(
|
||||
@@ -284,7 +261,7 @@ void test_recursive_variant_over()
|
||||
)
|
||||
);
|
||||
std::cout << "result1++: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 7 ) 7 ) ");
|
||||
|
||||
|
||||
var1_t vec1_another_copy(vec1_copy);
|
||||
@@ -293,11 +270,11 @@ void test_recursive_variant_over()
|
||||
var1_t(vec1_copy)
|
||||
);
|
||||
std::cout << "result1+++1: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 ( 3 5 ( 3 5 7 ) 7 ) 7 ) ");
|
||||
|
||||
result1 = printer()(vec1_another_copy);
|
||||
std::cout << "result1++2: " << result1 << '\n';
|
||||
BOOST_CHECK(result1 == "( 3 5 7 ) ");
|
||||
BOOST_TEST(result1 == "( 3 5 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant_over<
|
||||
boost::mpl::vector<
|
||||
@@ -316,7 +293,7 @@ void test_recursive_variant_over()
|
||||
std::string result2( printer()(var2) );
|
||||
|
||||
std::cout << "result2: " << result2 << '\n';
|
||||
BOOST_CHECK(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
BOOST_TEST(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant_over<
|
||||
boost::mpl::vector<
|
||||
@@ -354,7 +331,7 @@ void test_recursive_variant_over()
|
||||
std::string result3( printer()(var3) );
|
||||
|
||||
std::cout << "result2: " << result3 << '\n';
|
||||
BOOST_CHECK(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
BOOST_TEST(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
|
||||
|
||||
typedef boost::make_recursive_variant_over<
|
||||
boost::mpl::vector<
|
||||
@@ -371,13 +348,24 @@ void test_recursive_variant_over()
|
||||
std::string result5( printer()(vec5) );
|
||||
|
||||
std::cout << "result5: " << result5 << '\n';
|
||||
BOOST_CHECK(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
BOOST_TEST(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
void test_recursive_variant_from_variant()
|
||||
{
|
||||
// See https://github.com/boostorg/variant/issues/100
|
||||
typedef boost::variant<Nil, double> Atom;
|
||||
typedef boost::variant<Nil, boost::recursive_wrapper<Atom> > Variant;
|
||||
|
||||
BOOST_STATIC_ASSERT(!boost::is_constructible<Variant, Atom>::value);
|
||||
BOOST_STATIC_ASSERT(boost::is_constructible<boost::variant<Nil, Atom>, Atom>::value);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_recursive_variant();
|
||||
test_recursive_variant_over();
|
||||
test_recursive_variant_from_variant();
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#ifdef __cpp_inheriting_constructors
|
||||
// Test is based on reported issue:
|
||||
@@ -15,7 +15,6 @@
|
||||
// is_noexcept_move_constructible
|
||||
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/array.hpp>
|
||||
@@ -70,9 +69,9 @@ void run() {
|
||||
void run() {}
|
||||
#endif
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+47
-106
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2012-2014 Antony Polukhin
|
||||
// Copyright (c) 2012-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -11,13 +11,12 @@
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/type_traits/is_nothrow_move_assignable.hpp"
|
||||
#include "boost/mpl/bool.hpp"
|
||||
|
||||
#include <boost/blank.hpp>
|
||||
#include <boost/swap.hpp>
|
||||
|
||||
namespace swap_ambiguouty_test_ns {
|
||||
struct A {};
|
||||
@@ -39,11 +38,11 @@ public:
|
||||
static unsigned int copy_count;
|
||||
|
||||
move_copy_conting_class(){}
|
||||
move_copy_conting_class(BOOST_RV_REF(move_copy_conting_class) ) {
|
||||
move_copy_conting_class(move_copy_conting_class&& ) {
|
||||
++ moves_count;
|
||||
}
|
||||
|
||||
move_copy_conting_class& operator=(BOOST_RV_REF(move_copy_conting_class) ) {
|
||||
move_copy_conting_class& operator=(move_copy_conting_class&& ) {
|
||||
++ moves_count;
|
||||
return *this;
|
||||
}
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
move_copy_conting_class(const move_copy_conting_class&) {
|
||||
++ copy_count;
|
||||
}
|
||||
move_copy_conting_class& operator=(BOOST_COPY_ASSIGN_REF(move_copy_conting_class) ) {
|
||||
move_copy_conting_class& operator=(const move_copy_conting_class& ) {
|
||||
++ copy_count;
|
||||
return *this;
|
||||
}
|
||||
@@ -60,65 +59,18 @@ public:
|
||||
unsigned int move_copy_conting_class::moves_count = 0;
|
||||
unsigned int move_copy_conting_class::copy_count = 0;
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
void run()
|
||||
{
|
||||
// Making sure that internals of Boost.Move do not interfere with
|
||||
// internals of Boost.Variant and in case of C++03 or C++98 compilation
|
||||
// is still possible.
|
||||
typedef boost::variant<int, move_copy_conting_class> variant_I_type;
|
||||
variant_I_type v1, v2;
|
||||
v1 = move_copy_conting_class();
|
||||
v2 = v1;
|
||||
v2 = boost::move(v1);
|
||||
v1.swap(v2);
|
||||
|
||||
move_copy_conting_class val;
|
||||
v2 = boost::move(val);
|
||||
v2 = 10;
|
||||
|
||||
variant_I_type v3(boost::move(val));
|
||||
variant_I_type v4(boost::move(v1));
|
||||
}
|
||||
|
||||
void run1()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
}
|
||||
|
||||
void run_move_only()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
}
|
||||
|
||||
void run_moves_are_noexcept()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
}
|
||||
|
||||
|
||||
void run_const_rvalues()
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
typedef boost::variant<int, move_copy_conting_class> variant_I_type;
|
||||
variant_I_type v1, v2;
|
||||
|
||||
// Assuring that `move_copy_conting_class` was not created
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count == 0);
|
||||
|
||||
v1 = move_copy_conting_class();
|
||||
// Assuring that `move_copy_conting_class` was moved at least once
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
unsigned int total_count = move_copy_conting_class::moves_count + move_copy_conting_class::copy_count;
|
||||
move_copy_conting_class var;
|
||||
@@ -127,57 +79,57 @@ void run()
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = var;
|
||||
// Assuring that move assignment operator moves/copyes value not more times than copy assignment operator
|
||||
BOOST_CHECK(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
BOOST_TEST(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
v2 = std::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
|
||||
v1 = move_copy_conting_class();
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
v2 = std::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
total_count = move_copy_conting_class::moves_count + move_copy_conting_class::copy_count;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = v2;
|
||||
// Assuring that move assignment operator moves/copyes value not more times than copy assignment operator
|
||||
BOOST_CHECK(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
BOOST_TEST(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
|
||||
|
||||
typedef boost::variant<move_copy_conting_class, int> variant_II_type;
|
||||
variant_II_type v3;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = boost::move(v3);
|
||||
v1 = std::move(v3);
|
||||
// Assuring that `move_copy_conting_class` in v3 was moved at least once (v1 and v3 have different types)
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
v2 = std::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once (v1 and v3 have different types)
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
variant_I_type v5(boost::move(v1));
|
||||
variant_I_type v5(std::move(v1));
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
|
||||
total_count = move_copy_conting_class::moves_count + move_copy_conting_class::copy_count;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
variant_I_type v6(v1);
|
||||
// Assuring that move constructor moves/copyes value not more times than copy constructor
|
||||
BOOST_CHECK(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
BOOST_TEST(total_count <= move_copy_conting_class::moves_count + move_copy_conting_class::copy_count);
|
||||
}
|
||||
|
||||
void run1()
|
||||
@@ -187,11 +139,11 @@ void run1()
|
||||
|
||||
move_copy_conting_class c1;
|
||||
typedef boost::variant<int, move_copy_conting_class> variant_I_type;
|
||||
variant_I_type v1(boost::move(c1));
|
||||
variant_I_type v1(std::move(c1));
|
||||
|
||||
// Assuring that `move_copy_conting_class` was not copyied
|
||||
BOOST_CHECK(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_CHECK(move_copy_conting_class::moves_count > 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
BOOST_TEST(move_copy_conting_class::moves_count > 0);
|
||||
}
|
||||
|
||||
struct move_only_structure {
|
||||
@@ -215,26 +167,26 @@ void run_move_only()
|
||||
{
|
||||
move_only_structure mo;
|
||||
boost::variant<int, move_only_structure > vi, vi2(static_cast<move_only_structure&&>(mo));
|
||||
BOOST_CHECK(vi.which() == 0);
|
||||
BOOST_CHECK(vi2.which() == 1);
|
||||
BOOST_TEST(vi.which() == 0);
|
||||
BOOST_TEST(vi2.which() == 1);
|
||||
|
||||
vi = 10;
|
||||
vi2 = 10;
|
||||
BOOST_CHECK(vi.which() == 0);
|
||||
BOOST_CHECK(vi2.which() == 0);
|
||||
BOOST_TEST(vi.which() == 0);
|
||||
BOOST_TEST(vi2.which() == 0);
|
||||
|
||||
vi = static_cast<move_only_structure&&>(mo);
|
||||
vi2 = static_cast<move_only_structure&&>(mo);
|
||||
BOOST_CHECK(vi.which() == 1);
|
||||
BOOST_TEST(vi.which() == 1);
|
||||
|
||||
boost::variant<move_only_structure, int > rvi (1);
|
||||
BOOST_CHECK(rvi.which() == 1);
|
||||
BOOST_TEST(rvi.which() == 1);
|
||||
rvi = static_cast<move_only_structure&&>(mo);
|
||||
BOOST_CHECK(rvi.which() == 0);
|
||||
BOOST_TEST(rvi.which() == 0);
|
||||
rvi = 1;
|
||||
BOOST_CHECK(rvi.which() == 1);
|
||||
BOOST_TEST(rvi.which() == 1);
|
||||
rvi = static_cast<boost::variant<int, move_only_structure >&&>(vi2);
|
||||
BOOST_CHECK(rvi.which() == 0);
|
||||
BOOST_TEST(rvi.which() == 0);
|
||||
|
||||
move_only_structure from_visitor = boost::apply_visitor(visitor_returning_move_only_type(), vi);
|
||||
(void)from_visitor;
|
||||
@@ -243,12 +195,12 @@ void run_move_only()
|
||||
void run_moves_are_noexcept() {
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ > 4 || __GNUC_MINOR__ >= 8)
|
||||
typedef boost::variant<int, short, double> variant_noexcept_t;
|
||||
BOOST_CHECK(boost::is_nothrow_move_assignable<variant_noexcept_t>::value);
|
||||
BOOST_CHECK(boost::is_nothrow_move_constructible<variant_noexcept_t>::value);
|
||||
BOOST_TEST(boost::is_nothrow_move_assignable<variant_noexcept_t>::value);
|
||||
BOOST_TEST(boost::is_nothrow_move_constructible<variant_noexcept_t>::value);
|
||||
|
||||
typedef boost::variant<int, short, double, move_only_structure> variant_except_t;
|
||||
BOOST_CHECK(!boost::is_nothrow_move_assignable<variant_except_t>::value);
|
||||
BOOST_CHECK(!boost::is_nothrow_move_constructible<variant_except_t>::value);
|
||||
BOOST_TEST(!boost::is_nothrow_move_assignable<variant_except_t>::value);
|
||||
BOOST_TEST(!boost::is_nothrow_move_constructible<variant_except_t>::value);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -267,19 +219,16 @@ void run_const_rvalues()
|
||||
v4 = get_string();
|
||||
v5 = get_variant();
|
||||
v6 = get_variant2();
|
||||
v7 = boost::move(v1);
|
||||
v7 = std::move(v1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct nothrow_copyable_throw_movable {
|
||||
nothrow_copyable_throw_movable(){}
|
||||
nothrow_copyable_throw_movable(const nothrow_copyable_throw_movable&) BOOST_NOEXCEPT {}
|
||||
nothrow_copyable_throw_movable& operator=(const nothrow_copyable_throw_movable&) BOOST_NOEXCEPT { return *this; }
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
nothrow_copyable_throw_movable(nothrow_copyable_throw_movable&&) BOOST_NOEXCEPT_IF(false) {}
|
||||
nothrow_copyable_throw_movable& operator=(nothrow_copyable_throw_movable&&) BOOST_NOEXCEPT_IF(false) { return *this; }
|
||||
#endif
|
||||
};
|
||||
|
||||
// This test is created to cover the following situation:
|
||||
@@ -304,12 +253,12 @@ struct is_container<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
|
||||
void run_is_container_compilation_test()
|
||||
{
|
||||
BOOST_CHECK((!is_container<boost::variant<double, int> >::value));
|
||||
BOOST_CHECK((!is_container<boost::variant<double, int, char> >::value));
|
||||
BOOST_CHECK((!is_container<boost::variant<double, int, char, float> >::value));
|
||||
BOOST_TEST((!is_container<boost::variant<double, int> >::value));
|
||||
BOOST_TEST((!is_container<boost::variant<double, int, char> >::value));
|
||||
BOOST_TEST((!is_container<boost::variant<double, int, char, float> >::value));
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
swap_ambiguouty_test_ns::swap_ambiguouty_test();
|
||||
run();
|
||||
@@ -320,13 +269,5 @@ int test_main(int , char* [])
|
||||
run_const_rvalues();
|
||||
run_is_container_compilation_test();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ > 6)
|
||||
# ifdef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
BOOST_CHECK(false &&
|
||||
"Something wrong with macro definitions. GCC-4.7+ is known to work with variadic templates"
|
||||
);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+7
-7
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from const int to const short
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "class_a.h"
|
||||
@@ -121,11 +121,11 @@ void run()
|
||||
v1 = 3.4f;
|
||||
apply_visitor(ts, v1);
|
||||
|
||||
BOOST_CHECK(ts.result() == sizeof(int) + sizeof(double)*2);
|
||||
BOOST_TEST(ts.result() == sizeof(int) + sizeof(double)*2);
|
||||
|
||||
v11 = 5;
|
||||
string res_s = apply_visitor(int_printer(), v11);
|
||||
BOOST_CHECK(res_s == "5");
|
||||
BOOST_TEST(res_s == "5");
|
||||
|
||||
//
|
||||
// A variant object holding an std::vector
|
||||
@@ -138,13 +138,13 @@ void run()
|
||||
|
||||
v11 = int_vec_1;
|
||||
res_s = apply_visitor(int_printer(), v11);
|
||||
BOOST_CHECK(res_s == ",512,256,128,64");
|
||||
BOOST_TEST(res_s == ",512,256,128,64");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from 'const int' to 'const short'
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -141,9 +141,9 @@ void run()
|
||||
}
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
run();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -113,7 +113,7 @@ struct Calculator : boost::static_visitor<int>
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
int main()
|
||||
{
|
||||
|
||||
int n = 13;
|
||||
@@ -122,13 +122,13 @@ int test_main(int, char* [])
|
||||
std::ostringstream e1_str;
|
||||
e1_str << e1;
|
||||
|
||||
BOOST_CHECK(e1.type() == boost::typeindex::type_id<Add>());
|
||||
BOOST_CHECK(e1_str.str() == "(13+((40+2)-(10+4)))");
|
||||
BOOST_TEST(e1.type() == boost::typeindex::type_id<Add>());
|
||||
BOOST_TEST(e1_str.str() == "(13+((40+2)-(10+4)))");
|
||||
|
||||
//Evaluate expression
|
||||
int res = boost::apply_visitor(Calculator(), e1);
|
||||
BOOST_CHECK(res == n + 28);
|
||||
BOOST_TEST(res == n + 28);
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from 'const int' to 'const short'
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -32,7 +32,7 @@ typedef variant<std::string, class_a, short> var_type_2;
|
||||
|
||||
#include "class_a.h"
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
@@ -53,5 +53,5 @@ int test_main(int , char* [])
|
||||
v2 = 5;
|
||||
v1 = v2;
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -58,14 +58,14 @@ void run()
|
||||
verify(v3, spec<int>());
|
||||
|
||||
|
||||
BOOST_CHECK(apply_visitor(sum_int(), v2) == c0);
|
||||
BOOST_CHECK(apply_visitor(sum_int(), v3) == c0);
|
||||
BOOST_TEST(apply_visitor(sum_int(), v2) == c0);
|
||||
BOOST_TEST(apply_visitor(sum_int(), v3) == c0);
|
||||
|
||||
sum_int adder;
|
||||
apply_visitor(adder, v2);
|
||||
apply_visitor(adder, v3);
|
||||
|
||||
BOOST_CHECK(adder.result() == 2*c0);
|
||||
BOOST_TEST(adder.result() == 2*c0);
|
||||
|
||||
//
|
||||
// A variant holding a variant
|
||||
@@ -82,9 +82,9 @@ void run()
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -66,9 +66,9 @@ void run()
|
||||
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -16,7 +16,7 @@
|
||||
#pragma warning(disable:4244) // conversion from 'const int' to 'const short'
|
||||
#endif
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "jobs.h"
|
||||
@@ -69,8 +69,8 @@ struct Tracker
|
||||
static void remove(const jas& j)
|
||||
{
|
||||
iterator_type iter = s_this_to_sn_.find(&j);
|
||||
BOOST_CHECK(iter != s_this_to_sn_.end());
|
||||
BOOST_CHECK( ((*iter).second) == j.sn_);
|
||||
BOOST_TEST(iter != s_this_to_sn_.end());
|
||||
BOOST_TEST( ((*iter).second) == j.sn_);
|
||||
|
||||
int sn = (*iter).second;
|
||||
if(sn != j.sn_)
|
||||
@@ -79,7 +79,7 @@ struct Tracker
|
||||
<< ", other: this = " << &j << ", j.sn_ = " << j.sn_ << endl;
|
||||
}
|
||||
|
||||
BOOST_CHECK(sn == j.sn_);
|
||||
BOOST_TEST(sn == j.sn_);
|
||||
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ struct Tracker
|
||||
|
||||
static void check()
|
||||
{
|
||||
BOOST_CHECK(s_this_to_sn_.empty());
|
||||
BOOST_TEST(s_this_to_sn_.empty());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -214,13 +214,13 @@ void var_compare(const VariantType& v, ExpectedType expected)
|
||||
compare_helper<ExpectedType> ch(expected);
|
||||
|
||||
bool checks = boost::apply_visitor(ch, v);
|
||||
BOOST_CHECK(checks);
|
||||
BOOST_TEST(checks);
|
||||
}
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
variant<string, short> v0;
|
||||
boost::variant<string, short> v0;
|
||||
|
||||
var_compare(v0, string(""));
|
||||
|
||||
@@ -230,7 +230,7 @@ void run()
|
||||
v0 = "penny lane";
|
||||
var_compare(v0, string("penny lane"));
|
||||
|
||||
variant<jas, string, int> v1, v2 = jas(195);
|
||||
boost::variant<jas, string, int> v1, v2 = jas(195);
|
||||
var_compare(v1, jas(364));
|
||||
|
||||
v1 = jas(500);
|
||||
@@ -240,16 +240,16 @@ void run()
|
||||
var_compare(v2, jas(500));
|
||||
|
||||
|
||||
variant<string, int> v3;
|
||||
boost::variant<string, int> v3;
|
||||
var_compare(v3, string(""));
|
||||
}
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
Tracker::check();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+11
-12
@@ -10,14 +10,13 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
typedef variant<float, std::string, int, std::vector<std::string> > t_var1;
|
||||
@@ -41,12 +40,12 @@ struct int_sum : static_visitor<>
|
||||
template <typename T, typename Variant>
|
||||
T& check_pass(Variant& v, T value)
|
||||
{
|
||||
BOOST_CHECK(get<T>(&v));
|
||||
BOOST_TEST(get<T>(&v));
|
||||
|
||||
try
|
||||
{
|
||||
T& r = get<T>(v);
|
||||
BOOST_CHECK(r == value);
|
||||
BOOST_TEST(r == value);
|
||||
return r;
|
||||
}
|
||||
catch(boost::bad_get&)
|
||||
@@ -58,21 +57,21 @@ T& check_pass(Variant& v, T value)
|
||||
template <typename T, typename Variant>
|
||||
void check_fail(Variant& v)
|
||||
{
|
||||
BOOST_CHECK(!relaxed_get<T>(&v));
|
||||
BOOST_TEST(!relaxed_get<T>(&v));
|
||||
|
||||
try
|
||||
{
|
||||
T& r = relaxed_get<T>(v);
|
||||
(void)r; // suppress warning about r not being used
|
||||
BOOST_CHECK(false && relaxed_get<T>(&v)); // should never reach
|
||||
BOOST_TEST(false && relaxed_get<T>(&v)); // should never reach
|
||||
}
|
||||
catch(const boost::bad_get& e)
|
||||
{
|
||||
BOOST_CHECK(!!e.what()); // make sure that what() is const qualified and returnes something
|
||||
BOOST_TEST(!!e.what()); // make sure that what() is const qualified and returnes something
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
int_sum acc;
|
||||
t_var1 v1 = 800;
|
||||
@@ -88,12 +87,12 @@ int test_main(int , char* [])
|
||||
check_fail<const short>(v1);
|
||||
|
||||
apply_visitor(acc, v1);
|
||||
BOOST_CHECK(acc.result_ == 800);
|
||||
BOOST_TEST(acc.result_ == 800);
|
||||
|
||||
r1 = 920; // NOTE: modifies content of v1
|
||||
apply_visitor(acc, v1);
|
||||
BOOST_CHECK(cr1 == 920);
|
||||
BOOST_CHECK(acc.result_ == 800 + 920);
|
||||
BOOST_TEST(cr1 == 920);
|
||||
BOOST_TEST(acc.result_ == 800 + 920);
|
||||
}
|
||||
|
||||
// check const correctness:
|
||||
@@ -109,6 +108,6 @@ int test_main(int , char* [])
|
||||
//check_fail<short>(c);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016 Antony Polukhin
|
||||
// Copyright (c) 2016-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0551))
|
||||
# pragma warn -lvc // temporary used for parameter warning
|
||||
#endif
|
||||
|
||||
@@ -31,38 +31,38 @@ void assert_equality_comparable(
|
||||
)
|
||||
{
|
||||
// identity check
|
||||
BOOST_CHECK( !(&x == &y) || (x == y) );
|
||||
BOOST_CHECK( !(&x == &z) || (x == z) );
|
||||
BOOST_CHECK( !(&y == &z) || (y == z) );
|
||||
BOOST_CHECK( !(&x == &y) || !(x != y) );
|
||||
BOOST_CHECK( !(&x == &z) || !(x != z) );
|
||||
BOOST_CHECK( !(&y == &z) || !(y != z) );
|
||||
BOOST_TEST( !(&x == &y) || (x == y) );
|
||||
BOOST_TEST( !(&x == &z) || (x == z) );
|
||||
BOOST_TEST( !(&y == &z) || (y == z) );
|
||||
BOOST_TEST( !(&x == &y) || !(x != y) );
|
||||
BOOST_TEST( !(&x == &z) || !(x != z) );
|
||||
BOOST_TEST( !(&y == &z) || !(y != z) );
|
||||
|
||||
// reflexivity check
|
||||
BOOST_CHECK( (x == x) );
|
||||
BOOST_CHECK( (y == y) );
|
||||
BOOST_CHECK( (z == z) );
|
||||
BOOST_TEST( (x == x) );
|
||||
BOOST_TEST( (y == y) );
|
||||
BOOST_TEST( (z == z) );
|
||||
|
||||
// symmetry check
|
||||
BOOST_CHECK( !(x == y) || (y == x) );
|
||||
BOOST_CHECK( !(y == x) || (x == y) );
|
||||
BOOST_CHECK( (x != y) || (y == x) );
|
||||
BOOST_CHECK( (y != x) || (x == y) );
|
||||
BOOST_TEST( !(x == y) || (y == x) );
|
||||
BOOST_TEST( !(y == x) || (x == y) );
|
||||
BOOST_TEST( (x != y) || (y == x) );
|
||||
BOOST_TEST( (y != x) || (x == y) );
|
||||
|
||||
BOOST_CHECK( !(x == z) || (z == x) );
|
||||
BOOST_CHECK( !(z == x) || (x == z) );
|
||||
BOOST_CHECK( (x != z) || (z == x) );
|
||||
BOOST_CHECK( (z != x) || (x == z) );
|
||||
BOOST_TEST( !(x == z) || (z == x) );
|
||||
BOOST_TEST( !(z == x) || (x == z) );
|
||||
BOOST_TEST( (x != z) || (z == x) );
|
||||
BOOST_TEST( (z != x) || (x == z) );
|
||||
|
||||
BOOST_CHECK( !(y == z) || (z == y) );
|
||||
BOOST_CHECK( !(z == y) || (y == z) );
|
||||
BOOST_CHECK( (y != z) || (z == y) );
|
||||
BOOST_CHECK( (z != y) || (y == z) );
|
||||
BOOST_TEST( !(y == z) || (z == y) );
|
||||
BOOST_TEST( !(z == y) || (y == z) );
|
||||
BOOST_TEST( (y != z) || (z == y) );
|
||||
BOOST_TEST( (z != y) || (y == z) );
|
||||
|
||||
// transitivity check
|
||||
BOOST_CHECK( !(x == y && y == z) || (x == z) );
|
||||
BOOST_CHECK( !(x == z && z == y) || (x == y) );
|
||||
BOOST_CHECK( !(y == z && z == x) || (y == x) );
|
||||
BOOST_TEST( !(x == y && y == z) || (x == z) );
|
||||
BOOST_TEST( !(x == z && z == y) || (x == y) );
|
||||
BOOST_TEST( !(y == z && z == x) || (y == x) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -71,41 +71,41 @@ void assert_less_than_comparable(
|
||||
)
|
||||
{
|
||||
// irreflexivity check
|
||||
BOOST_CHECK( !(x < x) );
|
||||
BOOST_CHECK( !(y < y) );
|
||||
BOOST_CHECK( !(z < z) );
|
||||
BOOST_CHECK( !(x > x) );
|
||||
BOOST_CHECK( !(y > y) );
|
||||
BOOST_CHECK( !(z > z) );
|
||||
BOOST_TEST( !(x < x) );
|
||||
BOOST_TEST( !(y < y) );
|
||||
BOOST_TEST( !(z < z) );
|
||||
BOOST_TEST( !(x > x) );
|
||||
BOOST_TEST( !(y > y) );
|
||||
BOOST_TEST( !(z > z) );
|
||||
|
||||
BOOST_CHECK( (x <= x) );
|
||||
BOOST_CHECK( (y <= y) );
|
||||
BOOST_CHECK( (z <= z) );
|
||||
BOOST_CHECK( (x >= x) );
|
||||
BOOST_CHECK( (y >= y) );
|
||||
BOOST_CHECK( (z >= z) );
|
||||
BOOST_TEST( (x <= x) );
|
||||
BOOST_TEST( (y <= y) );
|
||||
BOOST_TEST( (z <= z) );
|
||||
BOOST_TEST( (x >= x) );
|
||||
BOOST_TEST( (y >= y) );
|
||||
BOOST_TEST( (z >= z) );
|
||||
|
||||
// transitivity check
|
||||
BOOST_CHECK( (x < y) );
|
||||
BOOST_CHECK( (y < z) );
|
||||
BOOST_CHECK( (x < z) );
|
||||
BOOST_TEST( (x < y) );
|
||||
BOOST_TEST( (y < z) );
|
||||
BOOST_TEST( (x < z) );
|
||||
|
||||
BOOST_CHECK( (x <= y) );
|
||||
BOOST_CHECK( (y <= z) );
|
||||
BOOST_CHECK( (x <= z) );
|
||||
BOOST_TEST( (x <= y) );
|
||||
BOOST_TEST( (y <= z) );
|
||||
BOOST_TEST( (x <= z) );
|
||||
|
||||
BOOST_CHECK( (z > y) );
|
||||
BOOST_CHECK( (y > x) );
|
||||
BOOST_CHECK( (z > x) );
|
||||
BOOST_TEST( (z > y) );
|
||||
BOOST_TEST( (y > x) );
|
||||
BOOST_TEST( (z > x) );
|
||||
|
||||
BOOST_CHECK( (z >= y) );
|
||||
BOOST_CHECK( (y >= x) );
|
||||
BOOST_CHECK( (z >= x) );
|
||||
BOOST_TEST( (z >= y) );
|
||||
BOOST_TEST( (y >= x) );
|
||||
BOOST_TEST( (z >= x) );
|
||||
|
||||
// antisymmetry check
|
||||
BOOST_CHECK( !(y < x) );
|
||||
BOOST_CHECK( !(z < y) );
|
||||
BOOST_CHECK( !(z < x) );
|
||||
BOOST_TEST( !(y < x) );
|
||||
BOOST_TEST( !(z < y) );
|
||||
BOOST_TEST( !(z < x) );
|
||||
}
|
||||
|
||||
template <typename It>
|
||||
@@ -122,7 +122,7 @@ std::string print_range(It first, It last)
|
||||
return result.str();
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
typedef boost::variant<int, std::string> var_t;
|
||||
|
||||
@@ -146,13 +146,13 @@ int test_main(int , char* [])
|
||||
std::sort(vec.begin(), vec.end());
|
||||
|
||||
std::string sort_result( print_range(vec.begin(), vec.end()) );
|
||||
BOOST_CHECK( sort_result == "3 5 goodbye hello " );
|
||||
BOOST_TEST( sort_result == "3 5 goodbye hello " );
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/11751
|
||||
int a = 0, b = 0;
|
||||
|
||||
boost::variant< int& > v (a), u (b);
|
||||
BOOST_CHECK(v == u);
|
||||
BOOST_TEST(v == u);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+105
-100
@@ -3,17 +3,22 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2017 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4127) // conditional expression is constant
|
||||
#pragma warning(disable: 4181) // qualifier applied to reference type; ignored
|
||||
#endif
|
||||
|
||||
#include "boost/variant/get.hpp"
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/polymorphic_get.hpp"
|
||||
#include "boost/variant/recursive_wrapper.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
struct base {
|
||||
int trash;
|
||||
@@ -59,32 +64,32 @@ inline void check_polymorphic_get_on_types_impl_single_type(V* v)
|
||||
const bool ref_same = !!boost::is_same<TypeInVariant, ref_test_t>::value;
|
||||
|
||||
if (exact_same || ref_same) {
|
||||
BOOST_CHECK(boost::polymorphic_get<TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
|
||||
BOOST_CHECK(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
|
||||
if (ref_same) {
|
||||
BOOST_CHECK(boost::polymorphic_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::polymorphic_relaxed_get<cref_test_t>(v));
|
||||
}
|
||||
} else {
|
||||
BOOST_CHECK(!boost::polymorphic_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_get<TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_strict_get<TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_strict_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<TestType>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<const TestType>(v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,32 +102,32 @@ inline void check_get_on_types_impl_single_type(V* v)
|
||||
const bool ref_same = !!boost::is_same<T, ref_test_t>::value;
|
||||
|
||||
if (exact_same || ref_same) {
|
||||
BOOST_CHECK(boost::get<TestType>(v));
|
||||
BOOST_CHECK(boost::get<const TestType>(v));
|
||||
BOOST_CHECK(boost::strict_get<TestType>(v));
|
||||
BOOST_CHECK(boost::strict_get<const TestType>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(boost::get<TestType>(v));
|
||||
BOOST_TEST(boost::get<const TestType>(v));
|
||||
BOOST_TEST(boost::strict_get<TestType>(v));
|
||||
BOOST_TEST(boost::strict_get<const TestType>(v));
|
||||
BOOST_TEST(boost::relaxed_get<TestType>(v));
|
||||
BOOST_TEST(boost::relaxed_get<const TestType>(v));
|
||||
|
||||
BOOST_CHECK(boost::get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::relaxed_get<cref_test_t>(v));
|
||||
|
||||
if (ref_same) {
|
||||
BOOST_CHECK(boost::get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::strict_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<ref_test_t>(v));
|
||||
BOOST_CHECK(boost::relaxed_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::strict_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::strict_get<cref_test_t>(v));
|
||||
BOOST_TEST(boost::relaxed_get<ref_test_t>(v));
|
||||
BOOST_TEST(boost::relaxed_get<cref_test_t>(v));
|
||||
}
|
||||
} else {
|
||||
BOOST_CHECK(!boost::get<TestType>(v));
|
||||
BOOST_CHECK(!boost::get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::strict_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::strict_get<const TestType>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<TestType>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::get<TestType>(v));
|
||||
BOOST_TEST(!boost::get<const TestType>(v));
|
||||
BOOST_TEST(!boost::strict_get<TestType>(v));
|
||||
BOOST_TEST(!boost::strict_get<const TestType>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<TestType>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<const TestType>(v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,19 +149,19 @@ inline void check_get_on_types_impl(V* v)
|
||||
check_polymorphic_get_on_types_impl_single_type<T, V, std::string>(v);
|
||||
|
||||
// Never exist in here
|
||||
BOOST_CHECK(!boost::relaxed_get<short>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<const short>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<char>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<char*>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<bool>(v));
|
||||
BOOST_CHECK(!boost::relaxed_get<const bool>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<short>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<const short>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<char>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<char*>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<bool>(v));
|
||||
BOOST_TEST(!boost::relaxed_get<const bool>(v));
|
||||
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<short>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<const short>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<char>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<char*>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<bool>(v));
|
||||
BOOST_CHECK(!boost::polymorphic_relaxed_get<const bool>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<short>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<const short>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<char>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<char*>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<bool>(v));
|
||||
BOOST_TEST(!boost::polymorphic_relaxed_get<const bool>(v));
|
||||
|
||||
boost::get<T>(*v); // Must compile
|
||||
boost::get<const T>(*v); // Must compile
|
||||
@@ -267,20 +272,20 @@ inline void get_cref_test()
|
||||
{
|
||||
int i = 0;
|
||||
var_cref_t v(i);
|
||||
BOOST_CHECK(boost::get<const int>(&v));
|
||||
BOOST_CHECK(boost::get<const int&>(&v));
|
||||
BOOST_CHECK(!boost::get<const base>(&v));
|
||||
BOOST_TEST(boost::get<const int>(&v));
|
||||
BOOST_TEST(boost::get<const int&>(&v));
|
||||
BOOST_TEST(!boost::get<const base>(&v));
|
||||
|
||||
base b;
|
||||
var_cref_t v1(b);
|
||||
BOOST_CHECK(boost::get<const base>(&v1));
|
||||
BOOST_CHECK(!boost::get<const derived1>(&v1));
|
||||
BOOST_CHECK(!boost::get<const int>(&v1));
|
||||
BOOST_TEST(boost::get<const base>(&v1));
|
||||
BOOST_TEST(!boost::get<const derived1>(&v1));
|
||||
BOOST_TEST(!boost::get<const int>(&v1));
|
||||
|
||||
std::string s("Hello");
|
||||
const var_cref_t v4 = s;
|
||||
BOOST_CHECK(boost::get<const std::string>(&v4));
|
||||
BOOST_CHECK(!boost::get<const int>(&v4));
|
||||
BOOST_TEST(boost::get<const std::string>(&v4));
|
||||
BOOST_TEST(!boost::get<const int>(&v4));
|
||||
}
|
||||
|
||||
inline void get_recursive_test()
|
||||
@@ -310,45 +315,45 @@ inline void check_that_does_not_exist_impl()
|
||||
{
|
||||
using namespace boost::detail::variant;
|
||||
|
||||
BOOST_CHECK((holds_element<T, const int>::value));
|
||||
BOOST_CHECK((!holds_element<T, short>::value));
|
||||
BOOST_CHECK((!holds_element<T, short>::value));
|
||||
BOOST_CHECK((!holds_element<T, const short>::value));
|
||||
BOOST_CHECK((!holds_element<T, char*>::value));
|
||||
BOOST_CHECK((!holds_element<T, const char*>::value));
|
||||
BOOST_CHECK((!holds_element<T, char[5]>::value));
|
||||
BOOST_CHECK((!holds_element<T, const char[5]>::value));
|
||||
BOOST_CHECK((!holds_element<T, bool>::value));
|
||||
BOOST_CHECK((!holds_element<T, const bool>::value));
|
||||
BOOST_TEST((holds_element<T, const int>::value));
|
||||
BOOST_TEST((!holds_element<T, short>::value));
|
||||
BOOST_TEST((!holds_element<T, short>::value));
|
||||
BOOST_TEST((!holds_element<T, const short>::value));
|
||||
BOOST_TEST((!holds_element<T, char*>::value));
|
||||
BOOST_TEST((!holds_element<T, const char*>::value));
|
||||
BOOST_TEST((!holds_element<T, char[5]>::value));
|
||||
BOOST_TEST((!holds_element<T, const char[5]>::value));
|
||||
BOOST_TEST((!holds_element<T, bool>::value));
|
||||
BOOST_TEST((!holds_element<T, const bool>::value));
|
||||
|
||||
BOOST_CHECK((!holds_element<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_CHECK((!holds_element<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_CHECK((!holds_element<T, boost::detail::reference_content<short> >::value));
|
||||
BOOST_TEST((!holds_element<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_TEST((!holds_element<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_TEST((!holds_element<T, boost::detail::reference_content<short> >::value));
|
||||
|
||||
|
||||
BOOST_CHECK((holds_element_polymorphic<T, const int>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const short>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, char*>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const char*>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, char[5]>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const char[5]>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, bool>::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, const bool>::value));
|
||||
BOOST_TEST((holds_element_polymorphic<T, const int>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, short>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const short>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, char*>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const char*>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, char[5]>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const char[5]>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, bool>::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, const bool>::value));
|
||||
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_CHECK((!holds_element_polymorphic<T, boost::detail::reference_content<short> >::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, boost::recursive_wrapper<int> >::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, boost::recursive_wrapper<short> >::value));
|
||||
BOOST_TEST((!holds_element_polymorphic<T, boost::detail::reference_content<short> >::value));
|
||||
}
|
||||
|
||||
inline void check_that_does_not_exist()
|
||||
{
|
||||
using namespace boost::detail::variant;
|
||||
|
||||
BOOST_CHECK((holds_element<var_t, int>::value));
|
||||
BOOST_CHECK((holds_element<var_ref_t, int>::value));
|
||||
BOOST_CHECK((!holds_element<var_cref_t, int>::value));
|
||||
BOOST_TEST((holds_element<var_t, int>::value));
|
||||
BOOST_TEST((holds_element<var_ref_t, int>::value));
|
||||
BOOST_TEST((!holds_element<var_cref_t, int>::value));
|
||||
|
||||
check_that_does_not_exist_impl<var_t>();
|
||||
check_that_does_not_exist_impl<var_ref_t>();
|
||||
@@ -362,12 +367,12 @@ public:
|
||||
MoveonlyType() {}
|
||||
~MoveonlyType() {}
|
||||
|
||||
MoveonlyType(MoveonlyType&& other) {}
|
||||
void operator=(MoveonlyType&& other) {}
|
||||
MoveonlyType(MoveonlyType&&) {}
|
||||
void operator=(MoveonlyType&&) {}
|
||||
|
||||
private:
|
||||
MoveonlyType(const MoveonlyType&);
|
||||
void operator=(const MoveonlyType& other);
|
||||
void operator=(const MoveonlyType&);
|
||||
};
|
||||
|
||||
const boost::variant<int, std::string> foo1() { return ""; }
|
||||
@@ -381,7 +386,7 @@ inline void get_rvref_test()
|
||||
boost::variant<MoveonlyType, int> v;
|
||||
|
||||
v = MoveonlyType();
|
||||
boost::get<MoveonlyType>(boost::move(v));
|
||||
boost::get<MoveonlyType>(std::move(v));
|
||||
|
||||
v = 3;
|
||||
|
||||
@@ -391,11 +396,11 @@ inline void get_rvref_test()
|
||||
boost::relaxed_get<MoveonlyType&>(boost::variant<MoveonlyType, int>());
|
||||
|
||||
v = MoveonlyType();
|
||||
MoveonlyType moved_from_variant(boost::get<MoveonlyType>(boost::move(v)));
|
||||
MoveonlyType moved_from_variant(boost::get<MoveonlyType>(std::move(v)));
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
get_test();
|
||||
get_test_no_fallback();
|
||||
@@ -408,5 +413,5 @@ int test_main(int , char* [])
|
||||
get_rvref_test();
|
||||
#endif
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2013-2015 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "boost/variant/multivisitors.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
struct my_noncopyable : boost::noncopyable {
|
||||
my_noncopyable(){}
|
||||
@@ -25,66 +25,66 @@ struct my_noncopyable : boost::noncopyable {
|
||||
typedef boost::variant<my_noncopyable, int> variant_noncopy_t;
|
||||
|
||||
|
||||
typedef boost::variant<char, unsigned char, signed char, unsigned short, int, unsigned int> variant6_t;
|
||||
typedef boost::variant<char, unsigned char, signed char, unsigned short, int> variant5_t;
|
||||
|
||||
struct test_visitor: boost::static_visitor<> {
|
||||
// operators that shall not be called
|
||||
template <class T1, class T2, class T3>
|
||||
void operator()(T1&, T2&, T3&) const
|
||||
{
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
void operator()(T1&, T2&, T3&, T4&) const
|
||||
{
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
void operator()(T1&, T2&, T3&, T4&, T5&) const
|
||||
{
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
// operators that are OK to call
|
||||
void operator()(char v0, unsigned char v1, signed char v2) const
|
||||
{
|
||||
BOOST_CHECK(v0 == 0);
|
||||
BOOST_CHECK(v1 == 1);
|
||||
BOOST_CHECK(v2 == 2);
|
||||
BOOST_TEST(v0 == 0);
|
||||
BOOST_TEST(v1 == 1);
|
||||
BOOST_TEST(v2 == 2);
|
||||
}
|
||||
|
||||
void operator()(char v0, unsigned char v1, signed char v2, unsigned short v3) const
|
||||
{
|
||||
BOOST_CHECK(v0 == 0);
|
||||
BOOST_CHECK(v1 == 1);
|
||||
BOOST_CHECK(v2 == 2);
|
||||
BOOST_CHECK(v3 == 3);
|
||||
BOOST_TEST(v0 == 0);
|
||||
BOOST_TEST(v1 == 1);
|
||||
BOOST_TEST(v2 == 2);
|
||||
BOOST_TEST(v3 == 3);
|
||||
}
|
||||
|
||||
void operator()(char v0, unsigned char v1, signed char v2, unsigned short v3, int v4) const
|
||||
{
|
||||
BOOST_CHECK(v0 == 0);
|
||||
BOOST_CHECK(v1 == 1);
|
||||
BOOST_CHECK(v2 == 2);
|
||||
BOOST_CHECK(v3 == 3);
|
||||
BOOST_CHECK(v4 == 4);
|
||||
BOOST_TEST(v0 == 0);
|
||||
BOOST_TEST(v1 == 1);
|
||||
BOOST_TEST(v2 == 2);
|
||||
BOOST_TEST(v3 == 3);
|
||||
BOOST_TEST(v4 == 4);
|
||||
}
|
||||
|
||||
|
||||
// Noncopyables
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
void operator()(my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&, my_noncopyable&) const {
|
||||
BOOST_CHECK(true);
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -103,47 +103,44 @@ struct if_visitor: public boost::static_visitor<arithmetics_t> {
|
||||
};
|
||||
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_visitor v;
|
||||
|
||||
variant6_t v_array6[6];
|
||||
v_array6[0] = char(0);
|
||||
v_array6[1] = static_cast<unsigned char>(1);
|
||||
v_array6[2] = static_cast<signed char>(2);
|
||||
v_array6[3] = static_cast<unsigned short>(3);
|
||||
v_array6[4] = static_cast<int>(4);
|
||||
v_array6[5] = static_cast<unsigned int>(5);
|
||||
variant5_t v_array5[5];
|
||||
v_array5[0] = char(0);
|
||||
v_array5[1] = static_cast<unsigned char>(1);
|
||||
v_array5[2] = static_cast<signed char>(2);
|
||||
v_array5[3] = static_cast<unsigned short>(3);
|
||||
v_array5[4] = static_cast<int>(4);
|
||||
|
||||
boost::apply_visitor(v, v_array6[0], v_array6[1], v_array6[2]);
|
||||
boost::apply_visitor(test_visitor(), v_array6[0], v_array6[1], v_array6[2]);
|
||||
boost::apply_visitor(v, v_array5[0], v_array5[1], v_array5[2]);
|
||||
boost::apply_visitor(test_visitor(), v_array5[0], v_array5[1], v_array5[2]);
|
||||
|
||||
// Following test also pass, but requires many Gigabytes of RAM for compilation and compile for about 15 minutes
|
||||
//#define BOOST_VARIANT_MULTIVISITORS_TEST_VERY_EXTREME
|
||||
#ifdef BOOST_VARIANT_MULTIVISITORS_TEST_VERY_EXTREME
|
||||
boost::apply_visitor(v, v_array6[0], v_array6[1], v_array6[2], v_array6[3]);
|
||||
boost::apply_visitor(test_visitor(), v_array6[0], v_array6[1], v_array6[2], v_array6[3]);
|
||||
boost::apply_visitor(v, v_array5[0], v_array5[1], v_array5[2], v_array5[3]);
|
||||
boost::apply_visitor(test_visitor(), v_array5[0], v_array5[1], v_array5[2], v_array5[3]);
|
||||
|
||||
boost::apply_visitor(v, v_array6[0], v_array6[1], v_array6[2], v_array6[3], v_array6[4]);
|
||||
boost::apply_visitor(test_visitor(), v_array6[0], v_array6[1], v_array6[2], v_array6[3], v_array6[4]);
|
||||
boost::apply_visitor(v, v_array5[0], v_array5[1], v_array5[2], v_array5[3], v_array5[4]);
|
||||
boost::apply_visitor(test_visitor(), v_array5[0], v_array5[1], v_array5[2], v_array5[3], v_array5[4]);
|
||||
#endif
|
||||
|
||||
bool_like_t v0(1), v1(true), v2(1.0);
|
||||
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(if_visitor(), v0, v1, v2)
|
||||
==
|
||||
arithmetics_t(true)
|
||||
);
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
if_visitor if_vis;
|
||||
BOOST_CHECK(
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(if_vis)(v0, v1, v2)
|
||||
==
|
||||
arithmetics_t(true)
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
variant_noncopy_t vnonc[6];
|
||||
@@ -155,5 +152,5 @@ int test_main(int , char* [])
|
||||
boost::apply_visitor(test_visitor(), vnonc[0], vnonc[1], vnonc[2], vnonc[3], vnonc[4], vnonc[5]);
|
||||
#endif
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
// Copyright (c) 2014-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/get.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
struct exception_on_assignment : std::exception {};
|
||||
@@ -197,21 +197,21 @@ inline void check_1_impl(int helper)
|
||||
boost::variant<throwing_class, Nonthrowing> v;
|
||||
try {
|
||||
v = throwing_class(helper);
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
}
|
||||
|
||||
try {
|
||||
throwing_class tc(helper);
|
||||
v = tc;
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,21 +230,21 @@ inline void check_2_impl(int helper)
|
||||
boost::variant<Nonthrowing, throwing_class> v;
|
||||
try {
|
||||
v = throwing_class(helper);
|
||||
BOOST_CHECK(v.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(v.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v));
|
||||
}
|
||||
|
||||
try {
|
||||
throwing_class cl(helper);
|
||||
v = cl;
|
||||
BOOST_CHECK(v.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v));
|
||||
BOOST_TEST(v.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v));
|
||||
BOOST_TEST(!v.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,30 +265,30 @@ inline void check_3_impl(int helper)
|
||||
swap(v1, v2);
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v1));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
v2 = throwing_class(helper);
|
||||
BOOST_CHECK(v2.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v2));
|
||||
BOOST_TEST(v2.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v2));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v2));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v2));
|
||||
}
|
||||
|
||||
|
||||
if (!v1.which() && !v2.which()) {
|
||||
swap(v1, v2); // Make sure that two backup holders swap well
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v2));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v2));
|
||||
|
||||
v1 = v2;
|
||||
}
|
||||
@@ -311,29 +311,29 @@ inline void check_4(int helper = 1)
|
||||
swap(v1, v2);
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<int>(&v1));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<int>(&v1));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
v2 = throwing_class(helper);
|
||||
BOOST_CHECK(v2.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v2));
|
||||
BOOST_TEST(v2.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v2));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<int>(&v2));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<int>(&v2));
|
||||
}
|
||||
|
||||
if (!v1.which() && !v2.which()) {
|
||||
swap(v1, v2);
|
||||
BOOST_CHECK(!v1.which());
|
||||
BOOST_CHECK(boost::get<int>(&v1));
|
||||
BOOST_CHECK(!v2.which());
|
||||
BOOST_CHECK(boost::get<int>(&v2));
|
||||
BOOST_TEST(!v1.which());
|
||||
BOOST_TEST(boost::get<int>(&v1));
|
||||
BOOST_TEST(!v2.which());
|
||||
BOOST_TEST(boost::get<int>(&v2));
|
||||
|
||||
v1 = v2;
|
||||
}
|
||||
@@ -353,11 +353,11 @@ inline void check_5_impl(int helper)
|
||||
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
}
|
||||
|
||||
boost::get<throwing_class>(v1).trash = throwing_class::do_not_throw;
|
||||
@@ -366,22 +366,22 @@ inline void check_5_impl(int helper)
|
||||
v2 = Nonthrowing();
|
||||
try {
|
||||
v1 = throwing_class(helper);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_CHECK(boost::get<Nonthrowing>(&v1));
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
BOOST_TEST(boost::get<Nonthrowing>(&v1));
|
||||
}
|
||||
|
||||
int v1_type = v1.which();
|
||||
int v2_type = v2.which();
|
||||
try {
|
||||
swap(v1, v2); // Make sure that backup holders swap well
|
||||
BOOST_CHECK(v1.which() == v2_type);
|
||||
BOOST_CHECK(v2.which() == v1_type);
|
||||
BOOST_TEST(v1.which() == v2_type);
|
||||
BOOST_TEST(v2.which() == v1_type);
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == v1_type);
|
||||
BOOST_CHECK(v2.which() == v2_type);
|
||||
BOOST_TEST(v1.which() == v1_type);
|
||||
BOOST_TEST(v2.which() == v2_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,18 +418,18 @@ inline void check_6_impl(int helper)
|
||||
throwing_class tc;
|
||||
tc.trash = helper;
|
||||
v1 = tc;
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(boost::get<throwing_class>(&v1));
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(boost::get<throwing_class>(&v1));
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
}
|
||||
|
||||
v2 = Nonthrowing();
|
||||
try {
|
||||
v2 = 2;
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
}
|
||||
|
||||
// Probably the most significant test:
|
||||
@@ -439,9 +439,9 @@ inline void check_6_impl(int helper)
|
||||
try {
|
||||
swap(v1, v2);
|
||||
} catch (const exception_on_assignment& /*e*/) {
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_CHECK(v2.which() == 0);
|
||||
BOOST_CHECK(boost::get<throwing_class>(v1).trash == helper);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
BOOST_TEST(v2.which() == 0);
|
||||
BOOST_TEST(boost::get<throwing_class>(v1).trash == helper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ inline void check_6(int helper = 1)
|
||||
check_6_impl<boost::blank>(helper);
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
// throwing_class::throw_after_1 + 1 => throw on first assignment/construction
|
||||
// throwing_class::throw_after_1 => throw on second assignment/construction
|
||||
@@ -470,5 +470,5 @@ int test_main(int , char* [])
|
||||
check_6(i);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/mpl/joint_view.hpp"
|
||||
@@ -22,9 +22,9 @@ template<class T, class Variant>
|
||||
void check_exception_on_get(Variant& v) {
|
||||
try {
|
||||
boost::get<T>(v);
|
||||
BOOST_FAIL("Expected exception boost::bad_get, but got nothing.");
|
||||
BOOST_ERROR("Expected exception boost::bad_get, but got nothing.");
|
||||
} catch (boost::bad_get&) { //okay it is expected behaviour
|
||||
} catch (...) { BOOST_FAIL("Expected exception boost::bad_get, but got something else."); }
|
||||
} catch (...) { BOOST_ERROR("Expected exception boost::bad_get, but got something else."); }
|
||||
}
|
||||
|
||||
void test_joint_view() {
|
||||
@@ -35,11 +35,11 @@ void test_joint_view() {
|
||||
v1 a = 1;
|
||||
v2 b = "2";
|
||||
v3 c = a;
|
||||
BOOST_CHECK(boost::get<int>(c) == 1);
|
||||
BOOST_CHECK(c.which() == 0);
|
||||
BOOST_TEST(boost::get<int>(c) == 1);
|
||||
BOOST_TEST(c.which() == 0);
|
||||
v3 d = b;
|
||||
BOOST_CHECK(boost::get<std::string>(d) == "2");
|
||||
BOOST_CHECK(d.which() == 1);
|
||||
BOOST_TEST(boost::get<std::string>(d) == "2");
|
||||
BOOST_TEST(d.which() == 1);
|
||||
check_exception_on_get<std::string>(c);
|
||||
check_exception_on_get<int>(d);
|
||||
}
|
||||
@@ -49,16 +49,16 @@ void test_set() {
|
||||
typedef boost::make_variant_over< types >::type v;
|
||||
|
||||
v a = 1;
|
||||
BOOST_CHECK(boost::get<int>(a) == 1);
|
||||
BOOST_TEST(boost::get<int>(a) == 1);
|
||||
check_exception_on_get<std::string>(a);
|
||||
a = "2";
|
||||
BOOST_CHECK(boost::get<std::string>(a) == "2");
|
||||
BOOST_TEST(boost::get<std::string>(a) == "2");
|
||||
check_exception_on_get<int>(a);
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
test_joint_view();
|
||||
test_set();
|
||||
return 0;
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2013-2014 Antony Polukhin
|
||||
// Copyright (c) 2013-2026 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "boost/variant/apply_visitor.hpp"
|
||||
#include "boost/variant/static_visitor.hpp"
|
||||
#include "boost/variant/polymorphic_get.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
struct base {int trash;};
|
||||
struct derived1 : base{};
|
||||
@@ -29,53 +29,53 @@ template <class T, class Variant>
|
||||
inline void check_throws(Variant& v) {
|
||||
try {
|
||||
boost::polymorphic_get<T>(v);
|
||||
BOOST_CHECK(false);
|
||||
BOOST_TEST(false);
|
||||
} catch (const boost::bad_polymorphic_get& e) {
|
||||
BOOST_CHECK(!!e.what());
|
||||
BOOST_CHECK(std::string(e.what()) != boost::bad_get().what());
|
||||
BOOST_TEST(!!e.what());
|
||||
BOOST_TEST(std::string(e.what()) != boost::bad_get().what());
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
typedef boost::variant<int, base, derived1, derived2> var_t;
|
||||
|
||||
var_t var1;
|
||||
BOOST_CHECK(!boost::polymorphic_get<base>(&var1));
|
||||
BOOST_TEST(!boost::polymorphic_get<base>(&var1));
|
||||
check_throws<base>(var1);
|
||||
BOOST_CHECK(!boost::polymorphic_get<const base>(&var1));
|
||||
BOOST_TEST(!boost::polymorphic_get<const base>(&var1));
|
||||
check_throws<base, const var_t>(var1);
|
||||
|
||||
var1 = derived1();
|
||||
BOOST_CHECK(boost::polymorphic_get<base>(&var1));
|
||||
BOOST_CHECK(boost::polymorphic_get<const base>(&var1));
|
||||
BOOST_TEST(boost::polymorphic_get<base>(&var1));
|
||||
BOOST_TEST(boost::polymorphic_get<const base>(&var1));
|
||||
|
||||
derived2 d;
|
||||
d.trash = 777;
|
||||
var_t var2 = d;
|
||||
BOOST_CHECK(boost::polymorphic_get<base>(var2).trash == 777);
|
||||
BOOST_CHECK(boost::polymorphic_get<const base>(var2).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<base>(var2).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<const base>(var2).trash == 777);
|
||||
|
||||
var2 = 777;
|
||||
BOOST_CHECK(!boost::polymorphic_get<base>(&var2));
|
||||
BOOST_TEST(!boost::polymorphic_get<base>(&var2));
|
||||
check_throws<base>(var2);
|
||||
BOOST_CHECK(!boost::polymorphic_get<const base>(&var2));
|
||||
BOOST_TEST(!boost::polymorphic_get<const base>(&var2));
|
||||
check_throws<base, const var_t>(var2);
|
||||
BOOST_CHECK(boost::polymorphic_get<int>(var2) == 777);
|
||||
BOOST_CHECK(boost::polymorphic_get<const int>(var2) == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<int>(var2) == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<const int>(var2) == 777);
|
||||
|
||||
typedef boost::variant<int, vbase, vderived1, vderived2, vderived3> vvar_t;
|
||||
|
||||
vvar_t v = vderived3();
|
||||
boost::polymorphic_get<vderived3>(v).trash = 777;
|
||||
const vvar_t& cv = v;
|
||||
BOOST_CHECK(boost::polymorphic_get<vbase>(cv).trash == 777);
|
||||
BOOST_CHECK(boost::polymorphic_get<const vbase>(cv).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<vbase>(cv).trash == 777);
|
||||
BOOST_TEST(boost::polymorphic_get<const vbase>(cv).trash == 777);
|
||||
|
||||
BOOST_CHECK(boost::polymorphic_get<vbase>(cv).foo() == 3);
|
||||
BOOST_CHECK(boost::polymorphic_get<vbase>(v).foo() == 3);
|
||||
BOOST_CHECK(boost::polymorphic_get<const vbase>(cv).foo() == 3);
|
||||
BOOST_CHECK(boost::polymorphic_get<const vbase>(v).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<vbase>(cv).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<vbase>(v).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<const vbase>(cv).foo() == 3);
|
||||
BOOST_TEST(boost::polymorphic_get<const vbase>(v).foo() == 3);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/type_traits/add_reference.hpp"
|
||||
@@ -55,37 +55,37 @@ wknd_get(boost::variant<T>& var, int)
|
||||
template <typename T>
|
||||
void test_reference_content(T& t, const T& value1, const T& value2)
|
||||
{
|
||||
BOOST_CHECK( !(value1 == value2) );
|
||||
BOOST_TEST( !(value1 == value2) );
|
||||
|
||||
/////
|
||||
|
||||
boost::variant< T& > var(t);
|
||||
BOOST_CHECK(( boost::get<T>(&var) == &t ));
|
||||
BOOST_TEST(( boost::get<T>(&var) == &t ));
|
||||
|
||||
t = value1;
|
||||
BOOST_CHECK(( boost::get<T>(var) == value1 ));
|
||||
BOOST_TEST(( boost::get<T>(var) == value1 ));
|
||||
|
||||
/////
|
||||
|
||||
boost::variant< T > var2(var);
|
||||
BOOST_CHECK(( boost::get<T>(var2) == value1 ));
|
||||
BOOST_TEST(( boost::get<T>(var2) == value1 ));
|
||||
|
||||
t = value2;
|
||||
BOOST_CHECK(( boost::get<T>(var2) == value1 ));
|
||||
BOOST_TEST(( boost::get<T>(var2) == value1 ));
|
||||
}
|
||||
|
||||
template <typename Base, typename Derived>
|
||||
void base_derived_test(Derived d)
|
||||
{
|
||||
Base b(d);
|
||||
BOOST_CHECK((check_base_derived(
|
||||
BOOST_TEST((check_base_derived(
|
||||
b
|
||||
, d
|
||||
, 1L
|
||||
)));
|
||||
|
||||
boost::variant<Base> base_var(d);
|
||||
BOOST_CHECK((check_base_derived(
|
||||
BOOST_TEST((check_base_derived(
|
||||
wknd_get(base_var, 1L)
|
||||
, d
|
||||
, 1L
|
||||
@@ -93,14 +93,14 @@ void base_derived_test(Derived d)
|
||||
|
||||
boost::variant<Derived> derived_var(d);
|
||||
boost::variant<Base> base_from_derived_var(derived_var);
|
||||
BOOST_CHECK((check_base_derived(
|
||||
BOOST_TEST((check_base_derived(
|
||||
wknd_get(base_from_derived_var, 1L)
|
||||
, wknd_get(derived_var, 1L)
|
||||
, 1L
|
||||
)));
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
test_reference_content(i, 1, 2);
|
||||
@@ -112,5 +112,5 @@ int test_main(int , char* [])
|
||||
base_derived_test< base_t*,derived_t* >(&d);
|
||||
base_derived_test< base_t&,derived_t& >(d);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -11,9 +11,8 @@
|
||||
|
||||
#include "boost/variant/get.hpp"
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -29,15 +28,15 @@ inline void run()
|
||||
var_t v = s;
|
||||
|
||||
// must spit an error at compile-time because of 'std::string&'
|
||||
std::string new_s = boost::strict_get<std::string&>(boost::move(v));
|
||||
std::string new_s = boost::strict_get<std::string&>(std::move(v));
|
||||
UNUSED(new_s);
|
||||
#else
|
||||
BOOST_STATIC_ASSERT_MSG(false, "Dummy compile-time error to pass the test on C++03");
|
||||
#endif
|
||||
}
|
||||
|
||||
int test_main(int /*argc*/, char* /*argv*/ [])
|
||||
int main()
|
||||
{
|
||||
run();
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
+20
-20
@@ -4,13 +4,13 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 ArtVPS Ltd.
|
||||
// Copyright (c) 2013 Antony Polukhin.
|
||||
// Copyright (c) 2013-2026 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/variant.hpp"
|
||||
|
||||
#include <vector>
|
||||
@@ -24,13 +24,13 @@ void run1()
|
||||
std::vector<int> vec;
|
||||
t_var v0(23), v1(&vec);
|
||||
|
||||
BOOST_REQUIRE(v0.which() == 0);
|
||||
BOOST_REQUIRE(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
swap(v0, v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
}
|
||||
|
||||
void run2()
|
||||
@@ -43,18 +43,18 @@ void run2()
|
||||
std::vector<double> vec2;
|
||||
t_var v0(vec1), v1(vec2);
|
||||
|
||||
BOOST_REQUIRE(v0.which() == 0);
|
||||
BOOST_REQUIRE(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
swap(v0, v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
|
||||
v0.swap(v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 0);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
}
|
||||
|
||||
void run3()
|
||||
@@ -65,26 +65,26 @@ void run3()
|
||||
|
||||
t_var v0(1), v1(2.0);
|
||||
|
||||
BOOST_REQUIRE(v0.which() == 0);
|
||||
BOOST_REQUIRE(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
|
||||
swap(v0, v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 1);
|
||||
BOOST_CHECK(v1.which() == 0);
|
||||
BOOST_TEST(v0.which() == 1);
|
||||
BOOST_TEST(v1.which() == 0);
|
||||
|
||||
v0.swap(v1);
|
||||
|
||||
BOOST_CHECK(v0.which() == 0);
|
||||
BOOST_CHECK(v1.which() == 1);
|
||||
BOOST_TEST(v0.which() == 0);
|
||||
BOOST_TEST(v1.which() == 1);
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
run1();
|
||||
run2();
|
||||
run3();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost-libs variant/test/variant_visit_internal_linkage.cpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018 Louis Dionne, Antony Polukhin
|
||||
//
|
||||
// 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)
|
||||
|
||||
// This test checks that we can visit a variant containing a type that has
|
||||
// internal linkage (anonymous namespace).
|
||||
|
||||
#include "boost/variant/variant.hpp"
|
||||
|
||||
#ifdef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
|
||||
void run() {}
|
||||
|
||||
#else
|
||||
|
||||
namespace {
|
||||
struct Foo { };
|
||||
|
||||
struct Visitor {
|
||||
void operator()(Foo const&) const { }
|
||||
};
|
||||
}
|
||||
|
||||
void run() {
|
||||
boost::variant<Foo> v = Foo();
|
||||
boost::apply_visitor(Visitor(), v);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
run();
|
||||
}
|
||||
|
||||
+42
-15
@@ -13,7 +13,7 @@
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/variant/apply_visitor.hpp"
|
||||
#include "boost/variant/static_visitor.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/mpl/and.hpp"
|
||||
@@ -62,43 +62,59 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS // BOOST_NO_CXX11_RVALUE_REFERENCES is not enough for disabling buggy GCCs < 4.8
|
||||
struct rvalue_ref_visitor
|
||||
{
|
||||
typedef int result_type;
|
||||
int operator()(udt1&&) const { return 0; }
|
||||
int operator()(udt2&&) const { return 1; }
|
||||
};
|
||||
#endif
|
||||
#ifdef BOOST_VARIANT_HAS_DECLTYPE_APPLY_VISITOR_RETURN_TYPE
|
||||
struct rvalue_ref_decltype_visitor
|
||||
{
|
||||
int operator()(udt1&&) const { return 0; }
|
||||
int operator()(udt2&&) const { return 1; }
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename Checker, typename Variant>
|
||||
inline void unary_test(Variant& var, Checker* = 0)
|
||||
inline void unary_test(Variant& var, Checker* = nullptr)
|
||||
{
|
||||
Checker checker;
|
||||
const Checker& const_checker = checker;
|
||||
|
||||
// standard tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker, var) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker, var) );
|
||||
BOOST_CHECK( boost::apply_visitor(Checker(), var) );
|
||||
BOOST_TEST( boost::apply_visitor(checker, var) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker, var) );
|
||||
BOOST_TEST( boost::apply_visitor(Checker(), var) );
|
||||
|
||||
// delayed tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker)(var) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker)(var) );
|
||||
BOOST_TEST( boost::apply_visitor(checker)(var) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker)(var) );
|
||||
}
|
||||
|
||||
template <typename Checker, typename Variant1, typename Variant2>
|
||||
inline void binary_test(Variant1& var1, Variant2& var2, Checker* = 0)
|
||||
inline void binary_test(Variant1& var1, Variant2& var2, Checker* = nullptr)
|
||||
{
|
||||
Checker checker;
|
||||
const Checker& const_checker = checker;
|
||||
|
||||
// standard tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker, var1, var2) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker, var1, var2) );
|
||||
BOOST_CHECK( boost::apply_visitor(Checker(), var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(checker, var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker, var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(Checker(), var1, var2) );
|
||||
|
||||
// delayed tests
|
||||
|
||||
BOOST_CHECK( boost::apply_visitor(checker)(var1, var2) );
|
||||
BOOST_CHECK( boost::apply_visitor(const_checker)(var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(checker)(var1, var2) );
|
||||
BOOST_TEST( boost::apply_visitor(const_checker)(var1, var2) );
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
int main()
|
||||
{
|
||||
typedef boost::variant<udt1,udt2> var_t;
|
||||
udt1 u1;
|
||||
@@ -124,6 +140,17 @@ int test_main(int , char* [])
|
||||
unary_test< check2_t >(var2);
|
||||
unary_test< check2_const_t >(cvar2);
|
||||
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS // BOOST_NO_CXX11_RVALUE_REFERENCES is not enough for disabling buggy GCCs < 4.8
|
||||
BOOST_TEST_EQ( (boost::apply_visitor(
|
||||
rvalue_ref_visitor(),
|
||||
boost::variant<udt1, udt2>(udt2()))), 1 );
|
||||
#endif
|
||||
#ifdef BOOST_VARIANT_HAS_DECLTYPE_APPLY_VISITOR_RETURN_TYPE
|
||||
BOOST_TEST_EQ( (boost::apply_visitor(
|
||||
rvalue_ref_decltype_visitor(),
|
||||
boost::variant<udt1, udt2>(udt2()))), 1 );
|
||||
#endif
|
||||
|
||||
//
|
||||
// binary tests
|
||||
//
|
||||
@@ -139,5 +166,5 @@ int test_main(int , char* [])
|
||||
binary_test< check21_t >(var2,var1);
|
||||
binary_test< check21_const_t >(cvar2,cvar1);
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user