Chris@16
|
1 #ifndef BOOST_SERIALIZATION_PFTO_HPP
|
Chris@16
|
2 #define BOOST_SERIALIZATION_PFTO_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@101
|
5 #if defined(_MSC_VER)
|
Chris@16
|
6 # pragma once
|
Chris@16
|
7 #endif
|
Chris@16
|
8
|
Chris@16
|
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
10 // pfto.hpp: workarounds for compilers which have problems supporting
|
Chris@16
|
11 // Partial Function Template Ordering (PFTO).
|
Chris@16
|
12
|
Chris@16
|
13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
14 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
15 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
16 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
17
|
Chris@16
|
18 // See http://www.boost.org/libs/serialization for updates, documentation, and revision history.
|
Chris@16
|
19 // PFTO version is used to specify the last argument of certain functions
|
Chris@16
|
20 // Function it is used to support compilers that fail to support correct Partial
|
Chris@16
|
21 // Template Ordering
|
Chris@16
|
22 #include <boost/config.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 // some compilers can use an exta argument and use function overloading
|
Chris@16
|
25 // to choose desired function. This extra argument is long in the default
|
Chris@16
|
26 // function implementation and int for the rest. The function is called
|
Chris@16
|
27 // with an int argument. This first attempts to match functions with an
|
Chris@16
|
28 // int argument before the default one (with a long argument). This is
|
Chris@16
|
29 // known to function with VC 6.0. On other compilers this fails (Borland)
|
Chris@16
|
30 // or causes other problems (GCC). note: this
|
Chris@16
|
31
|
Chris@16
|
32 #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
Chris@16
|
33 #define BOOST_PFTO long
|
Chris@16
|
34 #else
|
Chris@16
|
35 #define BOOST_PFTO
|
Chris@16
|
36 #endif
|
Chris@16
|
37
|
Chris@16
|
38 // here's another approach. Rather than use a default function - make sure
|
Chris@16
|
39 // there is no default at all by requiring that all function invocations
|
Chris@16
|
40 // have a "wrapped" argument type. This solves a problem with VC 6.0
|
Chris@16
|
41 // (and perhaps others) while implementing templated constructors.
|
Chris@16
|
42
|
Chris@16
|
43 namespace boost {
|
Chris@16
|
44 namespace serialization {
|
Chris@16
|
45
|
Chris@16
|
46 template<class T>
|
Chris@16
|
47 struct pfto_wrapper {
|
Chris@16
|
48 const T & t;
|
Chris@16
|
49 operator const T & (){
|
Chris@16
|
50 return t;
|
Chris@16
|
51 }
|
Chris@16
|
52 pfto_wrapper (const T & rhs) : t(rhs) {}
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@16
|
55 template<class T>
|
Chris@16
|
56 pfto_wrapper< T > make_pfto_wrapper(const T & t, BOOST_PFTO int){
|
Chris@16
|
57 return pfto_wrapper< T >(t);
|
Chris@16
|
58 }
|
Chris@16
|
59
|
Chris@16
|
60 template<class T>
|
Chris@16
|
61 pfto_wrapper< T > make_pfto_wrapper(const pfto_wrapper< T > & t, int){
|
Chris@16
|
62 return t;
|
Chris@16
|
63 }
|
Chris@16
|
64
|
Chris@16
|
65 } // namespace serialization
|
Chris@16
|
66 } // namespace boost
|
Chris@16
|
67
|
Chris@16
|
68 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
Chris@16
|
69 #define BOOST_PFTO_WRAPPER(T) \
|
Chris@16
|
70 boost::serialization::pfto_wrapper< T >
|
Chris@16
|
71 #define BOOST_MAKE_PFTO_WRAPPER(t) \
|
Chris@16
|
72 boost::serialization::make_pfto_wrapper(t, 0)
|
Chris@16
|
73 #else
|
Chris@16
|
74 #define BOOST_PFTO_WRAPPER(T) T
|
Chris@16
|
75 #define BOOST_MAKE_PFTO_WRAPPER(t) t
|
Chris@16
|
76 #endif
|
Chris@16
|
77
|
Chris@16
|
78 #endif // BOOST_SERIALIZATION_PFTO_HPP
|