utility.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef BOOST_SERIALIZATION_UTILITY_HPP
  2. #define BOOST_SERIALIZATION_UTILITY_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. // serialization/utility.hpp:
  9. // serialization for stl utility templates
  10. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  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/type_traits/remove_const.hpp>
  18. #include <boost/serialization/nvp.hpp>
  19. #include <boost/serialization/is_bitwise_serializable.hpp>
  20. #include <boost/mpl/and.hpp>
  21. namespace boost {
  22. namespace serialization {
  23. // pair
  24. template<class Archive, class F, class S>
  25. inline void serialize(
  26. Archive & ar,
  27. std::pair<F, S> & p,
  28. const unsigned int /* file_version */
  29. ){
  30. // note: we remove any const-ness on the first argument. The reason is that
  31. // for stl maps, the type saved is pair<const key, T). We remove
  32. // the const-ness in order to be able to load it.
  33. typedef typename boost::remove_const<F>::type typef;
  34. ar & boost::serialization::make_nvp("first", const_cast<typef &>(p.first));
  35. ar & boost::serialization::make_nvp("second", p.second);
  36. }
  37. /// specialization of is_bitwise_serializable for pairs
  38. template <class T, class U>
  39. struct is_bitwise_serializable<std::pair<T,U> >
  40. : public mpl::and_<is_bitwise_serializable< T >,is_bitwise_serializable<U> >
  41. {
  42. };
  43. } // serialization
  44. } // namespace boost
  45. #endif // BOOST_SERIALIZATION_UTILITY_HPP