You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
7.1 KiB
186 lines
7.1 KiB
3 years ago
|
#if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
|
||
|
|
||
|
#include <boost/proto/detail/preprocessed/basic_expr.hpp>
|
||
|
|
||
|
#elif !defined(BOOST_PP_IS_ITERATING)
|
||
|
|
||
|
/// INTERNAL ONLY
|
||
|
///
|
||
|
#define BOOST_PROTO_CHILD(Z, N, DATA) \
|
||
|
typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(proto_child, N); \
|
||
|
BOOST_PP_CAT(proto_child, N) BOOST_PP_CAT(child, N); \
|
||
|
/**< INTERNAL ONLY */
|
||
|
|
||
|
/// INTERNAL ONLY
|
||
|
///
|
||
|
#define BOOST_PROTO_VOID(Z, N, DATA) \
|
||
|
typedef void BOOST_PP_CAT(proto_child, N); \
|
||
|
/**< INTERNAL ONLY */
|
||
|
|
||
|
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
||
|
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/basic_expr.hpp")
|
||
|
#endif
|
||
|
|
||
|
///////////////////////////////////////////////////////////////////////////////
|
||
|
/// \file basic_expr.hpp
|
||
|
/// Contains definition of basic_expr\<\> class template.
|
||
|
//
|
||
|
// 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)
|
||
|
|
||
|
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
||
|
#pragma wave option(preserve: 1)
|
||
|
#endif
|
||
|
|
||
|
// The expr<> specializations are actually defined here.
|
||
|
#define BOOST_PROTO_DEFINE_TERMINAL
|
||
|
#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/proto/detail/basic_expr.hpp>))
|
||
|
#include BOOST_PP_ITERATE()
|
||
|
|
||
|
#undef BOOST_PROTO_DEFINE_TERMINAL
|
||
|
#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/basic_expr.hpp>))
|
||
|
#include BOOST_PP_ITERATE()
|
||
|
|
||
|
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
||
|
#pragma wave option(output: null)
|
||
|
#endif
|
||
|
|
||
|
#undef BOOST_PROTO_CHILD
|
||
|
#undef BOOST_PROTO_VOID
|
||
|
|
||
|
#else
|
||
|
|
||
|
#define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
|
||
|
|
||
|
/// \brief Simplified representation of a node in an expression tree.
|
||
|
///
|
||
|
/// \c proto::basic_expr\<\> is a node in an expression template tree. It
|
||
|
/// is a container for its child sub-trees. It also serves as
|
||
|
/// the terminal nodes of the tree.
|
||
|
///
|
||
|
/// \c Tag is type that represents the operation encoded by
|
||
|
/// this expression. It is typically one of the structs
|
||
|
/// in the \c boost::proto::tag namespace, but it doesn't
|
||
|
/// have to be.
|
||
|
///
|
||
|
/// \c Args is a type list representing the type of the children
|
||
|
/// of this expression. It is an instantiation of one
|
||
|
/// of \c proto::list1\<\>, \c proto::list2\<\>, etc. The
|
||
|
/// child types must all themselves be either \c expr\<\>
|
||
|
/// or <tt>proto::expr\<\>&</tt>. If \c Args is an
|
||
|
/// instantiation of \c proto::term\<\> then this
|
||
|
/// \c expr\<\> type represents a terminal expression;
|
||
|
/// the parameter to the \c proto::term\<\> template
|
||
|
/// represents the terminal's value type.
|
||
|
///
|
||
|
/// \c Arity is an integral constant representing the number of child
|
||
|
/// nodes this node contains. If \c Arity is 0, then this
|
||
|
/// node is a terminal.
|
||
|
///
|
||
|
/// \c proto::basic_expr\<\> is a valid Fusion random-access sequence, where
|
||
|
/// the elements of the sequence are the child expressions.
|
||
|
#ifdef BOOST_PROTO_DEFINE_TERMINAL
|
||
|
template<typename Tag, typename Arg0>
|
||
|
struct basic_expr<Tag, term<Arg0>, 0>
|
||
|
#else
|
||
|
template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, typename Arg)>
|
||
|
struct basic_expr<Tag, BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)>, BOOST_PP_ITERATION() >
|
||
|
#endif
|
||
|
{
|
||
|
typedef Tag proto_tag;
|
||
|
static const long proto_arity_c = BOOST_PP_ITERATION();
|
||
|
typedef mpl::long_<BOOST_PP_ITERATION() > proto_arity;
|
||
|
typedef basic_expr proto_base_expr;
|
||
|
#ifdef BOOST_PROTO_DEFINE_TERMINAL
|
||
|
typedef term<Arg0> proto_args;
|
||
|
#else
|
||
|
typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
|
||
|
#endif
|
||
|
typedef basic_expr proto_grammar;
|
||
|
typedef basic_default_domain proto_domain;
|
||
|
typedef default_generator proto_generator;
|
||
|
typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag;
|
||
|
typedef basic_expr proto_derived_expr;
|
||
|
typedef void proto_is_expr_; /**< INTERNAL ONLY */
|
||
|
|
||
|
BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD, ~)
|
||
|
BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
|
||
|
|
||
|
/// \return *this
|
||
|
///
|
||
|
BOOST_FORCEINLINE
|
||
|
basic_expr const &proto_base() const
|
||
|
{
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
/// \overload
|
||
|
///
|
||
|
BOOST_FORCEINLINE
|
||
|
basic_expr &proto_base()
|
||
|
{
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
#ifdef BOOST_PROTO_DEFINE_TERMINAL
|
||
|
/// \return A new \c expr\<\> object initialized with the specified
|
||
|
/// arguments.
|
||
|
///
|
||
|
template<typename A0>
|
||
|
BOOST_FORCEINLINE
|
||
|
static basic_expr const make(A0 &a0)
|
||
|
{
|
||
|
return detail::make_terminal(a0, static_cast<basic_expr *>(0), static_cast<proto_args *>(0));
|
||
|
}
|
||
|
|
||
|
/// \overload
|
||
|
///
|
||
|
template<typename A0>
|
||
|
BOOST_FORCEINLINE
|
||
|
static basic_expr const make(A0 const &a0)
|
||
|
{
|
||
|
return detail::make_terminal(a0, static_cast<basic_expr *>(0), static_cast<proto_args *>(0));
|
||
|
}
|
||
|
#else
|
||
|
/// \return A new \c expr\<\> object initialized with the specified
|
||
|
/// arguments.
|
||
|
///
|
||
|
template<BOOST_PP_ENUM_PARAMS(ARG_COUNT, typename A)>
|
||
|
BOOST_FORCEINLINE
|
||
|
static basic_expr const make(BOOST_PP_ENUM_BINARY_PARAMS(ARG_COUNT, A, const &a))
|
||
|
{
|
||
|
basic_expr that = {BOOST_PP_ENUM_PARAMS(ARG_COUNT, a)};
|
||
|
return that;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#if 1 == BOOST_PP_ITERATION()
|
||
|
/// If \c Tag is \c boost::proto::tag::address_of and \c proto_child0 is
|
||
|
/// <tt>T&</tt>, then \c address_of_hack_type_ is <tt>T*</tt>.
|
||
|
/// Otherwise, it is some undefined type.
|
||
|
typedef typename detail::address_of_hack<Tag, proto_child0>::type address_of_hack_type_;
|
||
|
|
||
|
/// \return The address of <tt>this->child0</tt> if \c Tag is
|
||
|
/// \c boost::proto::tag::address_of. Otherwise, this function will
|
||
|
/// fail to compile.
|
||
|
///
|
||
|
/// \attention Proto overloads <tt>operator&</tt>, which means that
|
||
|
/// proto-ified objects cannot have their addresses taken, unless we use
|
||
|
/// the following hack to make \c &x implicitly convertible to \c X*.
|
||
|
BOOST_FORCEINLINE
|
||
|
operator address_of_hack_type_() const
|
||
|
{
|
||
|
return boost::addressof(this->child0);
|
||
|
}
|
||
|
#else
|
||
|
/// INTERNAL ONLY
|
||
|
///
|
||
|
typedef detail::not_a_valid_type address_of_hack_type_;
|
||
|
#endif
|
||
|
};
|
||
|
|
||
|
#undef ARG_COUNT
|
||
|
|
||
|
#endif
|