From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../libs/serialization/example/demo_dll_b.hpp | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/boost/libs/serialization/example/demo_dll_b.hpp (limited to 'src/boost/libs/serialization/example/demo_dll_b.hpp') diff --git a/src/boost/libs/serialization/example/demo_dll_b.hpp b/src/boost/libs/serialization/example/demo_dll_b.hpp new file mode 100644 index 000000000..3fcfea672 --- /dev/null +++ b/src/boost/libs/serialization/example/demo_dll_b.hpp @@ -0,0 +1,113 @@ +#ifndef BOOST_SERIALIZATION_TEST_B_HPP +#define BOOST_SERIALIZATION_TEST_B_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// B.hpp + +// (C) Copyright 2002 Robert Ramey - 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include // for rand() +#include + +#include +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::rand; +} +#endif + +#include +#include +#include + +#include "A.hpp" + +/////////////////////////////////////////////////////// +// Derived class test +class B : public A +{ +private: + friend class boost::serialization::access; + template + void save(Archive &ar, const unsigned int /* file_version */) const + { + // write any base class info to the archive + ar << BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); + + // write out members + ar << BOOST_SERIALIZATION_NVP(s); + ar << BOOST_SERIALIZATION_NVP(t); + ar << BOOST_SERIALIZATION_NVP(u); + ar << BOOST_SERIALIZATION_NVP(v); + ar << BOOST_SERIALIZATION_NVP(w); + ar << BOOST_SERIALIZATION_NVP(x); + } + + template + void load(Archive & ar, const unsigned int file_version) + { + // read any base class info to the archive + ar >> BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); + switch(file_version){ + case 1: + case 2: + ar >> BOOST_SERIALIZATION_NVP(s); + ar >> BOOST_SERIALIZATION_NVP(t); + ar >> BOOST_SERIALIZATION_NVP(u); + ar >> BOOST_SERIALIZATION_NVP(v); + ar >> BOOST_SERIALIZATION_NVP(w); + ar >> BOOST_SERIALIZATION_NVP(x); + default: + break; + } + } + + BOOST_SERIALIZATION_SPLIT_MEMBER() + signed char s; + unsigned char t; + signed int u; + unsigned int v; + float w; + double x; +public: + B(); + virtual ~B(){}; + bool operator==(const B &rhs) const; +}; + +B::B() : + s(std::rand()), + t(std::rand()), + u(std::rand()), + v(std::rand()), + w((float)std::rand() / std::rand()), + x((double)std::rand() / std::rand()) +{ +} + +BOOST_CLASS_VERSION(B, 2) + +inline bool B::operator==(const B &rhs) const +{ + return + A::operator==(rhs) + && s == rhs.s + && t == rhs.t + && u == rhs.u + && v == rhs.v + && std::abs( boost::math::float_distance(w, rhs.w)) < 2 + && std::abs( boost::math::float_distance(x, rhs.x)) < 2 + ; +} + +#endif // BOOST_SERIALIZATION_TEST_B_HPP -- cgit v1.2.3