Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:28

0001 // Copyright David Abrahams 2006. Distributed under the Boost
0002 // Software License, Version 1.0. (See accompanying
0003 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0004 #ifndef BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP
0005 # define BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP
0006 
0007 namespace boost { namespace archive { namespace detail {
0008 
0009 // No instantiate_ptr_serialization overloads generated by
0010 // BOOST_SERIALIZATION_REGISTER_ARCHIVE that lexically follow the call
0011 // will be seen *unless* they are in an associated namespace of one of
0012 // the arguments, so we pass one of these along to make sure this
0013 // namespace is considered.  See temp.dep.candidate (14.6.4.2) in the
0014 // standard.
0015 struct adl_tag {};
0016 
0017 template <class Archive, class Serializable>
0018 struct ptr_serialization_support;
0019 
0020 // We could've just used ptr_serialization_support, above, but using
0021 // it with only a forward declaration causes vc6/7 to complain about a
0022 // missing instantiate member, even if it has one.  This is just a
0023 // friendly layer of indirection.
0024 template <class Archive, class Serializable>
0025 struct _ptr_serialization_support
0026   : ptr_serialization_support<Archive,Serializable>
0027 {
0028     typedef int type;
0029 };
0030 
0031 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5130)
0032 
0033 template<int N>
0034 struct counter : counter<N-1> {};
0035 template<>
0036 struct counter<0> {};
0037 
0038 template<class Serializable>
0039 void instantiate_ptr_serialization(Serializable* s, int, adl_tag) {
0040     instantiate_ptr_serialization(s, counter<20>());
0041 }
0042 
0043 template<class Archive>
0044 struct get_counter {
0045     static const int value = sizeof(adjust_counter(counter<20>()));
0046     typedef counter<value> type;
0047     typedef counter<value - 1> prior;
0048     typedef char (&next)[value+1];
0049 };
0050 
0051 char adjust_counter(counter<0>);
0052 template<class Serializable>
0053 void instantiate_ptr_serialization(Serializable*, counter<0>) {}
0054 
0055 #define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive)                     \
0056 namespace boost { namespace archive { namespace detail {                  \
0057     get_counter<Archive >::next adjust_counter(get_counter<Archive >::type);\
0058     template<class Serializable>                                          \
0059     void instantiate_ptr_serialization(Serializable* s,                   \
0060         get_counter<Archive >::type) {                                    \
0061         ptr_serialization_support<Archive, Serializable> x;               \
0062         instantiate_ptr_serialization(s, get_counter<Archive >::prior()); \
0063     }\
0064 }}}
0065 
0066 
0067 #else
0068 
0069 // This function gets called, but its only purpose is to participate
0070 // in overload resolution with the functions declared by
0071 // BOOST_SERIALIZATION_REGISTER_ARCHIVE, below.
0072 template <class Serializable>
0073 void instantiate_ptr_serialization(Serializable*, int, adl_tag ) {}
0074 
0075 // The function declaration generated by this macro never actually
0076 // gets called, but its return type gets instantiated, and that's
0077 // enough to cause registration of serialization functions between
0078 // Archive and any exported Serializable type.  See also:
0079 // boost/serialization/export.hpp
0080 # define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive)                  \
0081 namespace boost { namespace archive { namespace detail {                \
0082                                                                         \
0083 template <class Serializable>                                           \
0084 typename _ptr_serialization_support<Archive, Serializable>::type  \
0085 instantiate_ptr_serialization( Serializable*, Archive*, adl_tag );              \
0086                                                                         \
0087 }}}
0088 #endif
0089 }}} // namespace boost::archive::detail
0090 
0091 #endif // BOOST_ARCHIVE_DETAIL_INSTANTIATE_SERIALIZE_DWA2006521_HPP