williamr@2: #ifndef BOOST_PFTO_HPP williamr@2: #define BOOST_PFTO_HPP williamr@2: williamr@2: // MS compatible compilers support #pragma once williamr@2: #if defined(_MSC_VER) && (_MSC_VER >= 1020) williamr@2: # pragma once williamr@2: #endif williamr@2: williamr@2: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 williamr@2: // pfto.hpp: workarounds for compilers which have problems supporting williamr@2: // Partial Function Template Ordering (PFTO). williamr@2: williamr@2: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . williamr@2: // Use, modification and distribution is subject to the Boost Software williamr@2: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at williamr@2: // http://www.boost.org/LICENSE_1_0.txt) williamr@2: williamr@2: // See http://www.boost.org for updates, documentation, and revision history. williamr@2: // PFTO version is used to specify the last argument of certain functions williamr@2: // Function it is used to support compilers that fail to support correct Partial williamr@2: // Template Ordering williamr@2: #include williamr@2: williamr@2: // some compilers can use an exta argument and use function overloading williamr@2: // to choose desired function. This extra argument is long in the default williamr@2: // function implementation and int for the rest. The function is called williamr@2: // with an int argument. This first attempts to match functions with an williamr@2: // int argument before the default one (with a long argument). This is williamr@2: // known to function with VC 6.0. On other compilers this fails (Borland) williamr@2: // or causes other problems (GCC). note: this williamr@2: williamr@2: #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) williamr@2: #define BOOST_PFTO long williamr@2: #else williamr@2: #define BOOST_PFTO williamr@2: #endif williamr@2: williamr@2: // here's another approach. Rather than use a default function - make sure williamr@2: // there is no default at all by requiring that all function invocations williamr@2: // have a "wrapped" argument type. This solves a problem with VC 6.0 williamr@2: // (and perhaps others) while implementing templated constructors. williamr@2: williamr@2: namespace boost { williamr@2: williamr@2: template williamr@2: struct pfto_wrapper { williamr@2: const T & t; williamr@2: operator const T & (){ williamr@2: return t; williamr@2: } williamr@2: pfto_wrapper (const T & rhs) : t(rhs) {} williamr@2: }; williamr@2: williamr@2: template williamr@2: pfto_wrapper make_pfto_wrapper(const T & t, BOOST_PFTO int){ williamr@2: return pfto_wrapper(t); williamr@2: } williamr@2: williamr@2: template williamr@2: pfto_wrapper make_pfto_wrapper(const pfto_wrapper & t, int){ williamr@2: return t; williamr@2: } williamr@2: williamr@2: } // namespace boost williamr@2: williamr@2: #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING williamr@2: #define BOOST_PFTO_WRAPPER(T) boost::pfto_wrapper williamr@2: #define BOOST_MAKE_PFTO_WRAPPER(t) boost::make_pfto_wrapper(t, 0) williamr@2: #else williamr@2: #define BOOST_PFTO_WRAPPER(T) T williamr@2: #define BOOST_MAKE_PFTO_WRAPPER(t) t williamr@2: #endif williamr@2: williamr@2: #endif // BOOST_PFTO_HPP