Compare commits

...

15 Commits

17 changed files with 568 additions and 91 deletions

View File

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

View File

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

View File

@ -55,6 +55,11 @@ jobs:
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: g++-12
- toolset: gcc-13
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:23.04
install: g++-13
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
@ -118,9 +123,26 @@ jobs:
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:23.04
install: clang-16
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-11
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-12
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-13
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
@ -136,11 +158,13 @@ jobs:
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python git g++
apt-get -y install sudo python3 git g++
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
@ -160,7 +184,7 @@ jobs:
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
@ -241,6 +265,8 @@ jobs:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
runs-on: ${{matrix.os}}
@ -287,6 +313,8 @@ jobs:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
runs-on: ${{matrix.os}}
@ -343,6 +371,8 @@ jobs:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
- os: macos-13
runs-on: ${{matrix.os}}
@ -388,3 +418,183 @@ jobs:
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
windows-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Use library with add_subdirectory (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use library with add_subdirectory (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- name: Install (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Debug
- name: Install (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Release
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use the installed library (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
- name: Build tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Debug
- name: Run tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Debug
- name: Build tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Release
- name: Run tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release

View File

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

View File

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

View File

@ -8,6 +8,10 @@ https://www.boost.org/LICENSE_1_0.txt
# Revision History
:idprefix: changelog_
## Changes in 1.83.0
* Added `uses_double_storage()`.
## Changes in 1.81.0
* Added support for `boost::json::value_from` and `boost::json::value_to`.

View File

@ -250,6 +250,8 @@ public:
constexpr bool valueless_by_exception() const noexcept;
constexpr size_t index() const noexcept;
static constexpr bool uses_double_storage() noexcept;
// swap
void swap( variant& r ) noexcept( /*see below*/ );
@ -570,6 +572,18 @@ constexpr size_t index() const noexcept;
Returns: ::
The zero-based index of the active alternative.
```
static constexpr bool uses_double_storage() noexcept;
```
[none]
* {blank}
+
Returns: ::
`true` if the variant uses double storage to meet the never valueless
guarantee because one of the alternatives is not nothrow move constructible,
and `false` otherwise.
#### Swap
```

View 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&lt;*&gt;" Inheritable="true">
<Intrinsic Name="index" Expression="$T2==1?((int)ix_-1):((int)((ix_-2)/2))"/>
<DisplayString Condition="index()==0&amp;&amp;$T2==1" Optional="true">{st_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==1&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==2&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==3&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==4&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==5&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==6&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==7&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==8&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==9&amp;&amp;$T2==1" Optional="true">{st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==0&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==1&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==2&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==3&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==4&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==5&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==6&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==7&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==8&amp;&amp;$T2==0" Optional="true">{st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()})</DisplayString>
<DisplayString Condition="index()==9&amp;&amp;$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>

View File

@ -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:
@ -2475,16 +2497,16 @@ template<class V> struct tag_invoke_L2
boost::json::value const& v;
typename boost::json::result_for<V, boost::json::value>::type& r;
template<class I> void operator()( I i ) const
template<class I> void operator()( I /*i*/ ) const
{
if( !r )
{
using Ti = mp11::mp_at_c<V, i>;
using Ti = mp11::mp_at_c<V, I::value>;
auto r2 = boost::json::try_value_to<Ti>( v );
if( r2 )
{
r.emplace( in_place_index_t<i>{}, std::move( *r2 ) );
r.emplace( in_place_index_t<I::value>{}, std::move( *r2 ) );
}
}
}

View File

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

View File

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

View File

@ -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) );
}

View File

@ -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 );
}
{

View File

@ -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) );
}

View 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() );

View File

@ -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 );
}
{

View File

@ -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 );
}
{