wrapper.hpp 1.8 KB

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