From 8ee7c5aad0226a5d808f88b96f02cbf1e54f81fc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Jul 2022 14:47:06 +0300 Subject: [PATCH 01/91] Update ci.yml --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81b1e9b..159b202 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,10 @@ jobs: cxxstd: "03,11,14,17,2a" os: ubuntu-20.04 install: g++-11 + - toolset: gcc-12 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: g++-12 - toolset: clang compiler: clang++-3.9 cxxstd: "03,11,14" @@ -97,6 +101,16 @@ jobs: cxxstd: "03,11,14,17,2a" os: ubuntu-20.04 install: clang-12 + - toolset: clang + compiler: clang++-13 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-13 + - toolset: clang + compiler: clang++-14 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-14 - toolset: clang cxxstd: "03,11,14,17,2a" os: macos-10.15 @@ -148,18 +162,18 @@ jobs: matrix: include: - toolset: msvc-14.0 - cxxstd: "14" + cxxstd: "14,latest" addrmd: 32,64 os: windows-2019 - - toolset: msvc-14.1 - cxxstd: "14,17,latest" - addrmd: 32,64 - os: windows-2016 - toolset: msvc-14.2 - cxxstd: "14,17,latest" + cxxstd: "14,17,20,latest" addrmd: 32,64 os: windows-2019 - toolset: msvc-14.3 + cxxstd: "14,17,20,latest" + addrmd: 32,64 + os: windows-2022 + - toolset: clang-win cxxstd: "14,17,latest" addrmd: 32,64 os: windows-2022 @@ -199,7 +213,7 @@ jobs: shell: cmd run: | cd ../boost-root - b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release + b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker posix-cmake-subdir: strategy: @@ -208,6 +222,7 @@ jobs: include: - os: ubuntu-18.04 - os: ubuntu-20.04 + - os: ubuntu-22.04 - os: macos-10.15 runs-on: ${{matrix.os}} @@ -254,6 +269,7 @@ jobs: include: - os: ubuntu-18.04 - os: ubuntu-20.04 + - os: ubuntu-22.04 - os: macos-10.15 runs-on: ${{matrix.os}} @@ -310,6 +326,7 @@ jobs: include: - os: ubuntu-18.04 - os: ubuntu-20.04 + - os: ubuntu-22.04 - os: macos-10.15 runs-on: ${{matrix.os}} From c633a953dea46a8f146b35f37986f660b07ac101 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 15 Aug 2022 19:26:35 +0300 Subject: [PATCH 02/91] Change macos-10.15 to macos-11 in ci.yml --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 159b202..1fa5d59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,7 +113,7 @@ jobs: install: clang-14 - toolset: clang cxxstd: "03,11,14,17,2a" - os: macos-10.15 + os: macos-11 runs-on: ${{matrix.os}} @@ -223,7 +223,7 @@ jobs: - os: ubuntu-18.04 - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-10.15 + - os: macos-11 runs-on: ${{matrix.os}} @@ -270,7 +270,7 @@ jobs: - os: ubuntu-18.04 - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-10.15 + - os: macos-11 runs-on: ${{matrix.os}} @@ -327,7 +327,7 @@ jobs: - os: ubuntu-18.04 - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-10.15 + - os: macos-11 runs-on: ${{matrix.os}} From 4c5f254b9c63ef401082d5757df2652b55e6cfed Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 18 Aug 2022 16:03:07 -0700 Subject: [PATCH 03/91] add boost_variant2.natvis and interface source files --- CMakeLists.txt | 7 +++++++ extra/boost_variant2.natvis | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 extra/boost_variant2.natvis diff --git a/CMakeLists.txt b/CMakeLists.txt index 3826577..ec44983 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,13 @@ target_link_libraries(boost_variant2 Boost::mp11 ) +file(GLOB_RECURSE boost_variant2_IDEFILES CONFIGURE_DEPENDS include/*.hpp) +source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_variant2_IDEFILES}) +if (CMAKE_GENERATOR MATCHES "Visual Studio") + list(APPEND boost_variant2_IDEFILES extra/boost_variant2.natvis) +endif() +target_sources(boost_variant2 PRIVATE ${boost_variant2_IDEFILES}) + target_compile_features(boost_variant2 INTERFACE cxx_std_11) if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") diff --git a/extra/boost_variant2.natvis b/extra/boost_variant2.natvis new file mode 100644 index 0000000..8f8cab4 --- /dev/null +++ b/extra/boost_variant2.natvis @@ -0,0 +1,32 @@ + + + + + + {st_.rest_.first_} ({index()}) + {st_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) + + index() + ix_ + + + + From 78a974429ac8ff631e956f3a08f401f4c9a09ce6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 14 Oct 2022 19:28:20 +0300 Subject: [PATCH 04/91] Update ci.yml --- .github/workflows/ci.yml | 59 +++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fa5d59..835681d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,22 +19,26 @@ jobs: include: - toolset: gcc-4.8 cxxstd: "03,11" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: g++-4.8 - toolset: gcc-5 cxxstd: "03,11,14,1z" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: g++-5 - toolset: gcc-6 cxxstd: "03,11,14,1z" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: g++-6 - toolset: gcc-7 cxxstd: "03,11,14,17" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 - toolset: gcc-8 cxxstd: "03,11,14,17,2a" - os: ubuntu-18.04 + os: ubuntu-20.04 install: g++-8 - toolset: gcc-9 cxxstd: "03,11,14,17,2a" @@ -54,27 +58,30 @@ jobs: - toolset: clang compiler: clang++-3.9 cxxstd: "03,11,14" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: clang-3.9 - toolset: clang compiler: clang++-4.0 cxxstd: "03,11,14" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: clang-4.0 - toolset: clang compiler: clang++-5.0 cxxstd: "03,11,14,1z" - os: ubuntu-18.04 + os: ubuntu-latest + container: ubuntu:18.04 install: clang-5.0 - toolset: clang compiler: clang++-6.0 cxxstd: "03,11,14,17" - os: ubuntu-18.04 + os: ubuntu-20.04 install: clang-6.0 - toolset: clang compiler: clang++-7 cxxstd: "03,11,14,17" - os: ubuntu-18.04 + os: ubuntu-20.04 install: clang-7 - toolset: clang compiler: clang++-8 @@ -116,13 +123,24 @@ jobs: os: macos-11 runs-on: ${{matrix.os}} + container: ${{matrix.container}} + + defaults: + run: + shell: bash steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - name: Setup container environment + if: matrix.container + run: | + apt-get update + apt-get -y install sudo python git g++ - name: Install packages if: matrix.install - run: sudo apt install ${{matrix.install}} + run: sudo apt-get -y install ${{matrix.install}} - name: Setup Boost run: | @@ -185,7 +203,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Boost shell: cmd @@ -220,7 +238,6 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-18.04 - os: ubuntu-20.04 - os: ubuntu-22.04 - os: macos-11 @@ -228,11 +245,11 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages if: matrix.install - run: sudo apt install ${{matrix.install}} + run: sudo apt-get -y install ${{matrix.install}} - name: Setup Boost run: | @@ -267,7 +284,6 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-18.04 - os: ubuntu-20.04 - os: ubuntu-22.04 - os: macos-11 @@ -275,11 +291,11 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages if: matrix.install - run: sudo apt install ${{matrix.install}} + run: sudo apt-get -y install ${{matrix.install}} - name: Setup Boost run: | @@ -324,7 +340,6 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-18.04 - os: ubuntu-20.04 - os: ubuntu-22.04 - os: macos-11 @@ -332,11 +347,11 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages if: matrix.install - run: sudo apt install ${{matrix.install}} + run: sudo apt-get -y install ${{matrix.install}} - name: Setup Boost run: | From 6fe1c69bc8663f66b1b60192d5796d92ee651aaa Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 02:16:59 +0300 Subject: [PATCH 05/91] Add Drone support --- .drone.jsonnet | 263 +++++++++++++++++++++++++++++++++++++++++++++++ .drone/drone.bat | 23 +++++ .drone/drone.sh | 24 +++++ 3 files changed, 310 insertions(+) create mode 100644 .drone.jsonnet create mode 100644 .drone/drone.bat create mode 100755 .drone/drone.sh diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..9442280 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,263 @@ +# Copyright 2022 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +local library = "variant2"; + +local triggers = +{ + branch: [ "master", "develop", "feature/*" ] +}; + +local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' }; +local asan = { ASAN: '1' }; + +local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") = +{ + name: name, + kind: "pipeline", + type: "docker", + trigger: triggers, + platform: + { + os: "linux", + arch: arch + }, + steps: + [ + { + name: "everything", + image: image, + environment: environment, + commands: + [ + 'set -e', + 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -', + ] + + (if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) + + (if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) + + [ + 'export LIBRARY=' + library, + './.drone/drone.sh', + ] + } + ] +}; + +local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") = +{ + name: name, + kind: "pipeline", + type: "exec", + trigger: triggers, + platform: { + "os": "darwin", + "arch": arch + }, + node: { + "os": osx_version + }, + steps: [ + { + name: "everything", + environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" }, + commands: + [ + 'export LIBRARY=' + library, + './.drone/drone.sh', + ] + } + ] +}; + +local windows_pipeline(name, image, environment, arch = "amd64") = +{ + name: name, + kind: "pipeline", + type: "docker", + trigger: triggers, + platform: + { + os: "windows", + arch: arch + }, + "steps": + [ + { + name: "everything", + image: image, + environment: environment, + commands: + [ + 'cmd /C .drone\\\\drone.bat ' + library, + ] + } + ] +}; + +[ + linux_pipeline( + "Linux 14.04 GCC 4.8*", + "cppalliance/droneubuntu1404:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11' }, + ), + + linux_pipeline( + "Linux 14.04 GCC 4.9", + "cppalliance/droneubuntu1404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' }, + "g++-4.9", + [ "ppa:ubuntu-toolchain-r/test" ], + ), + + linux_pipeline( + "Linux 16.04 GCC 5*", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' }, + ), + + linux_pipeline( + "Linux 18.04 GCC 6", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' }, + "g++-6", + ), + + linux_pipeline( + "Linux 18.04 GCC 7* 32/64", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' }, + ), + + linux_pipeline( + "Linux 18.04 GCC 8", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' }, + "g++-8", + ), + + linux_pipeline( + "Linux 20.04 GCC 9* 32", + "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' }, + ), + + linux_pipeline( + "Linux 20.04 GCC 9* ARM64", + "cppalliance/droneubuntu2004:multiarch", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' }, + arch="arm64", + ), + + linux_pipeline( + "Linux 20.04 GCC 9* S390x", + "cppalliance/droneubuntu2004:multiarch", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' }, + arch="s390x", + ), + + linux_pipeline( + "Linux 20.04 GCC 10 32 ASAN", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' } + asan, + "g++-10-multilib", + ), + + linux_pipeline( + "Linux 20.04 GCC 10 64 ASAN", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan, + "g++-10-multilib", + ), + + 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", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' }, + "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, + "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' }, + "clang-15", + ["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"], + ), + + macos_pipeline( + "MacOS 10.15 Xcode 12.2 UBSAN", + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan, + ), + + macos_pipeline( + "MacOS 10.15 Xcode 12.2 ASAN", + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan, + ), + + windows_pipeline( + "Windows VS2015 msvc-14.0", + "cppalliance/dronevs2015", + { TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' }, + ), + + windows_pipeline( + "Windows VS2017 msvc-14.1", + "cppalliance/dronevs2017", + { TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' }, + ), + + windows_pipeline( + "Windows VS2019 msvc-14.2", + "cppalliance/dronevs2019", + { TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' }, + ), + + windows_pipeline( + "Windows VS2022 msvc-14.3", + "cppalliance/dronevs2022:1", + { TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' }, + ), +] diff --git a/.drone/drone.bat b/.drone/drone.bat new file mode 100644 index 0000000..66aaf78 --- /dev/null +++ b/.drone/drone.bat @@ -0,0 +1,23 @@ +@REM Copyright 2022 Peter Dimov +@REM Distributed under the Boost Software License, Version 1.0. +@REM https://www.boost.org/LICENSE_1_0.txt + +@ECHO ON + +set LIBRARY=%1 +set DRONE_BUILD_DIR=%CD% + +set BOOST_BRANCH=develop +if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master +cd .. +git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root +cd boost-root +git submodule update --init tools/boostdep +xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\ +python tools/boostdep/depinst/depinst.py %LIBRARY% +cmd /c bootstrap +b2 -d0 headers + +if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% +if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD% +b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker diff --git a/.drone/drone.sh b/.drone/drone.sh new file mode 100755 index 0000000..7172f7f --- /dev/null +++ b/.drone/drone.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Copyright 2022 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +set -ex + +DRONE_BUILD_DIR=$(pwd) + +BOOST_BRANCH=develop +if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi + +cd .. +git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root +cd boost-root +git submodule update --init tools/boostdep +cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY +python tools/boostdep/depinst/depinst.py $LIBRARY +./bootstrap.sh +./b2 -d0 headers + +echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam +./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} From 4a5f3dc498f7e159a479f81319e8a27bcbed9d7e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 02:33:29 +0300 Subject: [PATCH 06/91] Add variant::emplace tests to fish out -Wmaybe-uninitialized warnings --- test/variant_emplace_index.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/variant_emplace_index.cpp b/test/variant_emplace_index.cpp index 340cbcb..6aececa 100644 --- a/test/variant_emplace_index.cpp +++ b/test/variant_emplace_index.cpp @@ -288,5 +288,39 @@ int main() BOOST_TEST_EQ( Z1::instances, 0 ); BOOST_TEST_EQ( Z2::instances, 0 ); + { + variant v; + BOOST_TEST_EQ( v.index(), 0 ); + + v.emplace<0>(); + BOOST_TEST_EQ( v.index(), 0 ); + + v.emplace<1>(); + BOOST_TEST_EQ( v.index(), 1 ); + + v.emplace<1>(); + BOOST_TEST_EQ( v.index(), 1 ); + + v.emplace<0>(); + BOOST_TEST_EQ( v.index(), 0 ); + } + + { + variant v; + BOOST_TEST_EQ( v.index(), 0 ); + + v.emplace<0>(); + BOOST_TEST_EQ( v.index(), 0 ); + + v.emplace<1>(); + BOOST_TEST_EQ( v.index(), 1 ); + + v.emplace<1>(); + BOOST_TEST_EQ( v.index(), 1 ); + + v.emplace<0>(); + BOOST_TEST_EQ( v.index(), 0 ); + } + return boost::report_errors(); } From 457147d1b02c89f9f9f2a49928190d3f09a41ad0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 03:20:36 +0300 Subject: [PATCH 07/91] Suppress -Wmaybe-uninitialized in emplace_impl --- include/boost/variant2/variant.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 0f14659..e2bbc3a 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -685,7 +685,17 @@ template union variant_storage_impl BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_true, mp11::mp_size_t, A&&... a ) { +#if defined(BOOST_GCC) && (__GNUC__ >= 7) +# pragma GCC diagnostic push +// False positive in at least GCC 7 and GCC 10 ASAN triggered by monostate (via result) +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + *this = variant_storage_impl( mp11::mp_size_t(), std::forward(a)... ); + +#if defined(BOOST_GCC) && (__GNUC__ >= 7) +# pragma GCC diagnostic pop +#endif } template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t, A&&... a ) From 67a12199e65e37efcd96b69ab403eee58b559218 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 06:08:18 +0300 Subject: [PATCH 08/91] Add JSON support (refs #28) --- include/boost/variant2/variant.hpp | 89 +++++++++++++++++++++++++++++- test/Jamfile | 5 ++ test/variant_json_value_from.cpp | 41 ++++++++++++++ test/variant_json_value_to.cpp | 42 ++++++++++++++ 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 test/variant_json_value_from.cpp create mode 100644 test/variant_json_value_to.cpp diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index e2bbc3a..b474643 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -15,8 +15,9 @@ #include #include +#include #include -#include +#include #include #include #include @@ -24,8 +25,9 @@ #include #include #include // std::hash -#include #include +#include +#include // @@ -2402,6 +2404,89 @@ template<> struct hash< ::boost::variant2::monostate > } // namespace std +// JSON support + +namespace boost +{ +namespace json +{ + +class value; + +struct value_from_tag; + +template +void value_from( T&& t, value& jv ); + +template +struct value_to_tag; + +template +T value_to( value const & v ); + +template +struct try_value_to_tag; + +template +struct result_for; + +template +typename result_for::type +try_value_to( value const & jv ); + +template +typename result_for::type +result_from_errno( int e, boost::source_location const* loc ) noexcept; + +template struct is_null_like; + +template<> struct is_null_like< variant2::monostate, void >: std::true_type +{ +}; + +} // namespace json + +namespace variant2 +{ + +template + void tag_invoke( boost::json::value_from_tag const&, boost::json::value& v, variant const & w ) +{ + visit( [&](auto const& t){ + + boost::json::value_from( t, v ); + + }, w ); +} + +template + typename boost::json::result_for, boost::json::value>::type + tag_invoke( boost::json::try_value_to_tag> const&, boost::json::value const& v ) +{ + static constexpr boost::source_location loc = BOOST_CURRENT_LOCATION; + auto r = boost::json::result_from_errno< variant >( EINVAL, &loc ); + + mp11::mp_for_each>( [&](auto I){ + + if( !r ) + { + using Ti = mp11::mp_at_c, I>; + auto r2 = boost::json::try_value_to( v ); + + if( r2 ) + { + r.emplace( in_place_index, *r2 ); + } + } + + }); + + return r; +} + +} // namespace variant2 +} // namespace boost + #undef BOOST_VARIANT2_CX14_ASSERT #if defined(_MSC_VER) && _MSC_VER < 1910 diff --git a/test/Jamfile b/test/Jamfile index 2fbb975..3c67277 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -126,3 +126,8 @@ run variant_visit_by_index.cpp ; run variant_ostream_insert.cpp ; run is_output_streamable.cpp ; + +local JSON = /boost//json/off "msvc-14.0:no" "msvc-14.2:-wd5104" ; + +run variant_json_value_from.cpp : : : $(JSON) ; +run variant_json_value_to.cpp : : : $(JSON) ; diff --git a/test/variant_json_value_from.cpp b/test/variant_json_value_from.cpp new file mode 100644 index 0000000..9734c74 --- /dev/null +++ b/test/variant_json_value_from.cpp @@ -0,0 +1,41 @@ +// Copyright 2022 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include + +using namespace boost::variant2; +namespace json = boost::json; + +int main() +{ + { + monostate m; + json::value w = json::value_from( m ); + BOOST_TEST_EQ( w, json::value( nullptr ) ); + } + + { + variant v; + json::value w = json::value_from( v ); + BOOST_TEST_EQ( w, json::value( nullptr ) ); + } + + { + variant v( 17 ); + json::value w = json::value_from( v ); + BOOST_TEST_EQ( w, json::value( 17 ) ); + } + + { + variant v( "test" ); + json::value w = json::value_from( v ); + BOOST_TEST_EQ( w, json::value( "test" ) ); + } + + return boost::report_errors(); +} diff --git a/test/variant_json_value_to.cpp b/test/variant_json_value_to.cpp new file mode 100644 index 0000000..1263931 --- /dev/null +++ b/test/variant_json_value_to.cpp @@ -0,0 +1,42 @@ +// Copyright 2022 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include + +using namespace boost::variant2; +namespace json = boost::json; + +int main() +{ + { + json::value v; + auto r = json::try_value_to( v ); + BOOST_TEST( r.has_value() ); + } + + using V = variant; + + { + json::value v; + auto r = json::try_value_to( v ); + BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, V() ); + } + + { + json::value v( 12 ); + auto r = json::try_value_to( v ); + BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, V(12) ); + } + + { + json::value v( "test" ); + auto r = json::try_value_to( v ); + BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, V("test") ); + } + + return boost::report_errors(); +} From 1f8c4a19003dabeb3beaaa4a84740dd26412e8f9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 06:29:57 +0300 Subject: [PATCH 09/91] Replace polymorphic lambdas with function objects for C++11 --- include/boost/variant2/variant.hpp | 49 ++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index b474643..2c7b7bb 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2449,37 +2449,60 @@ template<> struct is_null_like< variant2::monostate, void >: std::true_type namespace variant2 { -template - void tag_invoke( boost::json::value_from_tag const&, boost::json::value& v, variant const & w ) +namespace detail +{ + +struct tag_invoke_L1 { - visit( [&](auto const& t){ + boost::json::value& v; + template void operator()( T const& t ) const + { boost::json::value_from( t, v ); + } +}; - }, w ); -} +} // namespace detail template - typename boost::json::result_for, boost::json::value>::type - tag_invoke( boost::json::try_value_to_tag> const&, boost::json::value const& v ) + void tag_invoke( boost::json::value_from_tag const&, boost::json::value& v, variant const & w ) { - static constexpr boost::source_location loc = BOOST_CURRENT_LOCATION; - auto r = boost::json::result_from_errno< variant >( EINVAL, &loc ); + visit( detail::tag_invoke_L1{ v }, w ); +} - mp11::mp_for_each>( [&](auto I){ +namespace detail +{ + +template struct tag_invoke_L2 +{ + boost::json::value const& v; + typename boost::json::result_for::type& r; + template void operator()( I i ) const + { if( !r ) { - using Ti = mp11::mp_at_c, I>; + using Ti = mp11::mp_at_c; auto r2 = boost::json::try_value_to( v ); if( r2 ) { - r.emplace( in_place_index, *r2 ); + r.emplace( in_place_index_t{}, *r2 ); } } + } +}; - }); +} // namespace detail + +template + typename boost::json::result_for, boost::json::value>::type + tag_invoke( boost::json::try_value_to_tag> const&, boost::json::value const& v ) +{ + static constexpr boost::source_location loc = BOOST_CURRENT_LOCATION; + auto r = boost::json::result_from_errno< variant >( EINVAL, &loc ); + + mp11::mp_for_each>( detail::tag_invoke_L2< variant >{ v, r } ); return r; } From aad1f86faed0dc179daf00340f97233750b68269 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 16:00:14 +0300 Subject: [PATCH 10/91] Reflect the change in is_null_like --- include/boost/variant2/variant.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 2c7b7bb..72c0083 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2438,11 +2438,9 @@ template typename result_for::type result_from_errno( int e, boost::source_location const* loc ) noexcept; -template struct is_null_like; +template struct is_null_like; -template<> struct is_null_like< variant2::monostate, void >: std::true_type -{ -}; +template<> struct is_null_like: std::true_type {}; } // namespace json From 423d350ff1685c992e56c2702b4806a27e9c597f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 16:01:31 +0300 Subject: [PATCH 11/91] Remove unneeded forward declarations --- include/boost/variant2/variant.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 72c0083..8365724 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2418,12 +2418,6 @@ struct value_from_tag; template void value_from( T&& t, value& jv ); -template -struct value_to_tag; - -template -T value_to( value const & v ); - template struct try_value_to_tag; From 32862d6db73871ce253abe7d7e3f30d334407ca4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 16:02:33 +0300 Subject: [PATCH 12/91] Add missing std::move --- include/boost/variant2/variant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 8365724..91920de 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2479,7 +2479,7 @@ template struct tag_invoke_L2 if( r2 ) { - r.emplace( in_place_index_t{}, *r2 ); + r.emplace( in_place_index_t{}, std::move( *r2 ) ); } } } From a948b85c74c445f82eb8a63458b631892929c539 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 18 Oct 2022 17:38:59 +0300 Subject: [PATCH 13/91] Update revision history --- doc/variant2/changelog.adoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc index 18d4b4a..dd903ee 100644 --- a/doc/variant2/changelog.adoc +++ b/doc/variant2/changelog.adoc @@ -1,5 +1,5 @@ //// -Copyright 2019-2021 Peter Dimov +Copyright 2019-2022 Peter Dimov Distributed under the Boost Software License, Version 1.0. https://www.boost.org/LICENSE_1_0.txt //// @@ -8,6 +8,10 @@ https://www.boost.org/LICENSE_1_0.txt # Revision History :idprefix: changelog_ +## Changes in 1.81.0 + +* Added support for `boost::json::value_from` and `boost::json::value_to`. + ## Changes in 1.79.0 * Added `operator<<` for `monostate`. From bcb879622569fe965312b33259beb411a29c8f57 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 24 Oct 2022 15:27:05 +0300 Subject: [PATCH 14/91] Add /permissive- jobs to Drone and Appveyor --- .drone.jsonnet | 12 ++++++++++++ .drone/drone.bat | 3 ++- appveyor.yml | 8 +++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 9442280..96ad270 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -249,12 +249,24 @@ local windows_pipeline(name, image, environment, arch = "amd64") = { TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' }, ), + windows_pipeline( + "Windows VS2017 msvc-14.1 Strict", + "cppalliance/dronevs2017", + { TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest', CXXFLAGS: '/permissive-' }, + ), + windows_pipeline( "Windows VS2019 msvc-14.2", "cppalliance/dronevs2019", { TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' }, ), + windows_pipeline( + "Windows VS2019 msvc-14.2 Strict", + "cppalliance/dronevs2019", + { TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest', CXXFLAGS: '/permissive-' }, + ), + windows_pipeline( "Windows VS2022 msvc-14.3", "cppalliance/dronevs2022:1", diff --git a/.drone/drone.bat b/.drone/drone.bat index 66aaf78..4509c7f 100644 --- a/.drone/drone.bat +++ b/.drone/drone.bat @@ -20,4 +20,5 @@ b2 -d0 headers if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD% -b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker +if not "%CXXFLAGS%" == "" set CXXFLAGS=cxxflags=%CXXFLAGS% +b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %CXXFLAGS% variant=debug,release embed-manifest-via=linker diff --git a/appveyor.yml b/appveyor.yml index baa4199..ecba9be 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,6 +21,11 @@ environment: TOOLSET: msvc-14.1 ADDRMD: 32,64 CXXSTD: 14,17,latest + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + TOOLSET: msvc-14.1 + ADDRMD: 32,64 + CXXSTD: 14,17,latest + CXXFLAGS: /permissive- - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 TOOLSET: clang-win ADDRMD: 64 @@ -51,4 +56,5 @@ build: off test_script: - if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% - if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD% - - b2 -j3 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker + - if not "%CXXFLAGS%" == "" set CXXFLAGS=cxxflags=%CXXFLAGS% + - b2 -j3 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %CXXFLAGS% variant=debug,release embed-manifest-via=linker From 376925a2099dab0221325c6001d970ddb18c9b8e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 24 Oct 2022 15:47:09 +0300 Subject: [PATCH 15/91] Work around msvc-14.1 /permissive- failure --- include/boost/variant2/variant.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 91920de..7451eda 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2448,6 +2448,11 @@ struct tag_invoke_L1 { boost::json::value& v; +#if defined(BOOST_MSVC) && BOOST_MSVC / 10 == 191 + // msvc-14.1 with /permissive- needs this + explicit tag_invoke_L1( boost::json::value& v_ ): v( v_ ) {} +#endif + template void operator()( T const& t ) const { boost::json::value_from( t, v ); From 4d1fd43d72b6738c24e2d5f9e7438839c4bfd134 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Oct 2022 21:25:57 +0300 Subject: [PATCH 16/91] Update supported compilers in documentation and README --- README.md | 2 +- doc/variant2/implementation.adoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d49356b..03a75f1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Supported compilers: * g++ 4.8 or later with `-std=c++11` or above * clang++ 3.9 or later with `-std=c++11` or above -* Visual Studio 2015, 2017, 2019 +* Visual Studio 2015 or later Tested on [Github Actions](https://github.com/boostorg/variant2/actions) and [Appveyor](https://ci.appveyor.com/project/pdimov/variant2-fkab9). diff --git a/doc/variant2/implementation.adoc b/doc/variant2/implementation.adoc index 0ccecfa..cbd6740 100644 --- a/doc/variant2/implementation.adoc +++ b/doc/variant2/implementation.adoc @@ -16,7 +16,7 @@ This implementation only depends on Boost.Config, Boost.Assert, and Boost.Mp11. * GCC 4.8 or later with `-std=c++11` or above * Clang 3.9 or later with `-std=c++11` or above -* Visual Studio 2015, 2017, 2019 +* Visual Studio 2015 or later Tested on https://github.com/boostorg/variant2/actions[Github Actions] and https://ci.appveyor.com/project/pdimov/variant2-fkab9[Appveyor]. From 604d3700ad6292476d3fbfb7ffce65466c26d1e3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Jan 2023 10:49:41 +0200 Subject: [PATCH 17/91] Add CMake tests to Appveyor --- appveyor.yml | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ecba9be..e4e3c00 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,6 +38,16 @@ environment: 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: 1 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + CMAKE: 1 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + CMAKE_SUBDIR: 1 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + CMAKE_INSTALL: 1 install: - set BOOST_BRANCH=develop @@ -57,4 +67,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 .. + - if not "%CMAKE%" == "" cmake --build . --target tests --config Debug & ctest --output-on-failure --no-tests=error -C Debug + - if not "%CMAKE%" == "" cmake --build . --target tests --config Release & ctest --output-on-failure --no-tests=error -C Release + - if not "%CMAKE%" == "" cmake --build . --target tests --config MinSizeRel & ctest --output-on-failure --no-tests=error -C MinSizeRel + - if not "%CMAKE%" == "" cmake --build . --target tests --config RelWithDebInfo & ctest --output-on-failure --no-tests=error -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 From 1b34c206854a3960c70bea1d664ecc75c0ccea41 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Jan 2023 18:38:10 +0200 Subject: [PATCH 18/91] Update appveyor.yml --- appveyor.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e4e3c00..15f59ca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,10 +41,6 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 CMAKE: 1 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - CMAKE: 1 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - CMAKE: 1 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 CMAKE_SUBDIR: 1 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 CMAKE_INSTALL: 1 @@ -70,7 +66,7 @@ test_script: - 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 .. + - if not "%CMAKE%" == "" cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=variant2 -DBoost_VERBOSE=ON .. - if not "%CMAKE%" == "" cmake --build . --target tests --config Debug & ctest --output-on-failure --no-tests=error -C Debug - if not "%CMAKE%" == "" cmake --build . --target tests --config Release & ctest --output-on-failure --no-tests=error -C Release - if not "%CMAKE%" == "" cmake --build . --target tests --config MinSizeRel & ctest --output-on-failure --no-tests=error -C MinSizeRel From a74ebd34dc44f864c675aeb45f45ef61eae4f7b1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Jan 2023 20:56:02 +0200 Subject: [PATCH 19/91] Update appveyor.yml --- appveyor.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 15f59ca..5e26b78 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,10 +30,6 @@ 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 @@ -67,10 +63,10 @@ test_script: - 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 --config Debug & ctest --output-on-failure --no-tests=error -C Debug - - if not "%CMAKE%" == "" cmake --build . --target tests --config Release & ctest --output-on-failure --no-tests=error -C Release - - if not "%CMAKE%" == "" cmake --build . --target tests --config MinSizeRel & ctest --output-on-failure --no-tests=error -C MinSizeRel - - if not "%CMAKE%" == "" cmake --build . --target tests --config RelWithDebInfo & ctest --output-on-failure --no-tests=error -C RelWithDebInfo + - 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 .. From ec2819a05eda433a31c85dbf9ea29494c21d97d6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 13 Jan 2023 00:56:45 +0200 Subject: [PATCH 20/91] Update CMakeLists.txt --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec44983..def59e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,12 +19,14 @@ target_link_libraries(boost_variant2 Boost::mp11 ) -file(GLOB_RECURSE boost_variant2_IDEFILES CONFIGURE_DEPENDS include/*.hpp) -source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_variant2_IDEFILES}) -if (CMAKE_GENERATOR MATCHES "Visual Studio") - list(APPEND boost_variant2_IDEFILES extra/boost_variant2.natvis) +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_sources(boost_variant2 PRIVATE ${boost_variant2_IDEFILES}) target_compile_features(boost_variant2 INTERFACE cxx_std_11) From 95a8c5ffec407533893fa39900bc7799c20c755e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 23 Jan 2023 03:53:25 +0200 Subject: [PATCH 21/91] Update .drone.jsonnet --- .drone.jsonnet | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 96ad270..92e5522 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -196,35 +196,32 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 20.04 Clang 13", - "cppalliance/droneubuntu2004:1", + "Linux 22.04 Clang 13", + "cppalliance/droneubuntu2204:1", { TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' }, "clang-13", - ["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"], ), linux_pipeline( - "Linux 20.04 Clang 14 UBSAN", - "cppalliance/droneubuntu2004:1", + "Linux 22.04 Clang 14 UBSAN", + "cppalliance/droneubuntu2204:1", { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan, "clang-14", - ["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"], ), linux_pipeline( - "Linux 20.04 Clang 14 ASAN", - "cppalliance/droneubuntu2004:1", + "Linux 22.04 Clang 14 ASAN", + "cppalliance/droneubuntu2204: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", + "Linux 22.04 Clang 15", + "cppalliance/droneubuntu2204:1", { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' }, "clang-15", - ["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"], + ["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"], ), macos_pipeline( From 26595285d36be6b506e8888283c2b0da30778d70 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 28 Jun 2023 22:10:43 +0300 Subject: [PATCH 22/91] Add variant<>::uses_double_storage(). Refs #37. --- include/boost/variant2/variant.hpp | 22 ++++++++++++ test/Jamfile | 2 ++ test/variant_uses_double_storage.cpp | 50 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 test/variant_uses_double_storage.cpp diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 7451eda..f0e8fef 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -920,6 +920,11 @@ template struct variant_base_impl this->emplace_impl( std::is_nothrow_constructible(), std::forward(a)... ); } + + static constexpr bool uses_double_storage() noexcept + { + return false; + } }; // trivially destructible, double buffered @@ -978,6 +983,11 @@ template struct variant_base_impl ix_ = J * 2 + i2; } + + static constexpr bool uses_double_storage() noexcept + { + return true; + } }; // not trivially destructible, single buffered @@ -1068,6 +1078,11 @@ template struct variant_base_impl st_.emplace( mp11::mp_size_t(), std::move(tmp) ); ix_ = J; } + + static constexpr bool uses_double_storage() noexcept + { + return false; + } }; // not trivially destructible, double buffered @@ -1193,6 +1208,11 @@ template struct variant_base_impl ix_ = J * 2 + i2; } + + static constexpr bool uses_double_storage() noexcept + { + return true; + } }; } // namespace detail @@ -1703,6 +1723,8 @@ template class variant: private detail::variant_ma_base using variant_base::index; + using variant_base::uses_double_storage; + // swap private: diff --git a/test/Jamfile b/test/Jamfile index 3c67277..f843257 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -131,3 +131,5 @@ local JSON = /boost//json/off "msvc-14.0:no" run variant_json_value_from.cpp : : : $(JSON) ; run variant_json_value_to.cpp : : : $(JSON) ; + +compile variant_uses_double_storage.cpp ; diff --git a/test/variant_uses_double_storage.cpp b/test/variant_uses_double_storage.cpp new file mode 100644 index 0000000..d78efc6 --- /dev/null +++ b/test/variant_uses_double_storage.cpp @@ -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 +#include + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X1 +{ +}; + +STATIC_ASSERT( std::is_nothrow_move_constructible::value ); +STATIC_ASSERT( std::is_trivially_destructible::value ); + +struct X2 +{ + ~X2() {} +}; + +STATIC_ASSERT( std::is_nothrow_move_constructible::value ); +STATIC_ASSERT( !std::is_trivially_destructible::value ); + +struct X3 +{ + X3( X3&& ) {} +}; + +STATIC_ASSERT( !std::is_nothrow_move_constructible::value ); +STATIC_ASSERT( std::is_trivially_destructible::value ); + +struct X4 +{ + ~X4() {} + X4( X4&& ) {} +}; + +STATIC_ASSERT( !std::is_nothrow_move_constructible::value ); +STATIC_ASSERT( !std::is_trivially_destructible::value ); + +// + +STATIC_ASSERT( !variant::uses_double_storage() ); +STATIC_ASSERT( !variant::uses_double_storage() ); +STATIC_ASSERT( !variant::uses_double_storage() ); +STATIC_ASSERT( variant::uses_double_storage() ); +STATIC_ASSERT( variant::uses_double_storage() ); From 129e27ce0915f0e0b45f653fb855f9c65987bc77 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 29 Jun 2023 01:49:21 +0300 Subject: [PATCH 23/91] Update Drone files --- .drone.jsonnet | 199 +++++++++++++++++++++++++++++++++++++----------- .drone/drone.sh | 1 + 2 files changed, 156 insertions(+), 44 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 92e5522..fe3d8e3 100644 --- a/.drone.jsonnet +++ b/.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,65 +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", - "cppalliance/droneubuntu2004:1", - { TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan, - "g++-10-multilib", + "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 11* 32", + "Linux 22.04 GCC 12 32 ASAN", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' }, + { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan, + "g++-12-multilib", ), linux_pipeline( - "Linux 22.04 GCC 11* 64", + "Linux 22.04 GCC 12 64 ASAN", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan, + "g++-12-multilib", ), 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 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: 'clang', COMPILER: 'clang++-7', CXXSTD: '03,11,14,17' }, + "clang-7", + ), + + linux_pipeline( + "Linux 20.04 Clang 8", + "cppalliance/droneubuntu2004:1", + { 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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20,2b' }, "clang-13", ), linux_pipeline( - "Linux 22.04 Clang 14 UBSAN", + "Linux 22.04 Clang 14", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' }, "clang-14", ), linux_pipeline( - "Linux 22.04 Clang 14 ASAN", + "Linux 22.04 Clang 15 UBSAN", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan, - "clang-14", + { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + "clang-15", ), linux_pipeline( - "Linux 22.04 Clang 15", + "Linux 22.04 Clang 15 ASAN", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' }, + { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' } + asan, "clang-15", - ["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"], + ), + + 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( @@ -234,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", diff --git a/.drone/drone.sh b/.drone/drone.sh index 7172f7f..2f2125d 100755 --- a/.drone/drone.sh +++ b/.drone/drone.sh @@ -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) From 30afb9e18356d640fb4018fd538cdb4e3d29ef21 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 29 Jun 2023 09:36:36 +0300 Subject: [PATCH 24/91] Update test/Jamfile to fix Drone issues --- test/Jamfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile b/test/Jamfile index f843257..85788b9 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -127,7 +127,7 @@ run variant_visit_by_index.cpp ; run variant_ostream_insert.cpp ; run is_output_streamable.cpp ; -local JSON = /boost//json/off "msvc-14.0:no" "msvc-14.2:-wd5104" ; +local JSON = /boost//json/off "msvc-14.0:no" "msvc-14.2:-wd5104" "norecover:static" ; run variant_json_value_from.cpp : : : $(JSON) ; run variant_json_value_to.cpp : : : $(JSON) ; From 82b98fb757629eb2414f23c6d2535dc27985e33e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 29 Jun 2023 10:46:54 +0300 Subject: [PATCH 25/91] Cast 3.14f to float because FLT_EVAL_METHOD (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108742) for discussion --- test/variant_get_by_index_cx.cpp | 4 ++-- test/variant_get_by_type_cx.cpp | 4 ++-- test/variant_in_place_index_construct_cx.cpp | 6 +++--- test/variant_in_place_type_construct_cx.cpp | 4 ++-- test/variant_value_construct_cx.cpp | 4 ++-- test/variant_visit_r.cpp | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/variant_get_by_index_cx.cpp b/test/variant_get_by_index_cx.cpp index 026b9d3..949e39c 100644 --- a/test/variant_get_by_index_cx.cpp +++ b/test/variant_get_by_index_cx.cpp @@ -58,7 +58,7 @@ int main() { constexpr variant 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 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 ); diff --git a/test/variant_get_by_type_cx.cpp b/test/variant_get_by_type_cx.cpp index 0f9a40c..d2777c8 100644 --- a/test/variant_get_by_type_cx.cpp +++ b/test/variant_get_by_type_cx.cpp @@ -58,7 +58,7 @@ int main() { constexpr variant v( 3.14f ); - STATIC_ASSERT( get(v) == 3.14f ); + STATIC_ASSERT( get(v) == (float)3.14f ); // see FLT_EVAL_METHOD STATIC_ASSERT_IF( get_if(&v) == nullptr ); STATIC_ASSERT_IF( get_if(&v) == &get(v) ); @@ -83,7 +83,7 @@ int main() { constexpr variant v( 3.14f ); - STATIC_ASSERT( get(v) == 3.14f ); + STATIC_ASSERT( get(v) == (float)3.14f ); STATIC_ASSERT_IF( get_if(&v) == &get(v) ); } diff --git a/test/variant_in_place_index_construct_cx.cpp b/test/variant_in_place_index_construct_cx.cpp index ea4b3ab..c8d85fe 100644 --- a/test/variant_in_place_index_construct_cx.cpp +++ b/test/variant_in_place_index_construct_cx.cpp @@ -68,7 +68,7 @@ int main() constexpr variant 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 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 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 ); } { diff --git a/test/variant_in_place_type_construct_cx.cpp b/test/variant_in_place_type_construct_cx.cpp index 832de3d..a9a8e4e 100644 --- a/test/variant_in_place_type_construct_cx.cpp +++ b/test/variant_in_place_type_construct_cx.cpp @@ -80,7 +80,7 @@ int main() constexpr variant v( in_place_type_t{}, 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(v) ); } @@ -89,7 +89,7 @@ int main() constexpr variant v( in_place_type_t{}, 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(v) ); } diff --git a/test/variant_value_construct_cx.cpp b/test/variant_value_construct_cx.cpp index 5ffad25..e055569 100644 --- a/test/variant_value_construct_cx.cpp +++ b/test/variant_value_construct_cx.cpp @@ -82,7 +82,7 @@ int main() STATIC_ASSERT( v.index() == 1 ); STATIC_ASSERT( holds_alternative(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(v) ); - STATIC_ASSERT( get<2>(v) == 3.14f ); + STATIC_ASSERT( get<2>(v) == (float)3.14f ); } { diff --git a/test/variant_visit_r.cpp b/test/variant_visit_r.cpp index 15ab60a..7b69e09 100644 --- a/test/variant_visit_r.cpp +++ b/test/variant_visit_r.cpp @@ -72,7 +72,7 @@ int main() variant const v2( 3.14f ); BOOST_TEST_EQ( visit( F2(), v1, v2 ), 4 ); - BOOST_TEST_EQ( visit( F2(), v1, v2 ), 1 + 3.14f ); + BOOST_TEST_EQ( visit( F2(), v1, v2 ), static_cast( 1 + 3.14f ) ); // see FLT_EVAL_METHOD } { From 2c590716ab222ab373a05143a7dab5740139b4f8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 29 Jun 2023 12:05:55 +0300 Subject: [PATCH 26/91] Use the exact 3.125f in variant_visit_r.cpp --- test/variant_visit_r.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/variant_visit_r.cpp b/test/variant_visit_r.cpp index 7b69e09..5dd01fc 100644 --- a/test/variant_visit_r.cpp +++ b/test/variant_visit_r.cpp @@ -61,18 +61,18 @@ int main() } { - variant const v( 3.14f ); + variant const v( 3.125f ); BOOST_TEST_EQ( visit( F1(), v ), 3 ); - BOOST_TEST_EQ( visit( F1(), v ), 3.14f ); + BOOST_TEST_EQ( visit( F1(), v ), 3.125f ); } { variant v1( 1 ); - variant const v2( 3.14f ); + variant const v2( 3.125f ); BOOST_TEST_EQ( visit( F2(), v1, v2 ), 4 ); - BOOST_TEST_EQ( visit( F2(), v1, v2 ), static_cast( 1 + 3.14f ) ); // see FLT_EVAL_METHOD + BOOST_TEST_EQ( visit( F2(), v1, v2 ), 1 + 3.125f ); } { From 362224a009e5a009efdc88445ab50b31eb474066 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 29 Jun 2023 15:00:49 +0300 Subject: [PATCH 27/91] Update ci.yml --- .github/workflows/ci.yml | 216 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 213 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 835681d..346adc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 From e2546b70ca04d4263f7a5917815506e488b6920f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 29 Jun 2023 18:32:58 +0300 Subject: [PATCH 28/91] Document uses_double_storage(). Refs #37. --- doc/variant2/changelog.adoc | 4 ++++ doc/variant2/reference.adoc | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc index dd903ee..fc14105 100644 --- a/doc/variant2/changelog.adoc +++ b/doc/variant2/changelog.adoc @@ -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`. diff --git a/doc/variant2/reference.adoc b/doc/variant2/reference.adoc index beede7b..04bd748 100644 --- a/doc/variant2/reference.adoc +++ b/doc/variant2/reference.adoc @@ -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 ``` From a5cb0582d5669e86ee913f97c001677987023967 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 3 Sep 2023 18:28:49 +0300 Subject: [PATCH 29/91] Make tag_invoke_L2 more msvc-14.0-friendly --- include/boost/variant2/variant.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index f0e8fef..e0d4739 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2497,16 +2497,16 @@ template struct tag_invoke_L2 boost::json::value const& v; typename boost::json::result_for::type& r; - template void operator()( I i ) const + template void operator()( I /*i*/ ) const { if( !r ) { - using Ti = mp11::mp_at_c; + using Ti = mp11::mp_at_c; auto r2 = boost::json::try_value_to( v ); if( r2 ) { - r.emplace( in_place_index_t{}, std::move( *r2 ) ); + r.emplace( in_place_index_t{}, std::move( *r2 ) ); } } } From db12c36b891f524a35924cdf7758eb81d0d676c9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Oct 2023 18:28:11 +0300 Subject: [PATCH 30/91] Remove unnecessary includes --- include/boost/variant2/variant.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index e0d4739..7300837 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -18,13 +18,11 @@ #include #include #include -#include #include #include #include -#include #include -#include // std::hash +#include // std::hash #include #include #include @@ -2319,8 +2317,8 @@ namespace detail inline std::size_t hash_value_impl_( mp11::mp_true, std::size_t index, std::size_t value ) { - boost::ulong_long_type hv = ( boost::ulong_long_type( 0xCBF29CE4 ) << 32 ) + 0x84222325; - boost::ulong_long_type const prime = ( boost::ulong_long_type( 0x00000100 ) << 32 ) + 0x000001B3; + unsigned long long hv = 0xCBF29CE484222325ull; + unsigned long long const prime = 0x100000001B3ull; hv ^= index; hv *= prime; From 55f1332ce08fe9eb2da036c3f69c2d69ee615682 Mon Sep 17 00:00:00 2001 From: Jonathan Stein Date: Mon, 23 Oct 2023 15:44:01 -0500 Subject: [PATCH 31/91] Suppress -Wuninitialized in emplace_impl Closes #38 --- include/boost/variant2/variant.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 7300837..aec8966 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -689,8 +689,11 @@ template union variant_storage_impl) # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#if __GNUC__ >= 12 +// False positive in at least GCC 12 and GCC 13 ASAN and -Og triggered by monostate (via result) +# pragma GCC diagnostic ignored "-Wuninitialized" +#endif #endif - *this = variant_storage_impl( mp11::mp_size_t(), std::forward(a)... ); #if defined(BOOST_GCC) && (__GNUC__ >= 7) From 9cf32980a973e77e54541fe307d5cea978a26b4a Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 11 Jan 2024 20:18:06 +0300 Subject: [PATCH 32/91] Add missing dots in visit_by_index docs --- doc/variant2/reference.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/variant2/reference.adoc b/doc/variant2/reference.adoc index 04bd748..fe38344 100644 --- a/doc/variant2/reference.adoc +++ b/doc/variant2/reference.adoc @@ -157,7 +157,7 @@ template // visit_by_index (extension) template - constexpr /*see below*/ visit_by_index(V&& v, F&&.. f); + constexpr /*see below*/ visit_by_index(V&& v, F&&... f); // monostate @@ -936,7 +936,7 @@ Remarks: :: If `R` is given explicitly, as in `visit`, the return ``` template - constexpr /*see below*/ visit_by_index(V&& v, F&&.. f); + constexpr /*see below*/ visit_by_index(V&& v, F&&... f); ``` [none] * {blank} From a38839febce159994d93cc2dfcb99f30196c6079 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 11 Jan 2024 21:07:33 +0200 Subject: [PATCH 33/91] Update ci.yml --- .github/workflows/ci.yml | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 346adc3..ee0284e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,23 +19,28 @@ jobs: include: - toolset: gcc-4.8 cxxstd: "03,11" + container: ubuntu:16.04 os: ubuntu-latest - container: ubuntu:18.04 install: g++-4.8 + - toolset: gcc-4.9 + cxxstd: "03,11" + container: ubuntu:16.04 + os: ubuntu-latest + install: g++-4.9 - toolset: gcc-5 cxxstd: "03,11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-5 - toolset: gcc-6 cxxstd: "03,11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-6 - toolset: gcc-7 cxxstd: "03,11,14,17" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest - toolset: gcc-8 cxxstd: "03,11,14,17,2a" os: ubuntu-20.04 @@ -57,26 +62,26 @@ jobs: install: g++-12 - toolset: gcc-13 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-latest container: ubuntu:23.04 + os: ubuntu-latest install: g++-13 - toolset: clang compiler: clang++-3.9 cxxstd: "03,11,14" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: clang-3.9 - toolset: clang compiler: clang++-4.0 cxxstd: "03,11,14" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: clang-4.0 - toolset: clang compiler: clang++-5.0 cxxstd: "03,11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: clang-5.0 - toolset: clang compiler: clang++-6.0 @@ -116,24 +121,33 @@ jobs: - toolset: clang compiler: clang++-13 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: clang-13 - toolset: clang compiler: clang++-14 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: clang-14 - toolset: clang compiler: clang++-15 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: clang-15 - toolset: clang compiler: clang++-16 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-latest container: ubuntu:23.04 + os: ubuntu-latest install: clang-16 + - toolset: clang + compiler: clang++-17 + cxxstd: "03,11,14,17,20,2b" + container: ubuntu:23.10 + os: ubuntu-latest + install: clang-17 - toolset: clang cxxstd: "03,11,14,17,2a" os: macos-11 @@ -184,7 +198,7 @@ jobs: cd boost-root cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep - python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python3 tools/boostdep/depinst/depinst.py $LIBRARY ./bootstrap.sh ./b2 -d0 headers From 3298078c8b3cdbe2691b1b2138e317973801fbf2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 11 Jan 2024 22:05:28 +0200 Subject: [PATCH 34/91] Update .drone.jsonnet --- .drone.jsonnet | 67 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index fe3d8e3..56e49fb 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -97,17 +97,17 @@ local windows_pipeline(name, image, environment, arch = "amd64") = [ linux_pipeline( - "Linux 14.04 GCC 4.8* 32/64", - "cppalliance/droneubuntu1404:1", + "Linux 16.04 GCC 4.8 32/64", + "cppalliance/droneubuntu1604:1", { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' }, + "g++-4.8-multilib", ), linux_pipeline( - "Linux 14.04 GCC 4.9 32/64", - "cppalliance/droneubuntu1404:1", + "Linux 16.04 GCC 4.9 32/64", + "cppalliance/droneubuntu1604:1", { TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11', ADDRMD: '32,64' }, "g++-4.9-multilib", - [ "ppa:ubuntu-toolchain-r/test" ], ), linux_pipeline( @@ -170,23 +170,37 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 22.04 GCC 12 32 ASAN", + "Linux 22.04 GCC 12 32/64", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan, + { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' }, "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 23.04 GCC 13 32 ASAN", + "cppalliance/droneubuntu2304:1", + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan, + "g++-13-multilib", + ), + + linux_pipeline( + "Linux 23.04 GCC 13 64 ASAN", + "cppalliance/droneubuntu2304:1", + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan, + "g++-13-multilib", ), linux_pipeline( - "Linux 23.04 GCC 13 32/64", + "Linux 23.04 GCC 13 32 UBSAN", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + ubsan, + "g++-13-multilib", + ), + + linux_pipeline( + "Linux 23.04 GCC 13 64 UBSAN", + "cppalliance/droneubuntu2304:1", + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + ubsan, "g++-13-multilib", ), @@ -303,16 +317,9 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 22.04 Clang 15 UBSAN", - "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' } + ubsan, - "clang-15", - ), - - linux_pipeline( - "Linux 22.04 Clang 15 ASAN", + "Linux 22.04 Clang 15", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' } + asan, + { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' }, "clang-15", ), @@ -323,6 +330,20 @@ local windows_pipeline(name, image, environment, arch = "amd64") = "clang-16", ), + linux_pipeline( + "Linux 23.10 Clang 17 UBSAN", + "cppalliance/droneubuntu2310:1", + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + "clang-17", + ), + + linux_pipeline( + "Linux 23.10 Clang 17 ASAN", + "cppalliance/droneubuntu2310:1", + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan, + "clang-17", + ), + macos_pipeline( "MacOS 10.15 Xcode 12.2 UBSAN", { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan, @@ -348,7 +369,7 @@ local windows_pipeline(name, image, environment, arch = "amd64") = windows_pipeline( "Windows VS2015 msvc-14.0", "cppalliance/dronevs2015", - { TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' }, + { TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' }, ), windows_pipeline( From c125b329386c0d8007613e4552edfcc800bd988d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 8 Feb 2024 20:58:45 +0200 Subject: [PATCH 35/91] Add msvc-14.3 /permissive- to Drone --- .drone.jsonnet | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 56e49fb..d01a9b9 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -379,9 +379,9 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), windows_pipeline( - "Windows VS2017 msvc-14.1 Strict", + "Windows VS2017 msvc-14.1 permissive-", "cppalliance/dronevs2017", - { TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest', CXXFLAGS: '/permissive-' }, + { TOOLSET: 'msvc-14.1', CXXSTD: '14,17', CXXFLAGS: '/permissive-' }, ), windows_pipeline( @@ -391,9 +391,9 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), windows_pipeline( - "Windows VS2019 msvc-14.2 Strict", + "Windows VS2019 msvc-14.2 permissive-", "cppalliance/dronevs2019", - { TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest', CXXFLAGS: '/permissive-' }, + { TOOLSET: 'msvc-14.2', CXXSTD: '14,17', CXXFLAGS: '/permissive-' }, ), windows_pipeline( @@ -401,4 +401,10 @@ local windows_pipeline(name, image, environment, arch = "amd64") = "cppalliance/dronevs2022:1", { TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' }, ), + + windows_pipeline( + "Windows VS2022 msvc-14.3 permissive-", + "cppalliance/dronevs2022:1", + { TOOLSET: 'msvc-14.3', CXXSTD: '14,17', CXXFLAGS: '/permissive-' }, + ), ] From 5c34125b142439f1c6b1ee646183d2a673b321f6 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 11 Mar 2024 08:38:17 -0500 Subject: [PATCH 36/91] Make the library modular usable. --- build.jam | 22 ++++++++++++++++++++++ test/Jamfile | 8 ++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 build.jam diff --git a/build.jam b/build.jam new file mode 100644 index 0000000..bfbd74c --- /dev/null +++ b/build.jam @@ -0,0 +1,22 @@ +# Copyright René Ferdinand Rivera Morell 2023 +# 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) + +import project ; + +project /boost/variant2 + : common-requirements + /boost/assert//boost_assert + /boost/config//boost_config + /boost/mp11//boost_mp11 + include + ; + +explicit + [ alias boost_variant2 ] + [ alias all : boost_variant2 test ] + ; + +call-if : boost-library variant2 + ; diff --git a/test/Jamfile b/test/Jamfile index 85788b9..271279e 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -7,7 +7,7 @@ # http://www.boost.org/LICENSE_1_0.txt import testing ; -import ../../config/checks/config : requires ; +import config : requires ; project : default-build @@ -15,12 +15,16 @@ project extra : requirements + /boost/config//boost_config + /boost/container_hash//boost_container_hash + /boost/core//boost_core [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_constexpr ] msvc:on gcc:on clang:on + ; run quick.cpp ; @@ -127,7 +131,7 @@ run variant_visit_by_index.cpp ; run variant_ostream_insert.cpp ; run is_output_streamable.cpp ; -local JSON = /boost//json/off "msvc-14.0:no" "msvc-14.2:-wd5104" "norecover:static" ; +local JSON = /boost/json//boost_json/off "msvc-14.0:no" "msvc-14.2:-wd5104" "norecover:static" ; run variant_json_value_from.cpp : : : $(JSON) ; run variant_json_value_to.cpp : : : $(JSON) ; From 77234b514cb81f5648920d2bb48e6c8c0a496cec Mon Sep 17 00:00:00 2001 From: Agustin Berge Date: Sat, 23 Mar 2024 16:04:54 -0300 Subject: [PATCH 37/91] Improve natvis: - extend support from 10 to 40 alternatives, - split single-buffer vs double-buffer definitions, - adjust display string to follow MS definition for std::variant --- extra/boost_variant2.natvis | 200 +++++++++++++++++++++++++++++++----- 1 file changed, 173 insertions(+), 27 deletions(-) diff --git a/extra/boost_variant2.natvis b/extra/boost_variant2.natvis index 8f8cab4..a8c29b8 100644 --- a/extra/boost_variant2.natvis +++ b/extra/boost_variant2.natvis @@ -1,32 +1,178 @@ - - - {st_.rest_.first_} ({index()}) - {st_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - {st_[ix_%2].rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.rest_.first_} ({index()}) - - index() - ix_ - - + + + {{ index=0, value={*($T2*)&st_} }} + {{ index=1, value={*($T3*)&st_} }} + {{ index=2, value={*($T4*)&st_} }} + {{ index=3, value={*($T5*)&st_} }} + {{ index=4, value={*($T6*)&st_} }} + {{ index=5, value={*($T7*)&st_} }} + {{ index=6, value={*($T8*)&st_} }} + {{ index=7, value={*($T9*)&st_} }} + {{ index=8, value={*($T10*)&st_} }} + {{ index=9, value={*($T11*)&st_} }} + {{ index=10, value={*($T12*)&st_} }} + {{ index=11, value={*($T13*)&st_} }} + {{ index=12, value={*($T14*)&st_} }} + {{ index=13, value={*($T15*)&st_} }} + {{ index=14, value={*($T16*)&st_} }} + {{ index=15, value={*($T17*)&st_} }} + {{ index=16, value={*($T18*)&st_} }} + {{ index=17, value={*($T19*)&st_} }} + {{ index=18, value={*($T20*)&st_} }} + {{ index=19, value={*($T21*)&st_} }} + {{ index=10, value={*($T22*)&st_} }} + {{ index=21, value={*($T23*)&st_} }} + {{ index=22, value={*($T24*)&st_} }} + {{ index=23, value={*($T25*)&st_} }} + {{ index=24, value={*($T26*)&st_} }} + {{ index=25, value={*($T27*)&st_} }} + {{ index=26, value={*($T28*)&st_} }} + {{ index=27, value={*($T29*)&st_} }} + {{ index=28, value={*($T30*)&st_} }} + {{ index=29, value={*($T31*)&st_} }} + {{ index=30, value={*($T32*)&st_} }} + {{ index=31, value={*($T33*)&st_} }} + {{ index=32, value={*($T34*)&st_} }} + {{ index=33, value={*($T35*)&st_} }} + {{ index=34, value={*($T36*)&st_} }} + {{ index=35, value={*($T37*)&st_} }} + {{ index=36, value={*($T38*)&st_} }} + {{ index=37, value={*($T39*)&st_} }} + {{ index=38, value={*($T40*)&st_} }} + {{ index=39, value={*($T41*)&st_} }} + + index() + *($T2*)&st_ + *($T3*)&st_ + *($T4*)&st_ + *($T5*)&st_ + *($T6*)&st_ + *($T7*)&st_ + *($T8*)&st_ + *($T9*)&st_ + *($T10*)&st_ + *($T11*)&st_ + *($T12*)&st_ + *($T13*)&st_ + *($T14*)&st_ + *($T15*)&st_ + *($T16*)&st_ + *($T17*)&st_ + *($T18*)&st_ + *($T19*)&st_ + *($T20*)&st_ + *($T21*)&st_ + *($T22*)&st_ + *($T23*)&st_ + *($T24*)&st_ + *($T25*)&st_ + *($T26*)&st_ + *($T27*)&st_ + *($T28*)&st_ + *($T29*)&st_ + *($T30*)&st_ + *($T31*)&st_ + *($T32*)&st_ + *($T33*)&st_ + *($T34*)&st_ + *($T35*)&st_ + *($T36*)&st_ + *($T37*)&st_ + *($T38*)&st_ + *($T39*)&st_ + *($T40*)&st_ + *($T41*)&st_ + + + + + + {{ index=0, value={*($T2*)&st_[ix_%2]} }} + {{ index=1, value={*($T3*)&st_[ix_%2]} }} + {{ index=2, value={*($T4*)&st_[ix_%2]} }} + {{ index=3, value={*($T5*)&st_[ix_%2]} }} + {{ index=4, value={*($T6*)&st_[ix_%2]} }} + {{ index=5, value={*($T7*)&st_[ix_%2]} }} + {{ index=6, value={*($T8*)&st_[ix_%2]} }} + {{ index=7, value={*($T9*)&st_[ix_%2]} }} + {{ index=8, value={*($T10*)&st_[ix_%2]} }} + {{ index=9, value={*($T11*)&st_[ix_%2]} }} + {{ index=10, value={*($T12*)&st_[ix_%2]} }} + {{ index=11, value={*($T13*)&st_[ix_%2]} }} + {{ index=12, value={*($T14*)&st_[ix_%2]} }} + {{ index=13, value={*($T15*)&st_[ix_%2]} }} + {{ index=14, value={*($T16*)&st_[ix_%2]} }} + {{ index=15, value={*($T17*)&st_[ix_%2]} }} + {{ index=16, value={*($T18*)&st_[ix_%2]} }} + {{ index=17, value={*($T19*)&st_[ix_%2]} }} + {{ index=18, value={*($T20*)&st_[ix_%2]} }} + {{ index=19, value={*($T21*)&st_[ix_%2]} }} + {{ index=20, value={*($T22*)&st_[ix_%2]} }} + {{ index=21, value={*($T23*)&st_[ix_%2]} }} + {{ index=22, value={*($T24*)&st_[ix_%2]} }} + {{ index=23, value={*($T25*)&st_[ix_%2]} }} + {{ index=24, value={*($T26*)&st_[ix_%2]} }} + {{ index=25, value={*($T27*)&st_[ix_%2]} }} + {{ index=26, value={*($T28*)&st_[ix_%2]} }} + {{ index=27, value={*($T29*)&st_[ix_%2]} }} + {{ index=28, value={*($T30*)&st_[ix_%2]} }} + {{ index=29, value={*($T31*)&st_[ix_%2]} }} + {{ index=30, value={*($T32*)&st_[ix_%2]} }} + {{ index=31, value={*($T33*)&st_[ix_%2]} }} + {{ index=32, value={*($T34*)&st_[ix_%2]} }} + {{ index=33, value={*($T35*)&st_[ix_%2]} }} + {{ index=34, value={*($T36*)&st_[ix_%2]} }} + {{ index=35, value={*($T37*)&st_[ix_%2]} }} + {{ index=36, value={*($T38*)&st_[ix_%2]} }} + {{ index=37, value={*($T39*)&st_[ix_%2]} }} + {{ index=38, value={*($T40*)&st_[ix_%2]} }} + {{ index=39, value={*($T41*)&st_[ix_%2]} }} + + index() + *($T2*)&st_[ix_%2] + *($T3*)&st_[ix_%2] + *($T4*)&st_[ix_%2] + *($T5*)&st_[ix_%2] + *($T6*)&st_[ix_%2] + *($T7*)&st_[ix_%2] + *($T8*)&st_[ix_%2] + *($T9*)&st_[ix_%2] + *($T10*)&st_[ix_%2] + *($T11*)&st_[ix_%2] + *($T12*)&st_[ix_%2] + *($T13*)&st_[ix_%2] + *($T14*)&st_[ix_%2] + *($T15*)&st_[ix_%2] + *($T16*)&st_[ix_%2] + *($T17*)&st_[ix_%2] + *($T18*)&st_[ix_%2] + *($T19*)&st_[ix_%2] + *($T20*)&st_[ix_%2] + *($T21*)&st_[ix_%2] + *($T22*)&st_[ix_%2] + *($T23*)&st_[ix_%2] + *($T24*)&st_[ix_%2] + *($T25*)&st_[ix_%2] + *($T26*)&st_[ix_%2] + *($T27*)&st_[ix_%2] + *($T28*)&st_[ix_%2] + *($T29*)&st_[ix_%2] + *($T30*)&st_[ix_%2] + *($T31*)&st_[ix_%2] + *($T32*)&st_[ix_%2] + *($T33*)&st_[ix_%2] + *($T34*)&st_[ix_%2] + *($T35*)&st_[ix_%2] + *($T36*)&st_[ix_%2] + *($T37*)&st_[ix_%2] + *($T38*)&st_[ix_%2] + *($T39*)&st_[ix_%2] + *($T40*)&st_[ix_%2] + *($T41*)&st_[ix_%2] + + From a936eae01b34d582364103f27892abaa7d4aa5ed Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 24 Mar 2024 18:41:49 +0200 Subject: [PATCH 38/91] Add test/variant_derived_construct2. Refs #43. --- test/Jamfile | 2 + test/variant_derived_construct2.cpp | 60 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 test/variant_derived_construct2.cpp diff --git a/test/Jamfile b/test/Jamfile index 85788b9..b9b3d9c 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -133,3 +133,5 @@ run variant_json_value_from.cpp : : : $(JSON) ; run variant_json_value_to.cpp : : : $(JSON) ; compile variant_uses_double_storage.cpp ; + +run variant_derived_construct2.cpp ; diff --git a/test/variant_derived_construct2.cpp b/test/variant_derived_construct2.cpp new file mode 100644 index 0000000..31488aa --- /dev/null +++ b/test/variant_derived_construct2.cpp @@ -0,0 +1,60 @@ +// Copyright 2024 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +struct expr: boost::variant2::variant +{ + using variant::variant; +}; + +int main() +{ + using boost::variant2::get; + + { + expr v{ true }; + + BOOST_TEST_EQ( v.index(), 0 ); + BOOST_TEST_EQ( get<0>(v), true ); + } + + { + expr v{ 2 }; + + BOOST_TEST_EQ( v.index(), 1 ); + BOOST_TEST_EQ( get<1>(v), 2 ); + } + + { + expr v{ 3.0 }; + + BOOST_TEST_EQ( v.index(), 2 ); + BOOST_TEST_EQ( get<2>(v), 3.0 ); + } + + { + expr v( true ); + + BOOST_TEST_EQ( v.index(), 0 ); + BOOST_TEST_EQ( get<0>(v), true ); + } + + { + expr v( 2 ); + + BOOST_TEST_EQ( v.index(), 1 ); + BOOST_TEST_EQ( get<1>(v), 2 ); + } + + { + expr v( 3.0 ); + + BOOST_TEST_EQ( v.index(), 2 ); + BOOST_TEST_EQ( get<2>(v), 3.0 ); + } + + return boost::report_errors(); +} From f0acc9326ee54534eb31ec1636608dd01f232790 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 24 Mar 2024 19:16:09 +0200 Subject: [PATCH 39/91] Work around MSVC failures in variant_derived_construct2. Refs #43. --- include/boost/variant2/variant.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index aec8966..1668436 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -1634,7 +1634,17 @@ template class variant: private detail::variant_ma_base template::type, class E1 = typename std::enable_if< !std::is_same::value && !std::is_base_of::value && !detail::is_in_place_index::value && !detail::is_in_place_type::value >::type, + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1940) + + class V = mp11::mp_apply_q< mp11::mp_bind_front, variant >, + +#else + class V = detail::resolve_overload_type, + +#endif + class E2 = typename std::enable_if::value>::type > constexpr variant( U&& u ) From 09f3802347e373350e5b0e25d8fd1e1152d780bc Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 29 Mar 2024 21:16:00 -0500 Subject: [PATCH 40/91] Switch to library requirements instead of source. As source puts extra source in install targets. --- build.jam | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.jam b/build.jam index bfbd74c..0a3fd5c 100644 --- a/build.jam +++ b/build.jam @@ -7,9 +7,9 @@ import project ; project /boost/variant2 : common-requirements - /boost/assert//boost_assert - /boost/config//boost_config - /boost/mp11//boost_mp11 + /boost/assert//boost_assert + /boost/config//boost_config + /boost/mp11//boost_mp11 include ; From 1324e32b3312f6f58ef81981b647bdcbc10b2f22 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 4 May 2024 23:33:36 -0500 Subject: [PATCH 41/91] Add missing import-search for cconfig/predef checks. --- test/Jamfile | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Jamfile b/test/Jamfile index 6552c2b..160c88d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -7,6 +7,7 @@ # http://www.boost.org/LICENSE_1_0.txt import testing ; +import-search /boost/config/checks ; import config : requires ; project From bb13b5be08321eec1276dfc9dc78fa2853307e7f Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sun, 5 May 2024 09:00:01 -0500 Subject: [PATCH 42/91] Add requires-b2 check to top-level build file. --- build.jam | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.jam b/build.jam index 0a3fd5c..a678597 100644 --- a/build.jam +++ b/build.jam @@ -3,6 +3,8 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +require-b2 5.1 ; + import project ; project /boost/variant2 From 78796d0e7df01f9f147775cfc025873cfcb0abe2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 May 2024 21:44:21 +0300 Subject: [PATCH 43/91] Increase workaround to < 1950, because VS2022 has reached _MSC_VER=1940. Refs #43. --- include/boost/variant2/variant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 1668436..71f6eaa 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -1635,7 +1635,7 @@ template class variant: private detail::variant_ma_base class Ud = typename std::decay::type, class E1 = typename std::enable_if< !std::is_same::value && !std::is_base_of::value && !detail::is_in_place_index::value && !detail::is_in_place_type::value >::type, -#if BOOST_WORKAROUND(BOOST_MSVC, < 1940) +#if BOOST_WORKAROUND(BOOST_MSVC, < 1950) class V = mp11::mp_apply_q< mp11::mp_bind_front, variant >, From 65ab0f8cef1567ebe6e95fb2d3bdd8c601b6fd9c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 May 2024 22:04:55 +0300 Subject: [PATCH 44/91] Update ci.yml --- .github/workflows/ci.yml | 92 +++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee0284e..e20d315 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,145 +18,159 @@ jobs: matrix: include: - toolset: gcc-4.8 - cxxstd: "03,11" + cxxstd: "11" container: ubuntu:16.04 os: ubuntu-latest install: g++-4.8 - toolset: gcc-4.9 - cxxstd: "03,11" + cxxstd: "11" container: ubuntu:16.04 os: ubuntu-latest install: g++-4.9 - toolset: gcc-5 - cxxstd: "03,11,14,1z" + cxxstd: "11,14,1z" container: ubuntu:18.04 os: ubuntu-latest install: g++-5 - toolset: gcc-6 - cxxstd: "03,11,14,1z" + cxxstd: "11,14,1z" container: ubuntu:18.04 os: ubuntu-latest install: g++-6 - toolset: gcc-7 - cxxstd: "03,11,14,17" + cxxstd: "11,14,17" container: ubuntu:18.04 os: ubuntu-latest - toolset: gcc-8 - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" os: ubuntu-20.04 install: g++-8 - toolset: gcc-9 - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" os: ubuntu-20.04 - toolset: gcc-10 - cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + cxxstd: "11,14,17,2a" + os: ubuntu-22.04 install: g++-10 - toolset: gcc-11 - cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + cxxstd: "11,14,17,2a" + os: ubuntu-22.04 install: g++-11 - toolset: gcc-12 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" os: ubuntu-22.04 install: g++-12 - toolset: gcc-13 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" container: ubuntu:23.04 os: ubuntu-latest install: g++-13 + - toolset: gcc-14 + cxxstd: "11,14,17,20,2b" + container: ubuntu:24.04 + os: ubuntu-latest + install: g++-14 - toolset: clang compiler: clang++-3.9 - cxxstd: "03,11,14" + cxxstd: "11,14" container: ubuntu:18.04 os: ubuntu-latest install: clang-3.9 - toolset: clang compiler: clang++-4.0 - cxxstd: "03,11,14" + cxxstd: "11,14" container: ubuntu:18.04 os: ubuntu-latest install: clang-4.0 - toolset: clang compiler: clang++-5.0 - cxxstd: "03,11,14,1z" + cxxstd: "11,14,1z" container: ubuntu:18.04 os: ubuntu-latest install: clang-5.0 - toolset: clang compiler: clang++-6.0 - cxxstd: "03,11,14,17" + cxxstd: "11,14,17" os: ubuntu-20.04 install: clang-6.0 - toolset: clang compiler: clang++-7 - cxxstd: "03,11,14,17" + cxxstd: "11,14,17" os: ubuntu-20.04 install: clang-7 - toolset: clang compiler: clang++-8 - cxxstd: "03,11,14,17" + cxxstd: "11,14,17" os: ubuntu-20.04 install: clang-8 - toolset: clang compiler: clang++-9 - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" os: ubuntu-20.04 install: clang-9 - toolset: clang compiler: clang++-10 - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" os: ubuntu-20.04 install: clang-10 - toolset: clang compiler: clang++-11 - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" os: ubuntu-20.04 install: clang-11 - toolset: clang compiler: clang++-12 - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" os: ubuntu-20.04 install: clang-12 - toolset: clang compiler: clang++-13 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" container: ubuntu:22.04 os: ubuntu-latest install: clang-13 - toolset: clang compiler: clang++-14 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" container: ubuntu:22.04 os: ubuntu-latest install: clang-14 - toolset: clang compiler: clang++-15 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" container: ubuntu:22.04 os: ubuntu-latest install: clang-15 - toolset: clang compiler: clang++-16 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" container: ubuntu:23.04 os: ubuntu-latest install: clang-16 - toolset: clang compiler: clang++-17 - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" container: ubuntu:23.10 os: ubuntu-latest install: clang-17 - toolset: clang - cxxstd: "03,11,14,17,2a" + compiler: clang++-18 + cxxstd: "11,14,17,20,2b" + container: ubuntu:24.04 + os: ubuntu-latest + install: clang-18 + - toolset: clang + cxxstd: "11,14,17,2a" os: macos-11 - toolset: clang - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" os: macos-12 - toolset: clang - cxxstd: "03,11,14,17,20,2b" + cxxstd: "11,14,17,20,2b" os: macos-13 + - toolset: clang + cxxstd: "11,14,17,20,2b" + os: macos-14 runs-on: ${{matrix.os}} container: ${{matrix.container}} @@ -234,14 +248,14 @@ jobs: addrmd: 32,64 os: windows-2022 - toolset: gcc - cxxstd: "03,11,14,17,2a" + cxxstd: "11,14,17,2a" addrmd: 64 os: windows-2019 runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd @@ -285,7 +299,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install @@ -333,7 +347,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install @@ -391,7 +405,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install @@ -444,7 +458,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd @@ -493,7 +507,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd @@ -560,7 +574,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd From 38293da18e53f0bf9a9cef5d7931419e09e067eb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 May 2024 22:39:29 +0300 Subject: [PATCH 45/91] Update .drone.jsonnet --- .drone.jsonnet | 108 +++++++++++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 40 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index d01a9b9..9b8a5b3 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -99,270 +99,298 @@ local windows_pipeline(name, image, environment, arch = "amd64") = linux_pipeline( "Linux 16.04 GCC 4.8 32/64", "cppalliance/droneubuntu1604:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11', ADDRMD: '32,64' }, "g++-4.8-multilib", ), linux_pipeline( "Linux 16.04 GCC 4.9 32/64", "cppalliance/droneubuntu1604:1", - { TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '11', ADDRMD: '32,64' }, "g++-4.9-multilib", ), linux_pipeline( "Linux 16.04 GCC 5* 32/64", "cppalliance/droneubuntu1604:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14', ADDRMD: '32,64' }, ), linux_pipeline( "Linux 18.04 GCC 6 32/64", "cppalliance/droneubuntu1804:1", - { TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '11,14', ADDRMD: '32,64' }, "g++-6-multilib", ), linux_pipeline( "Linux 18.04 GCC 7* 32/64", "cppalliance/droneubuntu1804:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17', ADDRMD: '32,64' }, ), linux_pipeline( "Linux 18.04 GCC 8 32/64", "cppalliance/droneubuntu1804:1", - { TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '11,14,17', ADDRMD: '32,64' }, "g++-8-multilib", ), linux_pipeline( "Linux 20.04 GCC 9* 32/64", "cppalliance/droneubuntu2004:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32,64' }, ), linux_pipeline( "Linux 20.04 GCC 9* ARM64", "cppalliance/droneubuntu2004:multiarch", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' }, arch="arm64", ), linux_pipeline( "Linux 20.04 GCC 9* S390x", "cppalliance/droneubuntu2004:multiarch", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' }, arch="s390x", ), linux_pipeline( "Linux 20.04 GCC 10 32/64", "cppalliance/droneubuntu2004:1", - { TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '11,14,17,20', ADDRMD: '32,64' }, "g++-10-multilib", ), linux_pipeline( "Linux 22.04 GCC 11* 32/64", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32,64' }, ), linux_pipeline( "Linux 22.04 GCC 12 32/64", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' }, "g++-12-multilib", ), linux_pipeline( "Linux 23.04 GCC 13 32 ASAN", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan, "g++-13-multilib", ), linux_pipeline( "Linux 23.04 GCC 13 64 ASAN", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + asan, "g++-13-multilib", ), linux_pipeline( "Linux 23.04 GCC 13 32 UBSAN", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + ubsan, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan, "g++-13-multilib", ), linux_pipeline( "Linux 23.04 GCC 13 64 UBSAN", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + ubsan, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan, "g++-13-multilib", ), + linux_pipeline( + "Linux 24.04 GCC 14 32", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' }, + "g++-14-multilib", + ), + + linux_pipeline( + "Linux 24.04 GCC 14 64", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' }, + "g++-14-multilib", + ), + linux_pipeline( "Linux 16.04 Clang 3.5", "cppalliance/droneubuntu1604:1", - { TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' }, + { TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-6.0', CXXSTD: '11,14,17' }, "clang-6.0", ), linux_pipeline( "Linux 20.04 Clang 7", "cppalliance/droneubuntu2004:1", - { TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '03,11,14,17' }, + { TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '11,14,17' }, "clang-7", ), linux_pipeline( "Linux 20.04 Clang 8", "cppalliance/droneubuntu2004:1", - { TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '03,11,14,17' }, + { TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-9', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-10', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-11', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-12', CXXSTD: '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' }, + { TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '11,14,17,20,2b' }, "clang-13", ), linux_pipeline( "Linux 22.04 Clang 14", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' }, + { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '11,14,17,20,2b' }, "clang-14", ), linux_pipeline( "Linux 22.04 Clang 15", "cppalliance/droneubuntu2204:1", - { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' }, + { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' }, "clang-15", ), linux_pipeline( "Linux 23.04 Clang 16", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '03,11,14,17,20,2b' }, + { TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' }, "clang-16", ), linux_pipeline( "Linux 23.10 Clang 17 UBSAN", "cppalliance/droneubuntu2310:1", - { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan, "clang-17", ), linux_pipeline( "Linux 23.10 Clang 17 ASAN", "cppalliance/droneubuntu2310:1", - { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan, + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan, "clang-17", ), + linux_pipeline( + "Linux 24.04 Clang 18 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + ubsan, + "clang-18", + ), + + linux_pipeline( + "Linux 24.04 Clang 18 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + asan, + "clang-18", + ), + macos_pipeline( "MacOS 10.15 Xcode 12.2 UBSAN", - { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan, ), macos_pipeline( "MacOS 10.15 Xcode 12.2 ASAN", - { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan, + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '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, + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '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, + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + asan, xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64", ), From f9bdafd3ca0f5025012f60a405b559888513a9be Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 May 2024 03:18:56 +0300 Subject: [PATCH 46/91] Remove C++11 requirements from test/Jamfile --- test/Jamfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index b9b3d9c..d7e92fb 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -16,8 +16,6 @@ project : requirements - [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_constexpr ] - msvc:on gcc:on clang:on From 4f207d7363dbbb845427be45cbc9ba9e0e54b839 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 14 Jun 2024 11:33:56 -0500 Subject: [PATCH 47/91] Bump B2 require to 5.2 --- build.jam | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.jam b/build.jam index a678597..244288f 100644 --- a/build.jam +++ b/build.jam @@ -3,9 +3,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -require-b2 5.1 ; - -import project ; +require-b2 5.2 ; project /boost/variant2 : common-requirements From fc088e72731e62552b596c79cd067dcdf22bab4e Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 20 Jul 2024 21:27:52 -0500 Subject: [PATCH 48/91] Change all references to . --- test/Jamfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index a89cae8..2592d01 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -16,9 +16,9 @@ project extra : requirements - /boost/config//boost_config - /boost/container_hash//boost_container_hash - /boost/core//boost_core + /boost/config//boost_config + /boost/container_hash//boost_container_hash + /boost/core//boost_core msvc:on gcc:on From f874a2cb1b6faad89fb86da7eb915fb498903857 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 20 Jul 2024 22:52:05 -0500 Subject: [PATCH 49/91] Update copyright dates. --- build.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.jam b/build.jam index 244288f..b561d81 100644 --- a/build.jam +++ b/build.jam @@ -1,4 +1,4 @@ -# Copyright René Ferdinand Rivera Morell 2023 +# 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) From d4f0e57b367632593c2695e8898fec384a32e584 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jul 2024 21:54:28 +0300 Subject: [PATCH 50/91] Update .drone.jsonnet --- .drone.jsonnet | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 9b8a5b3..df1f942 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -99,7 +99,7 @@ local windows_pipeline(name, image, environment, arch = "amd64") = linux_pipeline( "Linux 16.04 GCC 4.8 32/64", "cppalliance/droneubuntu1604:1", - { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11', ADDRMD: '32,64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '11', ADDRMD: '32,64' }, "g++-4.8-multilib", ), @@ -177,44 +177,37 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 23.04 GCC 13 32 ASAN", + "Linux 23.04 GCC 13 32/64", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' }, "g++-13-multilib", ), linux_pipeline( - "Linux 23.04 GCC 13 64 ASAN", - "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + asan, - "g++-13-multilib", - ), - - linux_pipeline( - "Linux 23.04 GCC 13 32 UBSAN", - "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan, - "g++-13-multilib", + "Linux 24.04 GCC 14 32 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan, + "g++-14-multilib", ), linux_pipeline( - "Linux 23.04 GCC 13 64 UBSAN", - "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan, - "g++-13-multilib", + "Linux 24.04 GCC 14 64 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + asan, + "g++-14-multilib", ), linux_pipeline( - "Linux 24.04 GCC 14 32", + "Linux 24.04 GCC 14 32 UBSAN", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' }, + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan, "g++-14-multilib", ), linux_pipeline( - "Linux 24.04 GCC 14 64", + "Linux 24.04 GCC 14 64 UBSAN", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' }, + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan, "g++-14-multilib", ), From e3cf721a23854ab4c227e30fded3b69949e3f6a8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jul 2024 22:20:27 +0300 Subject: [PATCH 51/91] Define BOOST_ALLOW_DEPRECATED in JSON tests for g++ 4.x --- test/variant_json_value_from.cpp | 6 ++++++ test/variant_json_value_to.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/test/variant_json_value_from.cpp b/test/variant_json_value_from.cpp index 9734c74..be5dc3a 100644 --- a/test/variant_json_value_from.cpp +++ b/test/variant_json_value_from.cpp @@ -2,6 +2,12 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include + +#if defined(BOOST_GCC) && BOOST_GCC < 50000 +# define BOOST_ALLOW_DEPRECATED +#endif + #include #include #include diff --git a/test/variant_json_value_to.cpp b/test/variant_json_value_to.cpp index 1263931..5b42cc0 100644 --- a/test/variant_json_value_to.cpp +++ b/test/variant_json_value_to.cpp @@ -2,6 +2,12 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include + +#if defined(BOOST_GCC) && BOOST_GCC < 50000 +# define BOOST_ALLOW_DEPRECATED +#endif + #include #include #include From 0e325dcf8d95088b80788d142fa19c061e7671a1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jul 2024 22:38:06 +0300 Subject: [PATCH 52/91] Update ci.yml --- .github/workflows/ci.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e20d315..c7fc0ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,9 +159,6 @@ jobs: container: ubuntu:24.04 os: ubuntu-latest install: clang-18 - - toolset: clang - cxxstd: "11,14,17,2a" - os: macos-11 - toolset: clang cxxstd: "11,14,17,20,2b" os: macos-12 @@ -180,6 +177,10 @@ jobs: shell: bash steps: + - name: Enable Node 16 + run: | + echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV + - uses: actions/checkout@v3 - name: Setup container environment @@ -292,9 +293,9 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-11 - os: macos-12 - os: macos-13 + - os: macos-14 runs-on: ${{matrix.os}} @@ -340,9 +341,9 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-11 - os: macos-12 - os: macos-13 + - os: macos-14 runs-on: ${{matrix.os}} @@ -398,9 +399,9 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-11 - os: macos-12 - os: macos-13 + - os: macos-14 runs-on: ${{matrix.os}} From f5cd36af3d47203038a6700f1163a554016ee0dc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 21 Jul 2024 22:55:40 +0300 Subject: [PATCH 53/91] Update MSVC workaround --- include/boost/variant2/variant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 71f6eaa..3eb5342 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -83,7 +83,7 @@ struct monostate { }; -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1940) +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1950) constexpr bool operator<(monostate, monostate) noexcept { return false; } constexpr bool operator>(monostate, monostate) noexcept { return false; } From ea4394914c6c32aa92c0c799ba41478cc27abe64 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 23 Jul 2024 22:34:24 -0500 Subject: [PATCH 54/91] Move inter-lib dependencies to a project variable and into the build targets. --- build.jam | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build.jam b/build.jam index b561d81..c655191 100644 --- a/build.jam +++ b/build.jam @@ -5,18 +5,21 @@ require-b2 5.2 ; +constant boost_dependencies : + /boost/assert//boost_assert + /boost/config//boost_config + /boost/mp11//boost_mp11 ; + project /boost/variant2 : common-requirements - /boost/assert//boost_assert - /boost/config//boost_config - /boost/mp11//boost_mp11 include ; explicit - [ alias boost_variant2 ] + [ alias boost_variant2 : : : : $(boost_dependencies) ] [ alias all : boost_variant2 test ] ; call-if : boost-library variant2 ; + From acf24454d85bdf457d685021cbc1360a7820501c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 28 Aug 2024 20:28:59 +0300 Subject: [PATCH 55/91] Update build.jam, test/Jamfile --- build.jam | 17 +++++++---------- test/Jamfile | 5 +++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build.jam b/build.jam index c655191..052680f 100644 --- a/build.jam +++ b/build.jam @@ -1,25 +1,22 @@ -# Copyright René Ferdinand Rivera Morell 2023-2024 +# Copyright 2023-2024 René Ferdinand Rivera Morell +# Copyright 2024 Peter Dimov # Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) +# https://www.boost.org/LICENSE_1_0.txt require-b2 5.2 ; constant boost_dependencies : /boost/assert//boost_assert /boost/config//boost_config - /boost/mp11//boost_mp11 ; - -project /boost/variant2 - : common-requirements - include + /boost/mp11//boost_mp11 ; +project /boost/variant2 ; + explicit - [ alias boost_variant2 : : : : $(boost_dependencies) ] + [ alias boost_variant2 : : : : include $(boost_dependencies) ] [ alias all : boost_variant2 test ] ; call-if : boost-library variant2 ; - diff --git a/test/Jamfile b/test/Jamfile index 2592d01..17cc75d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -16,9 +16,10 @@ project extra : requirements - /boost/config//boost_config - /boost/container_hash//boost_container_hash + + /boost/variant2//boost_variant2 /boost/core//boost_core + /boost/container_hash//boost_container_hash msvc:on gcc:on From c7c5eb2510dbe36adc64925e207a4bd28efa15cf Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 28 Aug 2024 20:45:27 +0300 Subject: [PATCH 56/91] Update .drone.jsonnet --- .drone.jsonnet | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.jsonnet b/.drone.jsonnet index df1f942..cef23e1 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -32,6 +32,8 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch commands: [ 'set -e', + 'uname -a', + 'echo $DRONE_STAGE_MACHINE', 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -', ] + (if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) + From a4b167b7238781d75df5d6684c9e9d40b26456dc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 28 Aug 2024 20:45:54 +0300 Subject: [PATCH 57/91] Add VERBATIM to add_custom_target --- test/cmake_install_test/CMakeLists.txt | 2 +- test/cmake_subdir_test/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cmake_install_test/CMakeLists.txt b/test/cmake_install_test/CMakeLists.txt index 62a1176..a91bc4c 100644 --- a/test/cmake_install_test/CMakeLists.txt +++ b/test/cmake_install_test/CMakeLists.txt @@ -14,4 +14,4 @@ target_link_libraries(quick Boost::variant2) enable_testing() add_test(quick quick) -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) +add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt index 036030b..c887c7a 100644 --- a/test/cmake_subdir_test/CMakeLists.txt +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -18,4 +18,4 @@ target_link_libraries(quick Boost::variant2) enable_testing() add_test(quick quick) -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) +add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) From 79061e470f59278cff1e6c0aab351a306062ade9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 22 Nov 2024 22:53:17 +0200 Subject: [PATCH 58/91] Update ci.yml --- .github/workflows/ci.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7fc0ec..b9ace52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: install: g++-12 - toolset: gcc-13 cxxstd: "11,14,17,20,2b" - container: ubuntu:23.04 + container: ubuntu:24.04 os: ubuntu-latest install: g++-13 - toolset: gcc-14 @@ -144,13 +144,13 @@ jobs: - toolset: clang compiler: clang++-16 cxxstd: "11,14,17,20,2b" - container: ubuntu:23.04 + container: ubuntu:24.04 os: ubuntu-latest install: clang-16 - toolset: clang compiler: clang++-17 cxxstd: "11,14,17,20,2b" - container: ubuntu:23.10 + container: ubuntu:24.04 os: ubuntu-latest install: clang-17 - toolset: clang @@ -160,14 +160,20 @@ jobs: os: ubuntu-latest install: clang-18 - toolset: clang + compiler: clang++-19 cxxstd: "11,14,17,20,2b" - os: macos-12 + container: ubuntu:24.10 + os: ubuntu-latest + install: clang-19 - toolset: clang cxxstd: "11,14,17,20,2b" os: macos-13 - toolset: clang cxxstd: "11,14,17,20,2b" os: macos-14 + - toolset: clang + cxxstd: "11,14,17,20,2b" + os: macos-15 runs-on: ${{matrix.os}} container: ${{matrix.container}} @@ -293,9 +299,10 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-12 + - os: ubuntu-24.04 - os: macos-13 - os: macos-14 + - os: macos-15 runs-on: ${{matrix.os}} @@ -341,9 +348,10 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-12 + - os: ubuntu-24.04 - os: macos-13 - os: macos-14 + - os: macos-15 runs-on: ${{matrix.os}} @@ -399,9 +407,10 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-12 + - os: ubuntu-24.04 - os: macos-13 - os: macos-14 + - os: macos-15 runs-on: ${{matrix.os}} From 1202390861ba3e2232a611881dc2e5189130870b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 22 Nov 2024 23:06:34 +0200 Subject: [PATCH 59/91] Update .drone.jsonnet --- .drone.jsonnet | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index cef23e1..b102569 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -179,8 +179,8 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 23.04 GCC 13 32/64", - "cppalliance/droneubuntu2304:1", + "Linux 24.04 GCC 13 32/64", + "cppalliance/droneubuntu2404:1", { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' }, "g++-13-multilib", ), @@ -333,22 +333,22 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 23.04 Clang 16", - "cppalliance/droneubuntu2304:1", + "Linux 24.04 Clang 16", + "cppalliance/droneubuntu2404:1", { TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' }, "clang-16", ), linux_pipeline( - "Linux 23.10 Clang 17 UBSAN", - "cppalliance/droneubuntu2310:1", + "Linux 24.04 Clang 17 UBSAN", + "cppalliance/droneubuntu2404:1", { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan, "clang-17", ), linux_pipeline( - "Linux 23.10 Clang 17 ASAN", - "cppalliance/droneubuntu2310:1", + "Linux 24.04 Clang 17 ASAN", + "cppalliance/droneubuntu2404:1", { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan, "clang-17", ), @@ -367,6 +367,13 @@ local windows_pipeline(name, image, environment, arch = "amd64") = "clang-18", ), + linux_pipeline( + "Linux 24.10 Clang 19", + "cppalliance/droneubuntu2410:1", + { TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' } + asan, + "clang-19", + ), + macos_pipeline( "MacOS 10.15 Xcode 12.2 UBSAN", { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan, From 9061e427c201a7ad456d3fcf7aad9b58757831fd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Nov 2024 03:13:28 +0200 Subject: [PATCH 60/91] Add test/variant_visit_cx.cpp. Refs #47. --- include/boost/variant2/variant.hpp | 2 +- test/Jamfile | 2 ++ test/variant_visit_cx.cpp | 51 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/variant_visit_cx.cpp diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 3eb5342..f6896f0 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -2125,7 +2125,7 @@ template struct visit_L1 F&& f; V1&& v1; - template auto operator()( I ) const -> Vret + template constexpr auto operator()( I ) const -> Vret { return std::forward(f)( unsafe_get( std::forward(v1) ) ); } diff --git a/test/Jamfile b/test/Jamfile index 17cc75d..2bed75d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -139,3 +139,5 @@ run variant_json_value_to.cpp : : : $(JSON) ; compile variant_uses_double_storage.cpp ; run variant_derived_construct2.cpp ; + +compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; diff --git a/test/variant_visit_cx.cpp b/test/variant_visit_cx.cpp new file mode 100644 index 0000000..4646242 --- /dev/null +++ b/test/variant_visit_cx.cpp @@ -0,0 +1,51 @@ +// Copyright 2017, 2024 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#include +using namespace boost::variant2; + +#if !defined(BOOST_MP11_HAS_CXX14_CONSTEXPR) + +#include + +BOOST_PRAGMA_MESSAGE("Skipping constexpr visit test because BOOST_MP11_HAS_CXX14_CONSTEXPR is not defined") + +int main() {} + +#else + +struct X +{ + constexpr operator int() const { return 2; } +}; + +struct F +{ + constexpr int operator()( int x ) const + { + return x; + } +}; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + { + constexpr variant v( 1 ); + STATIC_ASSERT( visit( F(), v ) == 1 ); + } + + { + constexpr variant v( 'a' ); + STATIC_ASSERT( visit( F(), v ) == 'a' ); + } + + { + constexpr variant v( X{} ); + STATIC_ASSERT( visit( F(), v ) == 2 ); + } +} + +#endif From bdc1098c80e81ef67286c84697408edf5bd16a08 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Nov 2024 03:38:27 +0200 Subject: [PATCH 61/91] Add test/variant_visit_r_cx.cpp. Refs #47. --- test/Jamfile | 1 + test/variant_visit_r_cx.cpp | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/variant_visit_r_cx.cpp diff --git a/test/Jamfile b/test/Jamfile index 2bed75d..ad7b7e1 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -141,3 +141,4 @@ compile variant_uses_double_storage.cpp ; run variant_derived_construct2.cpp ; compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; +compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; diff --git a/test/variant_visit_r_cx.cpp b/test/variant_visit_r_cx.cpp new file mode 100644 index 0000000..83672b6 --- /dev/null +++ b/test/variant_visit_r_cx.cpp @@ -0,0 +1,52 @@ +// Copyright 2017, 2024 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#include +using namespace boost::variant2; + +#if !defined(BOOST_MP11_HAS_CXX14_CONSTEXPR) + +#include + +BOOST_PRAGMA_MESSAGE("Skipping constexpr visit test because BOOST_MP11_HAS_CXX14_CONSTEXPR is not defined") + +int main() {} + +#else + +struct X +{ + int v; + constexpr operator int() const { return v; } +}; + +struct F +{ + template constexpr T operator()( T x ) const + { + return x; + } +}; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + { + constexpr variant v( 1 ); + STATIC_ASSERT( visit( F(), v ) == 1 ); + } + + { + constexpr variant v( 'a' ); + STATIC_ASSERT( visit( F(), v ) == 'a' ); + } + + { + constexpr variant v( X{2} ); + STATIC_ASSERT( visit( F(), v ) == 2 ); + } +} + +#endif From 19b75fffe4a74e9f928f05f5f07920806c93ed7f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Nov 2024 04:11:30 +0200 Subject: [PATCH 62/91] Add test/variant_visit_cx_2.cpp. Refs #47. --- test/Jamfile | 1 + test/variant_visit_cx_2.cpp | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/variant_visit_cx_2.cpp diff --git a/test/Jamfile b/test/Jamfile index ad7b7e1..4a5f6fe 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -141,4 +141,5 @@ compile variant_uses_double_storage.cpp ; run variant_derived_construct2.cpp ; compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; +compile variant_visit_cx_2.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; diff --git a/test/variant_visit_cx_2.cpp b/test/variant_visit_cx_2.cpp new file mode 100644 index 0000000..65c5d30 --- /dev/null +++ b/test/variant_visit_cx_2.cpp @@ -0,0 +1,53 @@ +// Copyright 2017, 2024 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !( defined(__cpp_constexpr) && __cpp_constexpr >= 201603L ) + +BOOST_PRAGMA_MESSAGE("Skipping constexpr visit test because __cpp_constexpr < 201603L") +int main() {} + +#elif !defined(BOOST_MP11_HAS_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Skipping constexpr visit test because BOOST_MP11_HAS_CXX14_CONSTEXPR is not defined") +int main() {} + +#else + +using namespace boost::variant2; + +struct F +{ + constexpr int operator()( int x1, int x2 ) const + { + return x1 + x2; + } + + constexpr int operator()( int x1, int x2, int x3 ) const + { + return x1 + x2 + x3; + } +}; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + { + constexpr variant v1( 1 ); + constexpr variant v2( '2' ); + STATIC_ASSERT( visit( F(), v1, v2 ) == 1 + '2' ); + } + + { + constexpr variant v1( 1 ); + constexpr variant v2( 2 ); + constexpr variant v3( '3' ); + STATIC_ASSERT( visit( F(), v1, v2, v3 ) == 1 + 2 + '3' ); + } +} + +#endif From 8333e9af93d1a5c925435b063ec80e22d70869cb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Dec 2024 19:44:14 +0200 Subject: [PATCH 63/91] Apply Node20 workaround --- .github/workflows/ci.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9ace52..6a77fa6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -176,24 +176,32 @@ jobs: os: macos-15 runs-on: ${{matrix.os}} - container: ${{matrix.container}} + + container: + image: ${{matrix.container}} + volumes: + - /node20217:/node20217:rw,rshared + - ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }} defaults: run: shell: bash steps: - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - - - uses: actions/checkout@v3 - - name: Setup container environment if: matrix.container run: | apt-get update - apt-get -y install sudo python3 git g++ + apt-get -y install sudo python3 git g++ curl xz-utils + + - name: Install nodejs20glibc2.17 + if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }} + run: | + curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz + tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217 + ldd /__e/node20/bin/node + + - uses: actions/checkout@v4 - name: Install packages if: matrix.install From 47e544959f4edb2e9e2971db4bd766b159b74be6 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Wed, 18 Dec 2024 02:57:01 +0300 Subject: [PATCH 64/91] Added missing std namespace qualifiers. --- include/boost/variant2/variant.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index f6896f0..9a1de15 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -880,7 +880,7 @@ template struct variant_base_impl template BOOST_CXX14_CONSTEXPR mp11::mp_at_c, I>& _get_impl( mp11::mp_size_t ) noexcept { - size_t const J = I+1; + std::size_t const J = I+1; BOOST_ASSERT( ix_ == J ); @@ -889,7 +889,7 @@ template struct variant_base_impl template constexpr mp11::mp_at_c, I> const& _get_impl( mp11::mp_size_t ) const noexcept { - // size_t const J = I+1; + // std::size_t const J = I+1; BOOST_VARIANT2_CX14_ASSERT( ix_ == I+1 ) @@ -958,7 +958,7 @@ template struct variant_base_impl { BOOST_ASSERT( index() == I ); - size_t const J = I+1; + std::size_t const J = I+1; constexpr mp11::mp_size_t j{}; return st_[ ix_ & 1 ].get( j ); @@ -968,7 +968,7 @@ template struct variant_base_impl { BOOST_VARIANT2_CX14_ASSERT( index() == I ) - // size_t const J = I+1; + // std::size_t const J = I+1; // constexpr mp_size_t j{}; return st_[ ix_ & 1 ].get( mp11::mp_size_t() ); @@ -976,7 +976,7 @@ template struct variant_base_impl template BOOST_CXX14_CONSTEXPR void emplace( A&&... a ) { - size_t const J = I+1; + std::size_t const J = I+1; unsigned i2 = 1 - ( ix_ & 1 ); @@ -1048,7 +1048,7 @@ template struct variant_base_impl template BOOST_CXX14_CONSTEXPR mp11::mp_at_c, I>& _get_impl( mp11::mp_size_t ) noexcept { - size_t const J = I+1; + std::size_t const J = I+1; BOOST_ASSERT( ix_ == J ); @@ -1057,7 +1057,7 @@ template struct variant_base_impl template constexpr mp11::mp_at_c, I> const& _get_impl( mp11::mp_size_t ) const noexcept { - // size_t const J = I+1; + // std::size_t const J = I+1; BOOST_VARIANT2_CX14_ASSERT( ix_ == I+1 ) @@ -1066,7 +1066,7 @@ template struct variant_base_impl template void emplace( A&&... a ) { - size_t const J = I+1; + std::size_t const J = I+1; using U = mp11::mp_at_c, I>; @@ -1182,7 +1182,7 @@ template struct variant_base_impl { BOOST_ASSERT( index() == I ); - size_t const J = I+1; + std::size_t const J = I+1; constexpr mp11::mp_size_t j{}; return storage( ix_ & 1 ).get( j ); @@ -1192,7 +1192,7 @@ template struct variant_base_impl { BOOST_VARIANT2_CX14_ASSERT( index() == I ) - // size_t const J = I+1; + // std::size_t const J = I+1; // constexpr mp_size_t j{}; return storage( ix_ & 1 ).get( mp11::mp_size_t() ); @@ -1200,7 +1200,7 @@ template struct variant_base_impl template void emplace( A&&... a ) { - size_t const J = I+1; + std::size_t const J = I+1; unsigned i2 = 1 - ( ix_ & 1 ); From 306a602d193065f9ef8141895f8ddf6faa19b71f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 21 Dec 2024 19:01:18 +0200 Subject: [PATCH 65/91] Compute the index type with a metafunction. Refs #50. --- include/boost/variant2/variant.hpp | 39 ++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 9a1de15..6315832 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -26,6 +26,7 @@ #include #include #include +#include // @@ -845,6 +846,10 @@ template using resolve_overload_type = typename decltype( o template using resolve_overload_index = mp11::mp_find, resolve_overload_type>; +// index_type + +template using get_index_type = unsigned; + // variant_base template struct variant_base_impl; @@ -855,8 +860,10 @@ struct none {}; // trivially destructible, single buffered template struct variant_base_impl { + using index_type = get_index_type; + variant_storage st_; - unsigned ix_; + index_type ix_; constexpr variant_base_impl(): st_( mp11::mp_size_t<0>() ), ix_( 0 ) { @@ -870,6 +877,8 @@ template struct variant_base_impl template void _replace( I, A&&... a ) { ::new( &st_ ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); + + static_assert( I::value + 1 <= (std::numeric_limits::max)(), "" ); ix_ = I::value + 1; } @@ -901,6 +910,8 @@ template struct variant_base_impl static_assert( std::is_nothrow_constructible::value, "Logic error: U must be nothrow constructible from A&&..." ); st_.emplace( mp11::mp_size_t(), std::forward(a)... ); + + static_assert( J <= (std::numeric_limits::max)(), "" ); ix_ = J; } @@ -911,6 +922,8 @@ template struct variant_base_impl U tmp( std::forward(a)... ); st_.emplace( mp11::mp_size_t(), std::move(tmp) ); + + static_assert( J <= (std::numeric_limits::max)(), "" ); ix_ = J; } @@ -931,8 +944,10 @@ template struct variant_base_impl // trivially destructible, double buffered template struct variant_base_impl { + using index_type = get_index_type; + variant_storage st_[ 2 ]; - unsigned ix_; + index_type ix_; constexpr variant_base_impl(): st_{ { mp11::mp_size_t<0>() }, { mp11::mp_size_t<0>() } }, ix_( 0 ) { @@ -946,6 +961,8 @@ template struct variant_base_impl template void _replace( I, A&&... a ) { ::new( &st_[ 0 ] ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); + + static_assert( ( I::value + 1 ) * 2 <= (std::numeric_limits::max)(), "" ); ix_ = ( I::value + 1 ) * 2; } @@ -982,6 +999,7 @@ template struct variant_base_impl st_[ i2 ].emplace( mp11::mp_size_t(), std::forward(a)... ); + static_assert( J * 2 + 1 <= (std::numeric_limits::max)(), "" ); ix_ = J * 2 + i2; } @@ -994,8 +1012,10 @@ template struct variant_base_impl // not trivially destructible, single buffered template struct variant_base_impl { + using index_type = get_index_type; + variant_storage st_; - unsigned ix_; + index_type ix_; constexpr variant_base_impl(): st_( mp11::mp_size_t<0>() ), ix_( 0 ) { @@ -1009,6 +1029,8 @@ template struct variant_base_impl template void _replace( I, A&&... a ) { ::new( &st_ ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); + + static_assert( I::value + 1 <= (std::numeric_limits::max)(), "" ); ix_ = I::value + 1; } @@ -1077,6 +1099,8 @@ template struct variant_base_impl _destroy(); st_.emplace( mp11::mp_size_t(), std::move(tmp) ); + + static_assert( J <= (std::numeric_limits::max)(), "" ); ix_ = J; } @@ -1089,12 +1113,14 @@ template struct variant_base_impl // not trivially destructible, double buffered template struct variant_base_impl { + using index_type = get_index_type; + #if defined(__GNUC__) && __GNUC__ < 11 && !defined(__clang__) && !defined(__INTEL_COMPILER) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63707 :-( variant_storage st1_, st2_; - unsigned ix_; + index_type ix_; constexpr variant_base_impl(): st1_( mp11::mp_size_t<0>() ), st2_( mp11::mp_size_t<0>() ), ix_( 0 ) { @@ -1117,7 +1143,7 @@ template struct variant_base_impl #else variant_storage st_[ 2 ]; - unsigned ix_; + index_type ix_; constexpr variant_base_impl(): st_{ { mp11::mp_size_t<0>() }, { mp11::mp_size_t<0>() } }, ix_( 0 ) { @@ -1143,6 +1169,8 @@ template struct variant_base_impl template void _replace( I, A&&... a ) { ::new( &storage( 0 ) ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); + + static_assert( ( I::value + 1 ) * 2 <= (std::numeric_limits::max)(), "" ); ix_ = ( I::value + 1 ) * 2; } @@ -1207,6 +1235,7 @@ template struct variant_base_impl storage( i2 ).emplace( mp11::mp_size_t(), std::forward(a)... ); _destroy(); + static_assert( J * 2 + 1 <= (std::numeric_limits::max)(), "" ); ix_ = J * 2 + i2; } From e2fc107ac7034cc29f8ae63bc9e66cd9d150d456 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 21 Dec 2024 20:15:45 +0200 Subject: [PATCH 66/91] Add test/variant_index_type.cpp. Refs #50. --- test/Jamfile | 2 + test/variant_index_type.cpp | 92 +++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 test/variant_index_type.cpp diff --git a/test/Jamfile b/test/Jamfile index 4a5f6fe..6939dd5 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -143,3 +143,5 @@ run variant_derived_construct2.cpp ; compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_cx_2.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; + +run variant_index_type.cpp : : : release ; diff --git a/test/variant_index_type.cpp b/test/variant_index_type.cpp new file mode 100644 index 0000000..94a532e --- /dev/null +++ b/test/variant_index_type.cpp @@ -0,0 +1,92 @@ +// Copyright 2024 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if defined(_MSC_VER) +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include +#include +#include + +using namespace boost::mp11; + +template struct X +{ +}; + +template using Xf = X< N::value >; + +template struct Y +{ + Y() = default; + Y( Y&& ) {} +}; + +template using Yf = Y< N::value >; + +template struct Z +{ + ~Z() {} +}; + +template using Zf = Z< N::value >; + +template struct W +{ + ~W() {} + + W() = default; + W( W&& ) {} +}; + +template using Wf = W< N::value >; + +template class F, std::size_t N> void test_() +{ + using V = mp_rename< mp_transform>, boost::variant2::variant >; + + { + V v( mp_back{} ); + BOOST_TEST_EQ( v.index(), mp_size() - 1 ); + } + + { + V v; + BOOST_TEST_EQ( v.index(), 0 ); + + v.template emplace< mp_back >(); + BOOST_TEST_EQ( v.index(), mp_size() - 1 ); + } +} + +template class F> void test() +{ + test_(); + test_(); + test_(); + test_(); + + test_(); + test_(); + test_(); + test_(); +} + +int main() +{ + static_assert( !boost::variant2::variant< X<0>, X<1> >::uses_double_storage(), "" ); + test(); + + static_assert( boost::variant2::variant< Y<0>, Y<1> >::uses_double_storage(), "" ); + test(); + + static_assert( !boost::variant2::variant< Z<0>, Z<1> >::uses_double_storage(), "" ); + test(); + + static_assert( boost::variant2::variant< W<0>, W<1> >::uses_double_storage(), "" ); + test(); + + return boost::report_errors(); +} From 94749d088d3f98a018d9ecb6afabed5f502ef0c3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 02:44:02 +0200 Subject: [PATCH 67/91] Disable variant_index_type.cpp for MSVC 32 bit --- test/Jamfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile b/test/Jamfile index 6939dd5..61fdff6 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -144,4 +144,4 @@ compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_cx_2.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; -run variant_index_type.cpp : : : release ; +run variant_index_type.cpp : : : release msvc,32:no ; From 639bd0232b4d5926ab9b15a99e04efe27a0ffdb2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 02:55:45 +0200 Subject: [PATCH 68/91] Add -ftemplate-depth=1024 for Clang (3.x needs it) --- test/Jamfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Jamfile b/test/Jamfile index 61fdff6..b707723 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -144,4 +144,8 @@ compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_cx_2.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; -run variant_index_type.cpp : : : release msvc,32:no ; +run variant_index_type.cpp : : : + release + msvc,32:no + clang:-ftemplate-depth=1024 +; From 2f5dbc19b5d6e082551d2252a82de834a288e04e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 02:56:30 +0200 Subject: [PATCH 69/91] Remove cxxstd=1z for Clang 5.0 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a77fa6..d687555 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: install: clang-4.0 - toolset: clang compiler: clang++-5.0 - cxxstd: "11,14,1z" + cxxstd: "11,14" container: ubuntu:18.04 os: ubuntu-latest install: clang-5.0 From 7b8e8c33bbc0d6783404447d1680773e7b4795e8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 03:09:28 +0200 Subject: [PATCH 70/91] Disable variant_index_type.cpp for msvc-14.0, because GHA fails with 'out of heap space' --- test/Jamfile | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Jamfile b/test/Jamfile index b707723..a2e228d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -147,5 +147,6 @@ compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; run variant_index_type.cpp : : : release msvc,32:no + msvc-14.0:no # fails on GHA (only) with "out of heap space" clang:-ftemplate-depth=1024 ; From 7c64abd41cb5c6f6b874ee30439c4822b228986d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 03:16:12 +0200 Subject: [PATCH 71/91] Remove clang-5.0/cxxstd=1z from Drone as well --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index b102569..656120f 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -258,7 +258,7 @@ local windows_pipeline(name, image, environment, arch = "amd64") = linux_pipeline( "Linux 18.04 Clang 5.0", "cppalliance/droneubuntu1804:1", - { TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '11,14,1z' }, + { TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '11,14' }, "clang-5.0", ), From 183aea23a9692cde33162a9dff267331c0ed5509 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 03:20:39 +0200 Subject: [PATCH 72/91] Only use -ftemplate-depth for Clang on Linux, because clang-cl doesn't like it (and Mac doesn't need it) --- test/Jamfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile b/test/Jamfile index a2e228d..d99094e 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -148,5 +148,5 @@ run variant_index_type.cpp : : : release msvc,32:no msvc-14.0:no # fails on GHA (only) with "out of heap space" - clang:-ftemplate-depth=1024 + clang,linux:-ftemplate-depth=1024 # for Clang 3.x ; From 8f6918554e40337aedaa27f1e884e9534e9c9535 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 04:31:47 +0200 Subject: [PATCH 73/91] Use -j2 on GHA and Appveyor to avoid MSVC out of heap errors --- .github/workflows/ci.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d687555..0753bc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -298,7 +298,7 @@ jobs: shell: cmd run: | cd ../boost-root - b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker + b2 -j2 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker posix-cmake-subdir: strategy: diff --git a/appveyor.yml b/appveyor.yml index 5e26b78..382121c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,7 +59,7 @@ test_script: - if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% - if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD% - if not "%CXXFLAGS%" == "" set CXXFLAGS=cxxflags=%CXXFLAGS% - - if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j3 libs/variant2/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %CXXFLAGS% variant=debug,release embed-manifest-via=linker + - if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j2 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 .. From d77d61c8ecd5573a4815524de305e470e31f1c14 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 04:52:07 +0200 Subject: [PATCH 74/91] Avoid use of mp_back in variant_index_type.cpp --- test/variant_index_type.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/variant_index_type.cpp b/test/variant_index_type.cpp index 94a532e..ebe76b1 100644 --- a/test/variant_index_type.cpp +++ b/test/variant_index_type.cpp @@ -47,17 +47,19 @@ template class F, std::size_t N> void test_() { using V = mp_rename< mp_transform>, boost::variant2::variant >; + using last_type = F>; + { - V v( mp_back{} ); - BOOST_TEST_EQ( v.index(), mp_size() - 1 ); + V v( last_type{} ); + BOOST_TEST_EQ( v.index(), N-1 ); } { V v; BOOST_TEST_EQ( v.index(), 0 ); - v.template emplace< mp_back >(); - BOOST_TEST_EQ( v.index(), mp_size() - 1 ); + v.template emplace(); + BOOST_TEST_EQ( v.index(), N-1 ); } } From 010c78598e8c1f18818da10c9f669800cc5f9cb0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 06:03:10 +0200 Subject: [PATCH 75/91] Split variant_index_type into separate runs for each variant size --- test/Jamfile | 11 +++++++++-- test/variant_index_type.cpp | 30 +++++++++++------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index d99094e..537543c 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -144,9 +144,16 @@ compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_cx_2.cpp : [ requires cxx14_constexpr ] ; compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ; -run variant_index_type.cpp : : : +local index-type-reqs = + release msvc,32:no - msvc-14.0:no # fails on GHA (only) with "out of heap space" clang,linux:-ftemplate-depth=1024 # for Clang 3.x ; + +local list-sizes = 126 127 128 129 254 255 256 257 ; + +for local list-size in $(list-sizes) +{ + run variant_index_type.cpp : : : $(index-type-reqs) LIST_SIZE=$(list-size) : variant_index_type_$(list-size) ; +} diff --git a/test/variant_index_type.cpp b/test/variant_index_type.cpp index ebe76b1..5e123ad 100644 --- a/test/variant_index_type.cpp +++ b/test/variant_index_type.cpp @@ -43,9 +43,11 @@ template struct W template using Wf = W< N::value >; -template class F, std::size_t N> void test_() +template class F> void test() { - using V = mp_rename< mp_transform>, boost::variant2::variant >; + using V = mp_rename< mp_transform, boost::variant2::variant >; + + constexpr std::size_t N = mp_size::value; using last_type = F>; @@ -63,32 +65,22 @@ template class F, std::size_t N> void test_() } } -template class F> void test() -{ - test_(); - test_(); - test_(); - test_(); - - test_(); - test_(); - test_(); - test_(); -} - int main() { + constexpr std::size_t N = LIST_SIZE; + using L = mp_iota_c; + static_assert( !boost::variant2::variant< X<0>, X<1> >::uses_double_storage(), "" ); - test(); + test(); static_assert( boost::variant2::variant< Y<0>, Y<1> >::uses_double_storage(), "" ); - test(); + test(); static_assert( !boost::variant2::variant< Z<0>, Z<1> >::uses_double_storage(), "" ); - test(); + test(); static_assert( boost::variant2::variant< W<0>, W<1> >::uses_double_storage(), "" ); - test(); + test(); return boost::report_errors(); } From 2630b3e57253e8e45a6dcbddb8d1d1d73ce3215b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 19:09:05 +0200 Subject: [PATCH 76/91] Use the smallest appropriate unsigned type for the index. Closes #50. --- include/boost/variant2/variant.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 6315832..311d83b 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -848,7 +848,15 @@ template using resolve_overload_index = mp11::mp_find using get_index_type = unsigned; +template using get_smallest_unsigned_type = mp11::mp_cond< + + mp11::mp_bool< N <= (std::numeric_limits::max)() >, unsigned char, + mp11::mp_bool< N <= (std::numeric_limits::max)() >, unsigned short, + mp11::mp_true, unsigned + +>; + +template using get_index_type = get_smallest_unsigned_type< (Double + 1) * sizeof...(T) >; // variant_base @@ -1000,7 +1008,7 @@ template struct variant_base_impl st_[ i2 ].emplace( mp11::mp_size_t(), std::forward(a)... ); static_assert( J * 2 + 1 <= (std::numeric_limits::max)(), "" ); - ix_ = J * 2 + i2; + ix_ = static_cast( J * 2 + i2 ); } static constexpr bool uses_double_storage() noexcept @@ -1193,7 +1201,7 @@ template struct variant_base_impl void _destroy() noexcept { - mp11::mp_with_index<1 + sizeof...(T)>( ix_ / 2, _destroy_L1{ this, ix_ & 1 } ); + mp11::mp_with_index<1 + sizeof...(T)>( ix_ / 2, _destroy_L1{ this, static_cast( ix_ & 1 ) } ); } ~variant_base_impl() noexcept @@ -1236,7 +1244,7 @@ template struct variant_base_impl _destroy(); static_assert( J * 2 + 1 <= (std::numeric_limits::max)(), "" ); - ix_ = J * 2 + i2; + ix_ = static_cast( J * 2 + i2 ); } static constexpr bool uses_double_storage() noexcept From df84f1f14691d8d22247d7d6d13f0b07205dabd5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 20:10:16 +0200 Subject: [PATCH 77/91] Work around Clang 3.x failures --- include/boost/variant2/variant.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index 311d83b..ed36b26 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -856,8 +856,16 @@ template using get_smallest_unsigned_type = mp11::mp_cond< >; +#if BOOST_WORKAROUND( BOOST_CLANG_VERSION, < 30800 ) + +template using get_index_type = unsigned short; + +#else + template using get_index_type = get_smallest_unsigned_type< (Double + 1) * sizeof...(T) >; +#endif + // variant_base template struct variant_base_impl; From 6669e070715861062fb80964c3c95b6d609f902c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Dec 2024 20:12:08 +0200 Subject: [PATCH 78/91] Work around GCC 5, 6 failures --- test/Jamfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index 537543c..0172afc 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -60,10 +60,10 @@ run variant_in_place_type_construct.cpp ; compile variant_in_place_type_construct_cx.cpp : msvc-14.0:no ; run variant_copy_assign.cpp ; -compile variant_copy_assign_cx.cpp : [ requires cxx14_constexpr ] ; +compile variant_copy_assign_cx.cpp : [ requires cxx14_constexpr ] gcc-5:no gcc-6:no ; run variant_move_assign.cpp ; -compile variant_move_assign_cx.cpp : [ requires cxx14_constexpr ] ; +compile variant_move_assign_cx.cpp : [ requires cxx14_constexpr ] gcc-5:no gcc-6:no ; run variant_value_assign.cpp ; compile variant_value_assign_cx.cpp : [ requires cxx14_constexpr ] ; From 8caa1a34843951b9e4e302dc85e90bc19ca4f3dd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 15 Jan 2025 19:44:18 +0200 Subject: [PATCH 79/91] Update revision history --- doc/variant2/changelog.adoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc index fc14105..9080c21 100644 --- a/doc/variant2/changelog.adoc +++ b/doc/variant2/changelog.adoc @@ -1,5 +1,5 @@ //// -Copyright 2019-2022 Peter Dimov +Copyright 2019-2025 Peter Dimov Distributed under the Boost Software License, Version 1.0. https://www.boost.org/LICENSE_1_0.txt //// @@ -8,6 +8,10 @@ https://www.boost.org/LICENSE_1_0.txt # Revision History :idprefix: changelog_ +## Changes in 1.88.0 + +* Use the smallest appropriate unsigned type for the index. + ## Changes in 1.83.0 * Added `uses_double_storage()`. From 28d23c14f6b4f226f7830f10e5ae8134b0e8004c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 Oct 2025 21:04:45 +0300 Subject: [PATCH 80/91] Update ci.yml --- .github/workflows/ci.yml | 71 ++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0753bc9..2010163 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,22 +43,27 @@ jobs: os: ubuntu-latest - toolset: gcc-8 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: g++-8 - toolset: gcc-9 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest - toolset: gcc-10 cxxstd: "11,14,17,2a" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: g++-10 - toolset: gcc-11 cxxstd: "11,14,17,2a" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: g++-11 - toolset: gcc-12 cxxstd: "11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: g++-12 - toolset: gcc-13 cxxstd: "11,14,17,20,2b" @@ -70,6 +75,11 @@ jobs: container: ubuntu:24.04 os: ubuntu-latest install: g++-14 + - toolset: gcc-15 + cxxstd: "11,14,17,20,23,2c" + container: ubuntu:25.04 + os: ubuntu-latest + install: g++-15 - toolset: clang compiler: clang++-3.9 cxxstd: "11,14" @@ -91,37 +101,44 @@ jobs: - toolset: clang compiler: clang++-6.0 cxxstd: "11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-6.0 - toolset: clang compiler: clang++-7 cxxstd: "11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-7 - toolset: clang compiler: clang++-8 cxxstd: "11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-8 - toolset: clang compiler: clang++-9 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-9 - toolset: clang compiler: clang++-10 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-10 - toolset: clang compiler: clang++-11 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-11 - toolset: clang compiler: clang++-12 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-12 - toolset: clang compiler: clang++-13 @@ -162,9 +179,15 @@ jobs: - toolset: clang compiler: clang++-19 cxxstd: "11,14,17,20,2b" - container: ubuntu:24.10 + container: ubuntu:24.04 os: ubuntu-latest install: clang-19 + - toolset: clang + compiler: clang++-20 + cxxstd: "11,14,17,20,23,2c" + container: ubuntu:25.04 + os: ubuntu-latest + install: clang-20 - toolset: clang cxxstd: "11,14,17,20,2b" os: macos-13 @@ -246,14 +269,6 @@ jobs: fail-fast: false matrix: include: - - toolset: msvc-14.0 - cxxstd: "14,latest" - addrmd: 32,64 - os: windows-2019 - - toolset: msvc-14.2 - cxxstd: "14,17,20,latest" - addrmd: 32,64 - os: windows-2019 - toolset: msvc-14.3 cxxstd: "14,17,20,latest" addrmd: 32,64 @@ -265,7 +280,7 @@ jobs: - toolset: gcc cxxstd: "11,14,17,2a" addrmd: 64 - os: windows-2019 + os: windows-2022 runs-on: ${{matrix.os}} @@ -305,7 +320,6 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - os: ubuntu-22.04 - os: ubuntu-24.04 - os: macos-13 @@ -354,7 +368,6 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - os: ubuntu-22.04 - os: ubuntu-24.04 - os: macos-13 @@ -413,7 +426,6 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - os: ubuntu-22.04 - os: ubuntu-24.04 - os: macos-13 @@ -470,8 +482,7 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - - os: windows-2022 + - os: windows-latest runs-on: ${{matrix.os}} @@ -519,8 +530,7 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - - os: windows-2022 + - os: windows-latest runs-on: ${{matrix.os}} @@ -586,8 +596,7 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - - os: windows-2022 + - os: windows-latest runs-on: ${{matrix.os}} From e708866c6564ea69dd014f3639b45fa64af6f3f7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 Oct 2025 22:24:26 +0300 Subject: [PATCH 81/91] Add more constexpr. Refs #53. --- include/boost/variant2/variant.hpp | 121 ++++++++++++++++------------- 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/include/boost/variant2/variant.hpp b/include/boost/variant2/variant.hpp index ed36b26..fe93a78 100644 --- a/include/boost/variant2/variant.hpp +++ b/include/boost/variant2/variant.hpp @@ -30,6 +30,15 @@ // +// constexpr destructors +#if defined(__cpp_constexpr_dynamic_alloc) && __cpp_constexpr_dynamic_alloc >= 201907L +# define BOOST_VARIANT2_CXX20_CONSTEXPR constexpr +#else +# define BOOST_VARIANT2_CXX20_CONSTEXPR +#endif + +// + namespace boost { @@ -557,16 +566,16 @@ template union variant_storage_impl void emplace( mp11::mp_size_t<0>, A&&... a ) + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<0>, A&&... a ) { ::new( &first_ ) T1( std::forward(a)... ); } - template void emplace( mp11::mp_size_t, A&&... a ) + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t, A&&... a ) { rest_.emplace( mp11::mp_size_t(), std::forward(a)... ); } @@ -606,22 +615,22 @@ template constexpr variant_storage_impl( mp11::mp_size_t, A&&... a ): rest_( mp11::mp_size_t(), std::forward(a)... ) {} - ~variant_storage_impl() + BOOST_VARIANT2_CXX20_CONSTEXPR ~variant_storage_impl() { } - template void emplace( mp11::mp_size_t<0>, A&&... a ) { ::new( &t0_ ) T0( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<1>, A&&... a ) { ::new( &t1_ ) T1( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<2>, A&&... a ) { ::new( &t2_ ) T2( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<3>, A&&... a ) { ::new( &t3_ ) T3( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<4>, A&&... a ) { ::new( &t4_ ) T4( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<5>, A&&... a ) { ::new( &t5_ ) T5( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<6>, A&&... a ) { ::new( &t6_ ) T6( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<7>, A&&... a ) { ::new( &t7_ ) T7( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<8>, A&&... a ) { ::new( &t8_ ) T8( std::forward(a)... ); } - template void emplace( mp11::mp_size_t<9>, A&&... a ) { ::new( &t9_ ) T9( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<0>, A&&... a ) { ::new( &t0_ ) T0( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<1>, A&&... a ) { ::new( &t1_ ) T1( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<2>, A&&... a ) { ::new( &t2_ ) T2( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<3>, A&&... a ) { ::new( &t3_ ) T3( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<4>, A&&... a ) { ::new( &t4_ ) T4( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<5>, A&&... a ) { ::new( &t5_ ) T5( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<6>, A&&... a ) { ::new( &t6_ ) T6( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<7>, A&&... a ) { ::new( &t7_ ) T7( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<8>, A&&... a ) { ::new( &t8_ ) T8( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t<9>, A&&... a ) { ::new( &t9_ ) T9( std::forward(a)... ); } - template void emplace( mp11::mp_size_t, A&&... a ) + template BOOST_CXX14_CONSTEXPR void emplace( mp11::mp_size_t, A&&... a ) { rest_.emplace( mp11::mp_size_t(), std::forward(a)... ); } @@ -674,7 +683,7 @@ template union variant_storage_impl void emplace_impl( mp11::mp_false, mp11::mp_size_t<0>, A&&... a ) + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<0>, A&&... a ) { ::new( &first_ ) T1( std::forward(a)... ); } @@ -742,16 +751,16 @@ template constexpr variant_storage_impl( mp11::mp_size_t, A&&... a ): rest_( mp11::mp_size_t(), std::forward(a)... ) {} - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<0>, A&&... a ) { ::new( &t0_ ) T0( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<1>, A&&... a ) { ::new( &t1_ ) T1( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<2>, A&&... a ) { ::new( &t2_ ) T2( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<3>, A&&... a ) { ::new( &t3_ ) T3( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<4>, A&&... a ) { ::new( &t4_ ) T4( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<5>, A&&... a ) { ::new( &t5_ ) T5( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<6>, A&&... a ) { ::new( &t6_ ) T6( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<7>, A&&... a ) { ::new( &t7_ ) T7( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<8>, A&&... a ) { ::new( &t8_ ) T8( std::forward(a)... ); } - template void emplace_impl( mp11::mp_false, mp11::mp_size_t<9>, A&&... a ) { ::new( &t9_ ) T9( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<0>, A&&... a ) { ::new( &t0_ ) T0( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<1>, A&&... a ) { ::new( &t1_ ) T1( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<2>, A&&... a ) { ::new( &t2_ ) T2( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<3>, A&&... a ) { ::new( &t3_ ) T3( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<4>, A&&... a ) { ::new( &t4_ ) T4( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<5>, A&&... a ) { ::new( &t5_ ) T5( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<6>, A&&... a ) { ::new( &t6_ ) T6( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<7>, A&&... a ) { ::new( &t7_ ) T7( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<8>, A&&... a ) { ::new( &t8_ ) T8( std::forward(a)... ); } + template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t<9>, A&&... a ) { ::new( &t9_ ) T9( std::forward(a)... ); } template BOOST_CXX14_CONSTEXPR void emplace_impl( mp11::mp_false, mp11::mp_size_t, A&&... a ) { @@ -890,7 +899,7 @@ template struct variant_base_impl } // requires: ix_ == 0 - template void _replace( I, A&&... a ) + template BOOST_CXX14_CONSTEXPR void _replace( I, A&&... a ) { ::new( &st_ ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); @@ -974,7 +983,7 @@ template struct variant_base_impl } // requires: ix_ == 0 - template void _replace( I, A&&... a ) + template BOOST_CXX14_CONSTEXPR void _replace( I, A&&... a ) { ::new( &st_[ 0 ] ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); @@ -1042,7 +1051,7 @@ template struct variant_base_impl } // requires: ix_ == 0 - template void _replace( I, A&&... a ) + template BOOST_CXX14_CONSTEXPR void _replace( I, A&&... a ) { ::new( &st_ ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); @@ -1059,14 +1068,14 @@ template struct variant_base_impl { variant_base_impl * this_; - template void operator()( I ) const noexcept + template BOOST_CXX14_CONSTEXPR void operator()( I ) const noexcept { using U = mp11::mp_at, I>; this_->st_.get( I() ).~U(); } }; - void _destroy() noexcept + BOOST_CXX14_CONSTEXPR void _destroy() noexcept { if( ix_ > 0 ) { @@ -1074,7 +1083,7 @@ template struct variant_base_impl } } - ~variant_base_impl() noexcept + BOOST_VARIANT2_CXX20_CONSTEXPR ~variant_base_impl() noexcept { _destroy(); } @@ -1102,7 +1111,7 @@ template struct variant_base_impl return st_.get( mp11::mp_size_t() ); } - template void emplace( A&&... a ) + template BOOST_CXX14_CONSTEXPR void emplace( A&&... a ) { std::size_t const J = I+1; @@ -1182,7 +1191,7 @@ template struct variant_base_impl #endif // requires: ix_ == 0 - template void _replace( I, A&&... a ) + template BOOST_CXX14_CONSTEXPR void _replace( I, A&&... a ) { ::new( &storage( 0 ) ) variant_storage( mp11::mp_size_t(), std::forward(a)... ); @@ -1200,19 +1209,19 @@ template struct variant_base_impl variant_base_impl * this_; unsigned i2_; - template void operator()( I ) const noexcept + template BOOST_CXX14_CONSTEXPR void operator()( I ) const noexcept { using U = mp11::mp_at, I>; this_->storage( i2_ ).get( I() ).~U(); } }; - void _destroy() noexcept + BOOST_CXX14_CONSTEXPR void _destroy() noexcept { mp11::mp_with_index<1 + sizeof...(T)>( ix_ / 2, _destroy_L1{ this, static_cast( ix_ & 1 ) } ); } - ~variant_base_impl() noexcept + BOOST_VARIANT2_CXX20_CONSTEXPR ~variant_base_impl() noexcept { _destroy(); } @@ -1242,7 +1251,7 @@ template struct variant_base_impl return storage( ix_ & 1 ).get( mp11::mp_size_t() ); } - template void emplace( A&&... a ) + template BOOST_CXX14_CONSTEXPR void emplace( A&&... a ) { std::size_t const J = I+1; @@ -1403,7 +1412,7 @@ template struct variant_cc_base_impl: public vari variant_base * this_; variant_base const & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { this_->_replace( i, r._get_impl( i ) ); } @@ -1411,7 +1420,7 @@ template struct variant_cc_base_impl: public vari public: - variant_cc_base_impl( variant_cc_base_impl const& r ) + BOOST_CXX14_CONSTEXPR variant_cc_base_impl( variant_cc_base_impl const& r ) noexcept( mp11::mp_all...>::value ) : variant_base() { @@ -1483,7 +1492,7 @@ template struct variant_ca_base_impl: public vari variant_base * this_; variant_base const & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { this_->template emplace( r._get_impl( i ) ); } @@ -1557,7 +1566,7 @@ template struct variant_mc_base_impl: public vari variant_base * this_; variant_base & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { this_->_replace( i, std::move( r._get_impl( i ) ) ); } @@ -1565,7 +1574,7 @@ template struct variant_mc_base_impl: public vari public: - variant_mc_base_impl( variant_mc_base_impl && r ) + BOOST_CXX14_CONSTEXPR variant_mc_base_impl( variant_mc_base_impl && r ) noexcept( mp11::mp_all...>::value ) { mp11::mp_with_index( r.index(), L2{ this, r } ); @@ -1636,7 +1645,7 @@ template struct variant_ma_base_impl: public vari variant_base * this_; variant_base & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { this_->template emplace( std::move( r._get_impl( i ) ) ); } @@ -1644,7 +1653,7 @@ template struct variant_ma_base_impl: public vari public: - variant_ma_base_impl& operator=( variant_ma_base_impl && r ) + BOOST_CXX14_CONSTEXPR variant_ma_base_impl& operator=( variant_ma_base_impl && r ) noexcept( mp11::mp_all...>::value ) { mp11::mp_with_index( r.index(), L4{ this, r } ); @@ -1790,7 +1799,7 @@ template class variant: private detail::variant_ma_base variant * this_; variant & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { using std::swap; swap( this_->_get_impl( i ), r._get_impl( i ) ); @@ -1799,7 +1808,7 @@ template class variant: private detail::variant_ma_base public: - void swap( variant& r ) noexcept( mp11::mp_all..., detail::is_nothrow_swappable...>::value ) + BOOST_CXX14_CONSTEXPR void swap( variant& r ) noexcept( mp11::mp_all..., detail::is_nothrow_swappable...>::value ) { if( index() == r.index() ) { @@ -1826,7 +1835,7 @@ template class variant: private detail::variant_ma_base variant_base * this_; variant const & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { using J = mp11::mp_find, mp11::mp_at, I>>; this_->_replace( J{}, r._get_impl( i ) ); @@ -1837,7 +1846,7 @@ template class variant: private detail::variant_ma_base template..., mp11::mp_contains, U>...>, void> > - variant( variant const& r ) + BOOST_CXX14_CONSTEXPR variant( variant const& r ) noexcept( mp11::mp_all...>::value ) { mp11::mp_with_index( r.index(), L6{ this, r } ); @@ -1850,7 +1859,7 @@ template class variant: private detail::variant_ma_base variant_base * this_; variant & r; - template void operator()( I i ) const + template BOOST_CXX14_CONSTEXPR void operator()( I i ) const { using J = mp11::mp_find, mp11::mp_at, I>>; this_->_replace( J{}, std::move( r._get_impl( i ) ) ); @@ -1861,7 +1870,7 @@ template class variant: private detail::variant_ma_base template..., mp11::mp_contains, U>...>, void> > - variant( variant && r ) + BOOST_CXX14_CONSTEXPR variant( variant && r ) noexcept( mp11::mp_all...>::value ) { mp11::mp_with_index( r.index(), L7{ this, r } ); @@ -1887,7 +1896,7 @@ template class variant: private detail::variant_ma_base { variant * this_; - template variant operator()( I i ) const + template BOOST_CXX14_CONSTEXPR variant operator()( I i ) const { using J = mp11::mp_find, mp11::mp_at, I>>; return this_->_subset_impl( J{}, this_->_get_impl( i ) ); @@ -1909,7 +1918,7 @@ template class variant: private detail::variant_ma_base { variant const * this_; - template variant operator()( I i ) const + template BOOST_CXX14_CONSTEXPR variant operator()( I i ) const { using J = mp11::mp_find, mp11::mp_at, I>>; return this_->_subset_impl( J{}, this_->_get_impl( i ) ); @@ -1931,7 +1940,7 @@ template class variant: private detail::variant_ma_base { variant * this_; - template variant operator()( I i ) const + template BOOST_CXX14_CONSTEXPR variant operator()( I i ) const { using J = mp11::mp_find, mp11::mp_at, I>>; return this_->_subset_impl( J{}, std::move( this_->_get_impl( i ) ) ); @@ -1957,7 +1966,7 @@ template class variant: private detail::variant_ma_base { variant const * this_; - template variant operator()( I i ) const + template BOOST_CXX14_CONSTEXPR variant operator()( I i ) const { using J = mp11::mp_find, mp11::mp_at, I>>; return this_->_subset_impl( J{}, std::move( this_->_get_impl( i ) ) ); @@ -2293,7 +2302,7 @@ template con // specialized algorithms template..., detail::is_swappable...>::value>::type> -void swap( variant & v, variant & w ) +BOOST_CXX14_CONSTEXPR void swap( variant & v, variant & w ) noexcept( noexcept(v.swap(w)) ) { v.swap( w ); From df001efb54c1fcec6c4a5e6864eff10e5390f637 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 17 Oct 2025 22:55:25 +0300 Subject: [PATCH 82/91] Add test/variant_default_construct_cx_2. Refs #53. --- test/Jamfile | 2 ++ test/variant_default_construct_cx_2.cpp | 32 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/variant_default_construct_cx_2.cpp diff --git a/test/Jamfile b/test/Jamfile index 0172afc..57adf58 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -157,3 +157,5 @@ for local list-size in $(list-sizes) { run variant_index_type.cpp : : : $(index-type-reqs) LIST_SIZE=$(list-size) : variant_index_type_$(list-size) ; } + +compile variant_default_construct_cx_2.cpp ; diff --git a/test/variant_default_construct_cx_2.cpp b/test/variant_default_construct_cx_2.cpp new file mode 100644 index 0000000..9f11e6c --- /dev/null +++ b/test/variant_default_construct_cx_2.cpp @@ -0,0 +1,32 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X +{ + constexpr ~X() {} +}; + +int main() +{ + constexpr variant v; + + STATIC_ASSERT( v.index() == 0 ); + STATIC_ASSERT( get<0>(v) == 0 ); +} + +#endif From b2109dee2a6c7688bca081f7b5989a14630caf99 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 02:37:21 +0300 Subject: [PATCH 83/91] Add test/variant_default_construct_cx_3. Refs #53. --- test/Jamfile | 1 + test/variant_default_construct_cx_3.cpp | 32 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/variant_default_construct_cx_3.cpp diff --git a/test/Jamfile b/test/Jamfile index 57adf58..795f83b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -159,3 +159,4 @@ for local list-size in $(list-sizes) } compile variant_default_construct_cx_2.cpp ; +compile variant_default_construct_cx_3.cpp ; diff --git a/test/variant_default_construct_cx_3.cpp b/test/variant_default_construct_cx_3.cpp new file mode 100644 index 0000000..e750de4 --- /dev/null +++ b/test/variant_default_construct_cx_3.cpp @@ -0,0 +1,32 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X +{ + ~X() {} +}; + +int main() +{ + constexpr variant v; + + STATIC_ASSERT( v.index() == 0 ); + STATIC_ASSERT( get<0>(v) == 0 ); +} + +#endif From 2af2d02fce131b9a295c2cb4c0e600e550459bc5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 02:41:28 +0300 Subject: [PATCH 84/91] Add test/variant_default_construct_cx_4. Refs #53. --- test/Jamfile | 1 + test/variant_default_construct_cx_4.cpp | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/variant_default_construct_cx_4.cpp diff --git a/test/Jamfile b/test/Jamfile index 795f83b..73d7429 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -160,3 +160,4 @@ for local list-size in $(list-sizes) compile variant_default_construct_cx_2.cpp ; compile variant_default_construct_cx_3.cpp ; +compile variant_default_construct_cx_4.cpp ; diff --git a/test/variant_default_construct_cx_4.cpp b/test/variant_default_construct_cx_4.cpp new file mode 100644 index 0000000..e9e73f0 --- /dev/null +++ b/test/variant_default_construct_cx_4.cpp @@ -0,0 +1,28 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + constexpr variant v; + + STATIC_ASSERT( v.index() == 0 ); + STATIC_ASSERT( get<0>(v) == 0 ); +} + +#endif From 43377dcada92000e8bce92f1a35b71ff57f99659 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 02:49:29 +0300 Subject: [PATCH 85/91] Add test/variant_default_construct_cx_5. Refs #53. --- test/Jamfile | 1 + test/variant_default_construct_cx_5.cpp | 44 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/variant_default_construct_cx_5.cpp diff --git a/test/Jamfile b/test/Jamfile index 73d7429..cfacc6d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -161,3 +161,4 @@ for local list-size in $(list-sizes) compile variant_default_construct_cx_2.cpp ; compile variant_default_construct_cx_3.cpp ; compile variant_default_construct_cx_4.cpp ; +compile variant_default_construct_cx_5.cpp ; diff --git a/test/variant_default_construct_cx_5.cpp b/test/variant_default_construct_cx_5.cpp new file mode 100644 index 0000000..24affd0 --- /dev/null +++ b/test/variant_default_construct_cx_5.cpp @@ -0,0 +1,44 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#elif defined(BOOST_MSVC) && BOOST_MSVC < 1950 + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because BOOST_MSVC < 1950") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X +{ +}; + +struct Y +{ + constexpr ~Y() {} +}; + +struct Z +{ + ~Z() {} +}; + +int main() +{ + constexpr variant v; + STATIC_ASSERT( v.index() == 0 ); +} + +#endif From 9d913eb1a00da478e536a79a2b5492fe6dae4925 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 03:01:19 +0300 Subject: [PATCH 86/91] Disable variant_default_construct_cx_3 on Clang < 18; earlier versions complain that the type isn't literal. --- test/variant_default_construct_cx_3.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/variant_default_construct_cx_3.cpp b/test/variant_default_construct_cx_3.cpp index e750de4..b540b3c 100644 --- a/test/variant_default_construct_cx_3.cpp +++ b/test/variant_default_construct_cx_3.cpp @@ -10,6 +10,11 @@ BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L") int main() {} +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 180000 + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because BOOST_CLANG_VERSION < 180000") +int main() {} + #else using namespace boost::variant2; From 5661f2ba15cc561dfb5c3a794cf1d88a19828f93 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 03:12:52 +0300 Subject: [PATCH 87/91] Disable variant_default_construct_cx_4, _5 on Clang < 18 as well --- test/variant_default_construct_cx_4.cpp | 5 +++++ test/variant_default_construct_cx_5.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/variant_default_construct_cx_4.cpp b/test/variant_default_construct_cx_4.cpp index e9e73f0..08efd12 100644 --- a/test/variant_default_construct_cx_4.cpp +++ b/test/variant_default_construct_cx_4.cpp @@ -11,6 +11,11 @@ BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because __cpp_constexpr_dynamic_alloc < 201907L") int main() {} +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 180000 + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because BOOST_CLANG_VERSION < 180000") +int main() {} + #else using namespace boost::variant2; diff --git a/test/variant_default_construct_cx_5.cpp b/test/variant_default_construct_cx_5.cpp index 24affd0..50408b1 100644 --- a/test/variant_default_construct_cx_5.cpp +++ b/test/variant_default_construct_cx_5.cpp @@ -15,6 +15,11 @@ int main() {} BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because BOOST_MSVC < 1950") int main() {} +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 180000 + +BOOST_PRAGMA_MESSAGE("Skipping constexpr destructor test because BOOST_CLANG_VERSION < 180000") +int main() {} + #else using namespace boost::variant2; From a63b03286e3347f9d570f2b75d480f129cec8ecc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 08:24:39 +0300 Subject: [PATCH 88/91] Add test/variant_value_construct_cx_2, 3, 4. Refs #53. --- test/Jamfile | 4 ++ test/variant_value_construct_cx_2.cpp | 32 +++++++++++++++ test/variant_value_construct_cx_3.cpp | 37 ++++++++++++++++++ test/variant_value_construct_cx_4.cpp | 56 +++++++++++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 test/variant_value_construct_cx_2.cpp create mode 100644 test/variant_value_construct_cx_3.cpp create mode 100644 test/variant_value_construct_cx_4.cpp diff --git a/test/Jamfile b/test/Jamfile index cfacc6d..344e1d0 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -162,3 +162,7 @@ compile variant_default_construct_cx_2.cpp ; compile variant_default_construct_cx_3.cpp ; compile variant_default_construct_cx_4.cpp ; compile variant_default_construct_cx_5.cpp ; + +compile variant_value_construct_cx_2.cpp ; +compile variant_value_construct_cx_3.cpp ; +compile variant_value_construct_cx_4.cpp ; diff --git a/test/variant_value_construct_cx_2.cpp b/test/variant_value_construct_cx_2.cpp new file mode 100644 index 0000000..ef6cbee --- /dev/null +++ b/test/variant_value_construct_cx_2.cpp @@ -0,0 +1,32 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X +{ + constexpr ~X() {} +}; + +int main() +{ + constexpr variant v( 5 ); + + STATIC_ASSERT( v.index() == 1 ); + STATIC_ASSERT( get<1>(v) == 5 ); +} + +#endif diff --git a/test/variant_value_construct_cx_3.cpp b/test/variant_value_construct_cx_3.cpp new file mode 100644 index 0000000..4025a8b --- /dev/null +++ b/test/variant_value_construct_cx_3.cpp @@ -0,0 +1,37 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 180000 + +BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_CLANG_VERSION < 180000") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X +{ + ~X() {} +}; + +int main() +{ + constexpr variant v( 5 ); + + STATIC_ASSERT( v.index() == 1 ); + STATIC_ASSERT( get<1>(v) == 5 ); +} + +#endif diff --git a/test/variant_value_construct_cx_4.cpp b/test/variant_value_construct_cx_4.cpp new file mode 100644 index 0000000..337baf0 --- /dev/null +++ b/test/variant_value_construct_cx_4.cpp @@ -0,0 +1,56 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +#if !defined(__cpp_constexpr_dynamic_alloc) || __cpp_constexpr_dynamic_alloc < 201907L + +BOOST_PRAGMA_MESSAGE("Skipping test because __cpp_constexpr_dynamic_alloc < 201907L") +int main() {} + +#elif defined(BOOST_MSVC) && BOOST_MSVC < 1950 + +BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_MSVC < 1950") +int main() {} + +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 180000 + +BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_CLANG_VERSION < 180000") +int main() {} + +#else + +using namespace boost::variant2; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct X +{ +}; + +struct Y +{ + constexpr ~Y() {} +}; + +struct Z +{ + ~Z() {} +}; + +int main() +{ + { + constexpr variant v( X{} ); + STATIC_ASSERT( v.index() == 0 ); + } + + { + constexpr variant v( Y{} ); + STATIC_ASSERT( v.index() == 1 ); + } +} + +#endif From b9d0499a8f1fbb29df3de4019a5b8265bb0cbb41 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 18 Oct 2025 20:23:49 +0300 Subject: [PATCH 89/91] BOOST_TEST_THROWS requires a semicolon after https://github.com/boostorg/core/pull/205 --- test/variant_copy_assign_throw.cpp | 2 +- test/variant_move_assign_throw.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/variant_copy_assign_throw.cpp b/test/variant_copy_assign_throw.cpp index a13dccb..2a96647 100644 --- a/test/variant_copy_assign_throw.cpp +++ b/test/variant_copy_assign_throw.cpp @@ -45,7 +45,7 @@ void test() variant v1( in_place_type_t{} ); variant v2( in_place_type_t{} ); - BOOST_TEST_THROWS( v1 = v2, std::runtime_error ) + BOOST_TEST_THROWS( v1 = v2, std::runtime_error ); } int main() diff --git a/test/variant_move_assign_throw.cpp b/test/variant_move_assign_throw.cpp index c1df594..1d72e48 100644 --- a/test/variant_move_assign_throw.cpp +++ b/test/variant_move_assign_throw.cpp @@ -45,7 +45,7 @@ void test() variant v1( in_place_type_t{} ); variant v2( in_place_type_t{} ); - BOOST_TEST_THROWS( v1 = std::move( v2 ), std::runtime_error ) + BOOST_TEST_THROWS( v1 = std::move( v2 ), std::runtime_error ); } int main() From edf1c7925b84748e075afa8fa3829ea2bfd9da62 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 19 Oct 2025 21:07:20 +0300 Subject: [PATCH 90/91] Correct CMake version check; VERSION_GREATER 3.18 is true for 3.18.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index def59e9..3155701 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ target_link_libraries(boost_variant2 Boost::mp11 ) -if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio") +if(NOT CMAKE_VERSION VERSION_LESS 3.19 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") From f267609ad6f5dac4aa2d664d613701b50ede0404 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 22 Oct 2025 21:03:21 +0300 Subject: [PATCH 91/91] Update revision history --- doc/variant2/changelog.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc index 9080c21..e16daa2 100644 --- a/doc/variant2/changelog.adoc +++ b/doc/variant2/changelog.adoc @@ -8,6 +8,11 @@ https://www.boost.org/LICENSE_1_0.txt # Revision History :idprefix: changelog_ +## Changes in 1.90.0 + +* More functions have been marked as `constexpr`, including `~variant`. + This didn't matter before {cpp}20, but does now. + ## Changes in 1.88.0 * Use the smallest appropriate unsigned type for the index.