Compare commits

...

69 Commits

Author SHA1 Message Date
Robert Ramey a20c4d97c3 removed C++03 dependency from test 2023-11-12 21:05:11 -08:00
Robert Ramey 9aa208d9be made C++ 11 the default 2023-11-02 20:23:32 -07:00
Robert Ramey ff0a5f9f4a corrected inclusion of <optional> 2023-11-02 20:17:08 -07:00
Robert Ramey e01b988e70 Merge branch 'develop'
* develop: (108 commits)
  removed unordered tests
  tests have been taken over by developers of boost unordered
  uploading changes regarding unordered ... uploading tweaks to CMakeLists.txt so accommodate static linking
  imported/implemented boost/serialization/variant  and test_variant
  Remove serialization support from Boost.Unordered containers
  Fix invalid vptr access in extended_type_info_no_rtti constructor
  Fix invalid downcast in ~xml_oarchive_impl
  altered boost optional to depend only public interface functions declared in std::optional. adjusted test_optional to test serialization of both boost::optional and std::optional
  Revert "Add serialization for std::optional"
  fix new requirement - if assigment is not defaulted, copy can't be either
  Fix clang-cl regression introduced by #282
  correction in previous merge
  Remove debug output from util/test.jam
  Fix Sub::operator== signature to avoid ambiguity errors in C++20
  Remove C++03 from GHA, because Variant and LexicalCast no longer compile under C++03
  incremement archive version number fix PR 274 fix PR 283
  committing most pending PRs
  Replace static_cast with reinterpet_cast in interface_oarchive
  Update xml_escape::fill() to default assign bstart, bend to an empty string
  Use the first instance of bos during serialization (for the case when there are multiple instances)
  ...
2023-11-01 14:17:27 -07:00
Robert Ramey e4756b71b5 removed unordered tests 2023-11-01 14:16:26 -07:00
Robert Ramey f3eaf91ca1 tests have been taken over by developers of boost unordered 2023-10-31 14:32:34 -07:00
Robert Ramey a2f93247e2 uploading changes regarding unordered ...
uploading tweaks to CMakeLists.txt so accommodate static linking
2023-10-20 15:20:43 -07:00
Robert Ramey 01c26ba107 Merge pull request #292 from cmazakas/ubsan-fixes-v2
ubsan fixes v2
2023-10-20 13:42:37 -07:00
Robert Ramey 404e0a31ae Merge pull request #289 from cmazakas/unordered-serialization
Remove serialization support from Boost.Unordered containers
2023-10-13 12:48:01 -07:00
Robert Ramey 90e3ce2fb9 cleanup of files which shouldn't be there. 2023-10-10 12:42:47 -07:00
Robert Ramey 897dec4c01 imported/implemented boost/serialization/variant and test_variant
imported/implemented boost/serialization/variant now contains code for serialization of boost::variant, boost::variant2 and std::variant. Care has been taken to depend only on the public interfaces of these types. Hence, it is reasonable to hope that the archives are compatible in that one type could be saved and subsequently loaded into a compatible type.  Hopefully this will be useful in some way.  At a minimum it minimizes code duplication.
2023-09-18 10:49:21 -07:00
Christian Mazakas f28482232d Remove serialization support from Boost.Unordered containers
Unordered now supports its Serialization functions so the headers just need to be updated to keep backwards compatibility
2023-09-11 14:52:51 -07:00
Christian Mazakas 6388138a0c Fix invalid vptr access in extended_type_info_no_rtti constructor
Initializing a base class in the initializer list with a member function in the derived is invalid in gcc as the object isn't fully-formed

We instead just inline the body of `get_key()` which avoids the issue.
2023-09-11 13:59:51 -07:00
Christian Mazakas 8d0fbb79f3 Fix invalid downcast in ~xml_oarchive_impl
The destructor of the xml_oarchive_impl winds up calling `this->windup()` which in turn invokes `this->This()->...` which essentially static_cast's to a Archive, which by this point in time is long-since destructed.

By simply inlining the implementation of windup(), we avoid the UB and minimize the required code changes
2023-09-11 13:59:51 -07:00
Robert Ramey 61a2b12076 altered boost optional to depend only public interface functions declared in std::optional.
adjusted test_optional to test serialization of both boost::optional and std::optional
2023-09-08 09:54:14 -07:00
Robert Ramey 5ba9e77ad6 Merge pull request #299 from boostorg/revert-163-add-std-optional-support
Revert "Add serialization for std::optional"
2023-09-03 14:37:14 -07:00
Robert Ramey 74c46ec43c Revert "Add serialization for std::optional" 2023-09-03 14:36:59 -07:00
Robert Ramey 1af820b02e Merge pull request #163 from sdebionne/add-std-optional-support
Add serialization for std::optional
2023-09-03 14:19:57 -07:00
Robert Ramey cb729f5d88 Merge pull request #148 from sdebionne/add-std-variant-support
Add support for C++17 std::variant
2023-09-03 13:06:00 -07:00
Robert Ramey ae305113ff Merge pull request #287 from olologin/fix_for_multiple_bos_in_process
Use the first instance of bos during serialization
2023-09-01 15:14:12 -07:00
Robert Ramey c241d3485c fix new requirement - if assigment is not defaulted, copy can't be either 2023-08-30 13:16:20 -07:00
Robert Ramey 9cd8257b08 Merge commit '6bf961f31e7e13c18548b553070e132347d2b58b' into develop
* commit '6bf961f31e7e13c18548b553070e132347d2b58b':
  Guard MSVC pragmas from clang-cl
2023-08-29 15:05:10 -07:00
Peter Dimov 030b627dce Fix clang-cl regression introduced by #282 2023-08-28 17:37:15 +03:00
Robert Ramey 14b10185de correction in previous merge 2023-08-27 07:40:09 -07:00
Robert Ramey 0e15a5984b Merge commit 'f395fa35faf32a89de4673fa54635eeb5eb39f0c' into develop
* commit 'f395fa35faf32a89de4673fa54635eeb5eb39f0c':
  Remove debug output from util/test.jam
2023-08-26 22:27:29 -07:00
Robert Ramey dfe5c018f8 Merge commit '48a60a2bbb6b214d3c295fc2943aff22db63a944' into develop
* commit '48a60a2bbb6b214d3c295fc2943aff22db63a944':
  Remove C++03 from GHA, because Variant and LexicalCast no longer compile under C++03
2023-08-26 22:27:05 -07:00
Peter Dimov f395fa35fa Remove debug output from util/test.jam 2023-08-26 00:27:50 +03:00
Peter Dimov 52bcaffa8c Fix Sub::operator== signature to avoid ambiguity errors in C++20 2023-08-26 00:08:48 +03:00
Peter Dimov 48a60a2bbb Remove C++03 from GHA, because Variant and LexicalCast no longer compile under C++03 2023-08-25 20:57:19 +03:00
Robert Ramey 9a72e5407b incremement archive version number
fix PR 274
fix PR 283
2023-08-24 11:47:59 -07:00
Robert Ramey ab1da83f40 committing most pending PRs 2023-08-23 15:49:25 -07:00
Robert Ramey 60a28371c5 Merge pull request #288 from cmazakas/xml-ubsan-fixes
XML ubsan fixes
2023-08-23 11:58:32 -07:00
Robert Ramey 2cda20b221 Merge pull request #285 from SilverPlate3/BOOT_CLASS_EXPORT__Issue222
Change BOOT_CLASS_EXPORT to BOOST_CLASS_EXPORT
2023-08-23 11:55:32 -07:00
Robert Ramey ae69bf4ba9 Merge pull request #284 from mborland/gha
Use containers to supported deprecated OS with GHA
2023-08-23 11:53:50 -07:00
Robert Ramey f3c564c1fd Merge pull request #282 from boostorg/better_config
Simplify no wstreambuf support.
2023-08-23 11:52:32 -07:00
Robert Ramey 5e8c130c5e Merge pull request #280 from ecatmur/deprecated-copy
Declare non-ODR-used copy constructor
2023-08-23 11:51:24 -07:00
Robert Ramey bb4d07e874 Merge pull request #277 from TobiasLange75443/develop
add ':' (colon) as valid char for an XML tag
2023-08-23 11:50:08 -07:00
Robert Ramey cc2d5dc850 Merge pull request #276 from Romain-Geissler-1A/fix-deprecated-copy-warning
Fix clang -Wdeprecated-copy warning when using -std=gnu++2b in boost/archive/detail/helper_collection.hpp
2023-08-23 11:47:41 -07:00
Robert Ramey 7d0e15503f Merge pull request #275 from josch/document-archive-version-19
src/basic_archive.cpp: improve docs for archive version 19
2023-08-23 11:43:46 -07:00
Christian Mazakas d56e16b391 Replace static_cast with reinterpet_cast in interface_oarchive
There's no inheritance so static_cast'ing to a base is incorrect, instead we use reinterpret_cast with the common initial sequence to avoid ubsan failures
2023-08-22 12:44:58 -07:00
Christian Mazakas 0e64d96019 Update xml_escape::fill() to default assign bstart, bend to an empty string
This avoids an extraneous warning when running Serialization code through ubsan which flags increments to a nullptr

The relevant condtional check (`++m_bnext < m_bend`) still passes with this change
2023-08-22 12:43:39 -07:00
olologin b83e440efe Use the first instance of bos during serialization (for the case when there are multiple instances) 2023-07-20 16:35:37 +03:00
SilverPlate3 2aabad74cc Change BOOT_CLASS_EXPORT to BOOST_CLASS_EXPORT 2023-07-08 14:35:34 +03:00
Matt Borland 5b08b01437 Add clang-win and MSVC 14.3 2023-07-07 10:03:06 +02:00
Matt Borland 9bd9550ad1 Suppress additional polymorphic UB warning 2023-07-06 10:39:00 +02:00
Matt Borland be9421f80f Suppress UB warning 2023-07-05 17:27:02 +02:00
Matt Borland cf5d908a8b Add msvc-14.0 2023-07-05 17:06:07 +02:00
Matt Borland 856eb3a567 Reduce UBSAN runs 2023-07-05 11:23:05 +02:00
Matt Borland efddba7b8f Change concurrency to support multiple workflows 2023-07-05 11:19:50 +02:00
Matt Borland ef7e8c4ca5 Change tested language standards 2023-06-30 15:19:25 +02:00
Matt Borland a0d30cbb18 Add null check 2023-06-30 13:58:34 +02:00
Matt Borland a278309f29 Update windows version and add concurrency feature 2023-06-29 13:03:57 +02:00
Matt Borland 85cb258dd2 Fix package being installed 2023-06-29 13:01:33 +02:00
Matt Borland 87e657de24 Change shell to bash 2023-06-29 09:38:51 +02:00
Matt Borland 7a70b2fca2 Increase timeout time 2023-06-28 18:14:06 +02:00
Matt Borland b7b504829f Use containers to supported deprecated OS with GHA 2023-06-28 08:23:07 +02:00
Ed Catmur 58d722996e Also: remove redundant copy assignment operator
since it deprecates the compiler-provided copy constructor

the compiler-provided copy assignment operator is identical
2023-02-22 23:01:21 +00:00
Ed Catmur a456d33e25 Declare non-ODR-used copy constructor
The compiler-generated copy constructor is deprecated since C++11 on classes with user-declared copy assignment operator.

This change allows clean compilation with the -Wdeprecated-copy/-Wdeprecated-copy-with-user-provided-ctor flag.
2023-02-22 19:59:38 +00:00
Tobias Lange c977d4e623 add ':' (colon) as valid char for an XML tag 2023-01-12 10:05:53 +01:00
Romain Geissler a7a8704438 Fix clang -Wdeprecated-copy warning when using -std=gnu++2b in boost/archive/detail/helper_collection.hpp
In file included from magadm/CmdGetInfoHTHSession.cpp:24:
In file included from /remote/users/mlamesch/CloneFromPlatinum/SI_Pack23-2/common/include/si/common/HTHSegmentationCacheInfoSerialization.h:19:
In file included from /data/mwrep/res/osp/Boost/23-0-0-0/include/boost/archive/text_iarchive.hpp:24:
In file included from /data/mwrep/res/osp/Boost/23-0-0-0/include/boost/archive/basic_text_iarchive.hpp:30:
In file included from /data/mwrep/res/osp/Boost/23-0-0-0/include/boost/archive/detail/common_iarchive.hpp:21:
In file included from /data/mwrep/res/osp/Boost/23-0-0-0/include/boost/archive/detail/basic_iarchive.hpp:28:
/data/mwrep/res/osp/Boost/23-0-0-0/include/boost/archive/detail/helper_collection.hpp:58:44: error: definition of implicit copy constructor for 'predicate' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
        BOOST_DELETED_FUNCTION(predicate & operator=(const predicate & rhs))
                                           ^
/opt/1A/toolchain/x86_64-v23.0.2/lib64/gcc/x86_64-1a-linux-gnu/13.0.0/../../../../include/c++/13.0.0/bits/predefined_ops.h:325:37: note: in implicit copy constructor for 'boost::archive::detail::helper_collection::predicate' first required here
    { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); }
                                    ^
/opt/1A/toolchain/x86_64-v23.0.2/lib64/gcc/x86_64-1a-linux-gnu/13.0.0/../../../../include/c++/13.0.0/bits/move.h:167:30: note: expanded from macro '_GLIBCXX_MOVE'
                             ^
/opt/1A/toolchain/x86_64-v23.0.2/lib64/gcc/x86_64-1a-linux-gnu/13.0.0/../../../../include/c++/13.0.0/bits/stl_algo.h:3923:26: note: in instantiation of function template specialization '__gnu_cxx::__ops::__pred_iter<boost::archive::detail::helper_collection::predicate>' requested here
                            __gnu_cxx::__ops::__pred_iter(__pred));
                                              ^
/data/mwrep/res/osp/Boost/23-0-0-0/include/boost/archive/detail/helper_collection.hpp:75:18: note: in instantiation of function template specialization 'std::find_if<__gnu_cxx::__normal_iterator<std::pair<const void *, boost::shared_ptr<void>> *, std::vector<std::pair<const void *, boost::shared_ptr<void>>>>, boost::archive::detail::helper_collection::predicate>' requested here
            std::find_if(
                 ^
2023-01-08 16:28:49 +00:00
Johannes Schauer Marin Rodrigues 48d47e4ed6 src/basic_archive.cpp: improve docs for archive version 19 2022-12-08 15:08:05 +01:00
Peter Dimov 6bf961f31e Guard MSVC pragmas from clang-cl 2021-02-28 04:04:15 +02:00
Samuel Debionne 97f7767505 Add support for Boost.Variant2 2020-05-05 19:49:01 +02:00
Samuel Debionne 2bbb0577a9 Add serialialization for std::optional 2020-05-05 11:02:50 +02:00
Samuel Debionne f19034cc9e Add serialize for std::monostate 2020-05-05 11:00:59 +02:00
Samuel Debionne aa4b6422db Fix name clash with boost::variant serialization
Allow serialization of non-copy-constructible types (use move instead)
2020-05-05 11:00:59 +02:00
Samuel Debionne 2dbe7b8005 Require variant header using Boost.Config 2020-05-05 11:00:59 +02:00
Samuel Debionne 1a13d6e552 Add cxxstd=17 to the std::variant test requirements 2020-05-05 11:00:59 +02:00
Samuel Debionne f914a185c3 Add support for std::variant 2020-05-05 11:00:59 +02:00
34 changed files with 1273 additions and 1191 deletions
+430 -51
View File
@@ -1,3 +1,12 @@
# 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:
@@ -8,83 +17,453 @@ on:
- 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.7
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8
cxxstd: "11"
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"
os: ubuntu-18.04
install: g++-4.9
cxxstd: "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"
os: ubuntu-18.04
cxxstd: "11,14,1z"
address_model: 64
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-5-multilib
- toolset: gcc-5
cxxstd: "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"
os: ubuntu-18.04
install: g++-6
cxxstd: "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"
os: ubuntu-18.04
install: g++-7
cxxstd: "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"
os: ubuntu-18.04
install: g++-8
cxxstd: "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"
os: ubuntu-18.04
install: g++-9
cxxstd: "11,14,17,2a"
address_model: 64
os: ubuntu-20.04
install:
- g++-9-multilib
- toolset: gcc-9
cxxstd: "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,2a"
os: ubuntu-18.04
install: g++-10
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: clang
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
install: clang
cxxstd: "11,14,17,20"
address_model: 64
os: ubuntu-20.04
install:
- g++-10-multilib
- toolset: gcc-11
cxxstd: "11,14,17,20,23"
address_model: 64
os: ubuntu-22.04
install:
- g++-11-multilib
- toolset: gcc-12
cxxstd: "11,14,17,20,23"
address_model: 64
os: ubuntu-22.04
install:
- g++-12-multilib
- toolset: gcc-12
cxxstd: "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: "11,20"
address_model: 64
ubsan: 1
os: ubuntu-22.04
install:
- g++-12-multilib
# Linux, clang
- toolset: clang
compiler: clang++-3.7
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "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: "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: "11,14,17,2a"
os: ubuntu-20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,20"
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,20"
os: ubuntu-22.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-12
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-14
- toolset: clang
compiler: clang++-14
cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,2b-gnu"
os: ubuntu-22.04
install:
- clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "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: "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: "11,14,17,2a"
os: macos-11
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-12
timeout-minutes: 360
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- uses: actions/checkout@v2
- 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: sudo apt install ${{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: |
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
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 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
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[@]}"
+26 -7
View File
@@ -8,6 +8,10 @@ on:
- develop
- feature/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
LIBRARY: serialization
@@ -17,30 +21,45 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: msvc-14.1
cxxstd: "14,17,latest"
- toolset: msvc-14.0
cxxstd: "11,14"
addrmd: 32,64
os: windows-2016
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"
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- 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
if "%GITHUB_BASE_REF%" == "master" set BOOST_BRANCH=master
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
@@ -54,4 +73,4 @@ jobs:
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=release
+16 -23
View File
@@ -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)
-1
View File
@@ -107,7 +107,6 @@ WSOURCES =
xml_woarchive
polymorphic_xml_wiarchive
polymorphic_xml_woarchive
$(SOURCES_HAS_STD_WSTREAMBUF)
;
lib boost_serialization
+1 -1
View File
@@ -250,7 +250,7 @@ EXCEPT for one special case.
<ul>
<li>Instances of a derived class are serialized through a base class pointer.
<li>Such instances are not "registered" neither implicitly nor explicitly. That
is, the macro <code style="white-space: normal">BOOT_CLASS_EXPORT</code> is used
is, the macro <code style="white-space: normal">BOOST_CLASS_EXPORT</code> is used
to instantiate the serialization code for the included archives.
</ul>
+1
View File
@@ -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>
@@ -55,10 +55,11 @@ class helper_collection
collection m_collection;
struct predicate {
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;
bool operator()(helper_value_type const &rhs) const {
bool operator()(helper_value_type const &rhs){
return m_ti == rhs.first;
}
predicate(const void * ti) :
@@ -18,6 +18,7 @@
#include <cstddef> // NULL
#include <boost/cstdint.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/detail/oserializer.hpp>
@@ -44,7 +45,7 @@ public:
// return a pointer to the most derived class
Archive * This(){
return static_cast<Archive *>(this);
return static_cast<Archive*>(this);
}
template<class T>
@@ -33,7 +33,7 @@ struct XML_name {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0, // -.
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, // 0-9
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, // 0-9
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // A-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, // -Z _
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // a-
@@ -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
+1 -1
View File
@@ -82,7 +82,7 @@ class escape :
}
void increment(){
if(++m_bnext < m_bend){
if(m_bnext != NULL && ++m_bnext < m_bend){
m_current_value = *m_bnext;
return;
}
@@ -76,6 +76,8 @@ char xml_escape<Base>::fill(
bend = bstart + 6;
break;
default:
bstart="";
bend=bstart;
return current_value;
}
return *bstart;
@@ -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
@@ -26,6 +26,8 @@
#include <boost/type_traits/is_polymorphic.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/serialization/static_warning.hpp>
#include <boost/serialization/singleton.hpp>
#include <boost/serialization/extended_type_info.hpp>
@@ -99,7 +101,8 @@ class extended_type_info_no_rtti :
};
public:
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();
}
+87 -23
View File
@@ -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
+1 -3
View File
@@ -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(
+204
View File
@@ -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 &ar, 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
+161 -22
View File
@@ -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,21 @@
#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>
#include <type_traits>
#endif
// Boost Variant2 supports all C++ versions back to C++11
#ifndef BOOST_NO_CXX17_HDR_VARIANT
#include <variant>
//#include <type_traits>
#endif
#include <boost/archive/archive_exception.hpp>
@@ -39,19 +59,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 +103,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 +141,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 +163,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 +197,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(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(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 +300,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
+176
View File
@@ -0,0 +1,176 @@
#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
// 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/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
+3 -3
View File
@@ -83,11 +83,11 @@ BOOST_ARCHIVE_SIGNATURE(){
// 18- addressed undefined behavior in archive constructors.
// init() called from base wrote archive header before archive
// was fully constructed.
// Boost 1.76
// 19- Boost 1.76 April 2021
// 20- Boost 1.84 April 2021
BOOST_SYMBOL_VISIBLE boost::serialization::library_version_type
BOOST_ARCHIVE_VERSION(){
return boost::serialization::library_version_type(19);
return boost::serialization::library_version_type(20);
}
} // namespace archive
+4 -11
View File
@@ -68,13 +68,6 @@ class basic_oarchive_impl {
return false;
return class_id < rhs.class_id;
}
aobject & operator=(const aobject & rhs)
{
address = rhs.address;
class_id = rhs.class_id;
object_id = rhs.object_id;
return *this;
}
aobject(
const void *a,
class_id_type class_id_,
@@ -269,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;
}
@@ -291,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;
}
@@ -360,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);
+19 -18
View File
@@ -60,52 +60,53 @@ namespace xml { // anonymous
template<class T>
struct assign_impl {
T & t;
void operator()(const T t_) const {
t = t_;
T & m_t;
void operator()(const T & rhs) const {
m_t = rhs;
}
assign_impl(T & t_)
: t(t_)
assign_impl(T & rhs)
: m_t(rhs)
{}
};
template<>
struct assign_impl<std::string> {
std::string & t;
std::string & m_t;
void operator()(
std::string::const_iterator b,
std::string::const_iterator e
) const {
t.resize(0);
m_t.resize(0);
while(b != e){
t += * b;
m_t += * b;
++b;
}
}
assign_impl<std::string> & operator=(
assign_impl<std::string> & rhs
);
assign_impl(std::string & t_)
: t(t_)
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)
{}
};
#ifndef BOOST_NO_STD_WSTRING
template<>
struct assign_impl<std::wstring> {
std::wstring & t;
std::wstring & m_t;
void operator()(
std::wstring::const_iterator b,
std::wstring::const_iterator e
) const {
t.resize(0);
m_t.resize(0);
while(b != e){
t += * b;
m_t += * b;
++b;
}
}
assign_impl(std::wstring & t_)
: t(t_)
assign_impl(std::wstring & rhs)
: m_t(rhs)
{}
};
#endif
-5
View File
@@ -79,8 +79,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 +97,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 ]
@@ -188,4 +184,3 @@ if ! $(BOOST_ARCHIVE_LIST) {
[ compile test_const_pass.cpp ]
;
}
-1
View File
@@ -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>
+3 -2
View File
@@ -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);
-142
View File
@@ -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;
}
-142
View File
@@ -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;
}
+3 -3
View File
@@ -31,7 +31,7 @@ struct Base1 {
Base1(){}
Base1(int x) : m_x(1 + x) {}
virtual ~Base1() {}
bool operator==(Base1 & rhs) const {
bool operator==(const Base1 & rhs) const {
return m_x == rhs.m_x;
}
// serialize
@@ -49,7 +49,7 @@ struct Base2 {
Base2(){}
Base2(int x) : m_x(2 + x) {}
virtual ~Base2() {}
bool operator==(Base2 & rhs) const {
bool operator==(const Base2 & rhs) const {
return m_x == rhs.m_x;
}
// serialize
@@ -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
View File
@@ -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;
}
-123
View File
@@ -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;
}
-123
View File
@@ -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;
}
+80 -192
View File
@@ -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)
@@ -25,7 +29,7 @@
#endif
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
namespace std {
using ::remove;
}
#endif
@@ -33,7 +37,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,9 +45,14 @@ 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/static_visitor.hpp>
namespace boost {
template<typename ResultType> class static_visitor;
}
#include "A.hpp"
#include "A.ipp"
@@ -53,6 +61,7 @@ class are_equal
: 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 +88,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,214 +112,87 @@ 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()
{
// 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
}
struct H {
int i;
};
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);
}
} // namespace serialization
} // namespace boost
inline bool operator==(H const & lhs, H const & rhs) {
return lhs.i == rhs.i;
}
inline bool operator!=(H const & lhs, H const & rhs) {
return !(lhs == rhs);
}
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(visit(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);
}
#include <boost/serialization/variant.hpp>
int test_main( int /* argc */, char* /* argv */[] )
{
int test_main( int /* argc */, char* /* argv */[] ){
// boost::variant - compatible with C++03
{
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(v);
const A a;
boost::variant<bool, int, float, double, const A *, std::string> v1 = & a;
test_type(v1);
}
test_pointer();
test_variant_set();
test_variant_map();
do_bad_read();
// boost::variant2/variant requires C++ 11
#if BOOST_CXX_VERSION >= 201103L
{
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);
}
#endif
// std::variant reqires C++ 17 or more
#ifndef BOOST_NO_CXX17_HDR_VARIANT
{
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);
}
#endif
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -205,7 +205,7 @@ rule test-bsl-run_files ( test-name : sources * : libs * : requirements * ) {
rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
local tests ;
for local defn in $(BOOST_ARCHIVE_LIST) {
ECHO polymorphic_$(defn:LB) ;
#ECHO polymorphic_$(defn:LB) ;
tests += [
test-bsl-run_archive $(test-name)
: polymorphic_$(defn:LB)