mirror of
https://github.com/boostorg/serialization.git
synced 2026-07-21 13:33:32 +00:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 91c265be64 | |||
| 863528b341 | |||
| 9030e357d9 | |||
| 47b7f7297d | |||
| acc30bc8a0 | |||
| 8322195a39 | |||
| ddc98ca384 | |||
| a842484cd3 | |||
| 097a6c63a1 | |||
| 635c447262 | |||
| 8a8c62864f | |||
| 03f542ab4e | |||
| 36f1ea6374 | |||
| aaaa80d148 | |||
| 6e84870afd | |||
| 3fa840faa7 | |||
| 2a33d54843 | |||
| 0c53f8e5bd | |||
| 38a3cd5420 | |||
| 9d9b0f4cfa | |||
| caa3806dcb | |||
| a08d9d54cc | |||
| 58c43bc283 | |||
| 1209707581 | |||
| 4310637105 | |||
| ab0b5d6154 | |||
| 46165e3514 | |||
| 2a29731838 | |||
| d8e072a78d | |||
| 098bcad5d5 | |||
| 6b64c89e2b | |||
| a32906b8e6 | |||
| 2e54522f1a | |||
| 2e044c7384 | |||
| d52537a5ad | |||
| f3a9811740 | |||
| 2805bc3faa | |||
| a20c4d97c3 | |||
| 9aa208d9be | |||
| ff0a5f9f4a | |||
| e01b988e70 | |||
| e4756b71b5 | |||
| f3eaf91ca1 | |||
| a2f93247e2 | |||
| 01c26ba107 | |||
| 404e0a31ae | |||
| 90e3ce2fb9 | |||
| 897dec4c01 | |||
| f28482232d | |||
| 6388138a0c | |||
| 8d0fbb79f3 | |||
| 61a2b12076 | |||
| 5ba9e77ad6 | |||
| 74c46ec43c | |||
| 1af820b02e | |||
| cb729f5d88 | |||
| ae305113ff | |||
| c241d3485c | |||
| 9cd8257b08 | |||
| 030b627dce | |||
| 14b10185de | |||
| 0e15a5984b | |||
| dfe5c018f8 | |||
| 52bcaffa8c | |||
| 48a60a2bbb | |||
| b83e440efe | |||
| 6bf961f31e | |||
| 97f7767505 | |||
| 2bbb0577a9 | |||
| f19034cc9e | |||
| aa4b6422db | |||
| 2dbe7b8005 | |||
| 1a13d6e552 | |||
| f914a185c3 |
@@ -0,0 +1,634 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-7
|
||||
cxxstd: "11,14,17"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: g++-7-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-8
|
||||
cxxstd: "11,14,17,2a"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: g++-8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: g++-9-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: g++-10-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-11
|
||||
cxxstd: "11,14,17,20"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: g++-11-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-12
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: g++-12-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-13-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: g++-14-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-15
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
container: ubuntu:26.04
|
||||
os: ubuntu-latest
|
||||
install: g++-15-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-16
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
container: ubuntu:26.04
|
||||
os: ubuntu-latest
|
||||
install: g++-16-multilib
|
||||
address-model: 32,64
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "11,14,17"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "11,14,17"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "11,14,17"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "11,14,17,2a"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "11,14,17,20"
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-15
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-18
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-19
|
||||
- toolset: clang
|
||||
compiler: clang++-20
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-20
|
||||
- toolset: clang
|
||||
compiler: clang++-21
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
container: ubuntu:26.04
|
||||
os: ubuntu-latest
|
||||
install: clang-21
|
||||
- toolset: clang
|
||||
compiler: clang++-22
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
container: ubuntu:26.04
|
||||
os: ubuntu-latest
|
||||
install: clang-22
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
os: macos-15
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,23,2c"
|
||||
os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python3 git g++ curl
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python3 tools/boostdep/depinst/depinst.py -I benchmark -I example --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
export ADDRMD=${{matrix.address-model}}
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: msvc-14.5
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2025-vs2026
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2025
|
||||
- toolset: gcc
|
||||
cxxstd: "11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 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 -I benchmark -I example --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
posix-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $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
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py -I benchmark -I example --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
windows-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 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-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 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-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 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 -I benchmark -I example --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
|
||||
@@ -1,487 +0,0 @@
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
# Copyright 2021 Alexander Grund
|
||||
# Copyright 2022 James E. King III
|
||||
# Copyright 2023 Matt Borland
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
name: POSIX
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
LIBRARY: serialization
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
GIT_FETCH_JOBS: 8
|
||||
NET_RETRY_COUNT: 5
|
||||
DEFAULT_BUILD_VARIANT: release
|
||||
|
||||
jobs:
|
||||
CI:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.6
|
||||
cxxstd: "03"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.7
|
||||
cxxstd: "03"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- "ppa:ubuntu-toolchain-r/test"
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-5-multilib
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03-gnu,11-gnu,14-gnu,1z-gnu"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- g++-5-multilib
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-6-multilib
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-7-multilib
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
address_model: 64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- g++-8-multilib
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
address_model: 64
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-9-multilib
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,2a-gnu"
|
||||
address_model: 64
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-9-multilib
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
address_model: 64
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- g++-10-multilib
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
address_model: 64
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-11-multilib
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
address_model: 64
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12-multilib
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
|
||||
address_model: 64
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12-multilib
|
||||
- name: UBSAN
|
||||
toolset: gcc-12
|
||||
cxxstd: "03,11,20"
|
||||
address_model: 64
|
||||
ubsan: 1
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- g++-12-multilib
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-7
|
||||
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install:
|
||||
- clang-8
|
||||
- g++-7
|
||||
gcc_toolchain: 7
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install:
|
||||
- clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.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
|
||||
compiler: clang++-14
|
||||
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
|
||||
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
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install:
|
||||
- clang-15
|
||||
- libc++-15-dev
|
||||
- libc++abi-15-dev
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-11
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-12
|
||||
|
||||
timeout-minutes: 360
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
steps:
|
||||
- name: Setup environment
|
||||
run: |
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
fi
|
||||
if [ -n "${{matrix.container}}" ]
|
||||
then
|
||||
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
|
||||
then
|
||||
PYTHON_PACKAGE="python-is-python3"
|
||||
else
|
||||
PYTHON_PACKAGE="python"
|
||||
fi
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake
|
||||
fi
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: |
|
||||
declare -a SOURCE_KEYS SOURCES
|
||||
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
|
||||
then
|
||||
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
|
||||
fi
|
||||
if [ -n "${{join(matrix.sources, ' ')}}" ]
|
||||
then
|
||||
SOURCES=("${{join(matrix.sources, '" "')}}")
|
||||
fi
|
||||
for key in "${SOURCE_KEYS[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
echo "Adding key: $key"
|
||||
wget -O - "$key" | sudo apt-key add - && break || sleep 2
|
||||
done
|
||||
done
|
||||
if [ ${#SOURCES[@]} -gt 0 ]
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS=("-y")
|
||||
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
|
||||
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
|
||||
then
|
||||
APT_ADD_REPO_COMMON_ARGS+=("-n")
|
||||
fi
|
||||
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
|
||||
for source in "${SOURCES[@]}"
|
||||
do
|
||||
for i in {1..$NET_RETRY_COUNT}
|
||||
do
|
||||
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
|
||||
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
|
||||
then
|
||||
case "$source" in
|
||||
"ppa:"*)
|
||||
APT_ADD_REPO_ARGS+=("-P")
|
||||
;;
|
||||
"deb "*)
|
||||
APT_ADD_REPO_ARGS+=("-S")
|
||||
;;
|
||||
*)
|
||||
APT_ADD_REPO_ARGS+=("-U")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
APT_ADD_REPO_ARGS+=("$source")
|
||||
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
|
||||
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
|
||||
done
|
||||
done
|
||||
fi
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
|
||||
- name: Setup GCC Toolchain
|
||||
if: matrix.gcc_toolchain
|
||||
run: |
|
||||
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
|
||||
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
|
||||
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT"
|
||||
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
|
||||
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
|
||||
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
DEPINST_ARGS=()
|
||||
GIT_VERSION="$(git --version | sed -e 's/git version //')"
|
||||
GIT_HAS_JOBS=1
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
|
||||
then
|
||||
GIT_HAS_JOBS=0
|
||||
fi
|
||||
else
|
||||
declare -a GIT_VER=(${GIT_VERSION//./ })
|
||||
declare -a GIT_MIN_VER=(2 8 0)
|
||||
for ((i=0; i<${#GIT_VER[@]}; i++))
|
||||
do
|
||||
if [ -z "${GIT_MIN_VER[i]}" ]
|
||||
then
|
||||
GIT_MIN_VER[i]=0
|
||||
fi
|
||||
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
|
||||
then
|
||||
GIT_HAS_JOBS=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$GIT_HAS_JOBS" -ne 0 ]
|
||||
then
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
fi
|
||||
cd ..
|
||||
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
if [ -z "${{matrix.cmake_tests}}" ]
|
||||
then
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
|
||||
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
|
||||
then
|
||||
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
|
||||
fi
|
||||
echo " ;" >> ~/user-config.jam
|
||||
fi
|
||||
fi
|
||||
- name: Run tests
|
||||
if: matrix.cmake_tests == ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}" "link=static,shared")
|
||||
if [ -n "${{matrix.build_variant}}" ]
|
||||
then
|
||||
B2_ARGS+=("variant=${{matrix.build_variant}}")
|
||||
else
|
||||
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
|
||||
fi
|
||||
if [ -n "${{matrix.threading}}" ]
|
||||
then
|
||||
B2_ARGS+=("threading=${{matrix.threading}}")
|
||||
fi
|
||||
if [ -n "${{matrix.ubsan}}" ]
|
||||
then
|
||||
export UBSAN_OPTIONS="print_stacktrace=1"
|
||||
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
|
||||
fi
|
||||
if [ -n "${{matrix.cxxflags}}" ]
|
||||
then
|
||||
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
|
||||
fi
|
||||
if [ -n "${{matrix.linkflags}}" ]
|
||||
then
|
||||
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
|
||||
fi
|
||||
if [ -n "${{matrix.address_model}}" ]
|
||||
then
|
||||
B2_ARGS+=("address-model=${{matrix.address_model}}")
|
||||
fi
|
||||
B2_ARGS+=("libs/$LIBRARY/test")
|
||||
./b2 "${B2_ARGS[@]}"
|
||||
@@ -1,76 +0,0 @@
|
||||
name: Windows
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
LIBRARY: serialization
|
||||
|
||||
jobs:
|
||||
CI:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "11,14"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
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%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=release
|
||||
+16
-23
@@ -1,6 +1,6 @@
|
||||
# CMake build control file for Serialization Library tests
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy (SET CMP0054 NEW)
|
||||
@@ -16,44 +16,43 @@ project("serialization")
|
||||
# Compiler settings
|
||||
#
|
||||
|
||||
message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )
|
||||
message(STATUS "C++ compiler is ${CMAKE_CXX_COMPILER_ID}" )
|
||||
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
|
||||
message(STATUS "C compiler is ${CMAKE_C_COMPILER_ID}" )
|
||||
|
||||
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
|
||||
add_definitions( -ftemplate-depth=255 )
|
||||
# we use gcc to test for C++03 compatibility
|
||||
add_definitions( -std=c++03 )
|
||||
message(STATUS "compiler is g++ c++03")
|
||||
set(COMPILER_SUPPORTS_CXX11 FALSE)
|
||||
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
|
||||
add_definitions( /wd4996 )
|
||||
message(STATUS "compiler is MSVC")
|
||||
set(COMPILER_SUPPORTS_CXX11 TRUE)
|
||||
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=300")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -dead_strip")
|
||||
set(COMPILER_SUPPORTS_CXX11 FALSE)
|
||||
set(COMPILER_SUPPORTS_CXX11 TRUE)
|
||||
endif()
|
||||
|
||||
add_definitions( -std=c++11 )
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
#
|
||||
# Locate Project Prerequisites
|
||||
#
|
||||
|
||||
# Boost
|
||||
|
||||
# note: we're assuming that boost has been built with:
|
||||
# ./b2 toolset=clang-darwin link=static,shared variant=debug,release stage
|
||||
|
||||
#
|
||||
# Project settings
|
||||
#
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" true)
|
||||
|
||||
find_package(Boost 1.74 REQUIRED COMPONENTS system filesystem)
|
||||
find_package(Boost 1.82 REQUIRED COMPONENTS system filesystem)
|
||||
|
||||
if(NOT Boost_FOUND)
|
||||
message("Boost NOT Found!")
|
||||
@@ -280,14 +279,10 @@ archive_test(test_list A)
|
||||
archive_test(test_list_ptrs A)
|
||||
|
||||
archive_test(test_map A)
|
||||
archive_test(test_map_boost_unordered A)
|
||||
CHECK_INCLUDE_FILE_CXX(hash_map HASH_MAP_FOUND)
|
||||
if(HASH_MAP_FOUND)
|
||||
archive_test(test_map_hashed A)
|
||||
endif()
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
archive_test(test_map_unordered A)
|
||||
endif()
|
||||
archive_test(test_mi)
|
||||
archive_test(test_multiple_ptrs A)
|
||||
archive_test(test_multiple_inheritance)
|
||||
@@ -308,14 +303,10 @@ archive_test(test_recursion A)
|
||||
archive_test(test_registered)
|
||||
|
||||
archive_test(test_set A)
|
||||
archive_test(test_set_boost_unordered A)
|
||||
CHECK_INCLUDE_FILE_CXX(hash_set HASH_SET_FOUND)
|
||||
if(HASH_SET_FOUND)
|
||||
archive_test(test_set_hashed A)
|
||||
endif()
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
archive_test(test_set_unordered A)
|
||||
endif()
|
||||
|
||||
archive_test(test_shared_ptr)
|
||||
archive_test(test_shared_ptr_multi_base)
|
||||
@@ -337,10 +328,12 @@ archive_test(test_valarray)
|
||||
archive_test(test_variant A)
|
||||
archive_test(test_vector A)
|
||||
|
||||
polymorphic_archive_test(test_dll_exported polymorphic_derived1)
|
||||
foreach(test_name IN ITEMS ${test_list} )
|
||||
if(BUILD_SHARED_LIBS)
|
||||
polymorphic_archive_test(test_dll_exported polymorphic_derived1)
|
||||
foreach(test_name IN ITEMS ${test_list} )
|
||||
target_link_libraries(${test_name} dll_polymorphic_derived2 dll_polymorphic_base serialization wserialization)
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
polymorphic_archive_test(test_no_rtti polymorphic_base polymorphic_derived1 polymorphic_derived2)
|
||||
polymorphic_archive_test(test_exported polymorphic_base polymorphic_derived1 polymorphic_derived2)
|
||||
|
||||
@@ -83,7 +83,6 @@ target_link_libraries(boost_serialization
|
||||
Boost::preprocessor
|
||||
Boost::smart_ptr
|
||||
Boost::spirit
|
||||
Boost::static_assert
|
||||
Boost::type_traits
|
||||
Boost::unordered
|
||||
Boost::utility
|
||||
|
||||
@@ -56,7 +56,6 @@ install:
|
||||
- git submodule init libs/range
|
||||
- git submodule init libs/smart_ptr
|
||||
- git submodule init libs/spirit
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/system
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/tuple
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/array//boost_array
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/core//boost_core
|
||||
/boost/detail//boost_detail
|
||||
/boost/integer//boost_integer
|
||||
/boost/io//boost_io
|
||||
/boost/iterator//boost_iterator
|
||||
/boost/move//boost_move
|
||||
/boost/mp11//boost_mp11
|
||||
/boost/mpl//boost_mpl
|
||||
/boost/optional//boost_optional
|
||||
/boost/predef//boost_predef
|
||||
/boost/preprocessor//boost_preprocessor
|
||||
/boost/smart_ptr//boost_smart_ptr
|
||||
/boost/spirit//boost_spirit
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/type_traits//boost_type_traits
|
||||
/boost/utility//boost_utility
|
||||
/boost/variant//boost_variant
|
||||
/boost/variant2//boost_variant2 ;
|
||||
|
||||
project /boost/serialization
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_serialization : build//boost_serialization ]
|
||||
[ alias boost_wserialization : build//boost_wserialization ]
|
||||
[ alias all : boost_serialization boost_wserialization example test ]
|
||||
;
|
||||
|
||||
call-if : boost-library serialization
|
||||
: install boost_serialization boost_wserialization
|
||||
;
|
||||
|
||||
+37
-41
@@ -1,60 +1,70 @@
|
||||
# Boost serialization Library Build Jamfile
|
||||
# (C) Copyright Robert Ramey 2002-2004.
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# See http://www.boost.org/libs/serialization for the library home page.
|
||||
|
||||
project boost/serialization
|
||||
require-b2 5.0.1 ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
|
||||
constant boost_dependencies_private :
|
||||
/boost/function//boost_function
|
||||
;
|
||||
|
||||
project
|
||||
: source-location ../src
|
||||
: common-requirements <library>$(boost_dependencies)
|
||||
: requirements
|
||||
<conditional>@include-spirit
|
||||
<library>$(boost_dependencies_private)
|
||||
: usage-requirements
|
||||
<define>BOOST_SERIALIZATION_NO_LIB=1
|
||||
;
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
SPIRIT_ROOT = [ modules.peek : SPIRIT_ROOT ] ;
|
||||
rule include-spirit ( properties * )
|
||||
{
|
||||
local old-compiler ;
|
||||
if <toolset>borland in $(properties)
|
||||
{
|
||||
if ! <toolset-borland:version>6.1.0 in $(properties)
|
||||
{
|
||||
old-compiler = true ;
|
||||
}
|
||||
if ! <toolset-borland:version>6.1.0 in $(properties)
|
||||
{
|
||||
old-compiler = true ;
|
||||
}
|
||||
|
||||
}
|
||||
else if <toolset>msvc in $(properties)
|
||||
{
|
||||
if <toolset-msvc:version>6.5 in $(properties)
|
||||
|| <toolset-msvc:version>7.0 in $(properties)
|
||||
{
|
||||
{
|
||||
old-compiler = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local result ;
|
||||
if $(old-compiler)
|
||||
{
|
||||
{
|
||||
if $(SPIRIT_ROOT)
|
||||
{
|
||||
# note - we can't use <include>$(SPIRIT_ROOT) because
|
||||
# note - we can't use <include>$(SPIRIT_ROOT) because
|
||||
# it puts -I$(SPIRIT_ROOT) AFTER the "../../.." in the command line.
|
||||
# so use these instead
|
||||
# so use these instead
|
||||
result = <cxxflags>-I$(SPIRIT_ROOT) ;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
echo **** spirit 1.6x required to build library with this compiler **** ;
|
||||
result = <build>no ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
SOURCES =
|
||||
SOURCES =
|
||||
archive_exception
|
||||
basic_archive
|
||||
basic_iarchive
|
||||
@@ -90,12 +100,12 @@ SOURCES =
|
||||
codecvt_null
|
||||
;
|
||||
|
||||
SOURCES_HAS_STD_WSTREAMBUF =
|
||||
SOURCES_HAS_STD_WSTREAMBUF =
|
||||
xml_oarchive
|
||||
utf8_codecvt_facet
|
||||
;
|
||||
|
||||
WSOURCES =
|
||||
WSOURCES =
|
||||
basic_text_wiprimitive
|
||||
basic_text_woprimitive
|
||||
text_wiarchive
|
||||
@@ -107,42 +117,28 @@ WSOURCES =
|
||||
xml_woarchive
|
||||
polymorphic_xml_wiarchive
|
||||
polymorphic_xml_woarchive
|
||||
$(SOURCES_HAS_STD_WSTREAMBUF)
|
||||
codecvt_null
|
||||
;
|
||||
|
||||
lib boost_serialization
|
||||
lib boost_serialization
|
||||
: ## sources ##
|
||||
$(SOURCES).cpp
|
||||
: ## requirements ##
|
||||
[ check-target-builds ../../config/checks//std_wstreambuf : <source>../src/$(SOURCES_HAS_STD_WSTREAMBUF).cpp ]
|
||||
[ check-target-builds /boost/config/checks//std_wstreambuf : <source>../src/$(SOURCES_HAS_STD_WSTREAMBUF).cpp ]
|
||||
<toolset>msvc:<cxxflags>/Gy
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||
<toolset>clang:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
<toolset>gcc:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
<toolset>darwin:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
|
||||
lib boost_wserialization
|
||||
: $(WSOURCES).cpp boost_serialization
|
||||
:
|
||||
lib boost_wserialization
|
||||
: $(WSOURCES).cpp boost_serialization
|
||||
:
|
||||
[ requires std_wstreambuf ]
|
||||
<toolset>msvc:<cxxflags>/Gy
|
||||
<toolset>msvc:<cxxflags>/Gy
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||
<toolset>clang:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
<toolset>gcc:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
<toolset>darwin:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
|
||||
# note: both serialization and wserialization are conditioned on the this
|
||||
# switch - don't change it to BOOST_WSERIALIZATION_DYN_LINK
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_serialization boost_wserialization ;
|
||||
|
||||
@@ -919,6 +919,7 @@ As of this writing, the library contains serialization of the following boost cl
|
||||
<li>shared_ptr
|
||||
<li>auto_ptr (demo)
|
||||
</ul>
|
||||
C++17 <code style="white-space: normal">std::variant is supported as well</code>.
|
||||
Others are being added to the list so check the boost files section and headers for
|
||||
new implementations!
|
||||
<hr>
|
||||
|
||||
@@ -19,7 +19,6 @@ import ../util/test :
|
||||
test-bsl-run
|
||||
test-bsl-run_archive
|
||||
test-bsl-run_files
|
||||
test-bsl-run_polymorphic_archive
|
||||
;
|
||||
|
||||
test-suite "demo-suite" :
|
||||
|
||||
@@ -55,7 +55,7 @@ class helper_collection
|
||||
collection m_collection;
|
||||
|
||||
struct predicate {
|
||||
// BOOST_DEFAULTED_FUNCTION(predicate(const predicate& rhs) : m_ti(rhs.m_ti), {})
|
||||
BOOST_DEFAULTED_FUNCTION(predicate(const predicate& rhs), : m_ti(rhs.m_ti) {})
|
||||
BOOST_DELETED_FUNCTION(predicate & operator=(const predicate & rhs))
|
||||
public:
|
||||
const void * const m_ti;
|
||||
|
||||
@@ -44,13 +44,6 @@ public:
|
||||
typedef mpl::bool_<true> is_saving;
|
||||
|
||||
// return a pointer to the most derived class
|
||||
#if BOOST_WORKAROUND(BOOST_GCC_VERSION,>=40900)||\
|
||||
BOOST_WORKAROUND(BOOST_CLANG,>=1)&&\
|
||||
(__clang_major__>3 || __clang_major__==3 && __clang_minor__ >= 8)
|
||||
/* https://github.com/boostorg/poly_collection/issues/15 */
|
||||
|
||||
__attribute__((no_sanitize("undefined")))
|
||||
#endif
|
||||
Archive * This(){
|
||||
return static_cast<Archive*>(this);
|
||||
}
|
||||
|
||||
@@ -131,8 +131,9 @@ BOOST_ARCHIVE_DECL
|
||||
xml_oarchive_impl<Archive>::~xml_oarchive_impl(){
|
||||
if(boost::core::uncaught_exceptions() > 0)
|
||||
return;
|
||||
if(0 == (this->get_flags() & no_header))
|
||||
this->windup();
|
||||
if(0 == (this->get_flags() & no_header)){
|
||||
this->put("</boost_serialization>\n");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace archive
|
||||
|
||||
@@ -82,7 +82,7 @@ class escape :
|
||||
}
|
||||
|
||||
void increment(){
|
||||
if(m_bnext != NULL && ++m_bnext < m_bend){
|
||||
if(m_bnext != m_bend && ++m_bnext < m_bend){
|
||||
m_current_value = *m_bnext;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,143 +18,11 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include <boost/serialization/utility.hpp>
|
||||
#include <boost/serialization/unordered_collections_save_imp.hpp>
|
||||
#include <boost/serialization/unordered_collections_load_imp.hpp>
|
||||
#include <boost/serialization/archive_input_unordered_map.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class T,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void save(
|
||||
Archive & ar,
|
||||
const boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::save_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class T,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void load(
|
||||
Archive & ar,
|
||||
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::load_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>,
|
||||
boost::serialization::stl::archive_input_unordered_map<
|
||||
Archive,
|
||||
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
|
||||
>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
// split non-intrusive serialization function member into separate
|
||||
// non intrusive save/load member functions
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class T,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int file_version
|
||||
){
|
||||
boost::serialization::split_free(ar, t, file_version);
|
||||
}
|
||||
|
||||
// unordered_multimap
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class T,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void save(
|
||||
Archive & ar,
|
||||
const boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::save_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class T,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void load(
|
||||
Archive & ar,
|
||||
boost::unordered_multimap<
|
||||
Key, T, HashFcn, EqualKey, Allocator
|
||||
> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::load_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>,
|
||||
boost::serialization::stl::archive_input_unordered_multimap<
|
||||
Archive,
|
||||
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
|
||||
>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
// split non-intrusive serialization function member into separate
|
||||
// non intrusive save/load member functions
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class T,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int file_version
|
||||
){
|
||||
boost::serialization::split_free(ar, t, file_version);
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
#include <boost/static_assert.hpp>
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
false,
|
||||
"Boost.Unordered now provides its own Serialization support. "
|
||||
"This header is no longer necessary and is now deprecated."
|
||||
)
|
||||
|
||||
#endif // BOOST_SERIALIZATION_BOOST_SERIALIZATION_UNORDERED_MAP_HPP
|
||||
|
||||
@@ -17,134 +17,11 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#include <boost/serialization/unordered_collections_save_imp.hpp>
|
||||
#include <boost/serialization/unordered_collections_load_imp.hpp>
|
||||
#include <boost/serialization/archive_input_unordered_set.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void save(
|
||||
Archive & ar,
|
||||
const boost::unordered_set<Key, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::save_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_set<Key, HashFcn, EqualKey, Allocator>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void load(
|
||||
Archive & ar,
|
||||
boost::unordered_set<Key, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::load_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_set<Key, HashFcn, EqualKey, Allocator>,
|
||||
boost::serialization::stl::archive_input_unordered_set<
|
||||
Archive,
|
||||
boost::unordered_set<Key, HashFcn, EqualKey, Allocator>
|
||||
>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
// split non-intrusive serialization function member into separate
|
||||
// non intrusive save/load member functions
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
boost::unordered_set<Key, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int file_version
|
||||
){
|
||||
boost::serialization::split_free(ar, t, file_version);
|
||||
}
|
||||
|
||||
// unordered_multiset
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void save(
|
||||
Archive & ar,
|
||||
const boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::save_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void load(
|
||||
Archive & ar,
|
||||
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int /*file_version*/
|
||||
){
|
||||
boost::serialization::stl::load_unordered_collection<
|
||||
Archive,
|
||||
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator>,
|
||||
boost::serialization::stl::archive_input_unordered_multiset<
|
||||
Archive,
|
||||
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator>
|
||||
>
|
||||
>(ar, t);
|
||||
}
|
||||
|
||||
// split non-intrusive serialization function member into separate
|
||||
// non intrusive save/load member functions
|
||||
template<
|
||||
class Archive,
|
||||
class Key,
|
||||
class HashFcn,
|
||||
class EqualKey,
|
||||
class Allocator
|
||||
>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
boost::unordered_multiset<Key, HashFcn, EqualKey, Allocator> &t,
|
||||
const unsigned int file_version
|
||||
){
|
||||
boost::serialization::split_free(ar, t, file_version);
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
#include <boost/static_assert.hpp>
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
false,
|
||||
"Boost.Unordered now provides its own Serialization support. "
|
||||
"This header is no longer necessary and is now deprecated."
|
||||
)
|
||||
|
||||
#endif // BOOST_SERIALIZATION_BOOST_UNORDERED_SET_HPP
|
||||
|
||||
@@ -100,13 +100,9 @@ class extended_type_info_no_rtti :
|
||||
}
|
||||
};
|
||||
public:
|
||||
#if BOOST_WORKAROUND(BOOST_GCC_VERSION,>=40900)||\
|
||||
BOOST_WORKAROUND(BOOST_CLANG,>=1)&&\
|
||||
(__clang_major__>3 || __clang_major__==3 && __clang_minor__ >= 8)
|
||||
__attribute__((no_sanitize("undefined")))
|
||||
#endif
|
||||
extended_type_info_no_rtti() :
|
||||
no_rtti_system::extended_type_info_no_rtti_0(get_key())
|
||||
no_rtti_system::extended_type_info_no_rtti_0(
|
||||
action<guid_defined< T >::value >::invoke())
|
||||
{
|
||||
key_register();
|
||||
}
|
||||
@@ -133,24 +129,26 @@ public:
|
||||
}
|
||||
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
|
||||
// count up the arguments
|
||||
void * r = NULL;
|
||||
std::va_list ap;
|
||||
va_start(ap, count);
|
||||
switch(count){
|
||||
case 0:
|
||||
return factory<typename boost::remove_const< T >::type, 0>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 0>(ap); break;
|
||||
case 1:
|
||||
return factory<typename boost::remove_const< T >::type, 1>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 1>(ap); break;
|
||||
case 2:
|
||||
return factory<typename boost::remove_const< T >::type, 2>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 2>(ap); break;
|
||||
case 3:
|
||||
return factory<typename boost::remove_const< T >::type, 3>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 3>(ap); break;
|
||||
case 4:
|
||||
return factory<typename boost::remove_const< T >::type, 4>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 4>(ap); break;
|
||||
default:
|
||||
BOOST_ASSERT(false); // too many arguments
|
||||
// throw exception here?
|
||||
return NULL;
|
||||
}
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
void destroy(void const * const p) const BOOST_OVERRIDE {
|
||||
boost::serialization::access::destroy(
|
||||
|
||||
@@ -112,24 +112,26 @@ public:
|
||||
}
|
||||
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
|
||||
// count up the arguments
|
||||
void * r = NULL;
|
||||
std::va_list ap;
|
||||
va_start(ap, count);
|
||||
switch(count){
|
||||
case 0:
|
||||
return factory<typename boost::remove_const< T >::type, 0>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 0>(ap); break;
|
||||
case 1:
|
||||
return factory<typename boost::remove_const< T >::type, 1>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 1>(ap); break;
|
||||
case 2:
|
||||
return factory<typename boost::remove_const< T >::type, 2>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 2>(ap); break;
|
||||
case 3:
|
||||
return factory<typename boost::remove_const< T >::type, 3>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 3>(ap); break;
|
||||
case 4:
|
||||
return factory<typename boost::remove_const< T >::type, 4>(ap);
|
||||
r = factory<typename boost::remove_const< T >::type, 4>(ap); break;
|
||||
default:
|
||||
BOOST_ASSERT(false); // too many arguments
|
||||
// throw exception here?
|
||||
return NULL;
|
||||
}
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
void destroy(void const * const p) const BOOST_OVERRIDE {
|
||||
boost::serialization::access::destroy(
|
||||
|
||||
@@ -7,16 +7,18 @@
|
||||
|
||||
// Provides non-intrusive serialization for boost::optional.
|
||||
|
||||
#ifndef BOOST_SERIALIZATION_OPTIONAL_HPP_
|
||||
#define BOOST_SERIALIZATION_OPTIONAL_HPP_
|
||||
#ifndef BOOST_SERIALIZATION_OPTIONAL_HPP
|
||||
#define BOOST_SERIALIZATION_OPTIONAL_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
#include <optional>
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/item_version_type.hpp>
|
||||
#include <boost/serialization/library_version_type.hpp>
|
||||
@@ -30,41 +32,43 @@
|
||||
// namespace - boost::serialization
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
namespace detail {
|
||||
|
||||
template<class Archive, class T>
|
||||
void save(
|
||||
// OT is of the form optional<T>
|
||||
template<class Archive, class OT>
|
||||
void save_impl(
|
||||
Archive & ar,
|
||||
const boost::optional< T > & t,
|
||||
const unsigned int /*version*/
|
||||
const OT & ot
|
||||
){
|
||||
// It is an inherent limitation to the serialization of optional.hpp
|
||||
// that the underlying type must be either a pointer or must have a
|
||||
// default constructor. It's possible that this could change sometime
|
||||
// in the future, but for now, one will have to work around it. This can
|
||||
// be done by serialization the optional<T> as optional<T *>
|
||||
#if ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::serialization::detail::is_default_constructible<T>::value
|
||||
|| boost::is_pointer<T>::value
|
||||
boost::serialization::detail::is_default_constructible<typename OT::value_type>::value
|
||||
|| boost::is_pointer<typename OT::value_type>::value
|
||||
);
|
||||
#endif
|
||||
const bool tflag = t.is_initialized();
|
||||
const bool tflag(ot);
|
||||
ar << boost::serialization::make_nvp("initialized", tflag);
|
||||
if (tflag){
|
||||
ar << boost::serialization::make_nvp("value", *t);
|
||||
ar << boost::serialization::make_nvp("value", *ot);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
void load(
|
||||
// OT is of the form optional<T>
|
||||
template<class Archive, class OT>
|
||||
void load_impl(
|
||||
Archive & ar,
|
||||
boost::optional< T > & t,
|
||||
OT & ot,
|
||||
const unsigned int version
|
||||
){
|
||||
bool tflag;
|
||||
ar >> boost::serialization::make_nvp("initialized", tflag);
|
||||
if(! tflag){
|
||||
t.reset();
|
||||
ot.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,26 +81,86 @@ void load(
|
||||
ar >> BOOST_SERIALIZATION_NVP(item_version);
|
||||
}
|
||||
}
|
||||
if(! t.is_initialized())
|
||||
t = T();
|
||||
ar >> boost::serialization::make_nvp("value", *t);
|
||||
typename OT::value_type t;
|
||||
ar >> boost::serialization::make_nvp("value",t);
|
||||
ot = t;
|
||||
}
|
||||
|
||||
} // detail
|
||||
|
||||
template<class Archive, class T>
|
||||
void save(
|
||||
Archive & ar,
|
||||
const boost::optional< T > & ot,
|
||||
const unsigned int /*version*/
|
||||
){
|
||||
detail::save_impl(ar, ot);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
template<class Archive, class T>
|
||||
void save(
|
||||
Archive & ar,
|
||||
const std::optional< T > & ot,
|
||||
const unsigned int /*version*/
|
||||
){
|
||||
detail::save_impl(ar, ot);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Archive, class T>
|
||||
void load(
|
||||
Archive & ar,
|
||||
boost::optional< T > & ot,
|
||||
const unsigned int version
|
||||
){
|
||||
detail::load_impl(ar, ot, version);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
template<class Archive, class T>
|
||||
void load(
|
||||
Archive & ar,
|
||||
std::optional< T > & ot,
|
||||
const unsigned int version
|
||||
){
|
||||
detail::load_impl(ar, ot, version);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Archive, class T>
|
||||
void serialize(
|
||||
Archive & ar,
|
||||
boost::optional< T > & t,
|
||||
boost::optional< T > & ot,
|
||||
const unsigned int version
|
||||
){
|
||||
boost::serialization::split_free(ar, t, version);
|
||||
boost::serialization::split_free(ar, ot, version);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
template<class Archive, class T>
|
||||
void serialize(
|
||||
Archive & ar,
|
||||
std::optional< T > & ot,
|
||||
const unsigned int version
|
||||
){
|
||||
boost::serialization::split_free(ar, ot, version);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct version<boost::optional<T> > {
|
||||
struct version<boost::optional<T> >{
|
||||
BOOST_STATIC_CONSTANT(int, value = 1);
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
template<class T>
|
||||
struct version<std::optional<T> >{
|
||||
BOOST_STATIC_CONSTANT(int, value = 1);
|
||||
};
|
||||
#endif
|
||||
|
||||
} // serialization
|
||||
} // boost
|
||||
|
||||
#endif // BOOST_SERIALIZATION_OPTIONAL_HPP_
|
||||
#endif // BOOST_SERIALIZATION_OPTIONAL_HPP
|
||||
|
||||
@@ -31,12 +31,11 @@ namespace archive {
|
||||
|
||||
namespace serialization {
|
||||
|
||||
//namespace detail {
|
||||
template<class Archive, class T>
|
||||
struct free_saver {
|
||||
static void invoke(
|
||||
Archive & ar,
|
||||
const T & t,
|
||||
const T & t,
|
||||
const unsigned int file_version
|
||||
){
|
||||
// use function overload (version_type) to workaround
|
||||
@@ -58,7 +57,6 @@ struct free_loader {
|
||||
load(ar, t, v);
|
||||
}
|
||||
};
|
||||
//} // namespace detail
|
||||
|
||||
template<class Archive, class T>
|
||||
inline void split_free(
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
#ifndef BOOST_SERIALIZATION_STD_VARIANT_HPP
|
||||
#define BOOST_SERIALIZATION_STD_VARIANT_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// variant.hpp - non-intrusive serialization of variant types
|
||||
//
|
||||
// copyright (c) 2019 Samuel Debionne, ESRF
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//
|
||||
// Widely inspired form boost::variant serialization
|
||||
//
|
||||
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
struct std_variant_save_visitor
|
||||
{
|
||||
std_variant_save_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
template<class T>
|
||||
void operator()(T const & value) const
|
||||
{
|
||||
m_ar << BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
private:
|
||||
Archive & m_ar;
|
||||
};
|
||||
|
||||
|
||||
template<class Archive>
|
||||
struct std_variant_load_visitor
|
||||
{
|
||||
std_variant_load_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
template<class T>
|
||||
void operator()(T & value) const
|
||||
{
|
||||
m_ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
private:
|
||||
Archive & m_ar;
|
||||
};
|
||||
|
||||
template<class Archive, class ...Types>
|
||||
void save(
|
||||
Archive & ar,
|
||||
std::variant<Types...> const & v,
|
||||
unsigned int /*version*/
|
||||
){
|
||||
const std::size_t which = v.index();
|
||||
ar << BOOST_SERIALIZATION_NVP(which);
|
||||
std_variant_save_visitor<Archive> visitor(ar);
|
||||
std::visit(visitor, v);
|
||||
}
|
||||
|
||||
// Minimalist metaprogramming for handling parameter pack
|
||||
namespace mp {
|
||||
namespace detail {
|
||||
template <typename Seq>
|
||||
struct front_impl;
|
||||
|
||||
template <template <typename...> class Seq, typename T, typename... Ts>
|
||||
struct front_impl<Seq<T, Ts...>> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <typename Seq>
|
||||
struct pop_front_impl;
|
||||
|
||||
template <template <typename...> class Seq, typename T, typename... Ts>
|
||||
struct pop_front_impl<Seq<T, Ts...>> {
|
||||
using type = Seq<Ts...>;
|
||||
};
|
||||
} //namespace detail
|
||||
|
||||
template <typename... Ts>
|
||||
struct typelist {};
|
||||
|
||||
template <typename Seq>
|
||||
using front = typename detail::front_impl<Seq>::type;
|
||||
|
||||
template <typename Seq>
|
||||
using pop_front = typename detail::pop_front_impl<Seq>::type;
|
||||
} // namespace mp
|
||||
|
||||
template<std::size_t N, class Seq>
|
||||
struct variant_impl
|
||||
{
|
||||
template<class Archive, class V>
|
||||
static void load (
|
||||
Archive & ar,
|
||||
std::size_t which,
|
||||
V & v,
|
||||
const unsigned int version
|
||||
){
|
||||
if(which == 0){
|
||||
// note: A non-intrusive implementation (such as this one)
|
||||
// necessary has to copy the value. This wouldn't be necessary
|
||||
// with an implementation that de-serialized to the address of the
|
||||
// aligned storage included in the variant.
|
||||
using type = mp::front<Seq>;
|
||||
type value;
|
||||
ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
v = std::move(value);
|
||||
type * new_address = & std::get<type>(v);
|
||||
ar.reset_object_address(new_address, & value);
|
||||
return;
|
||||
}
|
||||
//typedef typename mpl::pop_front<S>::type type;
|
||||
using types = mp::pop_front<Seq>;
|
||||
variant_impl<N - 1, types>::load(ar, which - 1, v, version);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Seq>
|
||||
struct variant_impl<0, Seq>
|
||||
{
|
||||
template<class Archive, class V>
|
||||
static void load (
|
||||
Archive & /*ar*/,
|
||||
std::size_t /*which*/,
|
||||
V & /*v*/,
|
||||
const unsigned int /*version*/
|
||||
){}
|
||||
};
|
||||
|
||||
template<class Archive, class... Types>
|
||||
void load(
|
||||
Archive & ar,
|
||||
std::variant<Types...>& v,
|
||||
const unsigned int version
|
||||
){
|
||||
std::size_t which;
|
||||
ar >> BOOST_SERIALIZATION_NVP(which);
|
||||
if(which >= sizeof...(Types))
|
||||
// this might happen if a type was removed from the list of variant types
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version
|
||||
)
|
||||
);
|
||||
variant_impl<sizeof...(Types), mp::typelist<Types...>>::load(ar, which, v, version);
|
||||
}
|
||||
|
||||
template<class Archive,class... Types>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
std::variant<Types...> & v,
|
||||
const unsigned int file_version
|
||||
){
|
||||
split_free(ar,v,file_version);
|
||||
}
|
||||
|
||||
// Specialization for std::monostate
|
||||
template<class Archive>
|
||||
void serialize(Archive &, std::monostate &, const unsigned int /*version*/)
|
||||
{}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
|
||||
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class... Types>
|
||||
struct tracking_level<
|
||||
std::variant<Types...>
|
||||
>{
|
||||
typedef mpl::integral_c_tag tag;
|
||||
typedef mpl::int_< ::boost::serialization::track_always> type;
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
};
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif //BOOST_SERIALIZATION_VARIANT_HPP
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
#include <boost/throw_exception.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
// troy d. straszheim <troy@resophonic.com>
|
||||
// http://www.resophonic.com
|
||||
//
|
||||
// copyright (c) 2019 Samuel Debionne, ESRF
|
||||
//
|
||||
// copyright (c) 2023
|
||||
// Robert Ramey <ramey@rrsd.com>
|
||||
// http://www.rrsd.com
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -31,7 +37,19 @@
|
||||
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
// Boost Variant supports all C++ versions back to C++03
|
||||
#include <boost/variant/variant.hpp>
|
||||
#include <boost/variant/get.hpp>
|
||||
|
||||
// Boost Variant2 supports all C++ versions back to C++11
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
#include <boost/variant2/variant.hpp>
|
||||
#endif
|
||||
|
||||
// std::variant supports all C++ versions back to C++11
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
#include <variant>
|
||||
#endif
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
@@ -39,19 +57,35 @@
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
|
||||
// use visitor from boost::variant
|
||||
template<class Visitor, BOOST_VARIANT_ENUM_PARAMS(class T)>
|
||||
typename Visitor::result_type visit(
|
||||
Visitor visitor,
|
||||
const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & t
|
||||
){
|
||||
return boost::apply_visitor(visitor, t);
|
||||
}
|
||||
template<class Visitor, BOOST_VARIANT_ENUM_PARAMS(class T)>
|
||||
typename Visitor::result_type visit(
|
||||
Visitor visitor,
|
||||
const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & t,
|
||||
const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & u
|
||||
){
|
||||
return boost::apply_visitor(visitor, t, u);
|
||||
}
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
struct variant_save_visitor :
|
||||
boost::static_visitor<>
|
||||
boost::static_visitor<void>
|
||||
{
|
||||
variant_save_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
template<class T>
|
||||
void operator()(T const & value) const
|
||||
{
|
||||
void operator()(T const & value) const {
|
||||
m_ar << BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
private:
|
||||
@@ -67,9 +101,37 @@ void save(
|
||||
int which = v.which();
|
||||
ar << BOOST_SERIALIZATION_NVP(which);
|
||||
variant_save_visitor<Archive> visitor(ar);
|
||||
v.apply_visitor(visitor);
|
||||
visit(visitor, v);
|
||||
}
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
template<class Archive, class ...Types>
|
||||
void save(
|
||||
Archive & ar,
|
||||
boost::variant2::variant<Types...> const & v,
|
||||
unsigned int /*version*/
|
||||
){
|
||||
int which = v.index();
|
||||
ar << BOOST_SERIALIZATION_NVP(which);
|
||||
const variant_save_visitor<Archive> visitor(ar);
|
||||
visit(visitor, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
template<class Archive, class ...Types>
|
||||
void save(
|
||||
Archive & ar,
|
||||
std::variant<Types...> const & v,
|
||||
unsigned int /*version*/
|
||||
){
|
||||
int which = v.index();
|
||||
ar << BOOST_SERIALIZATION_NVP(which);
|
||||
const variant_save_visitor<Archive> visitor(ar);
|
||||
visit(visitor, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class S>
|
||||
struct variant_impl {
|
||||
|
||||
@@ -77,17 +139,17 @@ struct variant_impl {
|
||||
template<class Archive, class V>
|
||||
static void invoke(
|
||||
Archive & /*ar*/,
|
||||
int /*which*/,
|
||||
std::size_t /*which*/,
|
||||
V & /*v*/,
|
||||
const unsigned int /*version*/
|
||||
){}
|
||||
};
|
||||
|
||||
struct load_impl {
|
||||
struct load_member {
|
||||
template<class Archive, class V>
|
||||
static void invoke(
|
||||
Archive & ar,
|
||||
int which,
|
||||
std::size_t which,
|
||||
V & v,
|
||||
const unsigned int version
|
||||
){
|
||||
@@ -99,31 +161,30 @@ struct variant_impl {
|
||||
typedef typename mpl::front<S>::type head_type;
|
||||
head_type value;
|
||||
ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
v = value;
|
||||
head_type * new_address = & boost::get<head_type>(v);
|
||||
v = std::move(value);;
|
||||
head_type * new_address = & get<head_type>(v);
|
||||
ar.reset_object_address(new_address, & value);
|
||||
return;
|
||||
}
|
||||
typedef typename mpl::pop_front<S>::type type;
|
||||
variant_impl<type>::load(ar, which - 1, v, version);
|
||||
variant_impl<type>::load_impl(ar, which - 1, v, version);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Archive, class V>
|
||||
static void load(
|
||||
static void load_impl(
|
||||
Archive & ar,
|
||||
int which,
|
||||
std::size_t which,
|
||||
V & v,
|
||||
const unsigned int version
|
||||
){
|
||||
typedef typename mpl::eval_if<mpl::empty<S>,
|
||||
mpl::identity<load_null>,
|
||||
mpl::identity<load_impl>
|
||||
mpl::identity<load_member>
|
||||
>::type typex;
|
||||
typex::invoke(ar, which, v, version);
|
||||
}
|
||||
|
||||
};
|
||||
}; // variant_impl
|
||||
|
||||
template<class Archive, BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
|
||||
void load(
|
||||
@@ -134,34 +195,99 @@ void load(
|
||||
int which;
|
||||
typedef typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;
|
||||
ar >> BOOST_SERIALIZATION_NVP(which);
|
||||
if(which >= mpl::size<types>::value)
|
||||
if(which >= mpl::size<types>::value){
|
||||
// this might happen if a type was removed from the list of variant types
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version
|
||||
)
|
||||
);
|
||||
variant_impl<types>::load(ar, which, v, version);
|
||||
}
|
||||
variant_impl<types>::load_impl(ar, which, v, version);
|
||||
}
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
template<class Archive, class ... Types>
|
||||
void load(
|
||||
Archive & ar,
|
||||
boost::variant2::variant<Types...> & v,
|
||||
const unsigned int version
|
||||
){
|
||||
int which;
|
||||
typedef typename boost::variant<Types...>::types types;
|
||||
ar >> BOOST_SERIALIZATION_NVP(which);
|
||||
if(static_cast<std::size_t>(which) >= sizeof...(Types)){
|
||||
// this might happen if a type was removed from the list of variant types
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version
|
||||
)
|
||||
);
|
||||
}
|
||||
variant_impl<types>::load_impl(ar, which, v, version);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
template<class Archive, class ... Types>
|
||||
void load(
|
||||
Archive & ar,
|
||||
std::variant<Types...> & v,
|
||||
const unsigned int version
|
||||
){
|
||||
int which;
|
||||
typedef typename boost::variant<Types...>::types types;
|
||||
ar >> BOOST_SERIALIZATION_NVP(which);
|
||||
if(static_cast<std::size_t>(which) >= sizeof...(Types)){
|
||||
// this might happen if a type was removed from the list of variant types
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version
|
||||
)
|
||||
);
|
||||
}
|
||||
variant_impl<types>::load_impl(ar, which, v, version);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Archive,BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & v,
|
||||
const unsigned int file_version
|
||||
){
|
||||
split_free(ar,v,file_version);
|
||||
boost::serialization::split_free(ar,v,file_version);
|
||||
}
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
template<class Archive, class ... Types>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
boost::variant2::variant<Types...> & v,
|
||||
const unsigned int file_version
|
||||
){
|
||||
boost::serialization::split_free(ar,v,file_version);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
template<class Archive, class ... Types>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
std::variant<Types...> & v,
|
||||
const unsigned int file_version
|
||||
){
|
||||
boost::serialization::split_free(ar,v,file_version);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
|
||||
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
namespace serialization {
|
||||
|
||||
template<BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
|
||||
struct tracking_level<
|
||||
@@ -172,6 +298,17 @@ struct tracking_level<
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
template<class... Types>
|
||||
struct tracking_level<
|
||||
std::variant<Types...>
|
||||
>{
|
||||
typedef mpl::integral_c_tag tag;
|
||||
typedef mpl::int_< ::boost::serialization::track_always> type;
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
#ifndef BOOST_SERIALIZATION_VARIANT2_HPP
|
||||
#define BOOST_SERIALIZATION_VARIANT2_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// variant2.hpp - non-intrusive serialization of variant types
|
||||
//
|
||||
// copyright (c) 2019 Samuel Debionne, ESRF
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//
|
||||
// Widely inspired from boost::variant serialization
|
||||
//
|
||||
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/mp11/list.hpp>
|
||||
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
struct variant2_save_visitor
|
||||
{
|
||||
variant2_save_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
template<class T>
|
||||
void operator()(T const & value) const
|
||||
{
|
||||
m_ar << BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
private:
|
||||
Archive & m_ar;
|
||||
};
|
||||
|
||||
|
||||
template<class Archive>
|
||||
struct variant2_load_visitor
|
||||
{
|
||||
variant2_load_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
template<class T>
|
||||
void operator()(T & value) const
|
||||
{
|
||||
m_ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
private:
|
||||
Archive & m_ar;
|
||||
};
|
||||
|
||||
template<class Archive, class ...Types>
|
||||
void save(
|
||||
Archive & ar,
|
||||
variant2::variant<Types...> const & v,
|
||||
unsigned int /*version*/
|
||||
){
|
||||
const std::size_t which = v.index();
|
||||
ar << BOOST_SERIALIZATION_NVP(which);
|
||||
variant2_save_visitor<Archive> visitor(ar);
|
||||
std::visit(visitor, v);
|
||||
}
|
||||
|
||||
template<class Seq>
|
||||
struct variant_impl
|
||||
{
|
||||
template<class Archive, class V>
|
||||
static void load (
|
||||
Archive & ar,
|
||||
std::size_t which,
|
||||
V & v,
|
||||
const unsigned int version
|
||||
){
|
||||
if(which == 0){
|
||||
// note: A non-intrusive implementation (such as this one)
|
||||
// necessary has to copy the value. This wouldn't be necessary
|
||||
// with an implementation that de-serialized to the address of the
|
||||
// aligned storage included in the variant.
|
||||
using type = mp11::mp_front<Seq>;
|
||||
type value;
|
||||
ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
v = std::move(value);
|
||||
type * new_address = & variant2::get<type>(v);
|
||||
ar.reset_object_address(new_address, & value);
|
||||
return;
|
||||
}
|
||||
//typedef typename mpl::pop_front<S>::type type;
|
||||
using types = mp11::mp_pop_front<Seq>;
|
||||
variant_impl<types>::load(ar, which - 1, v, version);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Seq>
|
||||
struct variant_impl<Seq>
|
||||
{
|
||||
template<class Archive, class V>
|
||||
static void load (
|
||||
Archive & /*ar*/,
|
||||
std::size_t /*which*/,
|
||||
V & /*v*/,
|
||||
const unsigned int /*version*/
|
||||
){}
|
||||
};
|
||||
|
||||
template<class Archive, class... Types>
|
||||
void load(
|
||||
Archive & ar,
|
||||
variant2::variant<Types...> & v,
|
||||
const unsigned int version
|
||||
){
|
||||
std::size_t which;
|
||||
ar >> BOOST_SERIALIZATION_NVP(which);
|
||||
if(which >= sizeof...(Types))
|
||||
// this might happen if a type was removed from the list of variant types
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version
|
||||
)
|
||||
);
|
||||
variant_impl<sizeof...(Types), mp11::mp_list<Types...>>::load(ar, which, v, version);
|
||||
}
|
||||
|
||||
template<class Archive,class... Types>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
variant2::variant<Types...> & v,
|
||||
const unsigned int file_version
|
||||
){
|
||||
split_free(ar,v,file_version);
|
||||
}
|
||||
|
||||
// Specialization for std::monostate
|
||||
template<class Archive>
|
||||
void serialize(Archive &ar, variant2::monostate &, const unsigned int /*version*/)
|
||||
{}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
|
||||
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class... Types>
|
||||
struct tracking_level<
|
||||
variant2::variant<Types...>
|
||||
>{
|
||||
typedef mpl::integral_c_tag tag;
|
||||
typedef mpl::int_< ::boost::serialization::track_always> type;
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
};
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif //BOOST_SERIALIZATION_VARIANT2_HPP
|
||||
@@ -21,7 +21,6 @@ import ../util/test :
|
||||
test-bsl-run
|
||||
test-bsl-run_archive
|
||||
test-bsl-run_files
|
||||
test-bsl-run_polymorphic_archive
|
||||
;
|
||||
|
||||
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
|
||||
@@ -33,7 +32,6 @@ test-suite "performance" :
|
||||
# [ test-bsl-run_files performance_vector ]
|
||||
# [ test-bsl-run_files performance_no_rtti ]
|
||||
# [ test-bsl-run_files performance_simple_class ]
|
||||
# [ test-bsl-run_polymorphic_archive performance_polymorphic : ../test/test_polymorphic_A ]
|
||||
|
||||
[ test-bsl-run-no-lib performance_iterators ]
|
||||
[ test-bsl-run-no-lib performance_iterators_base64 ]
|
||||
|
||||
@@ -15,8 +15,8 @@ then
|
||||
echo " threading=single,multi"
|
||||
echo " -sBOOST_ARCHIVE_LIST=<archive name>"
|
||||
else
|
||||
bjam --dump-tests variant=profile preserve-test-targets=on $@ >bjam.log 2>&1
|
||||
process_jam_log --v2 <bjam.log
|
||||
b2 --dump-tests variant=profile preserve-test-targets=on $@ >b2.log 2>&1
|
||||
process_jam_log --v2 <b2ls.log
|
||||
|
||||
# for each test directory
|
||||
|
||||
|
||||
@@ -262,11 +262,11 @@ basic_oarchive_impl::save_object(
|
||||
}
|
||||
|
||||
// we're not tracking this type of object
|
||||
if(! bos.tracking(m_flags)){
|
||||
if(! co.m_bos_ptr->tracking(m_flags)){
|
||||
// just windup the preamble - no object id to write
|
||||
ar.end_preamble();
|
||||
// and save the data
|
||||
(bos.save_object_data)(ar, t);
|
||||
(co.m_bos_ptr->save_object_data)(ar, t);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ basic_oarchive_impl::save_object(
|
||||
ar.vsave(oid);
|
||||
ar.end_preamble();
|
||||
// and data
|
||||
(bos.save_object_data)(ar, t);
|
||||
(co.m_bos_ptr->save_object_data)(ar, t);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ basic_oarchive_impl::save_pointer(
|
||||
}
|
||||
|
||||
// if we're not tracking
|
||||
if(! bos.tracking(m_flags)){
|
||||
if(! co.m_bos_ptr->tracking(m_flags)){
|
||||
// just save the data itself
|
||||
ar.end_preamble();
|
||||
serialization::state_saver<const void *> x(pending_object);
|
||||
|
||||
@@ -82,7 +82,9 @@ struct assign_impl<std::string> {
|
||||
++b;
|
||||
}
|
||||
}
|
||||
//assign_impl(const assign_impl & rhs);
|
||||
assign_impl(const assign_impl & rhs)
|
||||
: m_t(rhs.m_t)
|
||||
{}
|
||||
assign_impl & operator=(assign_impl & rhs);
|
||||
assign_impl(std::string & rhs)
|
||||
: m_t(rhs)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright 2018-2020, 2026 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(NOT HAVE_BOOST_TEST)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::serialization Boost::core)
|
||||
|
||||
boost_test(SOURCES quick.cpp)
|
||||
+16
-14
@@ -1,18 +1,22 @@
|
||||
# Boost serialization Library test Jamfile
|
||||
|
||||
# (C) Copyright Robert Ramey 2002-2004.
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
|
||||
project libs/serialization/test
|
||||
project
|
||||
: id serialization_test
|
||||
: requirements <library>/boost/filesystem
|
||||
: requirements <library>/boost/filesystem//boost_filesystem
|
||||
<library>/boost/math//boost_math_tr1
|
||||
;
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
|
||||
import testing ;
|
||||
|
||||
# import rules from the boost serialization test
|
||||
import ../util/test :
|
||||
@@ -27,9 +31,9 @@ import ../util/test :
|
||||
;
|
||||
|
||||
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
|
||||
|
||||
|
||||
lib dll_a
|
||||
:
|
||||
:
|
||||
dll_a.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
@@ -38,7 +42,7 @@ lib dll_a
|
||||
|
||||
lib dll_polymorphic_base
|
||||
:
|
||||
dll_polymorphic_base.cpp
|
||||
dll_polymorphic_base.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
<link>shared
|
||||
@@ -79,8 +83,6 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_list_ptrs : A ]
|
||||
[ test-bsl-run_files test_map : A ]
|
||||
[ test-bsl-run_files test_map_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
|
||||
[ test-bsl-run_files test_map_unordered : A : : [ requires cxx11_hdr_unordered_map ] ] # BOOST_NO_CXX11_HDR_UNORDERED_MAP
|
||||
[ test-bsl-run_files test_map_boost_unordered : A ]
|
||||
[ test-bsl-run_files test_mi ]
|
||||
[ test-bsl-run_files test_multiple_ptrs : A ]
|
||||
[ test-bsl-run_files test_multiple_inheritance ]
|
||||
@@ -99,8 +101,6 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_registered ]
|
||||
[ test-bsl-run_files test_set : A ]
|
||||
[ test-bsl-run_files test_set_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
|
||||
[ test-bsl-run_files test_set_unordered : A : : [ requires cxx11_hdr_unordered_set ] ] # BOOST_NO_CXX11_HDR_UNORDERED_SET
|
||||
[ test-bsl-run_files test_set_boost_unordered : A ]
|
||||
[ test-bsl-run_files test_simple_class : A ]
|
||||
[ test-bsl-run_files test_simple_class_ptr : A ]
|
||||
[ test-bsl-run_files test_slist : A : : [ requires slist ] ] # BOOST_HAS_SLIST ]
|
||||
@@ -134,7 +134,7 @@ test-suite "serialization" :
|
||||
;
|
||||
|
||||
if ! $(BOOST_ARCHIVE_LIST) {
|
||||
test-suite "serialization2" :
|
||||
test-suite "serialization2" :
|
||||
[ test-bsl-run test_inclusion ]
|
||||
[ test-bsl-run test_inclusion2 ]
|
||||
|
||||
@@ -182,10 +182,12 @@ if ! $(BOOST_ARCHIVE_LIST) {
|
||||
#[ compile test_const_save_warn1_nvp.cpp ]
|
||||
#[ compile test_const_save_warn2_nvp.cpp ]
|
||||
#[ compile test_const_save_warn3_nvp.cpp ]
|
||||
|
||||
|
||||
# should compile
|
||||
[ compile test_traits_pass.cpp ]
|
||||
[ compile test_const_pass.cpp ]
|
||||
;
|
||||
}
|
||||
|
||||
run quick.cpp ../build//boost_serialization ;
|
||||
compile quick.cpp : <exception-handling>off -<library>/boost/filesystem//boost_filesystem -<library>/boost/math//boost_math_tr1 : quick_nx ;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.31)
|
||||
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS serialization core)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::serialization Boost::core)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.31)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
set(BOOST_INCLUDE_LIBRARIES serialization core)
|
||||
add_subdirectory(../../../.. boostorg/boost)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::serialization Boost::core)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2026 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
struct A
|
||||
{
|
||||
int x, y;
|
||||
|
||||
template<class Ar> void serialize( Ar& ar, unsigned /*version*/ )
|
||||
{
|
||||
ar & x;
|
||||
ar & y;
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string tmp;
|
||||
|
||||
{
|
||||
A a = { 1, 2 };
|
||||
|
||||
std::ostringstream os;
|
||||
boost::archive::text_oarchive oa( os );
|
||||
|
||||
oa << a;
|
||||
|
||||
tmp = os.str();
|
||||
}
|
||||
|
||||
{
|
||||
A a = {};
|
||||
|
||||
std::istringstream is( tmp );
|
||||
boost::archive::text_iarchive ia( is );
|
||||
|
||||
ia >> a;
|
||||
|
||||
BOOST_TEST_EQ( a.x, 1 );
|
||||
BOOST_TEST_EQ( a.y, 2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization> <boost_serialization signature="serialization::archive" version="3"> <a class_id="0" tracking_level="0"> <b>1</b> <f>96953204</f> <g>177129195</g> <l>1</l> <m>5627</m> <n>23010</n> <o>7419</o> <p>16212</p> <q>4086</q> <r>2749</r> <c>-33</c> <s>124</s> <t>28</t> <u>32225</u> <v>17543</v> <w>0.84431422</w> <x>1.0170664757130923</x> <y>tjbx</y> <z>cuwjentqpkejp</z> </a> </boost_serialization>
|
||||
@@ -21,7 +21,6 @@ namespace std{
|
||||
#endif
|
||||
|
||||
#include "test_tools.hpp"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <string>
|
||||
@@ -108,7 +107,9 @@ int test_main( int /* argc */, char* /* argv */[] ){
|
||||
|
||||
std::vector<my_string> v1;
|
||||
for(int i=0; i<1000; ++i){
|
||||
v1.push_back(my_string(boost::lexical_cast<std::string>(i % 100)));
|
||||
char sbuffer[10];
|
||||
std::snprintf(sbuffer, sizeof(sbuffer), "%i", i % 100);
|
||||
v1.push_back(my_string(sbuffer));
|
||||
}
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_map.cpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (C) Copyright 2014 Jim Bell
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <algorithm> // std::copy
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cstddef> // size_t, NULL
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::rand;
|
||||
using ::size_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// a key value initialized with a random value for use
|
||||
// in testing STL map serialization
|
||||
struct random_key {
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
Archive & ar,
|
||||
const unsigned int /* file_version */
|
||||
){
|
||||
ar & boost::serialization::make_nvp("random_key", m_i);
|
||||
}
|
||||
int m_i;
|
||||
random_key() : m_i(std::rand()){};
|
||||
bool operator<(const random_key &rhs) const {
|
||||
return m_i < rhs.m_i;
|
||||
}
|
||||
bool operator==(const random_key &rhs) const {
|
||||
return m_i == rhs.m_i;
|
||||
}
|
||||
operator std::size_t () const { // required by hash_map
|
||||
return m_i;
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/serialization/boost_unordered_map.hpp>
|
||||
#include <functional> // requires changeset [69520]; Ticket #5254
|
||||
|
||||
namespace boost {
|
||||
template<>
|
||||
struct hash<random_key>{
|
||||
std::size_t operator()(const random_key& r) const {
|
||||
return static_cast<std::size_t>(r);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
void
|
||||
test_unordered_map(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
BOOST_CHECKPOINT("unordered_map");
|
||||
// test unordered_map of objects
|
||||
boost::unordered_map<random_key, A> anunordered_map;
|
||||
anunordered_map.insert(std::make_pair(random_key(), A()));
|
||||
anunordered_map.insert(std::make_pair(random_key(), A()));
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunorderedmap",anunordered_map);
|
||||
}
|
||||
boost::unordered_map<random_key, A> anunordered_map1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunorderedmap",anunordered_map1);
|
||||
}
|
||||
|
||||
std::vector< std::pair<random_key, A> > tvec, tvec1;
|
||||
std::copy(anunordered_map.begin(), anunordered_map.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_map1.begin(), anunordered_map1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
void
|
||||
test_unordered_multimap(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
BOOST_CHECKPOINT("unordered_multimap");
|
||||
boost::unordered_multimap<random_key, A> anunordered_multimap;
|
||||
anunordered_multimap.insert(std::make_pair(random_key(), A()));
|
||||
anunordered_multimap.insert(std::make_pair(random_key(), A()));
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunordered_multimap", anunordered_multimap);
|
||||
}
|
||||
boost::unordered_multimap<random_key, A> anunordered_multimap1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunordered_multimap", anunordered_multimap1);
|
||||
}
|
||||
std::vector< std::pair<random_key, A> > tvec, tvec1;
|
||||
tvec.clear();
|
||||
tvec1.clear();
|
||||
std::copy(anunordered_multimap.begin(), anunordered_multimap.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_multimap1.begin(), anunordered_multimap1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_unordered_map();
|
||||
test_unordered_multimap();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_map.cpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (C) Copyright 2014 Jim Bell
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <algorithm> // std::copy
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cstddef> // size_t, NULL
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::rand;
|
||||
using ::size_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// a key value initialized with a random value for use
|
||||
// in testing STL map serialization
|
||||
struct random_key {
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
Archive & ar,
|
||||
const unsigned int /* file_version */
|
||||
){
|
||||
ar & boost::serialization::make_nvp("random_key", m_i);
|
||||
}
|
||||
int m_i;
|
||||
random_key() : m_i(std::rand()){};
|
||||
bool operator<(const random_key &rhs) const {
|
||||
return m_i < rhs.m_i;
|
||||
}
|
||||
bool operator==(const random_key &rhs) const {
|
||||
return m_i == rhs.m_i;
|
||||
}
|
||||
operator std::size_t () const { // required by hash_map
|
||||
return m_i;
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/serialization/unordered_map.hpp>
|
||||
#include <functional> // requires changeset [69520]; Ticket #5254
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<random_key>{
|
||||
std::size_t operator()(const random_key& r) const {
|
||||
return static_cast<std::size_t>(r);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
void
|
||||
test_unordered_map(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
BOOST_CHECKPOINT("unordered_map");
|
||||
// test unordered_map of objects
|
||||
std::unordered_map<random_key, A> anunordered_map;
|
||||
anunordered_map.insert(std::make_pair(random_key(), A()));
|
||||
anunordered_map.insert(std::make_pair(random_key(), A()));
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunorderedmap",anunordered_map);
|
||||
}
|
||||
std::unordered_map<random_key, A> anunordered_map1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunorderedmap",anunordered_map1);
|
||||
}
|
||||
|
||||
std::vector< std::pair<random_key, A> > tvec, tvec1;
|
||||
std::copy(anunordered_map.begin(), anunordered_map.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_map1.begin(), anunordered_map1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
void
|
||||
test_unordered_multimap(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
BOOST_CHECKPOINT("unordered_multimap");
|
||||
std::unordered_multimap<random_key, A> anunordered_multimap;
|
||||
anunordered_multimap.insert(std::make_pair(random_key(), A()));
|
||||
anunordered_multimap.insert(std::make_pair(random_key(), A()));
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunordered_multimap", anunordered_multimap);
|
||||
}
|
||||
std::unordered_multimap<random_key, A> anunordered_multimap1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunordered_multimap", anunordered_multimap1);
|
||||
}
|
||||
std::vector< std::pair<random_key, A> > tvec, tvec1;
|
||||
tvec.clear();
|
||||
tvec1.clear();
|
||||
std::copy(anunordered_multimap.begin(), anunordered_multimap.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_multimap1.begin(), anunordered_multimap1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_unordered_map();
|
||||
test_unordered_multimap();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ struct Sub :
|
||||
Base2(x),
|
||||
m_x(x)
|
||||
{}
|
||||
bool operator==(Sub & rhs) const {
|
||||
bool operator==(const Sub & rhs) const {
|
||||
if(! Base2::operator==(rhs))
|
||||
return false;
|
||||
if(! Base1::operator==(rhs))
|
||||
|
||||
+30
-20
@@ -23,8 +23,6 @@ namespace std{
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/optional.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
struct A {
|
||||
int m_x;
|
||||
@@ -44,18 +42,19 @@ struct A {
|
||||
{}
|
||||
};
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
// Optional is the class optional implementation you use
|
||||
template<template<class> class Optional>
|
||||
int test(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
const boost::optional<int> aoptional1;
|
||||
const boost::optional<int> aoptional2(123);
|
||||
const boost::optional<A> aoptional3;
|
||||
const Optional<int> aoptional1;
|
||||
const Optional<int> aoptional2(123);
|
||||
const Optional<A> aoptional3;
|
||||
A a(1);
|
||||
const boost::optional<A> aoptional4(a);
|
||||
const boost::optional<A *> aoptional5;
|
||||
const boost::optional<A *> aoptional6(& a);
|
||||
const Optional<A> aoptional4(a);
|
||||
const Optional<A *> aoptional5;
|
||||
const Optional<A *> aoptional6(& a);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
@@ -66,12 +65,12 @@ int test_main( int /* argc */, char* /* argv */[] )
|
||||
oa << boost::serialization::make_nvp("aoptional5",aoptional5);
|
||||
oa << boost::serialization::make_nvp("aoptional6",aoptional6);
|
||||
}
|
||||
boost::optional<int> aoptional1a(999);
|
||||
boost::optional<int> aoptional2a;
|
||||
boost::optional<A> aoptional3a;
|
||||
boost::optional<A> aoptional4a;
|
||||
boost::optional<A *> aoptional5a;
|
||||
boost::optional<A *> aoptional6a;
|
||||
Optional<int> aoptional1a(999);
|
||||
Optional<int> aoptional2a;
|
||||
Optional<A> aoptional3a;
|
||||
Optional<A> aoptional4a;
|
||||
Optional<A *> aoptional5a;
|
||||
Optional<A *> aoptional6a;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
@@ -85,12 +84,23 @@ int test_main( int /* argc */, char* /* argv */[] )
|
||||
BOOST_CHECK(aoptional1 == aoptional1a);
|
||||
BOOST_CHECK(aoptional2 == aoptional2a);
|
||||
BOOST_CHECK(aoptional3 == aoptional3a);
|
||||
BOOST_CHECK(aoptional4.get() == aoptional4a.get());
|
||||
BOOST_CHECK(aoptional5 == aoptional5a);
|
||||
BOOST_CHECK(*aoptional6.get() == *aoptional6a.get());
|
||||
BOOST_CHECK(aoptional4 == aoptional4a);
|
||||
BOOST_CHECK(aoptional5 == aoptional5a); // not initialized
|
||||
BOOST_CHECK(**aoptional6 == **aoptional6a);
|
||||
|
||||
std::remove(testfile);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// EOF
|
||||
#include <boost/serialization/optional.hpp>
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
#include <optional>
|
||||
#endif
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] ){
|
||||
test<boost::optional>();
|
||||
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
|
||||
test<std::optional>();
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace std{
|
||||
#include <vector>
|
||||
|
||||
#include "test_tools.hpp"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
@@ -121,7 +120,9 @@ int test_main(int /* argc */, char * /* argv */ [])
|
||||
|
||||
std::vector<my_string> v1;
|
||||
for(int i=0; i<1000; ++i){
|
||||
v1.push_back(my_string(boost::lexical_cast<std::string>(i % 100)));
|
||||
char sbuffer[10];
|
||||
std::snprintf(sbuffer, sizeof(sbuffer), "%i", i % 100);
|
||||
v1.push_back(my_string(sbuffer));
|
||||
}
|
||||
|
||||
// test using using polymorphic implementation.
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_set.cpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (C) Copyright 2014 Jim Bell
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <cstddef> // NULLsize_t
|
||||
#include <cstdio> // remove
|
||||
#include <fstream>
|
||||
|
||||
#include <algorithm> // std::copy
|
||||
#include <vector>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::remove;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/set.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
#include <boost/serialization/boost_unordered_set.hpp>
|
||||
#include <functional> // requires changeset [69520]; Ticket #5254
|
||||
|
||||
namespace boost {
|
||||
template<>
|
||||
struct hash<A> {
|
||||
std::size_t operator()(const A& a) const {
|
||||
return static_cast<std::size_t>(a);
|
||||
}
|
||||
};
|
||||
} // namespace boost
|
||||
|
||||
void
|
||||
test_unordered_set(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
// test array of objects
|
||||
boost::unordered_set<A> anunordered_set;
|
||||
A a, a1;
|
||||
anunordered_set.insert(a);
|
||||
anunordered_set.insert(a1);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunordered_set", anunordered_set);
|
||||
}
|
||||
boost::unordered_set<A> anunordered_set1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunordered_set", anunordered_set1);
|
||||
}
|
||||
std::vector<A> tvec, tvec1;
|
||||
tvec.clear();
|
||||
tvec1.clear();
|
||||
std::copy(anunordered_set.begin(), anunordered_set.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_set1.begin(), anunordered_set1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
void
|
||||
test_unordered_multiset(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
boost::unordered_multiset<A> anunordered_multiset;
|
||||
anunordered_multiset.insert(A());
|
||||
anunordered_multiset.insert(A());
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunordered_multiset", anunordered_multiset);
|
||||
}
|
||||
boost::unordered_multiset<A> anunordered_multiset1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunordered_multiset", anunordered_multiset1);
|
||||
}
|
||||
|
||||
std::vector<A> tvec, tvec1;
|
||||
tvec.clear();
|
||||
tvec1.clear();
|
||||
std::copy(anunordered_multiset.begin(), anunordered_multiset.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_multiset1.begin(), anunordered_multiset1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] ){
|
||||
test_unordered_set();
|
||||
test_unordered_multiset();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_set.cpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (C) Copyright 2014 Jim Bell
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <cstddef> // NULLsize_t
|
||||
#include <cstdio> // remove
|
||||
#include <fstream>
|
||||
|
||||
#include <algorithm> // std::copy
|
||||
#include <vector>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::remove;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/set.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
#include <boost/serialization/unordered_set.hpp>
|
||||
#include <functional> // requires changeset [69520]; Ticket #5254
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<A> {
|
||||
std::size_t operator()(const A& a) const {
|
||||
return static_cast<std::size_t>(a);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
void
|
||||
test_unordered_set(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
// test array of objects
|
||||
std::unordered_set<A> anunordered_set;
|
||||
A a, a1;
|
||||
anunordered_set.insert(a);
|
||||
anunordered_set.insert(a1);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunordered_set", anunordered_set);
|
||||
}
|
||||
std::unordered_set<A> anunordered_set1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunordered_set", anunordered_set1);
|
||||
}
|
||||
std::vector<A> tvec, tvec1;
|
||||
tvec.clear();
|
||||
tvec1.clear();
|
||||
std::copy(anunordered_set.begin(), anunordered_set.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_set1.begin(), anunordered_set1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
void
|
||||
test_unordered_multiset(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
std::unordered_multiset<A> anunordered_multiset;
|
||||
anunordered_multiset.insert(A());
|
||||
anunordered_multiset.insert(A());
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("anunordered_multiset", anunordered_multiset);
|
||||
}
|
||||
std::unordered_multiset<A> anunordered_multiset1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("anunordered_multiset", anunordered_multiset1);
|
||||
}
|
||||
|
||||
std::vector<A> tvec, tvec1;
|
||||
tvec.clear();
|
||||
tvec1.clear();
|
||||
std::copy(anunordered_multiset.begin(), anunordered_multiset.end(), std::back_inserter(tvec));
|
||||
std::sort(tvec.begin(), tvec.end());
|
||||
std::copy(anunordered_multiset1.begin(), anunordered_multiset1.end(), std::back_inserter(tvec1));
|
||||
std::sort(tvec1.begin(), tvec1.end());
|
||||
BOOST_CHECK(tvec == tvec1);
|
||||
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] ){
|
||||
test_unordered_set();
|
||||
test_unordered_multiset();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+122
-187
@@ -6,6 +6,10 @@
|
||||
// troy d. straszheim <troy@resophonic.com>
|
||||
// http://www.resophonic.com
|
||||
//
|
||||
// copyright (c) 2023
|
||||
// Robert Ramey <ramey@rrsd.com>
|
||||
// http://www.rrsd.com
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -15,6 +19,8 @@
|
||||
// thanks to Robert Ramey and Peter Dimov.
|
||||
//
|
||||
|
||||
#include <boost/serialization/variant.hpp>
|
||||
|
||||
#include <cstddef> // NULL
|
||||
#include <cstdio> // remove
|
||||
#include <fstream>
|
||||
@@ -24,8 +30,13 @@
|
||||
#include <boost/math/special_functions/next.hpp>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_VARIANT) && defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 70000
|
||||
// Clang 6.0 can't compile std::visit from libstdc++ 9
|
||||
# define BOOST_NO_CXX17_HDR_VARIANT
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
namespace std {
|
||||
using ::remove;
|
||||
}
|
||||
#endif
|
||||
@@ -33,7 +44,6 @@ namespace std{
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1020)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
@@ -42,17 +52,29 @@ namespace std{
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/variant.hpp>
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
|
||||
#include <boost/variant/variant.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
# include <boost/variant2/variant.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
# include <variant>
|
||||
#endif
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
class are_equal
|
||||
class are_equal_vis
|
||||
: public boost::static_visitor<bool>
|
||||
{
|
||||
public:
|
||||
typedef bool result_type;
|
||||
// note extra rigamarole for compilers which don't support
|
||||
// partial function template ordering - specifically msvc 6.x
|
||||
struct same {
|
||||
@@ -79,6 +101,12 @@ public:
|
||||
return type::invoke(t, u);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
bool operator()(T * const & t, U * const & u) const
|
||||
{
|
||||
return this->operator()(*t, *u);
|
||||
}
|
||||
|
||||
bool operator()( const float & lhs, const float & rhs ) const
|
||||
{
|
||||
#if BOOST_CXX_VERSION > 199711L // only include floating point if C++ version >= C++11
|
||||
@@ -97,215 +125,122 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void test_type(const T& gets_written){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("written", gets_written);
|
||||
}
|
||||
|
||||
T got_read;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", got_read);
|
||||
}
|
||||
BOOST_CHECK(boost::apply_visitor(are_equal(), gets_written, got_read));
|
||||
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
// this verifies that if you try to read in a variant from a file
|
||||
// whose "which" is illegal for the one in memory (that is, you're
|
||||
// reading in to a different variant than you wrote out to) the load()
|
||||
// operation will throw. One could conceivably add checking for
|
||||
// sequence length as well, but this would add size to the archive for
|
||||
// dubious benefit.
|
||||
//
|
||||
void do_bad_read()
|
||||
template<class... T> bool are_equal( boost::variant<T...> const& v1, boost::variant<T...> const& v2 )
|
||||
{
|
||||
// Compiling this test invokes and ICE on msvc 6
|
||||
// So, we'll just to skip it for this compiler
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1020)
|
||||
boost::variant<bool, float, int, std::string> big_variant;
|
||||
big_variant = std::string("adrenochrome");
|
||||
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << BOOST_SERIALIZATION_NVP(big_variant);
|
||||
}
|
||||
boost::variant<bool, float, int> little_variant;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
bool exception_invoked = false;
|
||||
BOOST_TRY {
|
||||
ia >> BOOST_SERIALIZATION_NVP(little_variant);
|
||||
} BOOST_CATCH (boost::archive::archive_exception const& e) {
|
||||
BOOST_CHECK(boost::archive::archive_exception::unsupported_version == e.code);
|
||||
exception_invoked = true;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
BOOST_CHECK(exception_invoked);
|
||||
}
|
||||
#endif
|
||||
return boost::apply_visitor( are_equal_vis(), v1, v2 );
|
||||
}
|
||||
|
||||
struct H {
|
||||
int i;
|
||||
};
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive &ar, H & h, const unsigned int /*file_version*/){
|
||||
ar & boost::serialization::make_nvp("h", h.i);
|
||||
template<class... T> bool are_equal( boost::variant2::variant<T...> const& v1, boost::variant2::variant<T...> const& v2 )
|
||||
{
|
||||
return boost::variant2::visit( are_equal_vis(), v1, v2 );
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
#endif
|
||||
|
||||
inline bool operator==(H const & lhs, H const & rhs) {
|
||||
return lhs.i == rhs.i;
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
|
||||
template<class... T> bool are_equal( std::variant<T...> const& v1, std::variant<T...> const& v2 )
|
||||
{
|
||||
return std::visit( are_equal_vis(), v1, v2 );
|
||||
}
|
||||
|
||||
inline bool operator!=(H const & lhs, H const & rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline bool operator<(H const & lhs, H const & rhs) {
|
||||
return lhs.i < rhs.i;
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(H const & val) {
|
||||
return val.i;
|
||||
}
|
||||
|
||||
void test_pointer(){
|
||||
template<class Variant>
|
||||
bool test_type(const Variant & v){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
typedef boost::variant<H, int> variant_t;
|
||||
H const h = {5};
|
||||
variant_t v(h);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("written", v);
|
||||
const H * h_ptr = & boost::strict_get<H const &>(v);
|
||||
oa << boost::serialization::make_nvp("written", h_ptr);
|
||||
}
|
||||
variant_t v2;
|
||||
|
||||
Variant vx;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", v2);
|
||||
H * h2_ptr;
|
||||
ia >> boost::serialization::make_nvp("written", h2_ptr);
|
||||
BOOST_CHECK_EQUAL(h, boost::strict_get<H const>(v2));
|
||||
BOOST_CHECK_EQUAL(h2_ptr, & boost::strict_get<H const &>(v2));
|
||||
BOOST_TRY {
|
||||
ia >> boost::serialization::make_nvp("written", vx);
|
||||
BOOST_CHECK(are_equal(v, vx));
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception const& e) {
|
||||
return false;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
BOOST_CHECK_EQUAL(v, v2);
|
||||
std::remove(testfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <boost/serialization/map.hpp>
|
||||
#include <boost/serialization/set.hpp>
|
||||
|
||||
// test a pointer to an object contained into a variant that is an
|
||||
// element of a set
|
||||
void test_variant_set()
|
||||
template<class Variant>
|
||||
void test(Variant & v)
|
||||
{
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
typedef boost::variant<H, int> variant_t;
|
||||
typedef std::set<variant_t> uset_t;
|
||||
uset_t set;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
H const h = {5};
|
||||
variant_t v(h);
|
||||
set.insert(v);
|
||||
oa << boost::serialization::make_nvp("written", set);
|
||||
H const * const h_ptr = boost::strict_get<H const>(&(*set.begin()));
|
||||
oa << boost::serialization::make_nvp("written", h_ptr);
|
||||
}
|
||||
uset_t set2;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", set2);
|
||||
H * h_ptr;
|
||||
ia >> boost::serialization::make_nvp("written", h_ptr);
|
||||
const H * h_ptr2 = & boost::strict_get<H const>(*set2.begin());
|
||||
BOOST_CHECK_EQUAL(h_ptr, h_ptr2);
|
||||
}
|
||||
BOOST_CHECK_EQUAL(set, set2);
|
||||
// uninitialized
|
||||
test_type(v);
|
||||
v = false;
|
||||
test_type(v);
|
||||
v = 1;
|
||||
test_type(v);
|
||||
v = (float) 2.3;
|
||||
test_type(v);
|
||||
v = (double) 6.4;
|
||||
test_type(v);
|
||||
v = A();
|
||||
test_type(v);
|
||||
v = std::string("we can't stop here, this is Bat Country");
|
||||
test_type(v);
|
||||
}
|
||||
|
||||
// test a pointer to an object contained into a variant that is an
|
||||
// element of a map
|
||||
void test_variant_map()
|
||||
{
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
typedef boost::variant<H, int> variant_t;
|
||||
typedef std::map<int, variant_t> map_t;
|
||||
map_t map;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
H const h = {5};
|
||||
variant_t v(h);
|
||||
map[0] = v;
|
||||
BOOST_ASSERT(1 == map.size());
|
||||
oa << boost::serialization::make_nvp("written", map);
|
||||
H const * const h_ptr = boost::strict_get<H const>(&map[0]);
|
||||
BOOST_CHECK_EQUAL(h_ptr, boost::strict_get<H const>(&map[0]));
|
||||
oa << boost::serialization::make_nvp("written", h_ptr);
|
||||
}
|
||||
map_t map2;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", map2);
|
||||
BOOST_ASSERT(1 == map2.size());
|
||||
H * h_ptr;
|
||||
ia >> boost::serialization::make_nvp("written", h_ptr);
|
||||
H const * const h_ptr2 = boost::strict_get<H const>(&map2[0]);
|
||||
BOOST_CHECK_EQUAL(h_ptr, h_ptr2);
|
||||
}
|
||||
BOOST_CHECK_EQUAL(map, map2);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
{
|
||||
boost::variant<bool, int, float, double, A, std::string> v;
|
||||
v = false;
|
||||
test_type(v);
|
||||
v = 1;
|
||||
test_type(v);
|
||||
v = (float) 2.3;
|
||||
test_type(v);
|
||||
v = (double) 6.4;
|
||||
test_type(v);
|
||||
v = std::string("we can't stop here, this is Bat Country");
|
||||
test_type(v);
|
||||
v = A();
|
||||
test_type(v);
|
||||
}
|
||||
test_pointer();
|
||||
test_variant_set();
|
||||
test_variant_map();
|
||||
do_bad_read();
|
||||
int test_boost_variant(){
|
||||
std::cerr << "Testing boost_variant\n";
|
||||
boost::variant<bool, int, float, double, A, std::string> v;
|
||||
test(v);
|
||||
const A a;
|
||||
boost::variant<bool, int, float, double, const A *, std::string> v1 = & a;
|
||||
test_type(v1);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// boost::variant2/variant requires C++ 11
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
|
||||
int test_boost_variant2(){
|
||||
std::cerr << "Testing boost_variant2\n";
|
||||
boost::variant2::variant<bool, int, float, double, A, std::string> v;
|
||||
test(v);
|
||||
const A a;
|
||||
boost::variant2::variant<bool, int, float, double, const A *, std::string> v1 = & a;
|
||||
test_type(v1);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
// std::variant reqires C++ 17 or more
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
|
||||
int test_std_variant(){
|
||||
std::cerr << "Testing Std Variant\n";
|
||||
std::variant<bool, int, float, double, A, std::string> v;
|
||||
test(v);
|
||||
const A a;
|
||||
std::variant<bool, int, float, double, const A *, std::string> v1 = & a;
|
||||
test_type(v1);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] ){
|
||||
return test_boost_variant()
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
|| test_boost_variant2()
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|
||||
|| test_std_variant()
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
+39
-41
@@ -1,8 +1,8 @@
|
||||
# Boost serialization Library utility test Jamfile
|
||||
|
||||
# (C) Copyright Robert Ramey 2002-2004.
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# Use, modification, and distribution are subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying file
|
||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
# tests.
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
import config : requires ;
|
||||
|
||||
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
|
||||
|
||||
# these are used to shorten testing while in development. It permits
|
||||
# testing to be applied to just a particular type of archive
|
||||
if ! $(BOOST_ARCHIVE_LIST) {
|
||||
BOOST_ARCHIVE_LIST =
|
||||
"text_archive.hpp"
|
||||
"text_warchive.hpp"
|
||||
"binary_archive.hpp"
|
||||
"xml_archive.hpp"
|
||||
"xml_warchive.hpp"
|
||||
BOOST_ARCHIVE_LIST =
|
||||
"text_archive.hpp"
|
||||
"text_warchive.hpp"
|
||||
"binary_archive.hpp"
|
||||
"xml_archive.hpp"
|
||||
"xml_warchive.hpp"
|
||||
;
|
||||
# enable the tests which don't depend on a particular archive
|
||||
BOOST_SERIALIZATION_TEST = true ;
|
||||
@@ -50,15 +50,13 @@ rule run-template ( test-name : sources * : files * : requirements * ) {
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
|
||||
<toolset>msvc:<cxxflags>"-wd4996"
|
||||
<toolset>clang,<target-os>windows:<define>_CRT_SECURE_NO_WARNINGS
|
||||
<toolset>clang:<variant>debug:<cxxflags>"-fsanitize=memory"
|
||||
# toolset optimizations
|
||||
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>msvc:<cxxflags>"-Gy"
|
||||
# linking
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
<link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
<link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
|
||||
$(requirements)
|
||||
: # test name
|
||||
$(test-name)
|
||||
@@ -73,7 +71,7 @@ rule dependency-save-test ( test )
|
||||
if $(m)
|
||||
{
|
||||
return $(m[1])save$(m[2]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# each of the following tests is run with each type of archive
|
||||
@@ -82,7 +80,7 @@ rule run-invoke ( test-name : sources * : files * : requirements * )
|
||||
local save-test = [ dependency-save-test $(test-name) ] ;
|
||||
|
||||
local tests ;
|
||||
tests += [
|
||||
tests += [
|
||||
run-template $(test-name)
|
||||
: # sources
|
||||
$(sources)
|
||||
@@ -102,7 +100,7 @@ rule run-winvoke ( test-name : sources * : files * : requirements * )
|
||||
local save-test = [ dependency-save-test $(test-name) ] ;
|
||||
|
||||
local tests ;
|
||||
tests += [
|
||||
tests += [
|
||||
run-template $(test-name)
|
||||
: # sources
|
||||
$(sources)
|
||||
@@ -124,7 +122,7 @@ rule run-winvoke ( test-name : sources * : files * : requirements * )
|
||||
rule test-bsl-run-no-lib ( test-name : sources * : requirements * )
|
||||
{
|
||||
local tests ;
|
||||
tests += [
|
||||
tests += [
|
||||
run-template $(test-name)
|
||||
: # sources
|
||||
$(test-name).cpp $(sources).cpp
|
||||
@@ -139,8 +137,8 @@ rule test-bsl-run-no-lib ( test-name : sources * : requirements * )
|
||||
rule test-bsl-run ( test-name : sources * : libs * : requirements * )
|
||||
{
|
||||
local tests ;
|
||||
tests += [
|
||||
run-invoke $(test-name)
|
||||
tests += [
|
||||
run-invoke $(test-name)
|
||||
: # sources
|
||||
$(test-name).cpp $(sources).cpp $(libs)
|
||||
: # input files
|
||||
@@ -191,27 +189,27 @@ rule test-bsl-run_archive ( test-name : archive-name : sources * : libs * : requ
|
||||
rule test-bsl-run_files ( test-name : sources * : libs * : requirements * ) {
|
||||
local tests ;
|
||||
for local defn in $(BOOST_ARCHIVE_LIST) {
|
||||
tests += [
|
||||
test-bsl-run_archive $(test-name)
|
||||
: $(defn:LB)
|
||||
: $(test-name) $(sources)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
] ;
|
||||
}
|
||||
return $(tests) ;
|
||||
}
|
||||
|
||||
rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
|
||||
local tests ;
|
||||
for local defn in $(BOOST_ARCHIVE_LIST) {
|
||||
#ECHO polymorphic_$(defn:LB) ;
|
||||
tests += [
|
||||
test-bsl-run_archive $(test-name)
|
||||
: polymorphic_$(defn:LB)
|
||||
: $(test-name) $(sources)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
tests += [
|
||||
test-bsl-run_archive $(test-name)
|
||||
: $(defn:LB)
|
||||
: $(test-name) $(sources)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
] ;
|
||||
}
|
||||
return $(tests) ;
|
||||
}
|
||||
|
||||
rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
|
||||
local tests ;
|
||||
for local defn in $(BOOST_ARCHIVE_LIST) {
|
||||
#ECHO polymorphic_$(defn:LB) ;
|
||||
tests += [
|
||||
test-bsl-run_archive $(test-name)
|
||||
: polymorphic_$(defn:LB)
|
||||
: $(test-name) $(sources)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
] ;
|
||||
}
|
||||
return $(tests) ;
|
||||
|
||||
Reference in New Issue
Block a user