fix doc example typo
[boost.git] / boost / serialization / collection_traits.hpp
blob568b8074022c899e551163347d58966978d6864b
1 #ifndef BOOST_SERIALIZATION_COLLECTION_TRAITS_HPP
2 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_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 // collection_traits.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 // This header assigns a level implemenation trait to a collection type
20 // for all primitives. It is needed so that archives which are meant to be
21 // portable don't write class information in the archive. Since, not all
22 // compiles recognize the same set of primitive types, the possibility
23 // exists for archives to be non-portable if class information for primitive
24 // types is included. This is addressed by the following macros.
25 #include <boost/config.hpp>
26 #include <boost/mpl/integral_c.hpp>
27 #include <boost/mpl/integral_c_tag.hpp>
29 #include <boost/cstdint.hpp>
30 #include <climits> // ULONG_MAX
31 #include <boost/serialization/level.hpp>
33 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(T, C) \
34 template<> \
35 struct implementation_level< C < T > > { \
36 typedef mpl::integral_c_tag tag; \
37 typedef mpl::int_<object_serializable> type; \
38 BOOST_STATIC_CONSTANT(int, value = object_serializable); \
39 }; \
40 /**/
42 #if defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_INTRINSIC_WCHAR_T)
43 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C)
44 #else
45 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \
46 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(wchar_t, C) \
47 /**/
48 #endif
50 // determine if its necessary to handle (u)int64_t specifically
51 // i.e. that its not a synonym for (unsigned) long
52 // if there is no 64 bit int or if its the same as a long
53 // we shouldn't define separate functions for int64 data types.
54 #if defined(BOOST_NO_INT64_T)
55 #define BOOST_NO_INTRINSIC_INT64_T
56 #else
57 #if defined(ULLONG_MAX)
58 #if(ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
59 #define BOOST_NO_INTRINSIC_INT64_T
60 #endif
61 #elif defined(ULONG_MAX)
62 #if(ULONG_MAX != 0xffffffff && ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
63 #define BOOST_NO_INTRINSIC_INT64_T
64 #endif
65 #else
66 #define BOOST_NO_INTRINSIC_INT64_T
67 #endif
68 #endif
70 #if !defined(BOOST_NO_INTRINSIC_INT64_T)
71 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \
72 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::int64_t, C) \
73 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::uint64_t, C) \
74 /**/
75 #else
76 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C)
77 #endif
79 #define BOOST_SERIALIZATION_COLLECTION_TRAITS(C) \
80 namespace boost { namespace serialization { \
81 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(bool, C) \
82 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(char, C) \
83 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed char, C) \
84 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned char, C) \
85 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed int, C) \
86 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned int, C) \
87 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed long, C) \
88 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned long, C) \
89 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(float, C) \
90 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(double, C) \
91 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned short, C) \
92 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed short, C) \
93 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \
94 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \
95 } } \
96 /**/
98 #endif // BOOST_SERIALIZATION_COLLECTION_TRAITS