type_info_implementation.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef BOOST_SERIALIZATION_TYPE_INFO_IMPLEMENTATION_HPP
  2. #define BOOST_SERIALIZATION_TYPE_INFO_IMPLEMENTATION_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // type_info_implementation.hpp: interface for portable version of type_info
  9. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <boost/config.hpp>
  15. #include <boost/detail/workaround.hpp>
  16. #include <boost/static_assert.hpp>
  17. #include <boost/mpl/eval_if.hpp>
  18. #include <boost/mpl/identity.hpp>
  19. #include <boost/type_traits/is_base_and_derived.hpp>
  20. #include <boost/serialization/traits.hpp>
  21. namespace boost {
  22. namespace serialization {
  23. // note that T and const T are folded into const T so that
  24. // there is only one table entry per type
  25. template<class T>
  26. struct type_info_implementation {
  27. template<class U>
  28. struct traits_class_typeinfo_implementation {
  29. typedef typename U::type_info_implementation::type type;
  30. };
  31. // note: at least one compiler complained w/o the full qualification
  32. // on basic traits below
  33. typedef
  34. typename mpl::eval_if<
  35. is_base_and_derived<boost::serialization::basic_traits, T>,
  36. traits_class_typeinfo_implementation< T >,
  37. //else
  38. mpl::identity<
  39. typename extended_type_info_impl< T >::type
  40. >
  41. >::type type;
  42. };
  43. } // namespace serialization
  44. } // namespace boost
  45. // define a macro to assign a particular derivation of extended_type_info
  46. // to a specified a class.
  47. #define BOOST_CLASS_TYPE_INFO(T, ETI) \
  48. namespace boost { \
  49. namespace serialization { \
  50. template<> \
  51. struct type_info_implementation< T > { \
  52. typedef ETI type; \
  53. }; \
  54. template<> \
  55. struct type_info_implementation< const T > { \
  56. typedef ETI type; \
  57. }; \
  58. } \
  59. } \
  60. /**/
  61. #endif /// BOOST_SERIALIZATION_TYPE_INFO_IMPLEMENTATION_HPP