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