source: NonGTP/Boost/boost/pfto.hpp @ 857

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