fix doc example typo
[boost.git] / boost / serialization / split_member.hpp
blob69879450d8f8b5d8bed05e15030c488bd4d79a6b
1 #ifndef BOOST_SERIALIZATION_SPLIT_MEMBER_HPP
2 #define BOOST_SERIALIZATION_SPLIT_MEMBER_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // split_member.hpp:
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/config.hpp>
20 #include <boost/mpl/eval_if.hpp>
21 #include <boost/mpl/identity.hpp>
23 #include <boost/serialization/access.hpp>
25 namespace boost {
26 namespace archive {
27 namespace detail {
28 template<class Archive> class interface_oarchive;
29 template<class Archive> class interface_iarchive;
30 } // namespace detail
31 } // namespace archive
33 namespace serialization {
34 namespace detail {
36 template<class Archive, class T>
37 struct member_saver {
38 static void invoke(
39 Archive & ar,
40 const T & t,
41 const unsigned int file_version
43 access::member_save(ar, t, file_version);
47 template<class Archive, class T>
48 struct member_loader {
49 static void invoke(
50 Archive & ar,
51 T & t,
52 const unsigned int file_version
54 access::member_load(ar, t, file_version);
58 } // detail
60 template<class Archive, class T>
61 inline void split_member(
62 Archive & ar, T & t, const unsigned int file_version
64 typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
65 BOOST_DEDUCED_TYPENAME Archive::is_saving,
66 mpl::identity<detail::member_saver<Archive, T> >,
67 mpl::identity<detail::member_loader<Archive, T> >
68 >::type typex;
69 typex::invoke(ar, t, file_version);
72 } // namespace serialization
73 } // namespace boost
75 // split member function serialize funcition into save/load
76 #define BOOST_SERIALIZATION_SPLIT_MEMBER() \
77 template<class Archive> \
78 void serialize( \
79 Archive &ar, \
80 const unsigned int file_version \
81 ){ \
82 boost::serialization::split_member(ar, *this, file_version); \
83 } \
84 /**/
86 #endif // BOOST_SERIALIZATION_SPLIT_MEMBER_HPP