/usr/include/boost/phoenix/core
Edit: /usr/include/boost/phoenix/core/reference.hpp (4665B)
/*==============================================================================
Copyright (c) 2001-2010 Joel de Guzman
Copyright (c) 2010 Thomas Heller
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_PHOENIX_CORE_REFERENCE_HPP
#define BOOST_PHOENIX_CORE_REFERENCE_HPP
#include
#include
#include
#include
#include
namespace boost { namespace phoenix
{
/////////////////////////////////////////////////////////////////////////////
//
// reference
//
// function for evaluating references, e.g. ref(123)
//
/////////////////////////////////////////////////////////////////////////////
namespace expression
{
template
struct reference
: expression::terminal >
{
typedef
typename expression::terminal >::type
type;
static const type make(T & t)
{
typename reference::type const e = {{boost::ref(t)}};
return e;
}
};
template
struct reference
: expression::terminal >
{
typedef
typename expression::terminal >::type
type;
static const type make(T const & t)
{
typename reference::type const e = {{boost::cref(t)}};
return e;
}
};
}
namespace rule
{
struct reference
: expression::reference
{};
}
template
inline
typename expression::reference::type const
ref(T & t)
{
return expression::reference::make(t);
}
template
inline
typename expression::reference::type const
cref(T const & t)
{
return expression::reference::make(t);
}
// Call out boost::reference_wrapper for special handling
template
struct is_custom_terminal >
: mpl::true_
{};
// Special handling for boost::reference_wrapper
template
struct custom_terminal >
{
typedef T &result_type;
template
T &operator()(boost::reference_wrapper r, Context &) const
{
return r;
}
};
template
struct custom_terminal > >
{
template
struct result;
template
struct result > const &, Context)>
: boost::result_of &, Context)>
{};
template
struct result > &, Context)>
: boost::result_of &, Context)>
{};
template
typename boost::result_of &, Context const &)>::type
operator()(boost::reference_wrapper > & r, Context const & ctx) const
{
return boost::phoenix::eval(r, ctx);
}
};
template
struct custom_terminal const> >
{
template
struct result;
template
struct result const> const &, Context)>
: boost::result_of const&, Context)>
{};
template
struct result const> &, Context)>
: boost::result_of const&, Context)>
{};
template
typename boost::result_of const&, Context const &)>::type
operator()(boost::reference_wrapper const> const & r, Context & ctx) const
{
return boost::phoenix::eval(unwrap_ref(r), ctx);
}
};
}}
#endif