mirror of
https://github.com/boostorg/variant2.git
synced 2025-07-29 11:47:36 +02:00
Compare commits
12 Commits
boost-1.81
...
feature/us
Author | SHA1 | Date | |
---|---|---|---|
2c590716ab | |||
82b98fb757 | |||
30afb9e183 | |||
129e27ce09 | |||
26595285d3 | |||
95a8c5ffec | |||
ec2819a05e | |||
fcf9746a2d | |||
a74ebd34dc | |||
1b34c20685 | |||
604d3700ad | |||
4c5f254b9c |
236
.drone.jsonnet
236
.drone.jsonnet
@ -97,30 +97,30 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
|
||||
[
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.8*",
|
||||
"Linux 14.04 GCC 4.8* 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.9",
|
||||
"Linux 14.04 GCC 4.9 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' },
|
||||
"g++-4.9",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
"g++-4.9-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 5*",
|
||||
"Linux 16.04 GCC 5* 32/64",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 6",
|
||||
"Linux 18.04 GCC 6 32/64",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' },
|
||||
"g++-6",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14', ADDRMD: '32,64' },
|
||||
"g++-6-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
@ -130,22 +130,16 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 8",
|
||||
"Linux 18.04 GCC 8 32/64",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' },
|
||||
"g++-8",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
|
||||
"g++-8-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 32",
|
||||
"Linux 20.04 GCC 9* 32/64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
@ -163,68 +157,170 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 32 ASAN",
|
||||
"Linux 20.04 GCC 10 32/64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32,64' },
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 64 ASAN",
|
||||
"Linux 22.04 GCC 11* 32/64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 32 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 64 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan,
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 GCC 13 32/64",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' },
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.5",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' },
|
||||
"clang-3.5",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.6",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
|
||||
"clang-3.6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.7",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
|
||||
"clang-3.7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
|
||||
"clang-3.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 Clang 3.9",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '03,11,14' },
|
||||
"clang-3.9",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 Clang 4.0",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '03,11,14' },
|
||||
"clang-4.0",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 Clang 5.0",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '03,11,14,1z' },
|
||||
"clang-5.0",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 Clang 6.0",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-6.0', CXXSTD: '03,11,14,17' },
|
||||
"clang-6.0",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 7",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan,
|
||||
"g++-10-multilib",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '03,11,14,17' },
|
||||
"clang-7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 11* 32",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 11* 64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"g++-12",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 13",
|
||||
"Linux 20.04 Clang 8",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '03,11,14,17' },
|
||||
"clang-8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 9",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-9', CXXSTD: '03,11,14,17,2a' },
|
||||
"clang-9",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 10",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-10', CXXSTD: '03,11,14,17,2a' },
|
||||
"clang-10",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 11",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-11', CXXSTD: '03,11,14,17,2a' },
|
||||
"clang-11",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 12",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-12', CXXSTD: '03,11,14,17,2a' },
|
||||
"clang-12",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 13",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-13",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 14 UBSAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan,
|
||||
"Linux 22.04 Clang 14",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-14",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 14 ASAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan,
|
||||
"clang-14",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 15",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"Linux 22.04 Clang 15 UBSAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
"clang-15",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 15 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
"clang-15",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 Clang 16",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-16",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
@ -237,6 +333,18 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2015 msvc-14.0",
|
||||
"cppalliance/dronevs2015",
|
||||
|
@ -5,6 +5,7 @@
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
set -ex
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
DRONE_BUILD_DIR=$(pwd)
|
||||
|
||||
|
@ -19,6 +19,15 @@ target_link_libraries(boost_variant2
|
||||
Boost::mp11
|
||||
)
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
|
||||
file(GLOB_RECURSE boost_variant2_IDEFILES CONFIGURE_DEPENDS include/*.hpp)
|
||||
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_variant2_IDEFILES} PREFIX "Header Files")
|
||||
list(APPEND boost_variant2_IDEFILES extra/boost_variant2.natvis)
|
||||
target_sources(boost_variant2 PRIVATE ${boost_variant2_IDEFILES})
|
||||
|
||||
endif()
|
||||
|
||||
target_compile_features(boost_variant2 INTERFACE cxx_std_11)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
35
appveyor.yml
35
appveyor.yml
@ -30,14 +30,16 @@ environment:
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17,latest
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_SUBDIR: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CMAKE_INSTALL: 1
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
@ -57,4 +59,27 @@ test_script:
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- if not "%CXXFLAGS%" == "" set CXXFLAGS=cxxflags=%CXXFLAGS%
|
||||
- b2 -j3 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %CXXFLAGS% variant=debug,release embed-manifest-via=linker
|
||||
- if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j3 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %CXXFLAGS% variant=debug,release embed-manifest-via=linker
|
||||
|
||||
- if not "%CMAKE%" == "" mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE%" == "" cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=variant2 -DBoost_VERBOSE=ON ..
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Debug & ctest --output-on-failure --no-tests=error -j 3 -C Debug
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Release & ctest --output-on-failure --no-tests=error -j 3 -C Release
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config MinSizeRel & ctest --output-on-failure --no-tests=error -j 3 -C MinSizeRel
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config RelWithDebInfo & ctest --output-on-failure --no-tests=error -j 3 -C RelWithDebInfo
|
||||
|
||||
- if not "%CMAKE_SUBDIR%" == "" cd libs/variant2/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake ..
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config MinSizeRel && cmake --build . --target check --config MinSizeRel
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config RelWithDebInfo && cmake --build . --target check --config RelWithDebInfo
|
||||
|
||||
- if not "%CMAKE_INSTALL%" == "" mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake -DBOOST_INCLUDE_LIBRARIES=variant2 -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Debug
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Release
|
||||
- if not "%CMAKE_INSTALL%" == "" cd ../libs/variant2/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
|
||||
|
32
extra/boost_variant2.natvis
Normal file
32
extra/boost_variant2.natvis
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
|
||||
<Type Name="boost::variant2::detail::variant_ma_base_impl<*>" Inheritable="true">
|
||||
<Intrinsic Name="index" Expression="$T2==1?((int)ix_-1):((int)((ix_-2)/2))"/>
|
||||
<DisplayString Condition="index()==0&&$T2==1" Optional="true">{st_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==1&&$T2==1" Optional="true">{st_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==2&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==3&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==4&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==5&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==6&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==7&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==8&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==9&&$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==0&&$T2==0" Optional="true">{st_[ix_%2].rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==1&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==2&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==3&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==4&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==5&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==6&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==7&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==8&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<DisplayString Condition="index()==9&&$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[index]">index()</Item>
|
||||
<Item Name="ix_">ix_</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
</AutoVisualizer>
|
@ -920,6 +920,11 @@ template<class... T> struct variant_base_impl<true, true, T...>
|
||||
|
||||
this->emplace_impl<J, U>( std::is_nothrow_constructible<U, A&&...>(), std::forward<A>(a)... );
|
||||
}
|
||||
|
||||
static constexpr bool uses_double_storage() noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// trivially destructible, double buffered
|
||||
@ -978,6 +983,11 @@ template<class... T> struct variant_base_impl<true, false, T...>
|
||||
|
||||
ix_ = J * 2 + i2;
|
||||
}
|
||||
|
||||
static constexpr bool uses_double_storage() noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// not trivially destructible, single buffered
|
||||
@ -1068,6 +1078,11 @@ template<class... T> struct variant_base_impl<false, true, T...>
|
||||
st_.emplace( mp11::mp_size_t<J>(), std::move(tmp) );
|
||||
ix_ = J;
|
||||
}
|
||||
|
||||
static constexpr bool uses_double_storage() noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// not trivially destructible, double buffered
|
||||
@ -1193,6 +1208,11 @@ template<class... T> struct variant_base_impl<false, false, T...>
|
||||
|
||||
ix_ = J * 2 + i2;
|
||||
}
|
||||
|
||||
static constexpr bool uses_double_storage() noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@ -1703,6 +1723,8 @@ public:
|
||||
|
||||
using variant_base::index;
|
||||
|
||||
using variant_base::uses_double_storage;
|
||||
|
||||
// swap
|
||||
|
||||
private:
|
||||
|
@ -127,7 +127,9 @@ run variant_visit_by_index.cpp ;
|
||||
run variant_ostream_insert.cpp ;
|
||||
run is_output_streamable.cpp ;
|
||||
|
||||
local JSON = <library>/boost//json/<warnings>off "<toolset>msvc-14.0:<build>no" "<toolset>msvc-14.2:<cxxflags>-wd5104" ;
|
||||
local JSON = <library>/boost//json/<warnings>off "<toolset>msvc-14.0:<build>no" "<toolset>msvc-14.2:<cxxflags>-wd5104" "<undefined-sanitizer>norecover:<link>static" ;
|
||||
|
||||
run variant_json_value_from.cpp : : : $(JSON) ;
|
||||
run variant_json_value_to.cpp : : : $(JSON) ;
|
||||
|
||||
compile variant_uses_double_storage.cpp ;
|
||||
|
@ -58,7 +58,7 @@ int main()
|
||||
{
|
||||
constexpr variant<int, float> v( 3.14f );
|
||||
|
||||
STATIC_ASSERT( get<1>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<1>(v) == (float)3.14f ); // see FLT_EVAL_METHOD
|
||||
|
||||
STATIC_ASSERT_IF( get_if<0>(&v) == nullptr );
|
||||
STATIC_ASSERT_IF( get_if<1>(&v) == &get<1>(v) );
|
||||
@ -87,7 +87,7 @@ int main()
|
||||
{
|
||||
constexpr variant<int, int, float> v( 3.14f );
|
||||
|
||||
STATIC_ASSERT( get<2>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<2>(v) == (float)3.14f );
|
||||
|
||||
STATIC_ASSERT_IF( get_if<0>(&v) == nullptr );
|
||||
STATIC_ASSERT_IF( get_if<1>(&v) == nullptr );
|
||||
|
@ -58,7 +58,7 @@ int main()
|
||||
{
|
||||
constexpr variant<int, float> v( 3.14f );
|
||||
|
||||
STATIC_ASSERT( get<float>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<float>(v) == (float)3.14f ); // see FLT_EVAL_METHOD
|
||||
|
||||
STATIC_ASSERT_IF( get_if<int>(&v) == nullptr );
|
||||
STATIC_ASSERT_IF( get_if<float>(&v) == &get<float>(v) );
|
||||
@ -83,7 +83,7 @@ int main()
|
||||
{
|
||||
constexpr variant<int, int, float> v( 3.14f );
|
||||
|
||||
STATIC_ASSERT( get<float>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<float>(v) == (float)3.14f );
|
||||
|
||||
STATIC_ASSERT_IF( get_if<float>(&v) == &get<float>(v) );
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int main()
|
||||
constexpr variant<int, float> v( in_place_index_t<1>{}, 3.14f );
|
||||
|
||||
STATIC_ASSERT( v.index() == 1 );
|
||||
STATIC_ASSERT( get<1>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<1>(v) == (float)3.14f ); // see FLT_EVAL_METHOD
|
||||
}
|
||||
|
||||
{
|
||||
@ -89,14 +89,14 @@ int main()
|
||||
constexpr variant<int, int, float, float, X, X> v( in_place_index_t<2>{}, 3.14f );
|
||||
|
||||
STATIC_ASSERT( v.index() == 2 );
|
||||
STATIC_ASSERT( get<2>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<2>(v) == (float)3.14f );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr variant<int, int, float, float, X, X> v( in_place_index_t<3>{}, 3.14f );
|
||||
|
||||
STATIC_ASSERT( v.index() == 3 );
|
||||
STATIC_ASSERT( get<3>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<3>(v) == (float)3.14f );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ int main()
|
||||
constexpr variant<int, float> v( in_place_type_t<float>{}, 3.14f );
|
||||
|
||||
STATIC_ASSERT( v.index() == 1 );
|
||||
STATIC_ASSERT( get<1>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<1>(v) == (float)3.14f ); // see FLT_EVAL_METHOD
|
||||
|
||||
STATIC_ASSERT( holds_alternative<float>(v) );
|
||||
}
|
||||
@ -89,7 +89,7 @@ int main()
|
||||
constexpr variant<int, int, float, X> v( in_place_type_t<float>{}, 3.14f );
|
||||
|
||||
STATIC_ASSERT( v.index() == 2 );
|
||||
STATIC_ASSERT( get<2>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<2>(v) == (float)3.14f );
|
||||
|
||||
STATIC_ASSERT( holds_alternative<float>(v) );
|
||||
}
|
||||
|
50
test/variant_uses_double_storage.cpp
Normal file
50
test/variant_uses_double_storage.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace boost::variant2;
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
struct X1
|
||||
{
|
||||
};
|
||||
|
||||
STATIC_ASSERT( std::is_nothrow_move_constructible<X1>::value );
|
||||
STATIC_ASSERT( std::is_trivially_destructible<X1>::value );
|
||||
|
||||
struct X2
|
||||
{
|
||||
~X2() {}
|
||||
};
|
||||
|
||||
STATIC_ASSERT( std::is_nothrow_move_constructible<X2>::value );
|
||||
STATIC_ASSERT( !std::is_trivially_destructible<X2>::value );
|
||||
|
||||
struct X3
|
||||
{
|
||||
X3( X3&& ) {}
|
||||
};
|
||||
|
||||
STATIC_ASSERT( !std::is_nothrow_move_constructible<X3>::value );
|
||||
STATIC_ASSERT( std::is_trivially_destructible<X3>::value );
|
||||
|
||||
struct X4
|
||||
{
|
||||
~X4() {}
|
||||
X4( X4&& ) {}
|
||||
};
|
||||
|
||||
STATIC_ASSERT( !std::is_nothrow_move_constructible<X4>::value );
|
||||
STATIC_ASSERT( !std::is_trivially_destructible<X4>::value );
|
||||
|
||||
//
|
||||
|
||||
STATIC_ASSERT( !variant<int, float>::uses_double_storage() );
|
||||
STATIC_ASSERT( !variant<int, float, X1>::uses_double_storage() );
|
||||
STATIC_ASSERT( !variant<int, float, X2>::uses_double_storage() );
|
||||
STATIC_ASSERT( variant<int, float, X3>::uses_double_storage() );
|
||||
STATIC_ASSERT( variant<int, float, X4>::uses_double_storage() );
|
@ -82,7 +82,7 @@ int main()
|
||||
|
||||
STATIC_ASSERT( v.index() == 1 );
|
||||
STATIC_ASSERT( holds_alternative<float>(v) );
|
||||
STATIC_ASSERT( get<1>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<1>(v) == (float)3.14f ); // see FLT_EVAL_METHOD
|
||||
}
|
||||
|
||||
{
|
||||
@ -97,7 +97,7 @@ int main()
|
||||
|
||||
STATIC_ASSERT( v.index() == 2 );
|
||||
STATIC_ASSERT( holds_alternative<float>(v) );
|
||||
STATIC_ASSERT( get<2>(v) == 3.14f );
|
||||
STATIC_ASSERT( get<2>(v) == (float)3.14f );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -61,18 +61,18 @@ int main()
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float> const v( 3.14f );
|
||||
variant<int, float> const v( 3.125f );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F1(), v ), 3 );
|
||||
BOOST_TEST_EQ( visit<float>( F1(), v ), 3.14f );
|
||||
BOOST_TEST_EQ( visit<float>( F1(), v ), 3.125f );
|
||||
}
|
||||
|
||||
{
|
||||
variant<int, float> v1( 1 );
|
||||
variant<int, float> const v2( 3.14f );
|
||||
variant<int, float> const v2( 3.125f );
|
||||
|
||||
BOOST_TEST_EQ( visit<int>( F2(), v1, v2 ), 4 );
|
||||
BOOST_TEST_EQ( visit<float>( F2(), v1, v2 ), 1 + 3.14f );
|
||||
BOOST_TEST_EQ( visit<float>( F2(), v1, v2 ), 1 + 3.125f );
|
||||
}
|
||||
|
||||
{
|
||||
|
Reference in New Issue
Block a user