Brian Silverman | 8867871 | 2018-08-04 23:56:48 -0700 | [diff] [blame^] | 1 | #ifndef BOOST_SERIALIZATION_WRAPPER_HPP |
| 2 | #define BOOST_SERIALIZATION_WRAPPER_HPP |
| 3 | |
| 4 | // (C) Copyright 2005-2006 Matthias Troyer |
| 5 | // Use, modification and distribution is subject to the Boost Software |
| 6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | #include <boost/serialization/traits.hpp> |
| 10 | #include <boost/type_traits/is_base_and_derived.hpp> |
| 11 | #include <boost/mpl/eval_if.hpp> |
| 12 | #include <boost/mpl/bool_fwd.hpp> |
| 13 | |
| 14 | namespace boost { namespace serialization { |
| 15 | |
| 16 | /// the base class for serialization wrappers |
| 17 | /// |
| 18 | /// wrappers need to be treated differently at various places in the serialization library, |
| 19 | /// e.g. saving of non-const wrappers has to be possible. Since partial specialization |
| 20 | // is not supported by all compilers, we derive all wrappers from wrapper_traits. |
| 21 | |
| 22 | template< |
| 23 | class T, |
| 24 | int Level = object_serializable, |
| 25 | int Tracking = track_never, |
| 26 | unsigned int Version = 0, |
| 27 | class ETII = extended_type_info_impl< T > |
| 28 | > |
| 29 | struct wrapper_traits : |
| 30 | public traits<T,Level,Tracking,Version,ETII,mpl::true_> |
| 31 | {}; |
| 32 | |
| 33 | template<class T> |
| 34 | struct is_wrapper_impl : |
| 35 | boost::mpl::eval_if< |
| 36 | boost::is_base_and_derived<basic_traits,T>, |
| 37 | boost::mpl::true_, |
| 38 | boost::mpl::false_ |
| 39 | >::type |
| 40 | {}; |
| 41 | |
| 42 | template<class T> |
| 43 | struct is_wrapper { |
| 44 | typedef typename is_wrapper_impl<const T>::type type; |
| 45 | }; |
| 46 | |
| 47 | } // serialization |
| 48 | } // boost |
| 49 | |
| 50 | // A macro to define that a class is a wrapper |
| 51 | #define BOOST_CLASS_IS_WRAPPER(T) \ |
| 52 | namespace boost { \ |
| 53 | namespace serialization { \ |
| 54 | template<> \ |
| 55 | struct is_wrapper_impl<const T> : boost::mpl::true_ {}; \ |
| 56 | } \ |
| 57 | } \ |
| 58 | /**/ |
| 59 | |
| 60 | #endif //BOOST_SERIALIZATION_WRAPPER_HPP |