Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / serialization / type_info_implementation.hpp
1 #ifndef BOOST_SERIALIZATION_TYPE_INFO_IMPLEMENTATION_HPP
2 #define BOOST_SERIALIZATION_TYPE_INFO_IMPLEMENTATION_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // type_info_implementation.hpp: interface for portable version of type_info
11
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)
16
17 //  See http://www.boost.org for updates, documentation, and revision history.
18
19
20 #include <boost/config.hpp>
21 #include <boost/detail/workaround.hpp>
22
23 #include <boost/static_assert.hpp>
24 #include <boost/mpl/eval_if.hpp>
25 #include <boost/mpl/identity.hpp>
26 #include <boost/type_traits/is_base_and_derived.hpp>
27 #include <boost/serialization/traits.hpp>
28
29 namespace boost {
30 namespace serialization {
31
32 // note that T and const T are folded into const T so that
33 // there is only one table entry per type
34 template<class T>
35 struct type_info_implementation {
36     template<class U>
37     struct traits_class_typeinfo_implementation {
38       typedef typename U::type_info_implementation::type type;
39     };
40     // note: at least one compiler complained w/o the full qualification
41     // on basic traits below
42     typedef 
43         typename mpl::eval_if<
44             is_base_and_derived<boost::serialization::basic_traits, T>,
45             traits_class_typeinfo_implementation< T >,
46         //else
47             mpl::identity<
48                 typename extended_type_info_impl< T >::type
49             >
50         >::type type;
51 };
52
53 } // namespace serialization
54 } // namespace boost
55
56 // define a macro to assign a particular derivation of extended_type_info
57 // to a specified a class. 
58 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
59 #define BOOST_CLASS_TYPE_INFO(T, ETI)              \
60 namespace boost {                                  \
61 namespace serialization {                          \
62 template<>                                         \
63 struct type_info_implementation< T > {             \
64     typedef const ETI type;                        \
65 };                                                 \
66 }                                                  \
67 }                                                  \
68 /**/
69 #else
70 #define BOOST_CLASS_TYPE_INFO(T, ETI)              \
71 namespace boost {                                  \
72 namespace serialization {                          \
73 template<>                                         \
74 struct type_info_implementation< T > {             \
75     typedef ETI type;                              \
76 };                                                 \
77 template<>                                         \
78 struct type_info_implementation< const T > {       \
79     typedef ETI type;                              \
80 };                                                 \
81 }                                                  \
82 }                                                  \
83 /**/
84 #endif
85
86 #endif /// BOOST_SERIALIZATION_TYPE_INFO_IMPLEMENTATION_HPP