/usr/include/boost/proto/detail
Edit: /usr/include/boost/proto/detail/poly_function.hpp (6925B)
///////////////////////////////////////////////////////////////////////////////
/// \file poly_function.hpp
/// A wrapper that makes a tr1-style function object that handles const
/// and non-const refs and reference_wrapper arguments, too, and forwards
/// the arguments on to the specified implementation.
//
// Copyright 2008 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROTO_DETAIL_POLY_FUNCTION_EAN_2008_05_02
#define BOOST_PROTO_DETAIL_POLY_FUNCTION_EAN_2008_05_02
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4181) // const applied to reference type
#endif
namespace boost { namespace proto { namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct normalize_arg
{
typedef typename mpl::if_c::value, T &, T>::type type;
typedef T &reference;
};
template
struct normalize_arg
{
typedef typename mpl::if_c::value, T const &, T>::type type;
typedef T const &reference;
};
template
struct normalize_arg
{
typedef typename mpl::if_c::value, T &, T>::type type;
typedef T &reference;
};
template
struct normalize_arg
{
typedef typename mpl::if_c::value, T const &, T>::type type;
typedef T const &reference;
};
template
struct normalize_arg >
{
typedef T &type;
typedef T &reference;
};
template
struct normalize_arg const>
{
typedef T &type;
typedef T &reference;
};
template
struct normalize_arg &>
{
typedef T &type;
typedef T &reference;
};
template
struct normalize_arg const &>
{
typedef T &type;
typedef T &reference;
};
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct arg
{
typedef T const &type;
arg(type t)
: value(t)
{}
operator type() const
{
return this->value;
}
type operator()() const
{
return this->value;
}
BOOST_DELETED_FUNCTION(arg &operator =(arg const &))
private:
type value;
};
template
struct arg
{
typedef T &type;
arg(type t)
: value(t)
{}
operator type() const
{
return this->value;
}
type operator()() const
{
return this->value;
}
BOOST_DELETED_FUNCTION(arg &operator =(arg const &))
private:
type value;
};
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct is_poly_function
: mpl::false_
{};
template
struct is_poly_function
: mpl::true_
{};
////////////////////////////////////////////////////////////////////////////////////////////////
#define BOOST_PROTO_POLY_FUNCTION() \
typedef void is_poly_function_base_; \
/**/
////////////////////////////////////////////////////////////////////////////////////////////////
struct poly_function_base
{
/// INTERNAL ONLY
BOOST_PROTO_POLY_FUNCTION()
};
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct poly_function
: poly_function_base
{
template
struct result;
template
struct result
: Derived::template impl<>
{
typedef typename result::result_type type;
};
NullaryResult operator()() const
{
result impl;
return impl();
}
#include
};
template
struct wrap_t;
typedef char poly_function_t;
typedef char (&mono_function_t)[2];
typedef char (&unknown_function_t)[3];
template poly_function_t test_poly_function(T *, wrap_t * = 0);
template mono_function_t test_poly_function(T *, wrap_t * = 0);
template unknown_function_t test_poly_function(T *, ...);
////////////////////////////////////////////////////////////////////////////////////////////////
template(0,0))> >
struct poly_function_traits
{
typedef typename Fun::template result::type result_type;
typedef Fun function_type;
};
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct poly_function_traits >
{
typedef typename Fun::result_type result_type;
typedef Fun function_type;
};
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct as_mono_function_impl;
////////////////////////////////////////////////////////////////////////////////////////////////
template
struct as_mono_function;
#include
}}} // namespace boost::proto::detail
#ifdef _MSC_VER
# pragma warning(pop)
#endif
#endif