Files

656 lines
44 KiB
C++

///////////////////////////////////////////////////////////////////////////////
/// \file extends.hpp
/// Macros and a base class for defining end-user expression types
//
// 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 ACTIV_BOOST_PROTO_EXTENDS_HPP_EAN_11_1_2006
#define ACTIV_BOOST_PROTO_EXTENDS_HPP_EAN_11_1_2006
#include <cstddef> // for offsetof
#include <ActivBoost/config.hpp>
#include <ActivBoost/detail/workaround.hpp>
#include <ActivBoost/preprocessor/facilities/empty.hpp>
#include <ActivBoost/preprocessor/tuple/elem.hpp>
#include <ActivBoost/preprocessor/control/if.hpp>
#include <ActivBoost/preprocessor/arithmetic/inc.hpp>
#include <ActivBoost/preprocessor/arithmetic/dec.hpp>
#include <ActivBoost/preprocessor/iteration/local.hpp>
#include <ActivBoost/preprocessor/repetition/enum_params.hpp>
#include <ActivBoost/preprocessor/repetition/repeat_from_to.hpp>
#include <ActivBoost/preprocessor/repetition/enum_binary_params.hpp>
#include <ActivBoost/preprocessor/repetition/enum_trailing_params.hpp>
#include <ActivBoost/preprocessor/repetition/enum_trailing_binary_params.hpp>
#include <ActivBoost/preprocessor/seq/for_each.hpp>
#include <ActivBoost/utility/addressof.hpp>
#include <ActivBoost/utility/result_of.hpp>
#include <ActivBoost/proto/proto_fwd.hpp>
#include <ActivBoost/proto/traits.hpp>
#include <ActivBoost/proto/expr.hpp>
#include <ActivBoost/proto/args.hpp>
#include <ActivBoost/proto/traits.hpp>
#include <ActivBoost/proto/generate.hpp>
#include <ActivBoost/proto/detail/remove_typename.hpp>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined
#endif
namespace Boost { namespace proto
{
#ifdef __GNUC__
/// INTERNAL ONLY
///
# define ACTIV_BOOST_PROTO_ADDROF(x) ((char const volatile*)Boost::addressof(x))
/// INTERNAL ONLY
///
# define ACTIV_BOOST_PROTO_OFFSETOF(s,m) (ACTIV_BOOST_PROTO_ADDROF((((s *)this)->m)) - ACTIV_BOOST_PROTO_ADDROF(*((s *)this)))
#else
/// INTERNAL ONLY
///
# define ACTIV_BOOST_PROTO_OFFSETOF offsetof
#endif
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_CONST() const
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_TYPENAME() typename
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_TEMPLATE_YES_(Z, N) template<ACTIV_BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)>
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_TEMPLATE_NO_(Z, N)
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, Const) \
ACTIV_BOOST_PP_IF(N, ACTIV_BOOST_PROTO_TEMPLATE_YES_, ACTIV_BOOST_PROTO_TEMPLATE_NO_)(Z, N) \
ACTIV_BOOST_PROTO_PUSH_WARNINGS \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4180 \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
typename ACTIV_BOOST_PROTO_RESULT_OF< \
proto_generator( \
typename Boost::proto::result_of::ACTIV_BOOST_PP_CAT(funop, N)< \
proto_derived_expr Const() \
, proto_domain \
ACTIV_BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A) \
>::type \
) \
>::type const \
operator ()(ACTIV_BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) Const() \
{ \
typedef Boost::proto::result_of::ACTIV_BOOST_PP_CAT(funop, N)< \
proto_derived_expr Const() \
, proto_domain \
ACTIV_BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A) \
> funop; \
return proto_generator()( \
funop::call( \
*static_cast<proto_derived_expr Const() *>(this) \
ACTIV_BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, a) \
) \
); \
} \
ACTIV_BOOST_PROTO_POP_WARNINGS \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(Const) \
template<typename... A> \
ACTIV_BOOST_PROTO_PUSH_WARNINGS \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4180 \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
typename ACTIV_BOOST_PROTO_RESULT_OF< \
proto_generator( \
typename Boost::proto::result_of::funop< \
proto_derived_expr Const()(A const &...) \
, proto_derived_expr \
, proto_domain \
>::type \
) \
>::type const \
operator ()(A const &...a) Const() \
{ \
typedef Boost::proto::result_of::funop< \
proto_derived_expr Const()(A const &...) \
, proto_derived_expr \
, proto_domain \
> funop; \
return proto_generator()( \
funop::call( \
*static_cast<proto_derived_expr Const() *>(this) \
, a... \
) \
); \
} \
ACTIV_BOOST_PROTO_POP_WARNINGS \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_DEFINE_FUN_OP_CONST(Z, N, DATA) \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, ACTIV_BOOST_PROTO_CONST) \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_DEFINE_FUN_OP_NON_CONST(Z, N, DATA) \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, ACTIV_BOOST_PP_EMPTY) \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_DEFINE_FUN_OP(Z, N, DATA) \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_CONST(Z, N, DATA) \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_NON_CONST(Z, N, DATA) \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_EXTENDS_CHILD(Z, N, DATA) \
typedef \
typename proto_base_expr::ACTIV_BOOST_PP_CAT(proto_child, N) \
ACTIV_BOOST_PP_CAT(proto_child, N); \
/**/
#define ACTIV_BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain) \
Expr proto_expr_; \
\
typedef Expr proto_base_expr_; /**< INTERNAL ONLY */ \
typedef typename proto_base_expr_::proto_base_expr proto_base_expr; \
typedef ACTIV_BOOST_PROTO_REMOVE_TYPENAME(Domain) proto_domain; \
typedef Derived proto_derived_expr; \
typedef Domain::proto_generator proto_generator; \
typedef typename proto_base_expr::proto_tag proto_tag; \
typedef typename proto_base_expr::proto_args proto_args; \
typedef typename proto_base_expr::proto_arity proto_arity; \
typedef typename proto_base_expr::proto_grammar proto_grammar; \
typedef typename proto_base_expr::address_of_hack_type_ proto_address_of_hack_type_; \
typedef void proto_is_expr_; /**< INTERNAL ONLY */ \
static const long proto_arity_c = proto_base_expr::proto_arity_c; \
typedef Boost::proto::tag::proto_expr<proto_tag, proto_domain> fusion_tag; \
ACTIV_BOOST_PP_REPEAT(ACTIV_BOOST_PROTO_MAX_ARITY, ACTIV_BOOST_PROTO_EXTENDS_CHILD, ~) \
\
ACTIV_BOOST_PROTO_PUSH_WARNINGS \
\
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
static proto_derived_expr const make(Expr const &e) \
{ \
proto_derived_expr that = {e}; \
return that; \
} \
\
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
proto_base_expr &proto_base() \
{ \
return this->proto_expr_.proto_base(); \
} \
\
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
proto_base_expr const &proto_base() const \
{ \
return this->proto_expr_.proto_base(); \
} \
\
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
operator proto_address_of_hack_type_() const \
{ \
return Boost::addressof(this->proto_base().child0); \
} \
\
ACTIV_BOOST_PROTO_POP_WARNINGS \
/**/
#define ACTIV_BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain) \
ACTIV_BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain) \
typedef void proto_is_aggregate_; \
/**< INTERNAL ONLY */
#define ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, Const, Typename) \
ACTIV_BOOST_PROTO_PUSH_WARNINGS \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4522 \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
Typename() ACTIV_BOOST_PROTO_RESULT_OF< \
Typename() This::proto_generator( \
Typename() Boost::proto::base_expr< \
Typename() This::proto_domain \
, Boost::proto::tag::assign \
, Boost::proto::list2< \
This & \
, This Const() & \
> \
>::type \
) \
>::type const \
operator =(This Const() &a) \
{ \
typedef \
Typename() Boost::proto::base_expr< \
Typename() This::proto_domain \
, Boost::proto::tag::assign \
, Boost::proto::list2< \
This & \
, This Const() & \
> \
>::type \
that_type; \
that_type const that = { \
*this \
, a \
}; \
return Typename() This::proto_generator()(that); \
} \
ACTIV_BOOST_PROTO_POP_WARNINGS \
/**/
// MSVC 8.0 and higher seem to need copy-assignment operator to be overloaded on *both*
// const and non-const rhs arguments.
#if ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_MSVC, ACTIV_BOOST_TESTED_AT(1600)) && (ACTIV_BOOST_MSVC > 1310)
#define ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(This, Typename) \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, ACTIV_BOOST_PP_EMPTY, Typename) \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, ACTIV_BOOST_PROTO_CONST, Typename) \
/**/
#else
#define ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(This, Typename) \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, ACTIV_BOOST_PROTO_CONST, Typename) \
/**/
#endif
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(ThisConst, ThatConst) \
template<typename A> \
ACTIV_BOOST_PROTO_PUSH_WARNINGS \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4180 \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
typename ACTIV_BOOST_PROTO_RESULT_OF< \
proto_generator( \
typename Boost::proto::base_expr< \
proto_domain \
, Boost::proto::tag::assign \
, Boost::proto::list2< \
proto_derived_expr ThisConst() & \
, typename Boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
>::type \
) \
>::type const \
operator =(A ThatConst() &a) ThisConst() \
{ \
typedef \
typename Boost::proto::base_expr< \
proto_domain \
, Boost::proto::tag::assign \
, Boost::proto::list2< \
proto_derived_expr ThisConst() & \
, typename Boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
>::type \
that_type; \
that_type const that = { \
*static_cast<proto_derived_expr ThisConst() *>(this) \
, Boost::proto::as_child<proto_domain>(a) \
}; \
return proto_generator()(that); \
} \
ACTIV_BOOST_PROTO_POP_WARNINGS \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_CONST_() \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(ACTIV_BOOST_PROTO_CONST, ACTIV_BOOST_PP_EMPTY) \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(ACTIV_BOOST_PROTO_CONST, ACTIV_BOOST_PROTO_CONST) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST_() \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(ACTIV_BOOST_PP_EMPTY, ACTIV_BOOST_PP_EMPTY) \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(ACTIV_BOOST_PP_EMPTY, ACTIV_BOOST_PROTO_CONST) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_() \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_CONST_() \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST_() \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(proto_derived_expr, ACTIV_BOOST_PROTO_TYPENAME) \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_CONST_() \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(proto_derived_expr, ACTIV_BOOST_PROTO_TYPENAME) \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST_() \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_ASSIGN() \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(proto_derived_expr, ACTIV_BOOST_PROTO_TYPENAME) \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_() \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(ThisConst, ThatConst) \
template<typename A> \
ACTIV_BOOST_PROTO_PUSH_WARNINGS \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4180 \
ACTIV_BOOST_PROTO_DISABLE_MSVC_C4714 ACTIV_BOOST_FORCEINLINE \
typename ACTIV_BOOST_PROTO_RESULT_OF< \
proto_generator( \
typename Boost::proto::base_expr< \
proto_domain \
, Boost::proto::tag::subscript \
, Boost::proto::list2< \
proto_derived_expr ThisConst() & \
, typename Boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
>::type \
) \
>::type const \
operator [](A ThatConst() &a) ThisConst() \
{ \
typedef \
typename Boost::proto::base_expr< \
proto_domain \
, Boost::proto::tag::subscript \
, Boost::proto::list2< \
proto_derived_expr ThisConst() & \
, typename Boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
>::type \
that_type; \
that_type const that = { \
*static_cast<proto_derived_expr ThisConst() *>(this) \
, Boost::proto::as_child<proto_domain>(a) \
}; \
return proto_generator()(that); \
} \
ACTIV_BOOST_PROTO_POP_WARNINGS \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(ACTIV_BOOST_PROTO_CONST, ACTIV_BOOST_PP_EMPTY) \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(ACTIV_BOOST_PROTO_CONST, ACTIV_BOOST_PROTO_CONST) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_NON_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(ACTIV_BOOST_PP_EMPTY, ACTIV_BOOST_PP_EMPTY) \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(ACTIV_BOOST_PP_EMPTY, ACTIV_BOOST_PROTO_CONST) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT() \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_NON_CONST() \
/**/
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
template<typename Sig> \
struct result \
{ \
typedef \
typename ACTIV_BOOST_PROTO_RESULT_OF< \
proto_generator( \
typename Boost::proto::result_of::funop< \
Sig \
, proto_derived_expr \
, proto_domain \
>::type \
) \
>::type const \
type; \
}; \
/**/
#ifndef ACTIV_BOOST_NO_CXX11_VARIADIC_TEMPLATES
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(ACTIV_BOOST_PROTO_CONST) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_NON_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(ACTIV_BOOST_PP_EMPTY) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(ACTIV_BOOST_PP_EMPTY) \
ACTIV_BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(ACTIV_BOOST_PROTO_CONST) \
/**/
#else
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
ACTIV_BOOST_PP_REPEAT_FROM_TO( \
0 \
, ACTIV_BOOST_PROTO_MAX_FUNCTION_CALL_ARITY \
, ACTIV_BOOST_PROTO_DEFINE_FUN_OP_CONST \
, ~ \
) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_NON_CONST() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
ACTIV_BOOST_PP_REPEAT_FROM_TO( \
0 \
, ACTIV_BOOST_PROTO_MAX_FUNCTION_CALL_ARITY \
, ACTIV_BOOST_PROTO_DEFINE_FUN_OP_NON_CONST \
, ~ \
) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_FUNCTION() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION_() \
ACTIV_BOOST_PP_REPEAT_FROM_TO( \
0 \
, ACTIV_BOOST_PROTO_MAX_FUNCTION_CALL_ARITY \
, ACTIV_BOOST_PROTO_DEFINE_FUN_OP \
, ~ \
) \
/**/
#endif
#define ACTIV_BOOST_PROTO_EXTENDS(Expr, Derived, Domain) \
ACTIV_BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain) \
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN() \
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT() \
ACTIV_BOOST_PROTO_EXTENDS_FUNCTION() \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_USING_ASSIGN(Derived) \
typedef typename Derived::proto_extends proto_extends; \
using proto_extends::operator =; \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(Derived, ACTIV_BOOST_PROTO_TYPENAME) \
/**/
#define ACTIV_BOOST_PROTO_EXTENDS_USING_ASSIGN_NON_DEPENDENT(Derived) \
typedef Derived::proto_extends proto_extends; \
using proto_extends::operator =; \
ACTIV_BOOST_PROTO_EXTENDS_COPY_ASSIGN_(Derived, ACTIV_BOOST_PP_EMPTY) \
/**/
namespace exprns_
{
/// \brief Empty type to be used as a dummy template parameter of
/// POD expression wrappers. It allows argument-dependent lookup
/// to find Proto's operator overloads.
///
/// \c proto::is_proto_expr allows argument-dependent lookup
/// to find Proto's operator overloads. For example:
///
/// \code
/// template<typename T, typename Dummy = proto::is_proto_expr>
/// struct my_terminal
/// {
/// ACTIV_BOOST_PROTO_BASIC_EXTENDS(
/// typename proto::terminal<T>::type
/// , my_terminal<T>
/// , default_domain
/// )
/// };
///
/// // ...
/// my_terminal<int> _1, _2;
/// _1 + _2; // OK, uses proto::operator+
/// \endcode
///
/// Without the second \c Dummy template parameter, Proto's operator
/// overloads would not be considered by name lookup.
struct is_proto_expr
{};
/// \brief extends\<\> class template for adding behaviors to a Proto expression template
///
template<
typename Expr
, typename Derived
, typename Domain // = proto::default_domain
, long Arity // = Expr::proto_arity_c
>
struct extends
{
ACTIV_BOOST_FORCEINLINE
extends()
: proto_expr_()
{}
ACTIV_BOOST_FORCEINLINE
extends(Expr const &expr_)
: proto_expr_(expr_)
{}
typedef extends proto_extends;
ACTIV_BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, typename Domain)
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_CONST_()
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST()
// Instead of using ACTIV_BOOST_PROTO_EXTENDS_FUNCTION, which uses
// nested preprocessor loops, use file iteration here to generate
// the operator() overloads, which is more efficient.
#include <ActivBoost/proto/detail/extends_funop_const.hpp>
};
/// \brief extends\<\> class template for adding behaviors to a Proto expression template
///
template<typename Expr, typename Derived, typename Domain>
struct extends<Expr, Derived, Domain, 0>
{
ACTIV_BOOST_FORCEINLINE
extends()
: proto_expr_()
{}
ACTIV_BOOST_FORCEINLINE
extends(Expr const &expr_)
: proto_expr_(expr_)
{}
typedef extends proto_extends;
ACTIV_BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, typename Domain)
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_()
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT()
// Instead of using ACTIV_BOOST_PROTO_EXTENDS_FUNCTION, which uses
// nested preprocessor loops, use file iteration here to generate
// the operator() overloads, which is more efficient.
#include <ActivBoost/proto/detail/extends_funop.hpp>
};
/// INTERNAL ONLY
///
template<typename This, typename Fun, typename Domain>
struct virtual_member
{
typedef Domain proto_domain;
typedef typename Domain::proto_generator proto_generator;
typedef virtual_member<This, Fun, Domain> proto_derived_expr;
typedef tag::member proto_tag;
typedef list2<This &, expr<tag::terminal, term<Fun> > const &> proto_args;
typedef mpl::long_<2> proto_arity;
typedef detail::not_a_valid_type proto_address_of_hack_type_;
typedef void proto_is_expr_; /**< INTERNAL ONLY */
static const long proto_arity_c = 2;
typedef Boost::proto::tag::proto_expr<proto_tag, Domain> fusion_tag;
typedef This &proto_child0;
typedef expr<tag::terminal, term<Fun> > const &proto_child1;
typedef expr<proto_tag, proto_args, proto_arity_c> proto_base_expr;
typedef basic_expr<proto_tag, proto_args, proto_arity_c> proto_grammar;
typedef void proto_is_aggregate_; /**< INTERNAL ONLY */
ACTIV_BOOST_PROTO_EXTENDS_ASSIGN_()
ACTIV_BOOST_PROTO_EXTENDS_SUBSCRIPT()
// Instead of using ACTIV_BOOST_PROTO_EXTENDS_FUNCTION, which uses
// nested preprocessor loops, use file iteration here to generate
// the operator() overloads, which is more efficient.
#define ACTIV_BOOST_PROTO_NO_WAVE_OUTPUT
#include <ActivBoost/proto/detail/extends_funop.hpp>
#undef ACTIV_BOOST_PROTO_NO_WAVE_OUTPUT
ACTIV_BOOST_FORCEINLINE
proto_base_expr const proto_base() const
{
proto_base_expr that = {this->child0(), this->child1()};
return that;
}
ACTIV_BOOST_FORCEINLINE
proto_child0 child0() const
{
using std::size_t;
return *(This *)((char *)this - ACTIV_BOOST_PROTO_OFFSETOF(This, proto_member_union_start_));
}
ACTIV_BOOST_FORCEINLINE
proto_child1 child1() const
{
static expr<tag::terminal, term<Fun>, 0> const that = {Fun()};
return that;
}
};
/// INTERNAL ONLY
///
#define ACTIV_BOOST_PROTO_EXTENDS_MEMBER_(R, DOMAIN, ELEM) \
Boost::proto::exprns_::virtual_member< \
proto_derived_expr \
, ACTIV_BOOST_PP_TUPLE_ELEM(2, 0, ELEM) \
, DOMAIN \
> ACTIV_BOOST_PP_TUPLE_ELEM(2, 1, ELEM); \
/**/
/// \brief For declaring virtual data members in an extension class.
///
#define ACTIV_BOOST_PROTO_EXTENDS_MEMBERS_WITH_DOMAIN(SEQ, DOMAIN) \
union \
{ \
char proto_member_union_start_; \
ACTIV_BOOST_PP_SEQ_FOR_EACH(ACTIV_BOOST_PROTO_EXTENDS_MEMBER_, DOMAIN, SEQ) \
}; \
/**/
/// \brief For declaring virtual data members in an extension class.
///
#define ACTIV_BOOST_PROTO_EXTENDS_MEMBERS(SEQ) \
ACTIV_BOOST_PROTO_EXTENDS_MEMBERS_WITH_DOMAIN(SEQ, proto_domain) \
/**/
}
}}
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif