wrapper.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <boost/mpl/bool_fwd.hpp>
  11. namespace boost { namespace serialization {
  12. /// the base class for serialization wrappers
  13. ///
  14. /// wrappers need to be treated differently at various places in the serialization library,
  15. /// e.g. saving of non-const wrappers has to be possible. Since partial specialization
  16. // is not supported by all compilers, we derive all wrappers from wrapper_traits.
  17. template<
  18. class T,
  19. int Level = object_serializable,
  20. int Tracking = track_never,
  21. unsigned int Version = 0,
  22. class ETII = extended_type_info_impl< T >
  23. >
  24. struct wrapper_traits :
  25. public traits<T,Level,Tracking,Version,ETII,mpl::true_>
  26. {};
  27. template<class T>
  28. struct is_wrapper_impl :
  29. boost::mpl::eval_if<
  30. boost::is_base_and_derived<basic_traits,T>,
  31. boost::mpl::true_,
  32. boost::mpl::false_
  33. >::type
  34. {};
  35. template<class T>
  36. struct is_wrapper {
  37. typedef typename is_wrapper_impl<const T>::type type;
  38. };
  39. } // serialization
  40. } // boost
  41. // A macro to define that a class is a wrapper
  42. #define BOOST_CLASS_IS_WRAPPER(T) \
  43. namespace boost { \
  44. namespace serialization { \
  45. template<> \
  46. struct is_wrapper_impl<const T> : boost::mpl::true_ {}; \
  47. } \
  48. } \
  49. /**/
  50. #endif //BOOST_SERIALIZATION_WRAPPER_HPP