fix doc example typo
[boost.git] / boost / serialization / split_free.hpp
blob9dbcd2fd1d4894186dab916ade8d9b6d1de7b13c
1 #ifndef BOOST_SERIALIZATION_SPLIT_FREE_HPP
2 #define BOOST_SERIALIZATION_SPLIT_FREE_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_free.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>
22 #include <boost/serialization/serialization.hpp>
24 namespace boost {
25 namespace archive {
26 namespace detail {
27 template<class Archive> class interface_oarchive;
28 template<class Archive> class interface_iarchive;
29 } // namespace detail
30 } // namespace archive
32 namespace serialization {
34 //namespace detail {
35 template<class Archive, class T>
36 struct free_saver {
37 static void invoke(
38 Archive & ar,
39 const T & t,
40 const unsigned int file_version
42 // use function overload (version_type) to workaround
43 // two-phase lookup issue
44 const version_type v(file_version);
45 save(ar, t, v);
48 template<class Archive, class T>
49 struct free_loader {
50 static void invoke(
51 Archive & ar,
52 T & t,
53 const unsigned int file_version
55 // use function overload (version_type) to workaround
56 // two-phase lookup issue
57 const version_type v(file_version);
58 load(ar, t, v);
61 //} // namespace detail
63 template<class Archive, class T>
64 inline void split_free(
65 Archive & ar,
66 T & t,
67 const unsigned int file_version
69 typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
70 BOOST_DEDUCED_TYPENAME Archive::is_saving,
71 mpl::identity</* detail:: */ free_saver<Archive, T> >,
72 mpl::identity</* detail:: */ free_loader<Archive, T> >
73 >::type typex;
74 typex::invoke(ar, t, file_version);
77 } // namespace serialization
78 } // namespace boost
80 #define BOOST_SERIALIZATION_SPLIT_FREE(T) \
81 namespace boost { namespace serialization { \
82 template<class Archive> \
83 inline void serialize( \
84 Archive & ar, \
85 T & t, \
86 const unsigned int file_version \
87 ){ \
88 split_free(ar, t, file_version); \
89 } \
91 /**/
93 #endif // BOOST_SERIALIZATION_SPLIT_FREE_HPP