ephemeral.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef BOOST_SERIALIZATION_EPHEMERAL_HPP
  2. #define BOOST_SERIALIZATION_EPHEMERAL_HPP
  3. // MS compatible compilers support
  4. #pragma once
  5. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  6. # pragma once
  7. #endif
  8. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  9. // ephemeral_object.hpp: interface for serialization system.
  10. // (C) Copyright 2007 Matthias Troyer.
  11. // Use, modification and distribution is subject to the Boost Software
  12. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. // See http://www.boost.org for updates, documentation, and revision history.
  15. #include <utility>
  16. #include <boost/config.hpp>
  17. #include <boost/detail/workaround.hpp>
  18. // supress noise
  19. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
  20. # pragma warning (disable : 4786) // too long name, harmless warning
  21. #endif
  22. #include <boost/mpl/integral_c.hpp>
  23. #include <boost/mpl/integral_c_tag.hpp>
  24. #include <boost/serialization/level.hpp>
  25. #include <boost/serialization/tracking.hpp>
  26. #include <boost/serialization/split_member.hpp>
  27. #include <boost/serialization/base_object.hpp>
  28. #include <boost/serialization/traits.hpp>
  29. #include <boost/serialization/wrapper.hpp>
  30. namespace boost {
  31. namespace serialization {
  32. template<class T>
  33. struct ephemeral_object :
  34. public wrapper_traits<ephemeral_object<T> >
  35. {
  36. explicit ephemeral_object(T& t) :
  37. val(t)
  38. {}
  39. T & value() const {
  40. return val;
  41. }
  42. const T & const_value() const {
  43. return val;
  44. }
  45. template<class Archive>
  46. void serialize(Archive &ar, const unsigned int) const
  47. {
  48. ar & val;
  49. }
  50. private:
  51. T & val;
  52. };
  53. template<class T>
  54. inline
  55. #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  56. const
  57. #endif
  58. ephemeral_object<T> ephemeral(const char * name, T & t){
  59. return ephemeral_object<T>(name, t);
  60. }
  61. } // seralization
  62. } // boost
  63. #endif // BOOST_SERIALIZATION_EPHEMERAL_HPP