Compare commits

...

106 Commits

Author SHA1 Message Date
Peter Dimov 91c265be64 Merge branch '#315-fix-for-reverse-include-logic-in-throw_exception.hpp' of https://github.com/gaspardpetit/serialization into feature/issue-315 2026-06-28 16:16:06 +03:00
Peter Dimov 863528b341 Add a smoke test for <exception-handling>off. Refs #315. Refs #316. 2026-06-28 16:14:58 +03:00
Peter Dimov 9030e357d9 Disable std::variant testing under Clang 6.0 2026-06-28 15:06:57 +03:00
Peter Dimov 47b7f7297d Add CMake tests 2026-06-28 13:24:13 +03:00
Peter Dimov acc30bc8a0 Avoid visit ambiguity in test_variant.cpp 2026-06-28 12:54:10 +03:00
Peter Dimov 8322195a39 Define _CRT_SECURE_NO_WARNINGS for Clang-cl as well 2026-06-28 11:44:57 +03:00
Peter Dimov ddc98ca384 Add import testing to test/Jamfile 2026-06-27 21:38:04 +03:00
Peter Dimov a842484cd3 Replace ci.yml 2026-06-27 21:08:35 +03:00
Peter Dimov 097a6c63a1 Merge pull request #340 from Lastique/feature/remove_static_assert
Remove dependencies on Boost.StaticAssert
2026-04-25 21:31:13 +03:00
Andrey Semashev 635c447262 Remove dependencies on Boost.StaticAssert.
Boost.StaticAssert has been merged into Boost.Config, so remove
the dependency.
2026-01-22 22:40:52 +03:00
Robert Ramey 8a8c62864f Merge pull request #317 from grafikrobot/modular
Add support for modular build structure.
2024-08-18 11:53:35 -07:00
Rene Rivera 03f542ab4e Change math dep real target math/tr1. 2024-08-11 09:23:25 -05:00
Rene Rivera 36f1ea6374 Split b2 dependencies into public and private. 2024-07-26 17:46:20 -05:00
Rene Rivera aaaa80d148 Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:22 -05:00
Rene Rivera 6e84870afd Update copyright dates. 2024-07-20 22:52:03 -05:00
Rene Rivera 3fa840faa7 Bump B2 require to 5.2 2024-06-14 11:33:56 -05:00
Rene Rivera 2a33d54843 Sync from upstream. 2024-06-10 21:39:41 -05:00
Robert Ramey 0c53f8e5bd Merge commit '46165e3514e2b82e3073ddb5ff231b348fdc0ad5' into develop
* commit '46165e3514e2b82e3073ddb5ff231b348fdc0ad5':
  Remove no longer necessary command line options from build/Jamfile, util/test.jam
2024-06-08 10:48:33 -07:00
Robert Ramey 38a3cd5420 Merge commit '2a2973183824e1ab35efd8f536491cdd7bd316ed' into develop
* commit '2a2973183824e1ab35efd8f536491cdd7bd316ed':
  Fix -Wsign-compare warnings in variant.hpp; also catches the case when `which` is negative
2024-06-08 10:48:22 -07:00
Gaspard Petit 9d9b0f4cfa Fixed include logic when BOOST_NO_EXCEPTIONS is defined 2024-06-07 21:21:17 -04:00
Rene Rivera caa3806dcb Update dependencies. 2024-05-13 21:47:19 -05:00
Rene Rivera a08d9d54cc Add requires-b2 check to top-level build file. 2024-05-05 09:00:01 -05:00
Rene Rivera 58c43bc283 Remove import-search from non-project jam file. 2024-05-05 08:09:42 -05:00
Rene Rivera 1209707581 Add missing import-search for cconfig/predef checks. 2024-05-04 23:32:31 -05:00
Rene Rivera 4310637105 Add missing NO_LIB usage requirements. 2024-04-28 20:16:45 -05:00
Rene Rivera ab0b5d6154 Fix cross lib relative build ref. 2024-04-26 23:15:22 -05:00
Peter Dimov 46165e3514 Remove no longer necessary command line options from build/Jamfile, util/test.jam 2024-04-11 03:08:14 +03:00
Peter Dimov 2a29731838 Fix -Wsign-compare warnings in variant.hpp; also catches the case when which is negative 2024-04-11 02:40:21 +03:00
Peter Dimov d8e072a78d Add break statements inadvertently omitted in #310 2024-04-10 22:11:51 +03:00
Rene Rivera 098bcad5d5 Sync from upstream. 2024-04-10 07:56:24 -05:00
Rene Rivera 6b64c89e2b Switch to library requirements instead of source. As source puts extra source in install targets. 2024-03-29 21:15:59 -05:00
Robert Ramey a32906b8e6 changes to serialization of variants to support boost/variant, boost/variant2 and std::variant 2024-03-23 16:08:17 -07:00
Rene Rivera 2e54522f1a Sync from upstream. 2024-03-23 15:40:59 -05:00
Robert Ramey 2e044c7384 Merge pull request #310 from boostorg/feature/va-start
Restore removed va_start calls; add missing va_end as reported in #264.
2024-03-23 13:19:52 -07:00
Peter Dimov d52537a5ad Restore removed va_start calls; add missing va_end as reported in #264. 2024-03-14 19:04:57 +02:00
Rene Rivera f3a9811740 Make the library modular usable. 2024-03-11 08:38:17 -05:00
Robert Ramey 2805bc3faa removed test dependency on lexical cast 2024-01-08 22:20:18 -08:00
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
48 changed files with 1744 additions and 1386 deletions
+634
View File
@@ -0,0 +1,634 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-7
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "11,14,17,2a"
container: ubuntu:22.04
os: ubuntu-latest
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "11,14,17,20"
container: ubuntu:22.04
os: ubuntu-latest
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: g++-12-multilib
address-model: 32,64
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: g++-13-multilib
address-model: 32,64
- toolset: gcc-14
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: g++-14-multilib
address-model: 32,64
- toolset: gcc-15
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:26.04
os: ubuntu-latest
install: g++-15-multilib
address-model: 32,64
- toolset: gcc-16
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:26.04
os: ubuntu-latest
install: g++-16-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-12
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
- toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
compiler: clang++-19
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-19
- toolset: clang
compiler: clang++-20
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-20
- toolset: clang
compiler: clang++-21
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:26.04
os: ubuntu-latest
install: clang-21
- toolset: clang
compiler: clang++-22
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:26.04
os: ubuntu-latest
install: clang-22
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "11,14,17,20,23,2c"
os: macos-15
- toolset: clang
cxxstd: "11,14,17,20,23,2c"
os: macos-26
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
defaults:
run:
shell: bash
steps:
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++ curl
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py -I benchmark -I example --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
export ADDRMD=${{matrix.address-model}}
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: msvc-14.5
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2025-vs2026
- toolset: clang-win
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2025
- toolset: gcc
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2025
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py -I benchmark -I example --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py -I benchmark -I example --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
windows-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Use library with add_subdirectory (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use library with add_subdirectory (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- name: Install (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Debug
- name: Install (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Release
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use the installed library (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py -I benchmark -I example --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
- name: Build tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Debug
- name: Run tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Debug
- name: Build tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Release
- name: Run tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release
-90
View File
@@ -1,90 +0,0 @@
name: POSIX
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
LIBRARY: serialization
UBSAN_OPTIONS: print_stacktrace=1
jobs:
CI:
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
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: g++-7
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-9
- 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
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- 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
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
-57
View File
@@ -1,57 +0,0 @@
name: Windows
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
LIBRARY: serialization
jobs:
CI:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
if "%GITHUB_BASE_REF%" == "master" set BOOST_BRANCH=master
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,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
@@ -83,7 +83,6 @@ target_link_libraries(boost_serialization
Boost::preprocessor
Boost::smart_ptr
Boost::spirit
Boost::static_assert
Boost::type_traits
Boost::unordered
Boost::utility
-1
View File
@@ -56,7 +56,6 @@ install:
- git submodule init libs/range
- git submodule init libs/smart_ptr
- git submodule init libs/spirit
- git submodule init libs/static_assert
- git submodule init libs/system
- git submodule init libs/throw_exception
- git submodule init libs/tuple
+45
View File
@@ -0,0 +1,45 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.2 ;
constant boost_dependencies :
/boost/array//boost_array
/boost/assert//boost_assert
/boost/config//boost_config
/boost/core//boost_core
/boost/detail//boost_detail
/boost/integer//boost_integer
/boost/io//boost_io
/boost/iterator//boost_iterator
/boost/move//boost_move
/boost/mp11//boost_mp11
/boost/mpl//boost_mpl
/boost/optional//boost_optional
/boost/predef//boost_predef
/boost/preprocessor//boost_preprocessor
/boost/smart_ptr//boost_smart_ptr
/boost/spirit//boost_spirit
/boost/throw_exception//boost_throw_exception
/boost/type_traits//boost_type_traits
/boost/utility//boost_utility
/boost/variant//boost_variant
/boost/variant2//boost_variant2 ;
project /boost/serialization
: common-requirements
<include>include
;
explicit
[ alias boost_serialization : build//boost_serialization ]
[ alias boost_wserialization : build//boost_wserialization ]
[ alias all : boost_serialization boost_wserialization example test ]
;
call-if : boost-library serialization
: install boost_serialization boost_wserialization
;
+37 -41
View File
@@ -1,60 +1,70 @@
# Boost serialization Library Build Jamfile
# (C) Copyright Robert Ramey 2002-2004.
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# See http://www.boost.org/libs/serialization for the library home page.
project boost/serialization
require-b2 5.0.1 ;
import-search /boost/config/checks ;
import config : requires ;
constant boost_dependencies_private :
/boost/function//boost_function
;
project
: source-location ../src
: common-requirements <library>$(boost_dependencies)
: requirements
<conditional>@include-spirit
<library>$(boost_dependencies_private)
: usage-requirements
<define>BOOST_SERIALIZATION_NO_LIB=1
;
import ../../config/checks/config : requires ;
SPIRIT_ROOT = [ modules.peek : SPIRIT_ROOT ] ;
rule include-spirit ( properties * )
{
local old-compiler ;
if <toolset>borland in $(properties)
{
if ! <toolset-borland:version>6.1.0 in $(properties)
{
old-compiler = true ;
}
if ! <toolset-borland:version>6.1.0 in $(properties)
{
old-compiler = true ;
}
}
else if <toolset>msvc in $(properties)
{
if <toolset-msvc:version>6.5 in $(properties)
|| <toolset-msvc:version>7.0 in $(properties)
{
{
old-compiler = true ;
}
}
}
local result ;
if $(old-compiler)
{
{
if $(SPIRIT_ROOT)
{
# note - we can't use <include>$(SPIRIT_ROOT) because
# note - we can't use <include>$(SPIRIT_ROOT) because
# it puts -I$(SPIRIT_ROOT) AFTER the "../../.." in the command line.
# so use these instead
# so use these instead
result = <cxxflags>-I$(SPIRIT_ROOT) ;
}
else
else
{
echo **** spirit 1.6x required to build library with this compiler **** ;
result = <build>no ;
}
}
}
return $(result) ;
}
SOURCES =
SOURCES =
archive_exception
basic_archive
basic_iarchive
@@ -90,12 +100,12 @@ SOURCES =
codecvt_null
;
SOURCES_HAS_STD_WSTREAMBUF =
SOURCES_HAS_STD_WSTREAMBUF =
xml_oarchive
utf8_codecvt_facet
;
WSOURCES =
WSOURCES =
basic_text_wiprimitive
basic_text_woprimitive
text_wiarchive
@@ -107,42 +117,28 @@ WSOURCES =
xml_woarchive
polymorphic_xml_wiarchive
polymorphic_xml_woarchive
$(SOURCES_HAS_STD_WSTREAMBUF)
codecvt_null
;
lib boost_serialization
lib boost_serialization
: ## sources ##
$(SOURCES).cpp
: ## requirements ##
[ check-target-builds ../../config/checks//std_wstreambuf : <source>../src/$(SOURCES_HAS_STD_WSTREAMBUF).cpp ]
[ check-target-builds /boost/config/checks//std_wstreambuf : <source>../src/$(SOURCES_HAS_STD_WSTREAMBUF).cpp ]
<toolset>msvc:<cxxflags>/Gy
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
<toolset>clang:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>darwin:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
;
lib boost_wserialization
: $(WSOURCES).cpp boost_serialization
:
lib boost_wserialization
: $(WSOURCES).cpp boost_serialization
:
[ requires std_wstreambuf ]
<toolset>msvc:<cxxflags>/Gy
<toolset>msvc:<cxxflags>/Gy
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
<toolset>clang:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>darwin:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
# note: both serialization and wserialization are conditioned on the this
# switch - don't change it to BOOST_WSERIALIZATION_DYN_LINK
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
;
boost-install boost_serialization boost_wserialization ;
+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>
-1
View File
@@ -19,7 +19,6 @@ import ../util/test :
test-bsl-run
test-bsl-run_archive
test-bsl-run_files
test-bsl-run_polymorphic_archive
;
test-suite "demo-suite" :
@@ -55,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 != m_bend && ++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();
}
@@ -126,24 +129,26 @@ public:
}
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
// count up the arguments
void * r = NULL;
std::va_list ap;
va_start(ap, count);
switch(count){
case 0:
return factory<typename boost::remove_const< T >::type, 0>(ap);
r = factory<typename boost::remove_const< T >::type, 0>(ap); break;
case 1:
return factory<typename boost::remove_const< T >::type, 1>(ap);
r = factory<typename boost::remove_const< T >::type, 1>(ap); break;
case 2:
return factory<typename boost::remove_const< T >::type, 2>(ap);
r = factory<typename boost::remove_const< T >::type, 2>(ap); break;
case 3:
return factory<typename boost::remove_const< T >::type, 3>(ap);
r = factory<typename boost::remove_const< T >::type, 3>(ap); break;
case 4:
return factory<typename boost::remove_const< T >::type, 4>(ap);
r = factory<typename boost::remove_const< T >::type, 4>(ap); break;
default:
BOOST_ASSERT(false); // too many arguments
// throw exception here?
return NULL;
}
va_end(ap);
return r;
}
void destroy(void const * const p) const BOOST_OVERRIDE {
boost::serialization::access::destroy(
@@ -112,24 +112,26 @@ public:
}
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
// count up the arguments
void * r = NULL;
std::va_list ap;
va_start(ap, count);
switch(count){
case 0:
return factory<typename boost::remove_const< T >::type, 0>(ap);
r = factory<typename boost::remove_const< T >::type, 0>(ap); break;
case 1:
return factory<typename boost::remove_const< T >::type, 1>(ap);
r = factory<typename boost::remove_const< T >::type, 1>(ap); break;
case 2:
return factory<typename boost::remove_const< T >::type, 2>(ap);
r = factory<typename boost::remove_const< T >::type, 2>(ap); break;
case 3:
return factory<typename boost::remove_const< T >::type, 3>(ap);
r = factory<typename boost::remove_const< T >::type, 3>(ap); break;
case 4:
return factory<typename boost::remove_const< T >::type, 4>(ap);
r = factory<typename boost::remove_const< T >::type, 4>(ap); break;
default:
BOOST_ASSERT(false); // too many arguments
// throw exception here?
return NULL;
}
va_end(ap);
return r;
}
void destroy(void const * const p) const BOOST_OVERRIDE {
boost::serialization::access::destroy(
+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 &, std::monostate &, const unsigned int /*version*/)
{}
} // namespace serialization
} // namespace boost
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
#include <boost/serialization/tracking.hpp>
namespace boost {
namespace serialization {
template<class... Types>
struct tracking_level<
std::variant<Types...>
>{
typedef mpl::integral_c_tag tag;
typedef mpl::int_< ::boost::serialization::track_always> type;
BOOST_STATIC_CONSTANT(int, value = type::value);
};
} // namespace serialization
} // namespace boost
#endif //BOOST_SERIALIZATION_VARIANT_HPP
@@ -17,7 +17,7 @@
#include <boost/config.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#ifdef BOOST_NO_EXCEPTIONS
#include <boost/throw_exception.hpp>
#endif
+159 -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,19 @@
#include <boost/serialization/throw_exception.hpp>
#include <boost/variant.hpp>
// Boost Variant supports all C++ versions back to C++03
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
// Boost Variant2 supports all C++ versions back to C++11
#if BOOST_CXX_VERSION >= 201103L
#include <boost/variant2/variant.hpp>
#endif
// std::variant supports all C++ versions back to C++11
#ifndef BOOST_NO_CXX17_HDR_VARIANT
#include <variant>
#endif
#include <boost/archive/archive_exception.hpp>
@@ -39,19 +57,35 @@
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/nvp.hpp>
// use visitor from boost::variant
template<class Visitor, BOOST_VARIANT_ENUM_PARAMS(class T)>
typename Visitor::result_type visit(
Visitor visitor,
const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & t
){
return boost::apply_visitor(visitor, t);
}
template<class Visitor, BOOST_VARIANT_ENUM_PARAMS(class T)>
typename Visitor::result_type visit(
Visitor visitor,
const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & t,
const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & u
){
return boost::apply_visitor(visitor, t, u);
}
namespace boost {
namespace serialization {
template<class Archive>
struct variant_save_visitor :
boost::static_visitor<>
boost::static_visitor<void>
{
variant_save_visitor(Archive& ar) :
m_ar(ar)
{}
template<class T>
void operator()(T const & value) const
{
void operator()(T const & value) const {
m_ar << BOOST_SERIALIZATION_NVP(value);
}
private:
@@ -67,9 +101,37 @@ void save(
int which = v.which();
ar << BOOST_SERIALIZATION_NVP(which);
variant_save_visitor<Archive> visitor(ar);
v.apply_visitor(visitor);
visit(visitor, v);
}
#if BOOST_CXX_VERSION >= 201103L
template<class Archive, class ...Types>
void save(
Archive & ar,
boost::variant2::variant<Types...> const & v,
unsigned int /*version*/
){
int which = v.index();
ar << BOOST_SERIALIZATION_NVP(which);
const variant_save_visitor<Archive> visitor(ar);
visit(visitor, v);
}
#endif
#ifndef BOOST_NO_CXX17_HDR_VARIANT
template<class Archive, class ...Types>
void save(
Archive & ar,
std::variant<Types...> const & v,
unsigned int /*version*/
){
int which = v.index();
ar << BOOST_SERIALIZATION_NVP(which);
const variant_save_visitor<Archive> visitor(ar);
visit(visitor, v);
}
#endif
template<class S>
struct variant_impl {
@@ -77,17 +139,17 @@ struct variant_impl {
template<class Archive, class V>
static void invoke(
Archive & /*ar*/,
int /*which*/,
std::size_t /*which*/,
V & /*v*/,
const unsigned int /*version*/
){}
};
struct load_impl {
struct load_member {
template<class Archive, class V>
static void invoke(
Archive & ar,
int which,
std::size_t which,
V & v,
const unsigned int version
){
@@ -99,31 +161,30 @@ struct variant_impl {
typedef typename mpl::front<S>::type head_type;
head_type value;
ar >> BOOST_SERIALIZATION_NVP(value);
v = value;
head_type * new_address = & boost::get<head_type>(v);
v = std::move(value);;
head_type * new_address = & get<head_type>(v);
ar.reset_object_address(new_address, & value);
return;
}
typedef typename mpl::pop_front<S>::type type;
variant_impl<type>::load(ar, which - 1, v, version);
variant_impl<type>::load_impl(ar, which - 1, v, version);
}
};
template<class Archive, class V>
static void load(
static void load_impl(
Archive & ar,
int which,
std::size_t which,
V & v,
const unsigned int version
){
typedef typename mpl::eval_if<mpl::empty<S>,
mpl::identity<load_null>,
mpl::identity<load_impl>
mpl::identity<load_member>
>::type typex;
typex::invoke(ar, which, v, version);
}
};
}; // variant_impl
template<class Archive, BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
void load(
@@ -134,34 +195,99 @@ void load(
int which;
typedef typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;
ar >> BOOST_SERIALIZATION_NVP(which);
if(which >= mpl::size<types>::value)
if(which >= mpl::size<types>::value){
// this might happen if a type was removed from the list of variant types
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unsupported_version
)
);
variant_impl<types>::load(ar, which, v, version);
}
variant_impl<types>::load_impl(ar, which, v, version);
}
#if BOOST_CXX_VERSION >= 201103L
template<class Archive, class ... Types>
void load(
Archive & ar,
boost::variant2::variant<Types...> & v,
const unsigned int version
){
int which;
typedef typename boost::variant<Types...>::types types;
ar >> BOOST_SERIALIZATION_NVP(which);
if(static_cast<std::size_t>(which) >= sizeof...(Types)){
// this might happen if a type was removed from the list of variant types
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unsupported_version
)
);
}
variant_impl<types>::load_impl(ar, which, v, version);
}
#endif
#ifndef BOOST_NO_CXX17_HDR_VARIANT
template<class Archive, class ... Types>
void load(
Archive & ar,
std::variant<Types...> & v,
const unsigned int version
){
int which;
typedef typename boost::variant<Types...>::types types;
ar >> BOOST_SERIALIZATION_NVP(which);
if(static_cast<std::size_t>(which) >= sizeof...(Types)){
// this might happen if a type was removed from the list of variant types
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unsupported_version
)
);
}
variant_impl<types>::load_impl(ar, which, v, version);
}
#endif
template<class Archive,BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
inline void serialize(
Archive & ar,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & v,
const unsigned int file_version
){
split_free(ar,v,file_version);
boost::serialization::split_free(ar,v,file_version);
}
#if BOOST_CXX_VERSION >= 201103L
template<class Archive, class ... Types>
inline void serialize(
Archive & ar,
boost::variant2::variant<Types...> & v,
const unsigned int file_version
){
boost::serialization::split_free(ar,v,file_version);
}
#endif
#ifndef BOOST_NO_CXX17_HDR_VARIANT
template<class Archive, class ... Types>
inline void serialize(
Archive & ar,
std::variant<Types...> & v,
const unsigned int file_version
){
boost::serialization::split_free(ar,v,file_version);
}
#endif
} // namespace serialization
} // namespace boost
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
#include <boost/serialization/tracking.hpp>
namespace boost {
namespace serialization {
namespace serialization {
template<BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
struct tracking_level<
@@ -172,6 +298,17 @@ struct tracking_level<
BOOST_STATIC_CONSTANT(int, value = type::value);
};
#ifndef BOOST_NO_CXX17_HDR_VARIANT
template<class... Types>
struct tracking_level<
std::variant<Types...>
>{
typedef mpl::integral_c_tag tag;
typedef mpl::int_< ::boost::serialization::track_always> type;
BOOST_STATIC_CONSTANT(int, value = type::value);
};
#endif
} // namespace serialization
} // namespace boost
+174
View File
@@ -0,0 +1,174 @@
#ifndef BOOST_SERIALIZATION_VARIANT2_HPP
#define BOOST_SERIALIZATION_VARIANT2_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// variant2.hpp - non-intrusive serialization of variant types
//
// copyright (c) 2019 Samuel Debionne, ESRF
//
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org for updates, documentation, and revision history.
//
// Widely inspired from boost::variant serialization
//
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/mp11/list.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/nvp.hpp>
namespace boost {
namespace serialization {
template<class Archive>
struct variant2_save_visitor
{
variant2_save_visitor(Archive& ar) :
m_ar(ar)
{}
template<class T>
void operator()(T const & value) const
{
m_ar << BOOST_SERIALIZATION_NVP(value);
}
private:
Archive & m_ar;
};
template<class Archive>
struct variant2_load_visitor
{
variant2_load_visitor(Archive& ar) :
m_ar(ar)
{}
template<class T>
void operator()(T & value) const
{
m_ar >> BOOST_SERIALIZATION_NVP(value);
}
private:
Archive & m_ar;
};
template<class Archive, class ...Types>
void save(
Archive & ar,
variant2::variant<Types...> const & v,
unsigned int /*version*/
){
const std::size_t which = v.index();
ar << BOOST_SERIALIZATION_NVP(which);
variant2_save_visitor<Archive> visitor(ar);
std::visit(visitor, v);
}
template<class Seq>
struct variant_impl
{
template<class Archive, class V>
static void load (
Archive & ar,
std::size_t which,
V & v,
const unsigned int version
){
if(which == 0){
// note: A non-intrusive implementation (such as this one)
// necessary has to copy the value. This wouldn't be necessary
// with an implementation that de-serialized to the address of the
// aligned storage included in the variant.
using type = mp11::mp_front<Seq>;
type value;
ar >> BOOST_SERIALIZATION_NVP(value);
v = std::move(value);
type * new_address = & variant2::get<type>(v);
ar.reset_object_address(new_address, & value);
return;
}
//typedef typename mpl::pop_front<S>::type type;
using types = mp11::mp_pop_front<Seq>;
variant_impl<types>::load(ar, which - 1, v, version);
}
};
template<class Seq>
struct variant_impl<Seq>
{
template<class Archive, class V>
static void load (
Archive & /*ar*/,
std::size_t /*which*/,
V & /*v*/,
const unsigned int /*version*/
){}
};
template<class Archive, class... Types>
void load(
Archive & ar,
variant2::variant<Types...> & v,
const unsigned int version
){
std::size_t which;
ar >> BOOST_SERIALIZATION_NVP(which);
if(which >= sizeof...(Types))
// this might happen if a type was removed from the list of variant types
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unsupported_version
)
);
variant_impl<sizeof...(Types), mp11::mp_list<Types...>>::load(ar, which, v, version);
}
template<class Archive,class... Types>
inline void serialize(
Archive & ar,
variant2::variant<Types...> & v,
const unsigned int file_version
){
split_free(ar,v,file_version);
}
// Specialization for std::monostate
template<class Archive>
void serialize(Archive &ar, variant2::monostate &, const unsigned int /*version*/)
{}
} // namespace serialization
} // namespace boost
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
#include <boost/serialization/tracking.hpp>
namespace boost {
namespace serialization {
template<class... Types>
struct tracking_level<
variant2::variant<Types...>
>{
typedef mpl::integral_c_tag tag;
typedef mpl::int_< ::boost::serialization::track_always> type;
BOOST_STATIC_CONSTANT(int, value = type::value);
};
} // namespace serialization
} // namespace boost
#endif //BOOST_SERIALIZATION_VARIANT2_HPP
-2
View File
@@ -21,7 +21,6 @@ import ../util/test :
test-bsl-run
test-bsl-run_archive
test-bsl-run_files
test-bsl-run_polymorphic_archive
;
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
@@ -33,7 +32,6 @@ test-suite "performance" :
# [ test-bsl-run_files performance_vector ]
# [ test-bsl-run_files performance_no_rtti ]
# [ test-bsl-run_files performance_simple_class ]
# [ test-bsl-run_polymorphic_archive performance_polymorphic : ../test/test_polymorphic_A ]
[ test-bsl-run-no-lib performance_iterators ]
[ test-bsl-run-no-lib performance_iterators_base64 ]
+2 -2
View File
@@ -15,8 +15,8 @@ then
echo " threading=single,multi"
echo " -sBOOST_ARCHIVE_LIST=<archive name>"
else
bjam --dump-tests variant=profile preserve-test-targets=on $@ >bjam.log 2>&1
process_jam_log --v2 <bjam.log
b2 --dump-tests variant=profile preserve-test-targets=on $@ >b2.log 2>&1
process_jam_log --v2 <b2ls.log
# for each test directory
+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
+13
View File
@@ -0,0 +1,13 @@
# Copyright 2018-2020, 2026 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
endif()
set(BOOST_TEST_LINK_LIBRARIES Boost::serialization Boost::core)
boost_test(SOURCES quick.cpp)
+16 -14
View File
@@ -1,18 +1,22 @@
# Boost serialization Library test Jamfile
# (C) Copyright Robert Ramey 2002-2004.
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
project libs/serialization/test
project
: id serialization_test
: requirements <library>/boost/filesystem
: requirements <library>/boost/filesystem//boost_filesystem
<library>/boost/math//boost_math_tr1
;
# import rules for testing conditional on config file variables
import ../../config/checks/config : requires ;
import-search /boost/config/checks ;
import config : requires ;
import testing ;
# import rules from the boost serialization test
import ../util/test :
@@ -27,9 +31,9 @@ import ../util/test :
;
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
lib dll_a
:
:
dll_a.cpp
../build//boost_serialization
:
@@ -38,7 +42,7 @@ lib dll_a
lib dll_polymorphic_base
:
dll_polymorphic_base.cpp
dll_polymorphic_base.cpp
../build//boost_serialization
:
<link>shared
@@ -79,8 +83,6 @@ test-suite "serialization" :
[ test-bsl-run_files test_list_ptrs : A ]
[ test-bsl-run_files test_map : A ]
[ test-bsl-run_files test_map_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
[ test-bsl-run_files test_map_unordered : A : : [ requires cxx11_hdr_unordered_map ] ] # BOOST_NO_CXX11_HDR_UNORDERED_MAP
[ test-bsl-run_files test_map_boost_unordered : A ]
[ test-bsl-run_files test_mi ]
[ test-bsl-run_files test_multiple_ptrs : A ]
[ test-bsl-run_files test_multiple_inheritance ]
@@ -99,8 +101,6 @@ test-suite "serialization" :
[ test-bsl-run_files test_registered ]
[ test-bsl-run_files test_set : A ]
[ test-bsl-run_files test_set_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
[ test-bsl-run_files test_set_unordered : A : : [ requires cxx11_hdr_unordered_set ] ] # BOOST_NO_CXX11_HDR_UNORDERED_SET
[ test-bsl-run_files test_set_boost_unordered : A ]
[ test-bsl-run_files test_simple_class : A ]
[ test-bsl-run_files test_simple_class_ptr : A ]
[ test-bsl-run_files test_slist : A : : [ requires slist ] ] # BOOST_HAS_SLIST ]
@@ -134,7 +134,7 @@ test-suite "serialization" :
;
if ! $(BOOST_ARCHIVE_LIST) {
test-suite "serialization2" :
test-suite "serialization2" :
[ test-bsl-run test_inclusion ]
[ test-bsl-run test_inclusion2 ]
@@ -182,10 +182,12 @@ if ! $(BOOST_ARCHIVE_LIST) {
#[ compile test_const_save_warn1_nvp.cpp ]
#[ compile test_const_save_warn2_nvp.cpp ]
#[ compile test_const_save_warn3_nvp.cpp ]
# should compile
[ compile test_traits_pass.cpp ]
[ compile test_const_pass.cpp ]
;
}
run quick.cpp ../build//boost_serialization ;
compile quick.cpp : <exception-handling>off -<library>/boost/filesystem//boost_filesystem -<library>/boost/math//boost_math_tr1 : quick_nx ;
+17
View File
@@ -0,0 +1,17 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.31)
project(cmake_install_test LANGUAGES CXX)
find_package(Boost REQUIRED COMPONENTS serialization core)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::serialization Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
+18
View File
@@ -0,0 +1,18 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.31)
project(cmake_subdir_test LANGUAGES CXX)
set(BOOST_INCLUDE_LIBRARIES serialization core)
add_subdirectory(../../../.. boostorg/boost)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::serialization Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
+49
View File
@@ -0,0 +1,49 @@
// Copyright 2026 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
struct A
{
int x, y;
template<class Ar> void serialize( Ar& ar, unsigned /*version*/ )
{
ar & x;
ar & y;
}
};
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
int main()
{
std::string tmp;
{
A a = { 1, 2 };
std::ostringstream os;
boost::archive::text_oarchive oa( os );
oa << a;
tmp = os.str();
}
{
A a = {};
std::istringstream is( tmp );
boost::archive::text_iarchive ia( is );
ia >> a;
BOOST_TEST_EQ( a.x, 1 );
BOOST_TEST_EQ( a.y, 2 );
}
return boost::report_errors();
}
-1
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;
}
+3 -2
View File
@@ -33,7 +33,6 @@ namespace std{
#include <vector>
#include "test_tools.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/nvp.hpp>
@@ -121,7 +120,9 @@ int test_main(int /* argc */, char * /* argv */ [])
std::vector<my_string> v1;
for(int i=0; i<1000; ++i){
v1.push_back(my_string(boost::lexical_cast<std::string>(i % 100)));
char sbuffer[10];
std::snprintf(sbuffer, sizeof(sbuffer), "%i", i % 100);
v1.push_back(my_string(sbuffer));
}
// test using using polymorphic implementation.
-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;
}
+122 -187
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)
@@ -15,6 +19,8 @@
// thanks to Robert Ramey and Peter Dimov.
//
#include <boost/serialization/variant.hpp>
#include <cstddef> // NULL
#include <cstdio> // remove
#include <fstream>
@@ -24,8 +30,13 @@
#include <boost/math/special_functions/next.hpp>
#endif
#if !defined(BOOST_NO_CXX17_HDR_VARIANT) && defined(BOOST_CLANG) && BOOST_CLANG_VERSION < 70000
// Clang 6.0 can't compile std::visit from libstdc++ 9
# define BOOST_NO_CXX17_HDR_VARIANT
#endif
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
namespace std {
using ::remove;
}
#endif
@@ -33,7 +44,6 @@ namespace std{
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/serialization/throw_exception.hpp>
#if defined(_MSC_VER) && (_MSC_VER <= 1020)
# pragma warning (disable : 4786) // too long name, harmless warning
@@ -42,17 +52,29 @@ namespace std{
#include "test_tools.hpp"
#include <boost/archive/archive_exception.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#if BOOST_CXX_VERSION >= 201103L
# include <boost/variant2/variant.hpp>
#endif
#ifndef BOOST_NO_CXX17_HDR_VARIANT
# include <variant>
#endif
#include "A.hpp"
#include "A.ipp"
class are_equal
class are_equal_vis
: public boost::static_visitor<bool>
{
public:
typedef bool result_type;
// note extra rigamarole for compilers which don't support
// partial function template ordering - specifically msvc 6.x
struct same {
@@ -79,6 +101,12 @@ public:
return type::invoke(t, u);
}
template <class T, class U>
bool operator()(T * const & t, U * const & u) const
{
return this->operator()(*t, *u);
}
bool operator()( const float & lhs, const float & rhs ) const
{
#if BOOST_CXX_VERSION > 199711L // only include floating point if C++ version >= C++11
@@ -97,215 +125,122 @@ public:
}
};
template <class T>
void test_type(const T& gets_written){
const char * testfile = boost::archive::tmpnam(NULL);
BOOST_REQUIRE(testfile != NULL);
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
oa << boost::serialization::make_nvp("written", gets_written);
}
T got_read;
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("written", got_read);
}
BOOST_CHECK(boost::apply_visitor(are_equal(), gets_written, got_read));
std::remove(testfile);
}
// this verifies that if you try to read in a variant from a file
// whose "which" is illegal for the one in memory (that is, you're
// reading in to a different variant than you wrote out to) the load()
// operation will throw. One could conceivably add checking for
// sequence length as well, but this would add size to the archive for
// dubious benefit.
//
void do_bad_read()
template<class... T> bool are_equal( boost::variant<T...> const& v1, boost::variant<T...> const& v2 )
{
// Compiling this test invokes and ICE on msvc 6
// So, we'll just to skip it for this compiler
#if defined(_MSC_VER) && (_MSC_VER <= 1020)
boost::variant<bool, float, int, std::string> big_variant;
big_variant = std::string("adrenochrome");
const char * testfile = boost::archive::tmpnam(NULL);
BOOST_REQUIRE(testfile != NULL);
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
oa << BOOST_SERIALIZATION_NVP(big_variant);
}
boost::variant<bool, float, int> little_variant;
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
bool exception_invoked = false;
BOOST_TRY {
ia >> BOOST_SERIALIZATION_NVP(little_variant);
} BOOST_CATCH (boost::archive::archive_exception const& e) {
BOOST_CHECK(boost::archive::archive_exception::unsupported_version == e.code);
exception_invoked = true;
}
BOOST_CATCH_END
BOOST_CHECK(exception_invoked);
}
#endif
return boost::apply_visitor( are_equal_vis(), v1, v2 );
}
struct H {
int i;
};
#if BOOST_CXX_VERSION >= 201103L
namespace boost {
namespace serialization {
template<class Archive>
void serialize(Archive &ar, H & h, const unsigned int /*file_version*/){
ar & boost::serialization::make_nvp("h", h.i);
template<class... T> bool are_equal( boost::variant2::variant<T...> const& v1, boost::variant2::variant<T...> const& v2 )
{
return boost::variant2::visit( are_equal_vis(), v1, v2 );
}
} // namespace serialization
} // namespace boost
#endif
inline bool operator==(H const & lhs, H const & rhs) {
return lhs.i == rhs.i;
#ifndef BOOST_NO_CXX17_HDR_VARIANT
template<class... T> bool are_equal( std::variant<T...> const& v1, std::variant<T...> const& v2 )
{
return std::visit( are_equal_vis(), v1, v2 );
}
inline bool operator!=(H const & lhs, H const & rhs) {
return !(lhs == rhs);
}
#endif
inline bool operator<(H const & lhs, H const & rhs) {
return lhs.i < rhs.i;
}
inline std::size_t hash_value(H const & val) {
return val.i;
}
void test_pointer(){
template<class Variant>
bool test_type(const Variant & v){
const char * testfile = boost::archive::tmpnam(NULL);
BOOST_REQUIRE(testfile != NULL);
typedef boost::variant<H, int> variant_t;
H const h = {5};
variant_t v(h);
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
oa << boost::serialization::make_nvp("written", v);
const H * h_ptr = & boost::strict_get<H const &>(v);
oa << boost::serialization::make_nvp("written", h_ptr);
}
variant_t v2;
Variant vx;
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("written", v2);
H * h2_ptr;
ia >> boost::serialization::make_nvp("written", h2_ptr);
BOOST_CHECK_EQUAL(h, boost::strict_get<H const>(v2));
BOOST_CHECK_EQUAL(h2_ptr, & boost::strict_get<H const &>(v2));
BOOST_TRY {
ia >> boost::serialization::make_nvp("written", vx);
BOOST_CHECK(are_equal(v, vx));
}
BOOST_CATCH(boost::archive::archive_exception const& e) {
return false;
}
BOOST_CATCH_END
}
BOOST_CHECK_EQUAL(v, v2);
std::remove(testfile);
return true;
}
#include <boost/serialization/map.hpp>
#include <boost/serialization/set.hpp>
// test a pointer to an object contained into a variant that is an
// element of a set
void test_variant_set()
template<class Variant>
void test(Variant & v)
{
const char * testfile = boost::archive::tmpnam(NULL);
BOOST_REQUIRE(testfile != NULL);
typedef boost::variant<H, int> variant_t;
typedef std::set<variant_t> uset_t;
uset_t set;
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
H const h = {5};
variant_t v(h);
set.insert(v);
oa << boost::serialization::make_nvp("written", set);
H const * const h_ptr = boost::strict_get<H const>(&(*set.begin()));
oa << boost::serialization::make_nvp("written", h_ptr);
}
uset_t set2;
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("written", set2);
H * h_ptr;
ia >> boost::serialization::make_nvp("written", h_ptr);
const H * h_ptr2 = & boost::strict_get<H const>(*set2.begin());
BOOST_CHECK_EQUAL(h_ptr, h_ptr2);
}
BOOST_CHECK_EQUAL(set, set2);
// uninitialized
test_type(v);
v = false;
test_type(v);
v = 1;
test_type(v);
v = (float) 2.3;
test_type(v);
v = (double) 6.4;
test_type(v);
v = A();
test_type(v);
v = std::string("we can't stop here, this is Bat Country");
test_type(v);
}
// test a pointer to an object contained into a variant that is an
// element of a map
void test_variant_map()
{
const char * testfile = boost::archive::tmpnam(NULL);
BOOST_REQUIRE(testfile != NULL);
typedef boost::variant<H, int> variant_t;
typedef std::map<int, variant_t> map_t;
map_t map;
{
test_ostream os(testfile, TEST_STREAM_FLAGS);
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
H const h = {5};
variant_t v(h);
map[0] = v;
BOOST_ASSERT(1 == map.size());
oa << boost::serialization::make_nvp("written", map);
H const * const h_ptr = boost::strict_get<H const>(&map[0]);
BOOST_CHECK_EQUAL(h_ptr, boost::strict_get<H const>(&map[0]));
oa << boost::serialization::make_nvp("written", h_ptr);
}
map_t map2;
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("written", map2);
BOOST_ASSERT(1 == map2.size());
H * h_ptr;
ia >> boost::serialization::make_nvp("written", h_ptr);
H const * const h_ptr2 = boost::strict_get<H const>(&map2[0]);
BOOST_CHECK_EQUAL(h_ptr, h_ptr2);
}
BOOST_CHECK_EQUAL(map, map2);
}
int test_main( int /* argc */, char* /* argv */[] )
{
{
boost::variant<bool, int, float, double, A, std::string> v;
v = false;
test_type(v);
v = 1;
test_type(v);
v = (float) 2.3;
test_type(v);
v = (double) 6.4;
test_type(v);
v = std::string("we can't stop here, this is Bat Country");
test_type(v);
v = A();
test_type(v);
}
test_pointer();
test_variant_set();
test_variant_map();
do_bad_read();
int test_boost_variant(){
std::cerr << "Testing boost_variant\n";
boost::variant<bool, int, float, double, A, std::string> v;
test(v);
const A a;
boost::variant<bool, int, float, double, const A *, std::string> v1 = & a;
test_type(v1);
return EXIT_SUCCESS;
}
// boost::variant2/variant requires C++ 11
#if BOOST_CXX_VERSION >= 201103L
int test_boost_variant2(){
std::cerr << "Testing boost_variant2\n";
boost::variant2::variant<bool, int, float, double, A, std::string> v;
test(v);
const A a;
boost::variant2::variant<bool, int, float, double, const A *, std::string> v1 = & a;
test_type(v1);
return EXIT_SUCCESS;
}
#endif
// std::variant reqires C++ 17 or more
#ifndef BOOST_NO_CXX17_HDR_VARIANT
int test_std_variant(){
std::cerr << "Testing Std Variant\n";
std::variant<bool, int, float, double, A, std::string> v;
test(v);
const A a;
std::variant<bool, int, float, double, const A *, std::string> v1 = & a;
test_type(v1);
return EXIT_SUCCESS;
}
#endif
int test_main( int /* argc */, char* /* argv */[] ){
return test_boost_variant()
#if BOOST_CXX_VERSION >= 201103L
|| test_boost_variant2()
#endif
#ifndef BOOST_NO_CXX17_HDR_VARIANT
|| test_std_variant()
#endif
;
}
// EOF
+39 -41
View File
@@ -1,8 +1,8 @@
# Boost serialization Library utility test Jamfile
# (C) Copyright Robert Ramey 2002-2004.
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
@@ -11,19 +11,19 @@
# tests.
# import rules for testing conditional on config file variables
import ../../config/checks/config : requires ;
import config : requires ;
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
# these are used to shorten testing while in development. It permits
# testing to be applied to just a particular type of archive
if ! $(BOOST_ARCHIVE_LIST) {
BOOST_ARCHIVE_LIST =
"text_archive.hpp"
"text_warchive.hpp"
"binary_archive.hpp"
"xml_archive.hpp"
"xml_warchive.hpp"
BOOST_ARCHIVE_LIST =
"text_archive.hpp"
"text_warchive.hpp"
"binary_archive.hpp"
"xml_archive.hpp"
"xml_warchive.hpp"
;
# enable the tests which don't depend on a particular archive
BOOST_SERIALIZATION_TEST = true ;
@@ -50,15 +50,13 @@ rule run-template ( test-name : sources * : files * : requirements * ) {
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
<toolset>msvc:<cxxflags>"-wd4996"
<toolset>clang,<target-os>windows:<define>_CRT_SECURE_NO_WARNINGS
<toolset>clang:<variant>debug:<cxxflags>"-fsanitize=memory"
# toolset optimizations
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
<toolset>msvc:<cxxflags>"-Gy"
# linking
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
<link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
<link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
$(requirements)
: # test name
$(test-name)
@@ -73,7 +71,7 @@ rule dependency-save-test ( test )
if $(m)
{
return $(m[1])save$(m[2]) ;
}
}
}
# each of the following tests is run with each type of archive
@@ -82,7 +80,7 @@ rule run-invoke ( test-name : sources * : files * : requirements * )
local save-test = [ dependency-save-test $(test-name) ] ;
local tests ;
tests += [
tests += [
run-template $(test-name)
: # sources
$(sources)
@@ -102,7 +100,7 @@ rule run-winvoke ( test-name : sources * : files * : requirements * )
local save-test = [ dependency-save-test $(test-name) ] ;
local tests ;
tests += [
tests += [
run-template $(test-name)
: # sources
$(sources)
@@ -124,7 +122,7 @@ rule run-winvoke ( test-name : sources * : files * : requirements * )
rule test-bsl-run-no-lib ( test-name : sources * : requirements * )
{
local tests ;
tests += [
tests += [
run-template $(test-name)
: # sources
$(test-name).cpp $(sources).cpp
@@ -139,8 +137,8 @@ rule test-bsl-run-no-lib ( test-name : sources * : requirements * )
rule test-bsl-run ( test-name : sources * : libs * : requirements * )
{
local tests ;
tests += [
run-invoke $(test-name)
tests += [
run-invoke $(test-name)
: # sources
$(test-name).cpp $(sources).cpp $(libs)
: # input files
@@ -191,27 +189,27 @@ rule test-bsl-run_archive ( test-name : archive-name : sources * : libs * : requ
rule test-bsl-run_files ( test-name : sources * : libs * : requirements * ) {
local tests ;
for local defn in $(BOOST_ARCHIVE_LIST) {
tests += [
test-bsl-run_archive $(test-name)
: $(defn:LB)
: $(test-name) $(sources)
: $(libs)
: $(requirements)
] ;
}
return $(tests) ;
}
rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
local tests ;
for local defn in $(BOOST_ARCHIVE_LIST) {
ECHO polymorphic_$(defn:LB) ;
tests += [
test-bsl-run_archive $(test-name)
: polymorphic_$(defn:LB)
: $(test-name) $(sources)
: $(libs)
: $(requirements)
tests += [
test-bsl-run_archive $(test-name)
: $(defn:LB)
: $(test-name) $(sources)
: $(libs)
: $(requirements)
] ;
}
return $(tests) ;
}
rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
local tests ;
for local defn in $(BOOST_ARCHIVE_LIST) {
#ECHO polymorphic_$(defn:LB) ;
tests += [
test-bsl-run_archive $(test-name)
: polymorphic_$(defn:LB)
: $(test-name) $(sources)
: $(libs)
: $(requirements)
] ;
}
return $(tests) ;