mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-06-07 00:51:45 +00:00
delete breed/*
This commit is contained in:
parent
7f6081e0cc
commit
5bf20db49b
21 changed files with 0 additions and 4399 deletions
|
@ -1,128 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_ARGS_HPP
|
|
||||||
#define SPROUT_BREED_ARGS_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/utility/pack.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename T>
|
|
||||||
struct ref_only
|
|
||||||
: public std::integral_constant<
|
|
||||||
bool,
|
|
||||||
std::is_function<T>::value
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<typename Expr>
|
|
||||||
struct expr_traits {
|
|
||||||
public:
|
|
||||||
typedef Expr value_type;
|
|
||||||
typedef Expr& reference;
|
|
||||||
typedef Expr const& const_reference;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct expr_traits<Expr&> {
|
|
||||||
public:
|
|
||||||
typedef Expr value_type;
|
|
||||||
typedef Expr& reference;
|
|
||||||
typedef Expr& const_reference;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct expr_traits<Expr const&> {
|
|
||||||
public:
|
|
||||||
typedef Expr value_type;
|
|
||||||
typedef Expr const& reference;
|
|
||||||
typedef Expr const& const_reference;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct term_traits {
|
|
||||||
public:
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef T const& const_reference;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct term_traits<T&> {
|
|
||||||
public:
|
|
||||||
typedef typename std::conditional<sprout::breed::detail::ref_only<T>::value, T&, T>::type value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef T& const_reference;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct term_traits<T const&> {
|
|
||||||
public:
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T const& reference;
|
|
||||||
typedef T const& const_reference;
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct term_traits<T (&)[N]> {
|
|
||||||
public:
|
|
||||||
typedef T value_type[N];
|
|
||||||
typedef T (&reference)[N];
|
|
||||||
typedef T (&const_reference)[N];
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct term_traits<T const (&)[N]> {
|
|
||||||
public:
|
|
||||||
typedef T value_type[N];
|
|
||||||
typedef T const (&reference)[N];
|
|
||||||
typedef T const (&const_reference)[N];
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct term_traits<T[N]> {
|
|
||||||
public:
|
|
||||||
typedef T value_type[N];
|
|
||||||
typedef T (&reference)[N];
|
|
||||||
typedef T const (&const_reference)[N];
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct term_traits<T const[N]> {
|
|
||||||
public:
|
|
||||||
typedef T value_type[N];
|
|
||||||
typedef T const (&reference)[N];
|
|
||||||
typedef T const (&const_reference)[N];
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
namespace argsns_ {
|
|
||||||
//
|
|
||||||
// term
|
|
||||||
//
|
|
||||||
template<typename Arg>
|
|
||||||
struct term {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR long arity = 0;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct child
|
|
||||||
: public sprout::tppack_at<N, Arg>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
typedef Arg back_;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// list
|
|
||||||
//
|
|
||||||
template<typename... Args>
|
|
||||||
struct list {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR long arity = sizeof...(Args);
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct child
|
|
||||||
: public sprout::tppack_at<N, Args...>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
typedef typename child<sizeof...(Args) - 1>::type back_;
|
|
||||||
};
|
|
||||||
} // namespace argsns_ {
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_ARGS_HPP
|
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_BREED_HPP
|
|
||||||
#define SPROUT_BREED_BREED_HPP
|
|
||||||
|
|
||||||
#include <sprout/breed/core.hpp>
|
|
||||||
//#include <sprout/breed/debug.hpp>
|
|
||||||
//#include <sprout/breed/context.hpp>
|
|
||||||
//#include <sprout/breed/transform.hpp>
|
|
||||||
//#include <sprout/breed/functional.hpp>
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_BREED_HPP
|
|
|
@ -1,707 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_BREED_FWD_HPP
|
|
||||||
#define SPROUT_BREED_BREED_FWD_HPP
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <climits>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
typedef char yes_type;
|
|
||||||
typedef char (&no_type)[2];
|
|
||||||
|
|
||||||
template<long N>
|
|
||||||
struct sized_type {
|
|
||||||
public:
|
|
||||||
typedef char (&type)[N];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct dont_care;
|
|
||||||
struct undefined;
|
|
||||||
struct not_a_valid_type;
|
|
||||||
|
|
||||||
struct private_type_ {
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR private_type_ operator,(int) const; // ???
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct uncvref {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct uncvref<T const> {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct uncvref<T&> {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct uncvref<T const&> {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct uncvref<T const[N]> {
|
|
||||||
public:
|
|
||||||
typedef T type[N];
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct uncvref<T (&)[N]> {
|
|
||||||
public:
|
|
||||||
typedef T type[N];
|
|
||||||
};
|
|
||||||
template<typename T, std::size_t N>
|
|
||||||
struct uncvref<T const (&)[N]> {
|
|
||||||
public:
|
|
||||||
typedef T type[N];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ignore {
|
|
||||||
public:
|
|
||||||
ignore() = default;
|
|
||||||
ignore(ignore const&) = default;
|
|
||||||
ignore(ignore&&) = default;
|
|
||||||
template<typename T>
|
|
||||||
SPROUT_CONSTEXPR ignore(T const&) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _default;
|
|
||||||
|
|
||||||
struct not_a_domain;
|
|
||||||
struct not_a_grammar;
|
|
||||||
struct not_a_generator;
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct is_transform_;
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct is_aggregate_;
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
typedef sprout::breed::detail::ignore const ignore;
|
|
||||||
|
|
||||||
namespace argsns_ {
|
|
||||||
template<typename Arg>
|
|
||||||
struct term;
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
struct list;
|
|
||||||
} // namespace argsns_
|
|
||||||
using namespace argsns_;
|
|
||||||
|
|
||||||
namespace tagns_ {
|
|
||||||
namespace tag {
|
|
||||||
struct terminal;
|
|
||||||
struct unary_plus;
|
|
||||||
struct negate;
|
|
||||||
struct dereference;
|
|
||||||
struct complement;
|
|
||||||
struct address_of;
|
|
||||||
struct logical_not;
|
|
||||||
struct pre_inc;
|
|
||||||
struct pre_dec;
|
|
||||||
struct post_inc;
|
|
||||||
struct post_dec;
|
|
||||||
|
|
||||||
struct shift_left;
|
|
||||||
struct shift_right;
|
|
||||||
struct multiplies;
|
|
||||||
struct divides;
|
|
||||||
struct modulus;
|
|
||||||
struct plus;
|
|
||||||
struct minus;
|
|
||||||
struct less;
|
|
||||||
struct greater;
|
|
||||||
struct less_equal;
|
|
||||||
struct greater_equal;
|
|
||||||
struct equal_to;
|
|
||||||
struct not_equal_to;
|
|
||||||
struct logical_or;
|
|
||||||
struct logical_and;
|
|
||||||
struct bitwise_and;
|
|
||||||
struct bitwise_or;
|
|
||||||
struct bitwise_xor;
|
|
||||||
struct comma;
|
|
||||||
struct mem_ptr;
|
|
||||||
|
|
||||||
struct assign;
|
|
||||||
struct shift_left_assign;
|
|
||||||
struct shift_right_assign;
|
|
||||||
struct multiplies_assign;
|
|
||||||
struct divides_assign;
|
|
||||||
struct modulus_assign;
|
|
||||||
struct plus_assign;
|
|
||||||
struct minus_assign;
|
|
||||||
struct bitwise_and_assign;
|
|
||||||
struct bitwise_or_assign;
|
|
||||||
struct bitwise_xor_assign;
|
|
||||||
struct subscript;
|
|
||||||
struct member;
|
|
||||||
struct if_else_;
|
|
||||||
struct function;
|
|
||||||
|
|
||||||
// Fusion tags
|
|
||||||
struct breed_expr;
|
|
||||||
struct breed_expr_iterator;
|
|
||||||
struct breed_flat_view;
|
|
||||||
} // namespace tag
|
|
||||||
} // namespace tagns_
|
|
||||||
using namespace tagns_;
|
|
||||||
|
|
||||||
template<typename Expr>
|
|
||||||
struct tag_of;
|
|
||||||
|
|
||||||
struct _;
|
|
||||||
|
|
||||||
struct default_generator;
|
|
||||||
|
|
||||||
struct basic_default_generator;
|
|
||||||
|
|
||||||
template<template<typename> class Extends>
|
|
||||||
struct generator;
|
|
||||||
|
|
||||||
template<template<typename> class Extends>
|
|
||||||
struct pod_generator;
|
|
||||||
|
|
||||||
struct by_value_generator;
|
|
||||||
|
|
||||||
template<typename First, typename Second>
|
|
||||||
struct compose_generators;
|
|
||||||
|
|
||||||
template<typename Generator, typename Void = void>
|
|
||||||
struct wants_basic_expr;
|
|
||||||
|
|
||||||
template<typename Generator>
|
|
||||||
struct use_basic_expr;
|
|
||||||
|
|
||||||
namespace domainns_ {
|
|
||||||
typedef sprout::breed::detail::not_a_domain no_super_domain;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Generator = sprout::breed::default_generator,
|
|
||||||
typename Grammar = sprout::breed::_,
|
|
||||||
typename Super = sprout::breed::domainns_::no_super_domain
|
|
||||||
>
|
|
||||||
struct domain;
|
|
||||||
|
|
||||||
struct default_domain;
|
|
||||||
|
|
||||||
struct basic_default_domain;
|
|
||||||
|
|
||||||
struct deduce_domain;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Domain,
|
|
||||||
typename Tag,
|
|
||||||
typename Args,
|
|
||||||
bool WantsBasicExpr = sprout::breed::wants_basic_expr<typename Domain::breed_generator>::value
|
|
||||||
>
|
|
||||||
struct base_expr;
|
|
||||||
} // namespace domainns_
|
|
||||||
using namespace domainns_;
|
|
||||||
|
|
||||||
namespace exprns_ {
|
|
||||||
template<typename Tag, typename Args, long Arity = Args::arity>
|
|
||||||
struct basic_expr;
|
|
||||||
|
|
||||||
template<typename Tag, typename Args, long Arity = Args::arity>
|
|
||||||
struct expr;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Expr,
|
|
||||||
typename Derived,
|
|
||||||
typename Domain = sprout::breed::default_domain,
|
|
||||||
long Arity = Expr::breed_arity_c
|
|
||||||
>
|
|
||||||
struct extends;
|
|
||||||
|
|
||||||
template<typename This, typename Fun, typename Domain>
|
|
||||||
struct virtual_member;
|
|
||||||
|
|
||||||
struct is_breed_expr;
|
|
||||||
}
|
|
||||||
using exprns_::expr;
|
|
||||||
using exprns_::basic_expr;
|
|
||||||
using exprns_::extends;
|
|
||||||
using exprns_::is_breed_expr;
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
struct or_;
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
struct and_;
|
|
||||||
|
|
||||||
template<typename Grammar>
|
|
||||||
struct not_;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Condition,
|
|
||||||
typename Then = sprout::breed::_,
|
|
||||||
typename Else = sprout::breed::not_<sprout::breed::_>
|
|
||||||
>
|
|
||||||
struct if_;
|
|
||||||
|
|
||||||
template<typename Cases, typename Transform = sprout::breed::tag_of<sprout::breed::_>()>
|
|
||||||
struct switch_;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct exact;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct convertible_to;
|
|
||||||
|
|
||||||
template<typename Grammar>
|
|
||||||
struct vararg;
|
|
||||||
|
|
||||||
SPROUT_STATIC_CONSTEXPR int N = (INT_MAX >> 10);
|
|
||||||
|
|
||||||
namespace context {
|
|
||||||
struct null_context;
|
|
||||||
|
|
||||||
template<typename Expr, typename Context, long Arity = Expr::breed_arity_c>
|
|
||||||
struct null_eval;
|
|
||||||
|
|
||||||
struct default_context;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Expr,
|
|
||||||
typename Context,
|
|
||||||
typename Tag = typename Expr::breed_tag,
|
|
||||||
long Arity = Expr::breed_arity_c
|
|
||||||
>
|
|
||||||
struct default_eval;
|
|
||||||
|
|
||||||
template<typename Derived, typename DefaultCtx = sprout::breed::context::default_context>
|
|
||||||
struct callable_context;
|
|
||||||
|
|
||||||
template<typename Expr, typename Context, long Arity = Expr::breed_arity_c>
|
|
||||||
struct callable_eval;
|
|
||||||
} // namespace context
|
|
||||||
|
|
||||||
using context::null_context;
|
|
||||||
using context::null_eval;
|
|
||||||
using context::default_context;
|
|
||||||
using context::default_eval;
|
|
||||||
using context::callable_context;
|
|
||||||
using context::callable_eval;
|
|
||||||
|
|
||||||
namespace utility {
|
|
||||||
template<typename T, typename Domain = sprout::breed::default_domain>
|
|
||||||
struct literal;
|
|
||||||
} // namespace context
|
|
||||||
|
|
||||||
using utility::literal;
|
|
||||||
|
|
||||||
namespace result_of {
|
|
||||||
template<typename T, typename Domain = sprout::breed::default_domain>
|
|
||||||
struct as_expr;
|
|
||||||
|
|
||||||
template<typename T, typename Domain = sprout::breed::default_domain>
|
|
||||||
struct as_child;
|
|
||||||
|
|
||||||
template<typename Expr, typename N = std::integral_constant<long, 0> >
|
|
||||||
struct child;
|
|
||||||
|
|
||||||
template<typename Expr, long N>
|
|
||||||
struct child_c;
|
|
||||||
|
|
||||||
template<typename Expr>
|
|
||||||
struct left;
|
|
||||||
|
|
||||||
template<typename Expr>
|
|
||||||
struct right;
|
|
||||||
|
|
||||||
template<typename Expr>
|
|
||||||
struct deep_copy;
|
|
||||||
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
struct eval;
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Tag,
|
|
||||||
typename DomainOrArg,
|
|
||||||
typename... Args
|
|
||||||
>
|
|
||||||
struct make_expr;
|
|
||||||
|
|
||||||
template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename Void = void>
|
|
||||||
struct unpack_expr;
|
|
||||||
} // namespace result_of
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct is_expr;
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct is_domain;
|
|
||||||
|
|
||||||
template<typename SubDomain, typename SuperDomain>
|
|
||||||
struct is_sub_domain_of;
|
|
||||||
|
|
||||||
template<typename Expr>
|
|
||||||
struct arity_of;
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct domain_of;
|
|
||||||
|
|
||||||
template<typename Expr, typename Grammar>
|
|
||||||
struct matches;
|
|
||||||
|
|
||||||
template<typename Tag, typename Arg>
|
|
||||||
struct unary_expr;
|
|
||||||
|
|
||||||
template<typename Tag, typename Left, typename Right>
|
|
||||||
struct binary_expr;
|
|
||||||
|
|
||||||
template<typename Tag, typename... Args>
|
|
||||||
struct nary_expr;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct terminal;
|
|
||||||
template<typename T>
|
|
||||||
struct unary_plus;
|
|
||||||
template<typename T>
|
|
||||||
struct negate;
|
|
||||||
template<typename T>
|
|
||||||
struct dereference;
|
|
||||||
template<typename T>
|
|
||||||
struct complement;
|
|
||||||
template<typename T>
|
|
||||||
struct address_of;
|
|
||||||
template<typename T>
|
|
||||||
struct logical_not;
|
|
||||||
template<typename T>
|
|
||||||
struct pre_inc;
|
|
||||||
template<typename T>
|
|
||||||
struct pre_dec;
|
|
||||||
template<typename T>
|
|
||||||
struct post_inc;
|
|
||||||
template<typename T>
|
|
||||||
struct post_dec;
|
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct shift_left;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct shift_right;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct multiplies;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct divides;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct modulus;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct plus;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct minus;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct less;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct greater;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct less_equal;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct greater_equal;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct equal_to;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct not_equal_to;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct logical_or;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct logical_and;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct bitwise_and;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct bitwise_or;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct bitwise_xor;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct comma;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct mem_ptr;
|
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct shift_left_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct shift_right_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct multiplies_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct divides_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct modulus_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct plus_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct minus_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct bitwise_and_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct bitwise_or_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct bitwise_xor_assign;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct subscript;
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct member;
|
|
||||||
template<typename T, typename U, typename V>
|
|
||||||
struct if_else_;
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
struct function;
|
|
||||||
|
|
||||||
namespace functional {
|
|
||||||
struct left;
|
|
||||||
struct right;
|
|
||||||
struct eval;
|
|
||||||
struct deep_copy;
|
|
||||||
|
|
||||||
template<typename Domain = sprout::breed::default_domain>
|
|
||||||
struct as_expr;
|
|
||||||
|
|
||||||
template<typename Domain = sprout::breed::default_domain>
|
|
||||||
struct as_child;
|
|
||||||
|
|
||||||
template<typename N = std::integral_constant<long, 0> >
|
|
||||||
struct child;
|
|
||||||
|
|
||||||
template<long N>
|
|
||||||
struct child_c;
|
|
||||||
|
|
||||||
template<typename Tag, typename Domain = deduce_domain>
|
|
||||||
struct make_expr;
|
|
||||||
|
|
||||||
template<typename Tag, typename Domain = deduce_domain>
|
|
||||||
struct unpack_expr;
|
|
||||||
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::terminal> make_terminal;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::unary_plus> make_unary_plus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::negate> make_negate;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::dereference> make_dereference;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::complement> make_complement;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::address_of> make_address_of;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::logical_not> make_logical_not;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::pre_inc> make_pre_inc;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::pre_dec> make_pre_dec;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::post_inc> make_post_inc;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::post_dec> make_post_dec;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_left> make_shift_left;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_right> make_shift_right;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::multiplies> make_multiplies;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::divides> make_divides;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::modulus> make_modulus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::plus> make_plus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::minus> make_minus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::less> make_less;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::greater> make_greater;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::less_equal> make_less_equal;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::greater_equal> make_greater_equal;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::equal_to> make_equal_to;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::not_equal_to> make_not_equal_to;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::logical_or> make_logical_or;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::logical_and> make_logical_and;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_and> make_bitwise_and;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_or> make_bitwise_or;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_xor> make_bitwise_xor;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::comma> make_comma;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::mem_ptr> make_mem_ptr;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::assign> make_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_left_assign> make_shift_left_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_right_assign> make_shift_right_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::multiplies_assign> make_multiplies_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::divides_assign> make_divides_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::modulus_assign> make_modulus_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::plus_assign> make_plus_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::minus_assign> make_minus_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_and_assign> make_bitwise_and_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_or_assign> make_bitwise_or_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_xor_assign> make_bitwise_xor_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::subscript> make_subscript;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::if_else_> make_if_else;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::function> make_function;
|
|
||||||
|
|
||||||
struct flatten;
|
|
||||||
struct make_pair;
|
|
||||||
struct first;
|
|
||||||
struct second;
|
|
||||||
struct at;
|
|
||||||
struct pop_front;
|
|
||||||
struct push_front;
|
|
||||||
struct pop_back;
|
|
||||||
struct push_back;
|
|
||||||
struct reverse;
|
|
||||||
} // namespace functional
|
|
||||||
|
|
||||||
typedef functional::flatten _flatten;
|
|
||||||
typedef functional::make_pair _make_pair;
|
|
||||||
typedef functional::first _first;
|
|
||||||
typedef functional::second _second;
|
|
||||||
typedef functional::pop_front _at;
|
|
||||||
typedef functional::pop_front _pop_front;
|
|
||||||
typedef functional::push_front _push_front;
|
|
||||||
typedef functional::pop_back _pop_back;
|
|
||||||
typedef functional::push_back _push_back;
|
|
||||||
typedef functional::reverse _reverse;
|
|
||||||
typedef functional::eval _eval;
|
|
||||||
struct _deep_copy;
|
|
||||||
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::terminal> _make_terminal;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::unary_plus> _make_unary_plus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::negate> _make_negate;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::dereference> _make_dereference;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::complement> _make_complement;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::address_of> _make_address_of;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::logical_not> _make_logical_not;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::pre_inc> _make_pre_inc;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::pre_dec> _make_pre_dec;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::post_inc> _make_post_inc;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::post_dec> _make_post_dec;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_left> _make_shift_left;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_right> _make_shift_right;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::multiplies> _make_multiplies;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::divides> _make_divides;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::modulus> _make_modulus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::plus> _make_plus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::minus> _make_minus;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::less> _make_less;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::greater> _make_greater;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::less_equal> _make_less_equal;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::greater_equal> _make_greater_equal;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::equal_to> _make_equal_to;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::not_equal_to> _make_not_equal_to;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::logical_or> _make_logical_or;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::logical_and> _make_logical_and;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_and> _make_bitwise_and;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_or> _make_bitwise_or;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_xor> _make_bitwise_xor;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::comma> _make_comma;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::mem_ptr> _make_mem_ptr;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::assign> _make_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_left_assign> _make_shift_left_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::shift_right_assign> _make_shift_right_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::multiplies_assign> _make_multiplies_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::divides_assign> _make_divides_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::modulus_assign> _make_modulus_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::plus_assign> _make_plus_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::minus_assign> _make_minus_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_and_assign> _make_bitwise_and_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_or_assign> _make_bitwise_or_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::bitwise_xor_assign> _make_bitwise_xor_assign;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::subscript> _make_subscript;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::if_else_> _make_if_else;
|
|
||||||
typedef sprout::breed::functional::make_expr<sprout::breed::tag::function> _make_function;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct is_callable;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct is_transform;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct is_aggregate;
|
|
||||||
|
|
||||||
# define SPROUT_BREED_UNEXPR() typedef int breed_is_expr_;
|
|
||||||
# define SPROUT_BREED_CALLABLE() typedef void breed_is_callable_;
|
|
||||||
# define SPROUT_BREED_AGGREGATE() typedef void breed_is_aggregate_;
|
|
||||||
# define SPROUT_BREED_USE_BASIC_EXPR() typedef void breed_use_basic_expr_;
|
|
||||||
|
|
||||||
struct callable {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct external_transform;
|
|
||||||
|
|
||||||
template<typename PrimitiveTransform = void, typename X = void>
|
|
||||||
struct transform;
|
|
||||||
|
|
||||||
template<typename Grammar, typename Fun = Grammar>
|
|
||||||
struct when;
|
|
||||||
|
|
||||||
template<typename Fun>
|
|
||||||
struct otherwise;
|
|
||||||
|
|
||||||
template<typename Fun>
|
|
||||||
struct call;
|
|
||||||
|
|
||||||
template<typename Fun>
|
|
||||||
struct make;
|
|
||||||
|
|
||||||
template<typename PrimitiveTransform>
|
|
||||||
struct protect;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct noinvoke;
|
|
||||||
|
|
||||||
template<typename Fun>
|
|
||||||
struct lazy;
|
|
||||||
|
|
||||||
template<typename Sequence, typename State, typename Fun>
|
|
||||||
struct fold;
|
|
||||||
|
|
||||||
template<typename Sequence, typename State, typename Fun>
|
|
||||||
struct reverse_fold;
|
|
||||||
|
|
||||||
template<typename Sequence, typename State, typename Fun>
|
|
||||||
struct fold_tree;
|
|
||||||
|
|
||||||
template<typename Sequence, typename State, typename Fun>
|
|
||||||
struct reverse_fold_tree;
|
|
||||||
|
|
||||||
template<typename Grammar>
|
|
||||||
struct pass_through;
|
|
||||||
|
|
||||||
template<typename Grammar = sprout::breed::detail::_default>
|
|
||||||
struct _default;
|
|
||||||
|
|
||||||
struct _expr;
|
|
||||||
struct _state;
|
|
||||||
struct _data;
|
|
||||||
|
|
||||||
struct _value;
|
|
||||||
|
|
||||||
struct _void;
|
|
||||||
|
|
||||||
template<typename T, T I>
|
|
||||||
struct integral_c;
|
|
||||||
|
|
||||||
template<char I>
|
|
||||||
struct char_;
|
|
||||||
|
|
||||||
template<int I>
|
|
||||||
struct int_;
|
|
||||||
|
|
||||||
template<long I>
|
|
||||||
struct long_;
|
|
||||||
|
|
||||||
template<std::size_t I>
|
|
||||||
struct size_t;
|
|
||||||
|
|
||||||
template<int I>
|
|
||||||
struct _child_c;
|
|
||||||
|
|
||||||
typedef _child_c<0> _child0;
|
|
||||||
typedef _child_c<1> _child1;
|
|
||||||
typedef _child0 _child;
|
|
||||||
typedef _child0 _left;
|
|
||||||
typedef _child1 _right;
|
|
||||||
|
|
||||||
typedef _child_c<2> _child2;
|
|
||||||
|
|
||||||
struct _byref;
|
|
||||||
struct _byval;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct is_extension;
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_BREED_FWD_HPP
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_CORE_HPP
|
|
||||||
#define SPROUT_BREED_CORE_HPP
|
|
||||||
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/args.hpp>
|
|
||||||
#include <sprout/breed/tags.hpp>
|
|
||||||
#include <sprout/breed/eval.hpp>
|
|
||||||
#include <sprout/breed/expr.hpp>
|
|
||||||
#include <sprout/breed/traits.hpp>
|
|
||||||
#include <sprout/breed/domain.hpp>
|
|
||||||
#include <sprout/breed/matches.hpp>
|
|
||||||
//#include <sprout/breed/extends.hpp>
|
|
||||||
//#include <sprout/breed/literal.hpp>
|
|
||||||
#include <sprout/breed/generate.hpp>
|
|
||||||
//#include <sprout/breed/operators.hpp>
|
|
||||||
//#include <sprout/breed/deep_copy.hpp>
|
|
||||||
//#include <sprout/breed/make_expr.hpp>
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_CORE_HPP
|
|
|
@ -1,148 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DETAIL_AS_EXPR_HPP
|
|
||||||
#define SPROUT_BREED_DETAIL_AS_EXPR_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/args.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename Generator>
|
|
||||||
struct base_generator {
|
|
||||||
public:
|
|
||||||
typedef Generator type;
|
|
||||||
};
|
|
||||||
template<typename Generator>
|
|
||||||
struct base_generator<sprout::breed::use_basic_expr<Generator> > {
|
|
||||||
public:
|
|
||||||
typedef Generator type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, typename Generator, bool WantsBasicExpr>
|
|
||||||
struct as_expr;
|
|
||||||
template<typename T, typename Generator>
|
|
||||||
struct as_expr<T, Generator, false> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::term_traits<T const&>::value_type value_type;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<value_type>,
|
|
||||||
0
|
|
||||||
> expr_type;
|
|
||||||
typedef typename Generator::template result<Generator(expr_type)>::type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return Generator()(expr_type::make(t));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T, typename Generator>
|
|
||||||
struct as_expr<T, Generator, true> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::term_traits<T const&>::value_type value_type;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<value_type>,
|
|
||||||
0
|
|
||||||
> expr_type;
|
|
||||||
typedef typename Generator::template result<Generator(expr_type)>::type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return Generator()(expr_type::make(t));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct as_expr<T, sprout::breed::default_generator, false> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::term_traits<T const&>::value_type value_type;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<value_type>,
|
|
||||||
0
|
|
||||||
> result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return result_type::make(t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct as_expr<T, sprout::breed::default_generator, true> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::term_traits<T const&>::value_type value_type;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<value_type>,
|
|
||||||
0
|
|
||||||
> result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return result_type::make(t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, typename Generator, bool WantsBasicExpr>
|
|
||||||
struct as_child;
|
|
||||||
template<typename T, typename Generator>
|
|
||||||
struct as_child<T, Generator, false> {
|
|
||||||
public:
|
|
||||||
typedef T const& reference;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<reference>,
|
|
||||||
0
|
|
||||||
> expr_type;
|
|
||||||
typedef typename Generator::template result<Generator(expr_type)>::type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return Generator()(expr_type::make(t));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T, typename Generator>
|
|
||||||
struct as_child<T, Generator, true> {
|
|
||||||
public:
|
|
||||||
typedef T const& reference;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<reference>,
|
|
||||||
0
|
|
||||||
> expr_type;
|
|
||||||
typedef typename Generator::template result<Generator(expr_type)>::type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return Generator()(expr_type::make(t));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct as_child<T, sprout::breed::default_generator, false> {
|
|
||||||
public:
|
|
||||||
typedef T const& reference;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<reference>,
|
|
||||||
0
|
|
||||||
> result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return result_type::make(t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct as_child<T, sprout::breed::default_generator, true> {
|
|
||||||
public:
|
|
||||||
typedef T const& reference;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
sprout::breed::tag::terminal,
|
|
||||||
sprout::breed::term<reference>,
|
|
||||||
0
|
|
||||||
> result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& t) const {
|
|
||||||
return result_type::make(t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DETAIL_AS_EXPR_HPP
|
|
|
@ -1,22 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DETAIL_AS_LVALUE_HPP
|
|
||||||
#define SPROUT_BREED_DETAIL_AS_LVALUE_HPP
|
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename T>
|
|
||||||
inline SPROUT_CONSTEXPR T& as_lvalue(T& t) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
inline SPROUT_CONSTEXPR T const& as_lvalue(T const& t) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DETAIL_AS_LVALUE_HPP
|
|
|
@ -1,226 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DETAIL_DEDUCE_DOMAIN_HPP
|
|
||||||
#define SPROUT_BREED_DETAIL_DEDUCE_DOMAIN_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/index_tuple/metafunction.hpp>
|
|
||||||
#include <sprout/utility/pack.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
//
|
|
||||||
// SPROUT_BREED_ASSERT_VALID_DOMAIN
|
|
||||||
//
|
|
||||||
#ifndef SPROUT_BREED_ASSERT_VALID_DOMAIN
|
|
||||||
# define SPROUT_BREED_ASSERT_VALID_DOMAIN(DOM) static_assert( \
|
|
||||||
!std::is_same<DOM, sprout::breed::detail::not_a_domain>::value, \
|
|
||||||
"!std::is_same<DOM, sprout::breed::detail::not_a_domain>::value" \
|
|
||||||
)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename Domain>
|
|
||||||
struct domain_
|
|
||||||
: public domain_<typename Domain::breed_super_domain>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Domain type;
|
|
||||||
typedef domain_<typename Domain::breed_super_domain> base;
|
|
||||||
public:
|
|
||||||
using base::deduce_;
|
|
||||||
static SPROUT_CONSTEXPR type deduce_(domain_<Domain> const*);
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct domain_<sprout::breed::detail::not_a_domain> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::detail::not_a_domain type;
|
|
||||||
public:
|
|
||||||
static type deduce_(void const*);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct domain_<sprout::breed::default_domain>
|
|
||||||
: public domain_<sprout::breed::detail::not_a_domain>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct domain_<sprout::breed::basic_default_domain>
|
|
||||||
: public domain_<sprout::breed::detail::not_a_domain>
|
|
||||||
{};
|
|
||||||
|
|
||||||
sprout::breed::detail::sized_type<1>::type default_test(
|
|
||||||
void const*,
|
|
||||||
void const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<2>::type default_test(
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::default_domain> const*,
|
|
||||||
void const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<2>::type default_test(
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::basic_default_domain> const*, void const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<3>::type default_test(
|
|
||||||
void const*,
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::default_domain> const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<3>::type default_test(
|
|
||||||
void const*,
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::basic_default_domain> const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<4>::type default_test(
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::default_domain> const*,
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::default_domain> const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<4>::type default_test(
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::basic_default_domain> const*,
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::default_domain> const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<4>::type default_test(
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::default_domain> const*,
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::basic_default_domain> const*
|
|
||||||
);
|
|
||||||
sprout::breed::detail::sized_type<4>::type default_test(
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::basic_default_domain> const*,
|
|
||||||
sprout::breed::detail::domain_<sprout::breed::basic_default_domain> const*
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename D0>
|
|
||||||
struct common_domain1 {
|
|
||||||
public:
|
|
||||||
typedef D0 type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename E0>
|
|
||||||
struct deduce_domain1
|
|
||||||
: public sprout::breed::domain_of<E0>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename D0,
|
|
||||||
typename D1,
|
|
||||||
int DefaultCase = sizeof(
|
|
||||||
sprout::breed::detail::default_test(
|
|
||||||
static_cast<sprout::breed::detail::domain_<D0> const*>(0),
|
|
||||||
static_cast<sprout::breed::detail::domain_<D1> const*>(0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
>
|
|
||||||
struct common_domain2 {
|
|
||||||
public:
|
|
||||||
typedef decltype(sprout::breed::detail::domain_<D0>::deduce_(
|
|
||||||
static_cast<sprout::breed::detail::domain_<D1> const*>(0)
|
|
||||||
)) type;
|
|
||||||
};
|
|
||||||
template<typename D0, typename D1>
|
|
||||||
struct common_domain2<D0, D1, 2> {
|
|
||||||
public:
|
|
||||||
typedef D1 type;
|
|
||||||
};
|
|
||||||
template<typename D0, typename D1>
|
|
||||||
struct common_domain2<D0, D1, 3> {
|
|
||||||
public:
|
|
||||||
typedef D0 type;
|
|
||||||
};
|
|
||||||
template<typename D0>
|
|
||||||
struct common_domain2<D0, sprout::breed::default_domain, 4> {
|
|
||||||
public:
|
|
||||||
typedef D0 type;
|
|
||||||
};
|
|
||||||
template<typename D0>
|
|
||||||
struct common_domain2<D0, sprout::breed::basic_default_domain, 4> {
|
|
||||||
public:
|
|
||||||
typedef D0 type;
|
|
||||||
};
|
|
||||||
template<typename D1>
|
|
||||||
struct common_domain2<sprout::breed::default_domain, D1, 4> {
|
|
||||||
public:
|
|
||||||
typedef D1 type;
|
|
||||||
};
|
|
||||||
template<typename D1>
|
|
||||||
struct common_domain2<sprout::breed::basic_default_domain, D1, 4> {
|
|
||||||
public:
|
|
||||||
typedef D1 type;
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct common_domain2<sprout::breed::default_domain, sprout::breed::default_domain, 4> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::default_domain type;
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct common_domain2<sprout::breed::basic_default_domain, sprout::breed::default_domain, 4> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::default_domain type;
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct common_domain2<sprout::breed::default_domain, sprout::breed::basic_default_domain, 4> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::default_domain type;
|
|
||||||
};
|
|
||||||
template<>
|
|
||||||
struct common_domain2<sprout::breed::basic_default_domain, sprout::breed::basic_default_domain, 4> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::basic_default_domain type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename E0, typename E1>
|
|
||||||
struct deduce_domain2
|
|
||||||
: public common_domain2<
|
|
||||||
typename sprout::breed::domain_of<E0>::type,
|
|
||||||
typename sprout::breed::domain_of<E1>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
struct common_domain {
|
|
||||||
private:
|
|
||||||
template<typename Common, typename Head, typename... Tail>
|
|
||||||
struct common_impl {
|
|
||||||
public:
|
|
||||||
typedef typename common_impl<
|
|
||||||
typename sprout::breed::detail::common_domain2<Common, Head>::type,
|
|
||||||
Tail...
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
template<typename Common, typename Head>
|
|
||||||
struct common_impl<Common, Head> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::common_domain2<Common, Head>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Head, typename... Tail>
|
|
||||||
struct common
|
|
||||||
: public common_impl<Head, Tail...>
|
|
||||||
{};
|
|
||||||
template<typename Head>
|
|
||||||
struct common<Head>
|
|
||||||
: public sprout::breed::detail::common_domain1<Head>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
typedef typename common<Args...>::type type;
|
|
||||||
SPROUT_BREED_ASSERT_VALID_DOMAIN(type);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename IndexTuple, typename... Args>
|
|
||||||
struct deduce_domain_impl;
|
|
||||||
template<typename... Args, sprout::index_t... Indexes>
|
|
||||||
struct deduce_domain_impl<sprout::index_tuple<Indexes...>, Args...>
|
|
||||||
: public sprout::breed::detail::common_domain<
|
|
||||||
typename sprout::breed::domain_of<
|
|
||||||
typename sprout::tppack_at<Indexes, Args...>::type
|
|
||||||
>::type...
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
struct deduce_domain
|
|
||||||
: public sprout::breed::detail::deduce_domain_impl<
|
|
||||||
typename sprout::index_pack<Args...>::type,
|
|
||||||
Args...
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DETAIL_DEDUCE_DOMAIN_HPP
|
|
|
@ -1,207 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DETAIL_POLY_FUNCTION_HPP
|
|
||||||
#define SPROUT_BREED_DETAIL_POLY_FUNCTION_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename T>
|
|
||||||
struct normalize_arg {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
typedef T const& reference;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct normalize_arg<T&> {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
typedef T const& reference;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct normalize_arg<T const&> {
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
typedef T const& reference;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct arg {
|
|
||||||
public:
|
|
||||||
typedef T const& type;
|
|
||||||
private:
|
|
||||||
type value;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR arg(type t)
|
|
||||||
: value(t)
|
|
||||||
{}
|
|
||||||
SPROUT_CONSTEXPR operator type() const {
|
|
||||||
return this->value;
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR type operator()() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
arg& operator=(arg const&) SPROUT_DELETED_FUNCTION_DECL
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct arg<T&> {
|
|
||||||
public:
|
|
||||||
typedef T& type;
|
|
||||||
private:
|
|
||||||
type value;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR arg(type t)
|
|
||||||
: value(t)
|
|
||||||
{}
|
|
||||||
SPROUT_CONSTEXPR operator type() const {
|
|
||||||
return this->value;
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR type operator()() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
arg& operator=(arg const&) SPROUT_DELETED_FUNCTION_DECL
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct is_poly_function
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_poly_function<T, typename T::is_poly_function_base_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
|
|
||||||
# define SPROUT_BREED_POLY_FUNCTION() \
|
|
||||||
typedef void is_poly_function_base_;
|
|
||||||
|
|
||||||
struct poly_function_base {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_POLY_FUNCTION();
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Derived, typename NullaryResult = void>
|
|
||||||
struct poly_function
|
|
||||||
: public psprout::breed::detail::poly_function_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This>
|
|
||||||
struct result<This()>
|
|
||||||
: public Derived::template impl<>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename result::result_type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename... Args>
|
|
||||||
struct result<This(Args...)>
|
|
||||||
: public Derived::template impl<
|
|
||||||
typename normalize_arg<Args>::type...
|
|
||||||
>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename result::result_type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR NullaryResult operator()() const {
|
|
||||||
return result<Derived const()>().operator()();
|
|
||||||
}
|
|
||||||
template<typename... Args>
|
|
||||||
SPROUT_CONSTEXPR typename result<Derived const(Args const&...)>::type
|
|
||||||
operator()(Args const&... args) const {
|
|
||||||
return result<Derived const(Args const&...)>().operator()(
|
|
||||||
static_cast<typename normalize_arg<Args const&>::reference>(args)...
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct wrap_t;
|
|
||||||
|
|
||||||
typedef char poly_function_t;
|
|
||||||
typedef char (&mono_function_t)[2];
|
|
||||||
typedef char (&unknown_function_t)[3];
|
|
||||||
|
|
||||||
template<typename T> sprout::breed::detail::poly_function_t test_poly_function(
|
|
||||||
T const*,
|
|
||||||
sprout::breed::detail::wrap_t<typename T::is_poly_function_base_> const* = 0
|
|
||||||
);
|
|
||||||
template<typename T> sprout::breed::detail::mono_function_t test_poly_function(
|
|
||||||
T const*,
|
|
||||||
sprout::breed::detail::wrap_t<typename T::result_type> const* = 0
|
|
||||||
);
|
|
||||||
template<typename T> sprout::breed::detail::unknown_function_t test_poly_function(
|
|
||||||
T const*,
|
|
||||||
...
|
|
||||||
);
|
|
||||||
|
|
||||||
template<
|
|
||||||
typename Fun,
|
|
||||||
typename Sig,
|
|
||||||
typename Switch = std::integral_constant<
|
|
||||||
std::size_t,
|
|
||||||
sizeof(sprout::breed::detail::test_poly_function<Fun>(0, 0))
|
|
||||||
>
|
|
||||||
>
|
|
||||||
struct poly_function_traits {
|
|
||||||
public:
|
|
||||||
typedef typename Fun::template result<Sig>::type result_type;
|
|
||||||
typedef Fun function_type;
|
|
||||||
};
|
|
||||||
template<typename Fun, typename Sig>
|
|
||||||
struct poly_function_traits<
|
|
||||||
Fun,
|
|
||||||
Sig,
|
|
||||||
std::integral_constant<
|
|
||||||
std::size_t,
|
|
||||||
sizeof(sprout::breed::detail::mono_function_t)
|
|
||||||
>
|
|
||||||
> {
|
|
||||||
public:
|
|
||||||
typedef typename Fun::result_type result_type;
|
|
||||||
typedef Fun function_type;
|
|
||||||
};
|
|
||||||
template<typename PolyFun, typename... Args>
|
|
||||||
struct poly_function_traits<
|
|
||||||
PolyFun,
|
|
||||||
PolyFun(
|
|
||||||
Args...,
|
|
||||||
std::integral_constant<std::size_t, sizeof(sprout::breed::detail::poly_function_t)
|
|
||||||
)
|
|
||||||
> {
|
|
||||||
public:
|
|
||||||
typedef typename PolyFun::template impl<Args...> function_type;
|
|
||||||
typedef typename function_type::result_type result_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename PolyFunSig, bool IsPolyFunction>
|
|
||||||
struct as_mono_function_impl;
|
|
||||||
template<typename PolyFun, typename... Args>
|
|
||||||
struct as_mono_function_impl<PolyFun(Args...), true> {
|
|
||||||
public:
|
|
||||||
typedef typename PolyFun::template impl<Args const...> type;
|
|
||||||
};
|
|
||||||
template<typename PolyFun, typename... Args>
|
|
||||||
struct as_mono_function_impl<PolyFun(Args...), false> {
|
|
||||||
public:
|
|
||||||
typedef PolyFun type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename PolyFunSig>
|
|
||||||
struct as_mono_function;
|
|
||||||
template<typename PolyFun, typename... Args>
|
|
||||||
struct as_mono_function<PolyFun(Args...)>
|
|
||||||
: public sprout::breed::detail::as_mono_function_impl<
|
|
||||||
PolyFun(Args...),
|
|
||||||
sprout::breed::detail::is_poly_function<PolyFun>::value
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DETAIL_POLY_FUNCTION_HPP
|
|
|
@ -1,18 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DETAIL_STD_RESULT_OF_HPP
|
|
||||||
#define SPROUT_BREED_DETAIL_STD_RESULT_OF_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename F>
|
|
||||||
struct std_result_of
|
|
||||||
: public std::result_of<F>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DETAIL_STD_RESULT_OF_HPP
|
|
|
@ -1,25 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DETAIL_TEMPLATE_ARITY_HPP
|
|
||||||
#define SPROUT_BREED_DETAIL_TEMPLATE_ARITY_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename F>
|
|
||||||
struct template_arity_impl;
|
|
||||||
template<template<typename...> class F, typename... Args>
|
|
||||||
struct template_arity_impl<F<Args...> >
|
|
||||||
: public std::integral_constant<int, sizeof...(Args)>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
struct template_arity
|
|
||||||
: public sprout::breed::detail::template_arity_impl<F>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DETAIL_TEMPLATE_ARITY_HPP
|
|
|
@ -1,183 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_DOMAIN_HPP
|
|
||||||
#define SPROUT_BREED_DOMAIN_HPP
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/generate.hpp>
|
|
||||||
#include <sprout/breed/detail/as_expr.hpp>
|
|
||||||
#include <sprout/breed/detail/deduce_domain.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
struct not_a_generator {};
|
|
||||||
struct not_a_grammar {};
|
|
||||||
struct not_a_domain {};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
namespace domainns_ {
|
|
||||||
//
|
|
||||||
// domain
|
|
||||||
//
|
|
||||||
template<
|
|
||||||
typename Generator,
|
|
||||||
typename Grammar,
|
|
||||||
typename Super
|
|
||||||
>
|
|
||||||
struct domain
|
|
||||||
: public Generator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Generator breed_generator;
|
|
||||||
typedef Grammar breed_grammar;
|
|
||||||
typedef Super breed_super_domain;
|
|
||||||
typedef domain breed_base_domain;
|
|
||||||
typedef void breed_is_domain_;
|
|
||||||
public:
|
|
||||||
template<typename T, typename IsExpr = void, typename Callable = sprout::breed::callable>
|
|
||||||
struct as_expr
|
|
||||||
: public detail::as_expr<
|
|
||||||
T,
|
|
||||||
typename sprout::breed::detail::base_generator<Generator>::type,
|
|
||||||
sprout::breed::wants_basic_expr<Generator>::value
|
|
||||||
>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct as_expr<T, typename T::breed_is_expr_, sprout::breed::callable> {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
typedef typename std::remove_const<T>::type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& e) const {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T, typename IsExpr = void, typename Callable = sprout::breed::callable>
|
|
||||||
struct as_child
|
|
||||||
: public detail::as_child<
|
|
||||||
T,
|
|
||||||
typename sprout::breed::detail::base_generator<Generator>::type,
|
|
||||||
sprout::breed::wants_basic_expr<Generator>::value
|
|
||||||
>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct as_child<T, typename T::breed_is_expr_, sprout::breed::callable> {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
typedef T &result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& e) const {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// default_domain
|
|
||||||
//
|
|
||||||
struct default_domain
|
|
||||||
: public sprout::breed::domain<>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// basic_default_domain
|
|
||||||
//
|
|
||||||
struct basic_default_domain
|
|
||||||
: public sprout::breed::domain<sprout::breed::basic_default_generator>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// deduce_domain
|
|
||||||
//
|
|
||||||
struct deduce_domain
|
|
||||||
: public sprout::breed::domain<
|
|
||||||
sprout::breed::detail::not_a_generator,
|
|
||||||
sprout::breed::detail::not_a_grammar,
|
|
||||||
sprout::breed::detail::not_a_domain
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// base_expr
|
|
||||||
//
|
|
||||||
template<typename Domain, typename Tag, typename Args, bool WantsBasicExpr>
|
|
||||||
struct base_expr {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::expr<Tag, Args, Args::arity> type;
|
|
||||||
};
|
|
||||||
template<typename Domain, typename Tag, typename Args>
|
|
||||||
struct base_expr<Domain, Tag, Args, true> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::basic_expr<Tag, Args, Args::arity> type;
|
|
||||||
};
|
|
||||||
} // namespace domainns_
|
|
||||||
|
|
||||||
//
|
|
||||||
// is_domain
|
|
||||||
//
|
|
||||||
template<typename T, typename Void>
|
|
||||||
struct is_domain
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_domain<T, typename T::breed_is_domain_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// domain_of
|
|
||||||
//
|
|
||||||
template<typename T, typename Void>
|
|
||||||
struct domain_of {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::default_domain type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct domain_of<T, typename T::breed_is_expr_> {
|
|
||||||
public:
|
|
||||||
typedef typename T::breed_domain type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct domain_of<T&, void> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::domain_of<T>::type type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct domain_of<std::reference_wrapper<T>, void> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::domain_of<T>::type type;
|
|
||||||
};
|
|
||||||
template<typename T>
|
|
||||||
struct domain_of<std::reference_wrapper<T> const, void> {
|
|
||||||
typedef typename sprout::breed::domain_of<T>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// is_sub_domain_of
|
|
||||||
//
|
|
||||||
template<typename SubDomain, typename SuperDomain>
|
|
||||||
struct is_sub_domain_of
|
|
||||||
: public is_sub_domain_of<typename SubDomain::breed_super_domain, SuperDomain>
|
|
||||||
{};
|
|
||||||
template<typename SuperDomain>
|
|
||||||
struct is_sub_domain_of<sprout::breed::no_super_domain, SuperDomain>
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename SuperDomain>
|
|
||||||
struct is_sub_domain_of<SuperDomain, SuperDomain>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_DOMAIN_HPP
|
|
|
@ -1,87 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_EVAL_HPP
|
|
||||||
#define SPROUT_BREED_EVAL_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace result_of {
|
|
||||||
//
|
|
||||||
// eval
|
|
||||||
//
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
struct eval {
|
|
||||||
public:
|
|
||||||
typedef typename Context::template eval<Expr>::result_type type;
|
|
||||||
};
|
|
||||||
} // namespace result_of
|
|
||||||
|
|
||||||
namespace functional {
|
|
||||||
//
|
|
||||||
// eval
|
|
||||||
//
|
|
||||||
struct eval {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE();
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr, typename Context>
|
|
||||||
struct result<This(Expr, Context)> {
|
|
||||||
typedef typename sprout::breed::result_of::eval<
|
|
||||||
typename std::remove_reference<Expr>::type,
|
|
||||||
typename std::remove_reference<Context>::type
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
typename sprout::breed::result_of::eval<Expr, Context>::type
|
|
||||||
operator()(Expr& e, Context& ctx) const {
|
|
||||||
return typename Context::template eval<Expr>()(e, ctx);
|
|
||||||
}
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
typename sprout::breed::result_of::eval<Expr, Context>::type
|
|
||||||
operator()(Expr& e, Context const& ctx) const {
|
|
||||||
return typename Context::template eval<Expr>()(e, ctx);
|
|
||||||
}
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
typename sprout::breed::result_of::eval<Expr const, Context>::type
|
|
||||||
operator()(Expr const& e, Context& ctx) const {
|
|
||||||
return typename Context::template eval<Expr const>()(e, ctx);
|
|
||||||
}
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::eval<Expr const, Context>::type
|
|
||||||
operator()(Expr const& e, Context const& ctx) const {
|
|
||||||
return typename Context::template eval<Expr const>()(e, ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace functional
|
|
||||||
|
|
||||||
//
|
|
||||||
// eval
|
|
||||||
//
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
typename sprout::breed::result_of::eval<Expr, Context>::type
|
|
||||||
eval(Expr& e, Context& ctx) {
|
|
||||||
return typename Context::template eval<Expr>()(e, ctx);
|
|
||||||
}
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
typename sprout::breed::result_of::eval<Expr, Context>::type
|
|
||||||
eval(Expr& e, Context const& ctx) {
|
|
||||||
return typename Context::template eval<Expr>()(e, ctx);
|
|
||||||
}
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
typename sprout::breed::result_of::eval<Expr const, Context>::type
|
|
||||||
eval(Expr const& e, Context& ctx) {
|
|
||||||
return typename Context::template eval<Expr const>()(e, ctx);
|
|
||||||
}
|
|
||||||
template<typename Expr, typename Context>
|
|
||||||
SPROUT_CONSTEXPRtypename sprout::breed::result_of::eval<Expr const, Context>::type
|
|
||||||
eval(Expr const& e, Context const& ctx) {
|
|
||||||
return typename Context::template eval<Expr const>()(e, ctx);
|
|
||||||
}
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_EVAL_HPP
|
|
|
@ -1,478 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_EXPR_HPP
|
|
||||||
#define SPROUT_BREED_EXPR_HPP
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/utility/pack.hpp>
|
|
||||||
#include <sprout/tuple/tuple.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/args.hpp>
|
|
||||||
#include <sprout/breed/traits.hpp>
|
|
||||||
#include <sprout/assert.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
struct not_a_valid_type {
|
|
||||||
private:
|
|
||||||
SPROUT_CONSTEXPR not_a_valid_type() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Tag, typename Arg>
|
|
||||||
struct address_of_hack {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::detail::not_a_valid_type type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct address_of_hack<sprout::breed::tag::address_of, Expr&> {
|
|
||||||
typedef Expr* type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, typename Expr, typename Arg>
|
|
||||||
SPROUT_CONSTEXPR Expr make_terminal(T const& t, Expr*, sprout::breed::term<Arg> const*) {
|
|
||||||
return Expr(t);
|
|
||||||
}
|
|
||||||
template<typename T, typename Expr, typename Arg, std::size_t N>
|
|
||||||
SPROUT_CONSTEXPR Expr make_terminal(T const (&t)[N], Expr const*, sprout::breed::term<Arg[N]> const*) {
|
|
||||||
return SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), Expr();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct same_cv {
|
|
||||||
public:
|
|
||||||
typedef U type;
|
|
||||||
};
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct same_cv<T const, U> {
|
|
||||||
public:
|
|
||||||
typedef U const type;
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
namespace result_of {
|
|
||||||
namespace detail {
|
|
||||||
template<typename Expr, typename Domain, typename... Args>
|
|
||||||
struct funop_impl {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::base_expr<
|
|
||||||
Domain,
|
|
||||||
sprout::breed::tag::function,
|
|
||||||
sprout::breed::list<
|
|
||||||
Expr const&,
|
|
||||||
typename sprout::breed::result_of::as_child<Args, Domain>::type...
|
|
||||||
>
|
|
||||||
>::type type;
|
|
||||||
public:
|
|
||||||
static SPROUT_CONSTEXPR type const call(
|
|
||||||
Expr const& e,
|
|
||||||
Args const&... args
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return type(
|
|
||||||
e,
|
|
||||||
sprout::breed::as_child<Domain>(args)...
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
//
|
|
||||||
// funop
|
|
||||||
//
|
|
||||||
template<typename Sig, typename This, typename Domain>
|
|
||||||
struct funop;
|
|
||||||
template<typename Expr, typename... Args, typename This, typename Domain>
|
|
||||||
struct funop<Expr(Args...), This, Domain>
|
|
||||||
: public sprout::breed::result_of::detail::funop_impl<
|
|
||||||
typename sprout::breed::detail::same_cv<Expr, This>::type,
|
|
||||||
Domain,
|
|
||||||
typename std::remove_reference<Args>::type...
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
} // namespace result_of
|
|
||||||
|
|
||||||
namespace exprns_ {
|
|
||||||
//
|
|
||||||
// basic_expr
|
|
||||||
//
|
|
||||||
template<typename Tag, typename Arg>
|
|
||||||
struct basic_expr<Tag, term<Arg>, 0> {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR long breed_arity_c = 0;
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef std::integral_constant<long, breed_arity_c> breed_arity;
|
|
||||||
typedef basic_expr breed_base_expr;
|
|
||||||
typedef sprout::breed::term<Arg> breed_args;
|
|
||||||
typedef basic_expr breed_grammar;
|
|
||||||
typedef sprout::breed::basic_default_domain breed_domain;
|
|
||||||
typedef sprout::breed::default_generator breed_generator;
|
|
||||||
typedef sprout::breed::tag::breed_expr fusion_tag;
|
|
||||||
typedef basic_expr breed_derived_expr;
|
|
||||||
typedef void breed_is_expr_;
|
|
||||||
typedef sprout::breed::detail::not_a_valid_type address_of_hack_type_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, Arg>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename A>
|
|
||||||
static SPROUT_CONSTEXPR basic_expr make(A const& arg) {
|
|
||||||
return sprout::breed::detail::make_terminal(
|
|
||||||
arg,
|
|
||||||
static_cast<basic_expr const*>(0),
|
|
||||||
static_cast<breed_args const*>(0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
sprout::tuples::tuple<Arg> children_;
|
|
||||||
public:
|
|
||||||
explicit SPROUT_CONSTEXPR basic_expr(Arg const& arg)
|
|
||||||
: children_(arg)
|
|
||||||
{}
|
|
||||||
template<long N>
|
|
||||||
SPROUT_CONSTEXPR typename breed_child<N>::type const& child() const {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
template<long N>
|
|
||||||
typename breed_child<N>::type const& child() {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR basic_expr const& breed_base() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
basic_expr& breed_base() {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Tag, typename... Args>
|
|
||||||
struct basic_expr<Tag, sprout::breed::list<Args...>, sizeof...(Args)> {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR long breed_arity_c = sizeof...(Args);
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef std::integral_constant<long, breed_arity_c> breed_arity;
|
|
||||||
typedef basic_expr breed_base_expr;
|
|
||||||
typedef sprout::breed::list<Args...> breed_args;
|
|
||||||
typedef basic_expr breed_grammar;
|
|
||||||
typedef sprout::breed::basic_default_domain breed_domain;
|
|
||||||
typedef sprout::breed::default_generator breed_generator;
|
|
||||||
typedef sprout::breed::tag::breed_expr fusion_tag;
|
|
||||||
typedef basic_expr breed_derived_expr;
|
|
||||||
typedef void breed_is_expr_;
|
|
||||||
typedef sprout::breed::detail::not_a_valid_type address_of_hack_type_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, Args...>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename... As>
|
|
||||||
static SPROUT_CONSTEXPR basic_expr make(As const&... args) {
|
|
||||||
return basic_expr(args...);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
sprout::tuples::tuple<Args...> children_;
|
|
||||||
public:
|
|
||||||
explicit SPROUT_CONSTEXPR basic_expr(Args const&... args)
|
|
||||||
: children_(args...)
|
|
||||||
{}
|
|
||||||
template<long N>
|
|
||||||
SPROUT_CONSTEXPR typename breed_child<N>::type const& child() const {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
template<long N>
|
|
||||||
typename breed_child<N>::type const& child() {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR basic_expr const& breed_base() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
basic_expr& breed_base() {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// expr
|
|
||||||
//
|
|
||||||
template<typename Tag, typename Arg>
|
|
||||||
struct expr<Tag, sprout::breed::term<Arg>, 0> {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR long breed_arity_c = 0;
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef std::integral_constant<long, breed_arity_c> breed_arity;
|
|
||||||
typedef expr breed_base_expr;
|
|
||||||
typedef sprout::breed::term<Arg> breed_args;
|
|
||||||
typedef basic_expr<Tag, breed_args, 0> breed_grammar;
|
|
||||||
typedef sprout::breed::basic_default_domain breed_domain;
|
|
||||||
typedef sprout::breed::default_generator breed_generator;
|
|
||||||
typedef sprout::breed::tag::breed_expr fusion_tag;
|
|
||||||
typedef expr breed_derived_expr;
|
|
||||||
typedef void proto_is_expr_;
|
|
||||||
typedef sprout::breed::detail::not_a_valid_type address_of_hack_type_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, Arg>
|
|
||||||
{};
|
|
||||||
template<typename Sig>
|
|
||||||
struct result {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::result_of::funop<
|
|
||||||
Sig,
|
|
||||||
expr,
|
|
||||||
sprout::breed::default_domain
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename A>
|
|
||||||
static SPROUT_CONSTEXPR expr make(A const& arg) {
|
|
||||||
return sprout::breed::detail::make_terminal(
|
|
||||||
arg,
|
|
||||||
static_cast<expr const*>(0),
|
|
||||||
static_cast<breed_args const*>(0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
sprout::tuples::tuple<Arg> children_;
|
|
||||||
public:
|
|
||||||
explicit SPROUT_CONSTEXPR expr(Arg const& arg)
|
|
||||||
: children_(arg)
|
|
||||||
{}
|
|
||||||
template<long N>
|
|
||||||
SPROUT_CONSTEXPR typename breed_child<N>::type const& child() const {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
template<long N>
|
|
||||||
typename breed_child<N>::type const& child() {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR expr const& breed_base() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
expr& breed_base() {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, expr const&>,
|
|
||||||
2
|
|
||||||
> operator=(expr const& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, expr const&>,
|
|
||||||
2
|
|
||||||
>(*this, arg);
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
SPROUT_CONSTEXPR sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
> operator=(A const& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
> operator=(A& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
SPROUT_CONSTEXPR sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
> operator[](A const& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
> operator[](A& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename... As>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::funop<
|
|
||||||
expr(As const&...),
|
|
||||||
expr,
|
|
||||||
sprout::breed::default_domain
|
|
||||||
>::type operator()(As const&... args) const {
|
|
||||||
return sprout::breed::result_of::funop<
|
|
||||||
expr(As const&...),
|
|
||||||
expr,
|
|
||||||
sprout::breed::default_domain
|
|
||||||
>::call(*this, args...);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Tag, typename... Args>
|
|
||||||
struct expr<Tag, sprout::breed::list<Args...>, sizeof...(Args)> {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR long breed_arity_c = sizeof...(Args);
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef std::integral_constant<long, breed_arity_c> breed_arity;
|
|
||||||
typedef expr breed_base_expr;
|
|
||||||
typedef sprout::breed::list<Args...> breed_args;
|
|
||||||
typedef basic_expr<Tag, breed_args, 0> breed_grammar;
|
|
||||||
typedef sprout::breed::basic_default_domain breed_domain;
|
|
||||||
typedef sprout::breed::default_generator breed_generator;
|
|
||||||
typedef sprout::breed::tag::breed_expr fusion_tag;
|
|
||||||
typedef expr breed_derived_expr;
|
|
||||||
typedef void proto_is_expr_;
|
|
||||||
typedef sprout::breed::detail::not_a_valid_type address_of_hack_type_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, Args...>
|
|
||||||
{};
|
|
||||||
template<typename Sig>
|
|
||||||
struct result {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::result_of::funop<
|
|
||||||
Sig,
|
|
||||||
expr,
|
|
||||||
sprout::breed::default_domain
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename... As>
|
|
||||||
static SPROUT_CONSTEXPR basic_expr make(As const&... args) {
|
|
||||||
return basic_expr(args...);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
sprout::tuples::tuple<Arg> children_;
|
|
||||||
public:
|
|
||||||
explicit SPROUT_CONSTEXPR basic_expr(Args const&... args)
|
|
||||||
: children_(args...)
|
|
||||||
{}
|
|
||||||
template<long N>
|
|
||||||
SPROUT_CONSTEXPR typename breed_child<N>::type const& child() const {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
template<long N>
|
|
||||||
typename breed_child<N>::type const& child() {
|
|
||||||
return sprout::tuples::get<N>(children_);
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR basic_expr const& breed_base() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
basic_expr& breed_base() {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, expr const&>,
|
|
||||||
2
|
|
||||||
> operator=(expr const& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, expr const&>,
|
|
||||||
2
|
|
||||||
>(*this, arg);
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
SPROUT_CONSTEXPR sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
> operator=(A const& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
> operator=(A& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::assign,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
SPROUT_CONSTEXPR sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
> operator[](A const& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A const>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename A>
|
|
||||||
sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
> operator[](A& arg) const {
|
|
||||||
return sprout::breed::expr<
|
|
||||||
sprout::breed::tag::subscript,
|
|
||||||
sprout::breed::list<expr const&, typename sprout::breed::result_of::as_child<A>::type>,
|
|
||||||
2
|
|
||||||
>(*this, sprout::breed::as_child(arg));
|
|
||||||
}
|
|
||||||
template<typename... As>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::funop<
|
|
||||||
expr(As const&...),
|
|
||||||
expr,
|
|
||||||
sprout::breed::default_domain
|
|
||||||
>::type operator()(As const&... args) const {
|
|
||||||
return sprout::breed::result_of::funop<
|
|
||||||
expr(As const&...),
|
|
||||||
expr,
|
|
||||||
sprout::breed::default_domain
|
|
||||||
>::call(*this, args...);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace exprns_
|
|
||||||
|
|
||||||
//
|
|
||||||
// unexpr
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
struct unexpr
|
|
||||||
: public Expr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_UNEXPR();
|
|
||||||
public:
|
|
||||||
explicit SPROUT_CONSTEXPR unexpr(Expr const& e)
|
|
||||||
: Expr(e)
|
|
||||||
{}
|
|
||||||
using Expr::operator=;
|
|
||||||
};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_EXPR_HPP
|
|
|
@ -1,322 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_GENERATE_HPP
|
|
||||||
#define SPROUT_BREED_GENERATE_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/index_tuple/metafunction.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/args.hpp>
|
|
||||||
#include <sprout/breed/detail/std_result_of.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename Expr>
|
|
||||||
struct by_value_generator_;
|
|
||||||
template<typename Tag, typename Arg>
|
|
||||||
struct by_value_generator_<sprout::breed::expr<Tag, sprout::breed::term<Arg>, 0> > {
|
|
||||||
public:
|
|
||||||
typedef breed::expr<
|
|
||||||
Tag,
|
|
||||||
sprout::breed::term<typename sprout::breed::detail::term_traits<Arg>::value_type>,
|
|
||||||
0
|
|
||||||
> type;
|
|
||||||
public:
|
|
||||||
static SPROUT_CONSTEXPR type call(breed::expr<Tag, term<Arg>, 0> const& e) {
|
|
||||||
return type(e.template child<0>());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Tag, typename Arg>
|
|
||||||
struct by_value_generator_<sprout::breed::basic_expr<Tag, sprout::breed::term<Arg>, 0> > {
|
|
||||||
public:
|
|
||||||
typedef breed::expr<
|
|
||||||
Tag,
|
|
||||||
sprout::breed::term<typename sprout::breed::detail::term_traits<Arg>::value_type>,
|
|
||||||
0
|
|
||||||
> type;
|
|
||||||
public:
|
|
||||||
static SPROUT_CONSTEXPR type call(breed::expr<Tag, term<Arg>, 0> const& e) {
|
|
||||||
return type(e.template child<0>());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Tag, typename... Args>
|
|
||||||
struct by_value_generator_<
|
|
||||||
sprout::breed::expr<Tag, sprout::breed::list<Args...>, sizeof...(Args)>
|
|
||||||
> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::list<Args...> src_args;
|
|
||||||
typedef sprout::breed::list<typename sprout::breed::detail::uncvref<Args>::type...> dst_args;
|
|
||||||
typedef sprout::breed::expr<Tag, src_args, N> src_type;
|
|
||||||
typedef sprout::breed::expr<Tag, dst_args, N> type;
|
|
||||||
private:
|
|
||||||
template<sprout::index_t... Indexes>
|
|
||||||
static SPROUT_CONSTEXPR type call_impl(src_type const& e, sprout::index_tuple<Indexes...>) {
|
|
||||||
return type(e.template child<Indexes>()...);
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
static SPROUT_CONSTEXPR type call(src_type const& e) {
|
|
||||||
return call_impl(sprout::index_pack<Args...>::make());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Tag, typename... Args>
|
|
||||||
struct by_value_generator_<
|
|
||||||
sprout::breed::basic_expr<Tag, sprout::breed::list<Args...>, sizeof...(Args)>
|
|
||||||
> {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::list<Args...> src_args;
|
|
||||||
typedef sprout::breed::list<typename sprout::breed::detail::uncvref<Args>::type...> dst_args;
|
|
||||||
typedef sprout::breed::basic_expr<Tag, src_args, N> src_type;
|
|
||||||
typedef sprout::breed::basic_expr<Tag, dst_args, N> type;
|
|
||||||
private:
|
|
||||||
template<sprout::index_t... Indexes>
|
|
||||||
static SPROUT_CONSTEXPR type call_impl(src_type const& e, sprout::index_tuple<Indexes...>) {
|
|
||||||
return type(e.template child<Indexes>()...);
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
static SPROUT_CONSTEXPR type call(src_type const& e) {
|
|
||||||
return call_impl(sprout::index_pack<Args...>::make());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
//
|
|
||||||
// use_basic_expr
|
|
||||||
//
|
|
||||||
template<typename Generator>
|
|
||||||
struct use_basic_expr
|
|
||||||
: public Generator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_USE_BASIC_EXPR();
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// default_generator
|
|
||||||
//
|
|
||||||
struct default_generator {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Expr type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
#ifdef SPROUT_BREED_STRICT_RESULT_OF
|
|
||||||
SPROUT_CONSTEXPR Expr
|
|
||||||
#else
|
|
||||||
SPROUT_CONSTEXPR Expr const&
|
|
||||||
#endif
|
|
||||||
operator()(Expr const& e) const {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// basic_default_generator
|
|
||||||
//
|
|
||||||
struct basic_default_generator
|
|
||||||
: public sprout::breed::use_basic_expr<sprout::breed::default_generator>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// generator
|
|
||||||
//
|
|
||||||
template<template<typename> class Extends>
|
|
||||||
struct generator {
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
SPROUT_BREED_USE_BASIC_EXPR()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Extends<Expr> type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr&)> {
|
|
||||||
public:
|
|
||||||
typedef Extends<Expr> type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr const&)>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Extends<Expr> type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR Extends<Expr> operator()(Expr const& e) const {
|
|
||||||
return Extends<Expr>(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// pod_generator
|
|
||||||
//
|
|
||||||
template<template<typename> class Extends>
|
|
||||||
struct pod_generator {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
SPROUT_BREED_USE_BASIC_EXPR()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Extends<Expr> type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr&)> {
|
|
||||||
public:
|
|
||||||
typedef Extends<Expr> type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr const&)> {
|
|
||||||
public:
|
|
||||||
typedef Extends<Expr> type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR Extends<Expr> operator()(Expr const& e) const {
|
|
||||||
return Extends<Expr>(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// by_value_generator
|
|
||||||
//
|
|
||||||
struct by_value_generator {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::by_value_generator_<Expr>::type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr&)> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::by_value_generator_<Expr>::type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr const&)> {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::by_value_generator_<Expr>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result<by_value_generator(Expr)>::type operator()(Expr const& e) const {
|
|
||||||
return sprout::breed::detail::by_value_generator_<Expr>::call(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// compose_generators
|
|
||||||
//
|
|
||||||
template<typename First, typename Second>
|
|
||||||
struct compose_generators {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename Second::template result<
|
|
||||||
Second(typename First::template result<First(Expr)>::type)
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr&)> {
|
|
||||||
public:
|
|
||||||
typedef typename Second::template result<
|
|
||||||
Second(typename First::template result<First(Expr)>::type)
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr const&)> {
|
|
||||||
public:
|
|
||||||
typedef typename Second::template result<
|
|
||||||
Second(typename First::template result<First(Expr)>::type)
|
|
||||||
>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result<compose_generators(Expr)>::type operator()(Expr const& e) const {
|
|
||||||
return Second()(First()(e));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// wants_basic_expr
|
|
||||||
//
|
|
||||||
template<typename Generator, typename Void>
|
|
||||||
struct wants_basic_expr
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename Generator>
|
|
||||||
struct wants_basic_expr<Generator, typename Generator::breed_use_basic_expr_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// is_callable
|
|
||||||
//
|
|
||||||
template<>
|
|
||||||
struct is_callable<default_generator>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<template<typename> class Extends>
|
|
||||||
struct is_callable<sprout::breed::generator<Extends> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<template<typename> class Extends>
|
|
||||||
struct is_callable<sprout::breed::pod_generator<Extends> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<>
|
|
||||||
struct is_callable<sprout::breed::by_value_generator>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<typename First, typename Second>
|
|
||||||
struct is_callable<sprout::breed::compose_generators<First, Second> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<typename Expr>
|
|
||||||
struct std_result_of<sprout::breed::default_domain(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Expr type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct std_result_of<sprout::breed::basic_default_domain(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Expr type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct std_result_of<sprout::breed::default_generator(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Expr type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct std_result_of<sprout::breed::basic_default_generator(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef Expr type;
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_GENERATE_HPP
|
|
|
@ -1,18 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_MATCHES_HPP
|
|
||||||
#define SPROUT_BREED_MATCHES_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/traits.hpp>
|
|
||||||
#include <sprout/breed/transform/when.hpp>
|
|
||||||
#include <sprout/breed/transform/impl.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_MATCHES_HPP
|
|
|
@ -1,62 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_TAGS_HPP
|
|
||||||
#define SPROUT_BREED_TAGS_HPP
|
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace tagns_ {
|
|
||||||
namespace tag {
|
|
||||||
struct terminal {};
|
|
||||||
struct unary_plus {};
|
|
||||||
struct negate {};
|
|
||||||
struct dereference {};
|
|
||||||
struct complement {};
|
|
||||||
struct address_of {};
|
|
||||||
struct logical_not {};
|
|
||||||
struct pre_inc {};
|
|
||||||
struct pre_dec {};
|
|
||||||
struct post_inc {};
|
|
||||||
struct post_dec {};
|
|
||||||
struct shift_left {};
|
|
||||||
struct shift_right {};
|
|
||||||
struct multiplies {};
|
|
||||||
struct divides {};
|
|
||||||
struct modulus {};
|
|
||||||
struct plus {};
|
|
||||||
struct minus {};
|
|
||||||
struct less {};
|
|
||||||
struct greater {};
|
|
||||||
struct less_equal {};
|
|
||||||
struct greater_equal {};
|
|
||||||
struct equal_to {};
|
|
||||||
struct not_equal_to {};
|
|
||||||
struct logical_or {};
|
|
||||||
struct logical_and {};
|
|
||||||
struct bitwise_and {};
|
|
||||||
struct bitwise_or {};
|
|
||||||
struct bitwise_xor {};
|
|
||||||
struct comma {};
|
|
||||||
struct mem_ptr {};
|
|
||||||
struct assign {};
|
|
||||||
struct shift_left_assign {};
|
|
||||||
struct shift_right_assign {};
|
|
||||||
struct multiplies_assign {};
|
|
||||||
struct divides_assign {};
|
|
||||||
struct modulus_assign {};
|
|
||||||
struct plus_assign {};
|
|
||||||
struct minus_assign {};
|
|
||||||
struct bitwise_and_assign {};
|
|
||||||
struct bitwise_or_assign {};
|
|
||||||
struct bitwise_xor_assign {};
|
|
||||||
struct subscript {};
|
|
||||||
struct member {};
|
|
||||||
struct if_else_ {};
|
|
||||||
struct function {};
|
|
||||||
} // namespace tag
|
|
||||||
} // namespace tagns_
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_TAGS_HPP
|
|
|
@ -1,926 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_TRAITS_HPP
|
|
||||||
#define SPROUT_BREED_TRAITS_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/utility/pack.hpp>
|
|
||||||
#include <sprout/tuple/tuple.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/args.hpp>
|
|
||||||
#include <sprout/breed/domain.hpp>
|
|
||||||
#include <sprout/breed/transform/pass_through.hpp>
|
|
||||||
#include <sprout/breed/detail/template_arity.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct if_vararg {};
|
|
||||||
template<typename T>
|
|
||||||
struct if_vararg<T, typename T::breed_is_vararg_>
|
|
||||||
: public T
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<typename T, typename Void = void>
|
|
||||||
struct is_callable2_
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_callable2_<T, typename T::breed_is_callable_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<typename T, long Arity = sprout::breed::detail::template_arity<T>::value>
|
|
||||||
struct is_callable_
|
|
||||||
: public sprout::breed::detail::is_callable2_<T>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
//
|
|
||||||
// is_callable
|
|
||||||
//
|
|
||||||
template<typename T>
|
|
||||||
struct is_callable
|
|
||||||
: public sprout::breed::detail::is_callable_<T>
|
|
||||||
{};
|
|
||||||
template<>
|
|
||||||
struct is_callable<sprout::breed::_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<>
|
|
||||||
struct is_callable<sprout::breed::callable>
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename PrimitiveTransform, typename X>
|
|
||||||
struct is_callable<sprout::breed::transform<PrimitiveTransform, X> >
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<typename T, typename Void>
|
|
||||||
struct is_transform_
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_transform_<T, typename T::breed_is_transform_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
//
|
|
||||||
// is_transform
|
|
||||||
//
|
|
||||||
template<typename T>
|
|
||||||
struct is_transform
|
|
||||||
: public sprout::breed::detail::is_transform_<T>
|
|
||||||
{};
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<typename T, typename Void>
|
|
||||||
struct is_aggregate_
|
|
||||||
: public std::is_pod<T>
|
|
||||||
{};
|
|
||||||
template<typename Tag, typename Args, long N>
|
|
||||||
struct is_aggregate_<sprout::breed::expr<Tag, Args, N>, void>
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename Tag, typename Args, long N>
|
|
||||||
struct is_aggregate_<sprout::breed::basic_expr<Tag, Args, N>, void>
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_aggregate_<T, typename T::breed_is_aggregate_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
//
|
|
||||||
// is_transform
|
|
||||||
//
|
|
||||||
template<typename T>
|
|
||||||
struct is_aggregate
|
|
||||||
: public sprout::breed::detail::is_aggregate_<T>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// is_transform
|
|
||||||
//
|
|
||||||
template<typename T, typename Void>
|
|
||||||
struct is_expr
|
|
||||||
: public std::false_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_expr<T, typename T::breed_is_expr_>
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<typename T>
|
|
||||||
struct is_expr<T&, void>
|
|
||||||
: public is_expr<T>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// tag_of
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
struct tag_of {
|
|
||||||
public:
|
|
||||||
typedef typename Expr::breed_tag type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct tag_of<Expr&> {
|
|
||||||
public:
|
|
||||||
typedef typename Expr::breed_tag type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// arity_of
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
struct arity_of
|
|
||||||
: public Expr::breed_arity
|
|
||||||
{};
|
|
||||||
template<typename Expr>
|
|
||||||
struct arity_of<Expr&>
|
|
||||||
: public Expr::breed_arity
|
|
||||||
{};
|
|
||||||
|
|
||||||
namespace result_of {
|
|
||||||
//
|
|
||||||
// as_expr
|
|
||||||
//
|
|
||||||
template<typename T, typename Domain>
|
|
||||||
struct as_expr {
|
|
||||||
public:
|
|
||||||
typedef typename Domain::template as_expr<T>::result_type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// as_child
|
|
||||||
//
|
|
||||||
template<typename T, typename Domain>
|
|
||||||
struct as_child {
|
|
||||||
public:
|
|
||||||
typedef typename Domain::template as_child<T>::result_type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// child
|
|
||||||
//
|
|
||||||
template<typename Expr, typename N>
|
|
||||||
struct child
|
|
||||||
: public child_c<Expr, N::value>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//
|
|
||||||
// value
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
struct value {
|
|
||||||
static_assert(0 == Expr::breed_arity_c, "0 == Expr::breed_arity_c");
|
|
||||||
public:
|
|
||||||
typedef typename Expr::template breed_child<0>::type value_type;
|
|
||||||
typedef typename sprout::breed::detail::term_traits<value_type>::value_type type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct value<Expr&> {
|
|
||||||
static_assert(0 == Expr::breed_arity_c, "0 == Expr::breed_arity_c");
|
|
||||||
public:
|
|
||||||
typedef typename Expr:template breed_child<0>::type value_type;
|
|
||||||
typedef typename sprout::breed::detail::term_traits<value_type>::reference type;
|
|
||||||
};
|
|
||||||
template<typename Expr>
|
|
||||||
struct value<Expr const&> {
|
|
||||||
static_assert(0 == Expr::breed_arity_c, "0 == Expr::breed_arity_c");
|
|
||||||
public:
|
|
||||||
typedef typename Expr:template breed_child<0>::type value_type;
|
|
||||||
typedef typename sprout::breed::detail::term_traits<value_type>::const_reference type;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// left
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
struct left
|
|
||||||
: public sprout::breed::result_of::child_c<Expr, 0>
|
|
||||||
{};
|
|
||||||
//
|
|
||||||
// right
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
struct right
|
|
||||||
: public child_c<Expr, 1>
|
|
||||||
{};
|
|
||||||
} // namespace result_of
|
|
||||||
|
|
||||||
//
|
|
||||||
// terminal
|
|
||||||
//
|
|
||||||
template<typename T>
|
|
||||||
struct terminal
|
|
||||||
: public sprout::breed::transform<sprout::breed::terminal<T>, int>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::tag::terminal breed_tag;
|
|
||||||
typedef sprout::breed::expr<sprout::breed::tag::terminal, sprout::breed::term<T>, 0> type;
|
|
||||||
typedef sprout::breed::basic_expr<sprout::breed::tag::terminal, sprout::breed::term<T>, 0> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, T>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Expr result_type;
|
|
||||||
public:
|
|
||||||
#ifdef SPROUT_BREED_STRICT_RESULT_OF
|
|
||||||
SPROUT_CONSTEXPR result_type
|
|
||||||
#else
|
|
||||||
SPROUT_CONSTEXPR typename impl::expr_param
|
|
||||||
#endif
|
|
||||||
operator()(
|
|
||||||
typename impl::expr_param e,
|
|
||||||
typename impl::state_param,
|
|
||||||
typename impl::data_param
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// if_else_
|
|
||||||
//
|
|
||||||
template<typename T, typename U, typename V>
|
|
||||||
struct if_else_
|
|
||||||
: public sprout::breed::transform<if_else_<T, U, V>, int>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::tag::if_else_ breed_tag;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
sprout::breed::tag::if_else_, sprout::breed::sprout::breed::list<T, U, V>,
|
|
||||||
3
|
|
||||||
> type;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
sprout::breed::tag::if_else_,
|
|
||||||
sprout::breed::sprout::breed::list<T, U, V>,
|
|
||||||
3
|
|
||||||
> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, T, U, V>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::detail::pass_through_impl<sprout::breed::if_else_, Expr, State, Data>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// nullary_expr
|
|
||||||
//
|
|
||||||
template<typename Tag, typename T>
|
|
||||||
struct nullary_expr
|
|
||||||
: public sprout::breed::transform<sprout::breed::nullary_expr<Tag, T>, int>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef sprout::breed::expr<Tag, sprout::breed::term<T>, 0> type;
|
|
||||||
typedef sprout::breed::basic_expr<Tag, sprout::breed::term<T>, 0> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, T>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Expr result_type;
|
|
||||||
public:
|
|
||||||
#ifdef SPROUT_BREED_STRICT_RESULT_OF
|
|
||||||
SPROUT_CONSTEXPR result_type
|
|
||||||
#else
|
|
||||||
SPROUT_CONSTEXPR typename impl::expr_param
|
|
||||||
#endif
|
|
||||||
operator()(
|
|
||||||
typename impl::expr_param e,
|
|
||||||
typename impl::state_param,
|
|
||||||
typename impl::data_param
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// unary_expr
|
|
||||||
//
|
|
||||||
template<typename Tag, typename T>
|
|
||||||
struct unary_expr
|
|
||||||
: public sprout::breed::transform<sprout::breed::unary_expr<Tag, T>, int>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef sprout::breed::expr<Tag, sprout::breed::sprout::breed::list<T>, 1> type;
|
|
||||||
typedef sprout::breed::basic_expr<Tag, sprout::breed::sprout::breed::list<T>, 1> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, T>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::detail::pass_through_impl<sprout::breed::unary_expr, Expr, State, Data>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// binary_expr
|
|
||||||
//
|
|
||||||
template<typename Tag, typename T, typename U>
|
|
||||||
struct binary_expr
|
|
||||||
: public sprout::breed::transform<sprout::breed::binary_expr<Tag, T, U>, int>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef sprout::breed::expr<Tag, sprout::breed::list<T, U>, 2> type;
|
|
||||||
typedef sprout::breed::basic_expr<Tag, sprout::breed::list<T, U>, 2> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child
|
|
||||||
: public sprout::tppack_at<N, T, U>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::detail::pass_through_impl<binary_expr, Expr, State, Data>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
# define SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(op) \
|
|
||||||
template<typename T> \
|
|
||||||
struct op \
|
|
||||||
: public sprout::breed::transform<op<T>, int> \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
typedef sprout::breed::tag::op breed_tag; \
|
|
||||||
typedef sprout::breed::expr<sprout::breed::tag::op, sprout::breed::list<T>, 1> type; \
|
|
||||||
typedef sprout::breed::basic_expr<sprout::breed::tag::op, sprout::breed::list<T>, 1> breed_grammar; \
|
|
||||||
public: \
|
|
||||||
template<long N> \
|
|
||||||
struct breed_child \
|
|
||||||
: public sprout::tppack_at<N, T> \
|
|
||||||
{}; \
|
|
||||||
public: \
|
|
||||||
template<typename Expr, typename State, typename Data> \
|
|
||||||
struct impl \
|
|
||||||
: public sprout::breed::detail::pass_through_impl<op, Expr, State, Data> \
|
|
||||||
{}; \
|
|
||||||
};
|
|
||||||
# define SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(op) \
|
|
||||||
template<typename T, typename U> \
|
|
||||||
struct op \
|
|
||||||
: public sprout::breed::transform<op<T, U>, int> \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
typedef sprout::breed::tag::op breed_tag; \
|
|
||||||
typedef sprout::breed::expr<sprout::breed::tag::op, sprout::breed::list<T, U>, 2> type; \
|
|
||||||
typedef sprout::breed::basic_expr<sprout::breed::tag::op, sprout::breed::list<T, U>, 2> breed_grammar; \
|
|
||||||
public: \
|
|
||||||
template<long N> \
|
|
||||||
struct breed_child \
|
|
||||||
: public sprout::tppack_at<N, T, U> \
|
|
||||||
{}; \
|
|
||||||
public: \
|
|
||||||
template<typename Expr, typename State, typename Data> \
|
|
||||||
struct impl \
|
|
||||||
: public sprout::breed::detail::pass_through_impl<op, Expr, State, Data> \
|
|
||||||
{}; \
|
|
||||||
};
|
|
||||||
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(unary_plus)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(negate)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(dereference)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(complement)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(address_of)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(logical_not)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(pre_inc)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(pre_dec)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(post_inc)
|
|
||||||
SPROUT_BREED_DEFINE_UNARY_METAFUNCTION(post_dec)
|
|
||||||
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(shift_left)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(shift_right)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(multiplies)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(divides)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(modulus)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(plus)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(minus)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(less)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(greater)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(less_equal)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(greater_equal)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(equal_to)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(not_equal_to)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(logical_or)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(logical_and)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(bitwise_or)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(bitwise_and)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(bitwise_xor)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(comma)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(mem_ptr)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(shift_left_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(shift_right_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(multiplies_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(divides_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(modulus_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(plus_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(minus_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(bitwise_or_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(bitwise_and_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(bitwise_xor_assign)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(subscript)
|
|
||||||
SPROUT_BREED_DEFINE_BINARY_METAFUNCTION(member)
|
|
||||||
|
|
||||||
# undef SPROUT_BREED_DEFINE_UNARY_METAFUNCTION
|
|
||||||
# undef SPROUT_BREED_DEFINE_BINARY_METAFUNCTION
|
|
||||||
|
|
||||||
//
|
|
||||||
// function
|
|
||||||
//
|
|
||||||
template<typename... Args>
|
|
||||||
struct function
|
|
||||||
: public sprout::breed::transform<
|
|
||||||
sprout::breed::function<Args...>,
|
|
||||||
int
|
|
||||||
>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::tag::function breed_tag;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
sprout::breed::tag::function, sprout::breed::list<Args...>,
|
|
||||||
sizeof...(Args)
|
|
||||||
> type;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
sprout::breed::tag::function, sprout::breed::list<Args...>,
|
|
||||||
sizeof...(Args)
|
|
||||||
> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child {
|
|
||||||
public:
|
|
||||||
typedef std::conditional<
|
|
||||||
N < sizeof...(Args),
|
|
||||||
sprout::tppack_at<N, Args...>,
|
|
||||||
sprout::breed::detail::if_vararg<typename sprout::tppack_at<sizeof...(Args) - 1, Args...>::type>
|
|
||||||
>::type::type
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::detail::pass_through_impl<function, Expr, State, Data>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// nary_expr
|
|
||||||
//
|
|
||||||
template<typename Tag, typename... Args>
|
|
||||||
struct nary_expr
|
|
||||||
: public sprout::breed::transform<
|
|
||||||
sprout::breed::nary_expr<Tag, Args...>,
|
|
||||||
int
|
|
||||||
>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Tag breed_tag;
|
|
||||||
typedef sprout::breed::expr<
|
|
||||||
Tag,
|
|
||||||
sprout::breed::list<Args...>,
|
|
||||||
sizeof...(Args)
|
|
||||||
> type;
|
|
||||||
typedef sprout::breed::basic_expr<
|
|
||||||
Tag,
|
|
||||||
sprout::breed::list<Args...>,
|
|
||||||
sizeof...(Args)
|
|
||||||
> breed_grammar;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct breed_child {
|
|
||||||
public:
|
|
||||||
typedef std::conditional<
|
|
||||||
N < sizeof...(Args),
|
|
||||||
sprout::tppack_at<N, Args...>,
|
|
||||||
sprout::breed::detail::if_vararg<typename sprout::tppack_at<sizeof...(Args) - 1, Args...>::type>
|
|
||||||
>::type::type
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::detail::pass_through_impl<sprout::breed::nary_expr, Expr, State, Data>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<template<typename...> class T, typename... Args>
|
|
||||||
struct is_callable_<T<Args...>, sizeof...(Args)>
|
|
||||||
: public std::is_same<
|
|
||||||
typename sprout::tppack_at<sizeof...(Args) - 1, Args...>::type,
|
|
||||||
sprout::breed::callable
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
namespace result_of {
|
|
||||||
//
|
|
||||||
// child_c
|
|
||||||
//
|
|
||||||
template<typename Expr, long N>
|
|
||||||
struct child_c {
|
|
||||||
static_assert(0 != Expr::proto_arity_c, "0 != Expr::proto_arity_c");
|
|
||||||
public:
|
|
||||||
typedef typename Expr::template breed_child<N>::type value_type;
|
|
||||||
typedef typename sprout::breed::detail::expr_traits<value_type>::value_type type;
|
|
||||||
};
|
|
||||||
template<typename Expr, long N>
|
|
||||||
struct child_c<Expr&, N> {
|
|
||||||
static_assert(0 != Expr::proto_arity_c, "0 != Expr::proto_arity_c");
|
|
||||||
public:
|
|
||||||
typedef typename Expr::template breed_child<N>::type value_type;
|
|
||||||
typedef typename detail::expr_traits<value_type>::reference type;
|
|
||||||
public:
|
|
||||||
static type call(Expr& e) {
|
|
||||||
return e.proto_base().breed child<N>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, long N>
|
|
||||||
struct child_c<Expr const&, N> {
|
|
||||||
static_assert(0 != Expr::proto_arity_c, "0 != Expr::proto_arity_c");
|
|
||||||
public:
|
|
||||||
typedef typename Expr::template breed_child<N>::type value_type;
|
|
||||||
typedef typename detail::expr_traits<value_type>::const_reference type;
|
|
||||||
public:
|
|
||||||
static SPROUT_CONSTEXPR type call(Expr const& e) {
|
|
||||||
return e.proto_base().breed child<N>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace result_of
|
|
||||||
|
|
||||||
namespace functional {
|
|
||||||
//
|
|
||||||
// as_expr
|
|
||||||
//
|
|
||||||
template<typename Domain>
|
|
||||||
struct as_expr {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename T>
|
|
||||||
struct result<This(T)> {
|
|
||||||
typedef typename Domain::template as_expr<T>::result_type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename T>
|
|
||||||
struct result<This(T&)> {
|
|
||||||
typedef typename Domain::template as_expr<T>::result_type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename T>
|
|
||||||
SPROUT_CONSTEXPR typename std::add_const<
|
|
||||||
typename result<sprout::breed::as_expr(T const&)>::type
|
|
||||||
>::type operator()(T const& t) const {
|
|
||||||
return typename Domain::template as_expr<T const>()(t);
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
typename std::add_const<
|
|
||||||
typename result<sprout::breed::as_expr(T&)>::type
|
|
||||||
>::type operator()(T& t) const {
|
|
||||||
return typename Domain::template as_expr<T>()(t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// as_child
|
|
||||||
//
|
|
||||||
template<typename Domain>
|
|
||||||
struct as_child {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename T>
|
|
||||||
struct result<This(T)> {
|
|
||||||
public:
|
|
||||||
typedef typename Domain::template as_child<T>::result_type type;
|
|
||||||
};
|
|
||||||
template<typename This, typename T>
|
|
||||||
struct result<This(T&)> {
|
|
||||||
public:
|
|
||||||
typedef typename Domain::template as_child<T>::result_type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename T>
|
|
||||||
SPROUT_CONSTEXPR typename std::add_const<
|
|
||||||
typename result<as_child(T const&)>::type
|
|
||||||
>::type operator()(T const& t) const {
|
|
||||||
return typename Domain::template as_child<T const>()(t);
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
typename std::add_const<
|
|
||||||
typename result<as_child(T&)>::type
|
|
||||||
>::type operator()(T& t) const {
|
|
||||||
return typename Domain::template as_child<T const>()(t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// child_c
|
|
||||||
//
|
|
||||||
template<long N>
|
|
||||||
struct child_c {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename result_of::child_c<Expr, N>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result_of::child_c<Expr const&, N>::type operator()(Expr const& e) const {
|
|
||||||
return result_of::child_c<Expr const&, N>::call(e);
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename result_of::child_c<Expr const&, N>::type operator()(Expr& e) const {
|
|
||||||
return result_of::child_c<Expr&, N>::call(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// child
|
|
||||||
//
|
|
||||||
template<typename N>
|
|
||||||
struct child {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename result_of::child<Expr, N>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result_of::child<Expr const&, N>::type operator()(Expr const& e) const {
|
|
||||||
return result_of::child<Expr const&, N>::call(e);
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename result_of::child<Expr&, N>::type operator()(Expr const& e) const {
|
|
||||||
return result_of::child<Expr&, N>::call(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// value
|
|
||||||
//
|
|
||||||
struct value {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename result_of::value<Expr>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result_of::value<Expr const&>::type operator()(Expr const& e) const {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename result_of::value<Expr&>::type operator()(Expr& e) const {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// left
|
|
||||||
//
|
|
||||||
struct left {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename result_of::left<Expr>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result_of::value<Expr const&>::type operator()(Expr const& e) const {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename result_of::value<Expr&>::type operator()(Expr& e) const {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// right
|
|
||||||
//
|
|
||||||
struct right {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_CALLABLE()
|
|
||||||
public:
|
|
||||||
template<typename Sig>
|
|
||||||
struct result;
|
|
||||||
template<typename This, typename Expr>
|
|
||||||
struct result<This(Expr)> {
|
|
||||||
public:
|
|
||||||
typedef typename result_of::right<Expr>::type type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename result_of::value<Expr const&>::type operator()(Expr const& e) const {
|
|
||||||
return e.breed_base().template child<1>();
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename result_of::value<Expr&>::type operator()(Expr& e) const {
|
|
||||||
return e.breed_base().template child<1>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace functional
|
|
||||||
|
|
||||||
//
|
|
||||||
// as_expr
|
|
||||||
//
|
|
||||||
template<typename T>
|
|
||||||
SPROUT_CONSTEXPR typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_expr<T const, sprout::breed::default_domain>::type
|
|
||||||
>::type as_expr(T const& t) {
|
|
||||||
return sprout::breed::default_domain::as_expr<T const>()(t);
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_expr<T, sprout::breed::default_domain>::type
|
|
||||||
>::type as_expr(T& t) {
|
|
||||||
return sprout::breed::default_domain::as_expr<T>()(t);
|
|
||||||
}
|
|
||||||
template<typename Domain, typename T>
|
|
||||||
SPROUT_CONSTEXPR typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_expr<T const, Domain>::type
|
|
||||||
>::type as_expr(T const& t) {
|
|
||||||
return typename Domain::template as_expr<T const>()(t);
|
|
||||||
}
|
|
||||||
template<typename Domain, typename T>
|
|
||||||
typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_expr<T, Domain>::type
|
|
||||||
>::type as_expr(T& t) {
|
|
||||||
return typename Domain::template as_expr<T>()(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// as_child
|
|
||||||
//
|
|
||||||
template<typename T>
|
|
||||||
SPROUT_CONSTEXPR typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_child<T const, sprout::breed::default_domain>::type
|
|
||||||
>::type as_child(T const& t)
|
|
||||||
{
|
|
||||||
return sprout::breed::default_domain::as_child<T const>()(t);
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_child<T, sprout::breed::default_domain>::type
|
|
||||||
>::type as_child(T& t)
|
|
||||||
{
|
|
||||||
return sprout::breed::default_domain::as_child<T>()(t);
|
|
||||||
}
|
|
||||||
template<typename Domain, typename T>
|
|
||||||
SPROUT_CONSTEXPR typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_child<T const, Domain>::type
|
|
||||||
>::type as_child(T const& t)
|
|
||||||
{
|
|
||||||
return typename Domain::template as_child<T const>()(t);
|
|
||||||
}
|
|
||||||
template<typename Domain, typename T>
|
|
||||||
typename std::add_const<
|
|
||||||
typename sprout::breed::result_of::as_child<T, Domain>::type
|
|
||||||
>::type as_child(T& t)
|
|
||||||
{
|
|
||||||
return typename Domain::template as_child<T>()(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// child
|
|
||||||
//
|
|
||||||
template<typename N, typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::child<Expr const&, N>::type child(Expr const& e) {
|
|
||||||
return sprout::breed::result_of::child<Expr const&, N>::call(e);
|
|
||||||
}
|
|
||||||
template<typename N, typename Expr>
|
|
||||||
typename sprout::breed::result_of::child<Expr&, N>::type child(Expr& e) {
|
|
||||||
return sprout::breed::result_of::child<Expr&, N>::call(e);
|
|
||||||
}
|
|
||||||
template<typename Expr2>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::detail::expr_traits<
|
|
||||||
typename Expr2::breed_base_expr:template breed_child<0>::type
|
|
||||||
>::const_reference child(Expr2 const& expr2) {
|
|
||||||
return expr2.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
template<typename Expr2>
|
|
||||||
typename sprout::breed::detail::expr_traits<
|
|
||||||
typename Expr2::breed_base_expr:template breed_child<0>::type
|
|
||||||
>::reference child(Expr2& expr2) {
|
|
||||||
return expr2.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// child_c
|
|
||||||
//
|
|
||||||
template<long N, typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::child_c<Expr const&, N>::type child_c(Expr const& e) {
|
|
||||||
return sprout::breed::result_of::child_c<Expr const&, N>::call(e);
|
|
||||||
}
|
|
||||||
template<long N, typename Expr>
|
|
||||||
typename sprout::breed::result_of::child_c<Expr&, N>::type child_c(Expr& e) {
|
|
||||||
return sprout::breed::result_of::child_c<Expr&, N>::call(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// value
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::value<Expr const&>::type value(Expr const& e) {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename sprout::breed::result_of::value<Expr&>::type value(Expr& e) {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// left
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::left<Expr const&>::type left(Expr const& e) {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename sprout::breed::result_of::left<Expr&>::type left(Expr& e) {
|
|
||||||
return e.breed_base().template child<0>();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// right
|
|
||||||
//
|
|
||||||
template<typename Expr>
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::result_of::right<Expr const&>::type right(Expr const& e) {
|
|
||||||
return e.breed_base().template child<1>();
|
|
||||||
}
|
|
||||||
template<typename Expr>
|
|
||||||
typename sprout::breed::result_of::right<Expr&>::type right(Expr& e) {
|
|
||||||
return e.breed_base().template child<1>();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// is_callable
|
|
||||||
//
|
|
||||||
template<typename Domain>
|
|
||||||
struct is_callable<sprout::breed::functional::as_expr<Domain> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<typename Domain>
|
|
||||||
struct is_callable<sprout::breed::functional::as_child<Domain> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<long N>
|
|
||||||
struct is_callable<sprout::breed::functional::child_c<N> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
template<typename N>
|
|
||||||
struct is_callable<sprout::breed::functional::child<N> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_TRAITS_HPP
|
|
|
@ -1,393 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_TRANSFORM_CALL_HPP
|
|
||||||
#define SPROUT_BREED_TRANSFORM_CALL_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/utility/pack.hpp>
|
|
||||||
#include <sprout/type/type_tuple.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/traits.hpp>
|
|
||||||
#include <sprout/breed/transform/impl.hpp>
|
|
||||||
#include <sprout/breed/detail/std_result_of.hpp>
|
|
||||||
#include <sprout/breed/detail/as_lvalue.hpp>
|
|
||||||
#include <sprout/breed/detail/poly_function.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
//
|
|
||||||
// call
|
|
||||||
//
|
|
||||||
template<typename PrimitiveTransform>
|
|
||||||
struct call
|
|
||||||
: public PrimitiveTransform
|
|
||||||
{};
|
|
||||||
template<typename Fun>
|
|
||||||
struct call<Fun()>
|
|
||||||
: public sprout::breed::transform<sprout::breed::call<Fun()> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data, bool B>
|
|
||||||
struct impl2
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::detail::std_result_of<Fun()>::type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(
|
|
||||||
typename impl2::expr_param,
|
|
||||||
typename impl2::state_param,
|
|
||||||
typename impl2::data_param
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return Fun()();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl2<Expr, State, Data, true>
|
|
||||||
: public Fun::template impl<Expr, State, Data>
|
|
||||||
{};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public impl2<Expr, State, Data, sprout::breed::detail::is_transform_<Fun>::value>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
template<typename Fun, typename A0>
|
|
||||||
struct call<Fun(A0)>
|
|
||||||
: public sprout::breed::transform<sprout::breed::call<Fun(A0)> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data, bool B>
|
|
||||||
struct impl2
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct fun_ {
|
|
||||||
public:
|
|
||||||
typedef Fun type(typename a_<Args>::type::result_type...);
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct function_
|
|
||||||
: public sprout::breed::detail::poly_function_traits<
|
|
||||||
Fun,
|
|
||||||
typename fun_<Args...>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, A0>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef function_<A0> function_traits;
|
|
||||||
typedef typename function_traits::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return typename function_traits::function_type()(
|
|
||||||
sprout::breed::detail::as_lvalue(a_<A0>()(e, s, d))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl2<Expr, State, Data, true>
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
typedef Fun::template impl<typename a_<A0>::type, State, Data> function_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, A0>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef template function_::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return function_()(
|
|
||||||
typename a_<A0>::type()(e, s, d),
|
|
||||||
s,
|
|
||||||
d
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public impl2<Expr, State, Data, sprout::breed::detail::is_transform_<Fun>::value>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
template<typename Fun, typename A0, typename A1>
|
|
||||||
struct call<Fun(A0, A1)>
|
|
||||||
: public sprout::breed::transform<sprout::breed::call<Fun(A0, A1)> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data, bool B>
|
|
||||||
struct impl2
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct fun_ {
|
|
||||||
public:
|
|
||||||
typedef Fun type(typename a_<Args>::type::result_type...);
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct function_
|
|
||||||
: public sprout::breed::detail::poly_function_traits<
|
|
||||||
Fun,
|
|
||||||
typename fun_<Args...>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, A0, A1>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef function_<A0, A1> function_traits;
|
|
||||||
typedef typename function_traits::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return typename function_traits::function_type()(
|
|
||||||
sprout::breed::detail::as_lvalue(a_<A0>()(e, s, d)),
|
|
||||||
sprout::breed::detail::as_lvalue(a_<A1>()(e, s, d))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl2<Expr, State, Data, true>
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
typedef Fun::template impl<typename a_<A0>::type, typename a_<A1>::type, Data> function_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, A0, A1>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef template function_::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return function_()(
|
|
||||||
typename a_<A0>::type()(e, s, d),
|
|
||||||
typename a_<A1>::type()(e, s, d),
|
|
||||||
d
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public impl2<Expr, State, Data, sprout::breed::detail::is_transform_<Fun>::value>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
template<typename Fun, typename A0, typename A1, typename A2>
|
|
||||||
struct call<Fun(A0, A1, A2)>
|
|
||||||
: public sprout::breed::transform<sprout::breed::call<Fun(A0, A1, A2)> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data, bool B>
|
|
||||||
struct impl2
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct fun_ {
|
|
||||||
public:
|
|
||||||
typedef Fun type(typename a_<Args>::type::result_type...);
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct function_
|
|
||||||
: public sprout::breed::detail::poly_function_traits<
|
|
||||||
Fun,
|
|
||||||
typename fun_<Args...>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, A0, A1, A2>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef function_<A0, A1, A2> function_traits;
|
|
||||||
typedef typename function_traits::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return typename function_traits::function_type()(
|
|
||||||
sprout::breed::detail::as_lvalue(a_<A0>()(e, s, d)),
|
|
||||||
sprout::breed::detail::as_lvalue(a_<A1>()(e, s, d)),
|
|
||||||
sprout::breed::detail::as_lvalue(a_<A2>()(e, s, d))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl2<Expr, State, Data, true>
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
typedef Fun::template impl<typename a_<A0>::type, typename a_<A1>::type, typename a_<A2>::type> function_;
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, A0, A1, A2>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef template function_::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return function_()(
|
|
||||||
typename a_<A0>::type()(e, s, d),
|
|
||||||
typename a_<A1>::type()(e, s, d),
|
|
||||||
typename a_<A2>::type()(e, s, d)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public impl2<Expr, State, Data, sprout::breed::detail::is_transform_<Fun>::value>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
template<typename Fun, typename... Args>
|
|
||||||
struct call<Fun(Args...)>
|
|
||||||
: public sprout::breed::transform<sprout::breed::call<Fun(Args...)> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
template<typename A>
|
|
||||||
struct a_ {
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::when<sprout::breed::_, A>::template impl<
|
|
||||||
Expr,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct fun_ {
|
|
||||||
public:
|
|
||||||
typedef Fun type(typename a_<Args>::type::result_type...);
|
|
||||||
};
|
|
||||||
template<typename... Args>
|
|
||||||
struct function_
|
|
||||||
: public sprout::breed::detail::poly_function_traits<
|
|
||||||
Fun,
|
|
||||||
typename fun_<Args...>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
public:
|
|
||||||
template<long N>
|
|
||||||
struct a {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, Args...>::type>::type type;
|
|
||||||
};
|
|
||||||
template<long N>
|
|
||||||
struct b {
|
|
||||||
public:
|
|
||||||
typedef typename a_<typename sprout::tppack_at<N, Args...>::type>::type::result_type type;
|
|
||||||
};
|
|
||||||
typedef function_<Args...> function_traits;
|
|
||||||
typedef typename function_traits::result_type result_type;
|
|
||||||
SPROUT_CONSTEXPR result_type operator ()(
|
|
||||||
typename impl2::expr_param e,
|
|
||||||
typename impl2::state_param s,
|
|
||||||
typename impl2::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return typename function_traits::function_type()(
|
|
||||||
sprout::breed::detail::as_lvalue(typename a_<Args>::type()(e, s, d))...
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// is_callable
|
|
||||||
//
|
|
||||||
template<typename Fun>
|
|
||||||
struct is_callable<sprout::breed::call<Fun> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_TRANSFORM_CALL_HPP
|
|
|
@ -1,166 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_TRANSFORM_IMPL_HPP
|
|
||||||
#define SPROUT_BREED_TRANSFORM_IMPL_HPP
|
|
||||||
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
//
|
|
||||||
// SPROUT_BREED_TRANSFORM_
|
|
||||||
//
|
|
||||||
# define SPROUT_BREED_TRANSFORM_(PrimitiveTransform, X) \
|
|
||||||
public: \
|
|
||||||
SPROUT_BREED_CALLABLE() \
|
|
||||||
typedef X breed_is_transform_; \
|
|
||||||
typedef PrimitiveTransform transform_type; \
|
|
||||||
public: \
|
|
||||||
template<typename Sig> \
|
|
||||||
struct result { \
|
|
||||||
public: \
|
|
||||||
typedef typename sprout::breed::detail::apply_transform<Sig>::result_type type; \
|
|
||||||
}; \
|
|
||||||
template<typename Expr> \
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::detail::apply_transform< \
|
|
||||||
transform_type(Expr const&) \
|
|
||||||
>::result_type operator()(Expr&& e) const { \
|
|
||||||
return sprout::breed::detail::apply_transform< \
|
|
||||||
transform_type(Expr const&) \
|
|
||||||
>()(e, 0, 0); \
|
|
||||||
} \
|
|
||||||
template<typename Expr, typename State> \
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::detail::apply_transform< \
|
|
||||||
transform_type(Expr const&, State const&) \
|
|
||||||
>::result_type operator()(Expr&& e, State&& s) const \
|
|
||||||
{ \
|
|
||||||
return sprout::breed::detail::apply_transform< \
|
|
||||||
transform_type(Expr const&, State const&) \
|
|
||||||
>()(e, s, 0); \
|
|
||||||
} \
|
|
||||||
template<typename Expr, typename State, typename Data> \
|
|
||||||
SPROUT_CONSTEXPR typename sprout::breed::detail::apply_transform< \
|
|
||||||
transform_type(Expr const&, State const&, Data const&) \
|
|
||||||
>::result_type operator()(Expr&& e, State&& s, Data&& d) const { \
|
|
||||||
return sprout::breed::detail::apply_transform< \
|
|
||||||
transform_type(Expr const&, State const&, Data const&) \
|
|
||||||
>()(e, s, d); \
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// SPROUT_BREED_TRANSFORM
|
|
||||||
//
|
|
||||||
# define SPROUT_BREED_TRANSFORM(PrimitiveTransform) \
|
|
||||||
SPROUT_BREED_TRANSFORM_(PrimitiveTransform, void)
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template<typename Sig>
|
|
||||||
struct apply_transform;
|
|
||||||
template<typename PrimitiveTransform, typename Expr>
|
|
||||||
struct apply_transform<PrimitiveTransform(Expr)>
|
|
||||||
: public PrimitiveTransform::template impl<Expr, int, int>
|
|
||||||
{};
|
|
||||||
template<typename PrimitiveTransform, typename Expr, typename State>
|
|
||||||
struct apply_transform<PrimitiveTransform(Expr, State)>
|
|
||||||
: public PrimitiveTransform::template impl<Expr, State, int>
|
|
||||||
{};
|
|
||||||
template<typename PrimitiveTransform, typename Expr, typename State, typename Data>
|
|
||||||
struct apply_transform<PrimitiveTransform(Expr, State, Data)>
|
|
||||||
: public PrimitiveTransform::template impl<Expr, State, Data>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
//
|
|
||||||
// transform
|
|
||||||
//
|
|
||||||
template<typename PrimitiveTransform, typename X>
|
|
||||||
struct transform {
|
|
||||||
public:
|
|
||||||
SPROUT_BREED_TRANSFORM_(PrimitiveTransform, X);
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// transform_impl
|
|
||||||
//
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl {
|
|
||||||
public:
|
|
||||||
typedef Expr const expr;
|
|
||||||
typedef Expr const& expr_param;
|
|
||||||
typedef State const state;
|
|
||||||
typedef State const& state_param;
|
|
||||||
typedef Data const data;
|
|
||||||
typedef Data const& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr&, State, Data> {
|
|
||||||
public:
|
|
||||||
typedef Expr expr;
|
|
||||||
typedef Expr& expr_param;
|
|
||||||
typedef State const state;
|
|
||||||
typedef State const& state_param;
|
|
||||||
typedef Data const data;
|
|
||||||
typedef Data const& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr, State&, Data> {
|
|
||||||
public:
|
|
||||||
typedef Expr const expr;
|
|
||||||
typedef Expr const& expr_param;
|
|
||||||
typedef State state;
|
|
||||||
typedef State& state_param;
|
|
||||||
typedef Data const data;
|
|
||||||
typedef Data const& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr, State, Data&> {
|
|
||||||
public:
|
|
||||||
typedef Expr const expr;
|
|
||||||
typedef Expr const& expr_param;
|
|
||||||
typedef State const state;
|
|
||||||
typedef State const& state_param;
|
|
||||||
typedef Data data;
|
|
||||||
typedef Data& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr&, State&, Data> {
|
|
||||||
public:
|
|
||||||
typedef Expr expr;
|
|
||||||
typedef Expr& expr_param;
|
|
||||||
typedef State state;
|
|
||||||
typedef State& state_param;
|
|
||||||
typedef Data const data;
|
|
||||||
typedef Data const& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr&, State, Data&> {
|
|
||||||
public:
|
|
||||||
typedef Expr expr;
|
|
||||||
typedef Expr& expr_param;
|
|
||||||
typedef State const state;
|
|
||||||
typedef State const& state_param;
|
|
||||||
typedef Data data;
|
|
||||||
typedef Data& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr, State&, Data&> {
|
|
||||||
public:
|
|
||||||
typedef Expr const expr;
|
|
||||||
typedef Expr const& expr_param;
|
|
||||||
typedef State state;
|
|
||||||
typedef State& state_param;
|
|
||||||
typedef Data data;
|
|
||||||
typedef Data& data_param;
|
|
||||||
};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct transform_impl<Expr&, State&, Data&> {
|
|
||||||
public:
|
|
||||||
typedef Expr expr;
|
|
||||||
typedef Expr& expr_param;
|
|
||||||
typedef State state;
|
|
||||||
typedef State& state_param;
|
|
||||||
typedef Data data;
|
|
||||||
typedef Data& data_param;
|
|
||||||
};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_TRANSFORM_IMPL_HPP
|
|
|
@ -1,128 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_TRANSFORM_PASS_THROUGH_HPP
|
|
||||||
#define SPROUT_BREED_TRANSFORM_PASS_THROUGH_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/index_tuple/metafunction.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/args.hpp>
|
|
||||||
#include <sprout/breed/transform/impl.hpp>
|
|
||||||
#include <sprout/breed/detail/std_result_of.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
namespace detail {
|
|
||||||
template<
|
|
||||||
typename Grammar,
|
|
||||||
typename Expr,
|
|
||||||
typename State,
|
|
||||||
typename Data,
|
|
||||||
long Arity = sprout::breed::arity_of<Expr>::value
|
|
||||||
>
|
|
||||||
struct pass_through_impl
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename pass_through_impl::expr unref_expr;
|
|
||||||
private:
|
|
||||||
template<typename IndexTuple>
|
|
||||||
struct list_impl {};
|
|
||||||
template<sprout::index_t... Indexes>
|
|
||||||
struct list_impl<sprout::index_tuple<Indexes...> > {
|
|
||||||
public:
|
|
||||||
typedef sprout::breed::list<
|
|
||||||
typename Grammar::template breed_child<Indexes>::type::template impl<
|
|
||||||
typename sprout::breed::result_of::child_c<Expr, Indexes>::type,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
>::result_type...
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
typedef typename sprout::breed::base_expr<
|
|
||||||
typename unref_expr::breed_domain,
|
|
||||||
typename unref_expr::breed_tag,
|
|
||||||
typename list_impl<typename sprout::make_index_tuple<Arity>::type>::type
|
|
||||||
>::type expr_type;
|
|
||||||
typedef typename unref_expr::breed_generator breed_generator;
|
|
||||||
typedef typename sprout::breed::detail::std_result_of<
|
|
||||||
breed_generator(expr_type)
|
|
||||||
>::type result_type;
|
|
||||||
private:
|
|
||||||
template<sprout::index_t... Indexes>
|
|
||||||
SPROUT_CONSTEXPR result_type call_impl(
|
|
||||||
typename pass_through_impl::expr_param e,
|
|
||||||
typename pass_through_impl::state_param s,
|
|
||||||
typename pass_through_impl::data_param d,
|
|
||||||
sprout::index_tuple<Indexes...>
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return breed_generator()(
|
|
||||||
expr_type(
|
|
||||||
typename Grammar::template breed_child<Indexes>::type::template impl<
|
|
||||||
typename sprout::breed::result_of::child_c<Expr, Indexes>::type,
|
|
||||||
State,
|
|
||||||
Data
|
|
||||||
>()(e.proto_base().template child<Indexes>(), s, d)...
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(
|
|
||||||
typename pass_through_impl::expr_param e,
|
|
||||||
typename pass_through_impl::state_param s,
|
|
||||||
typename pass_through_impl::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return call_impl(e, s, d, sprout::make_index_tuple<Arity>::make());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename Grammar, typename Expr, typename State, typename Data>
|
|
||||||
struct pass_through_impl<Grammar, Expr, State, Data, 0>
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Expr result_type;
|
|
||||||
public:
|
|
||||||
#ifdef SPROUT_BREED_STRICT_RESULT_OF
|
|
||||||
SPROUT_CONSTEXPR result_type
|
|
||||||
#else
|
|
||||||
SPROUT_CONSTEXPR typename pass_through_impl::expr_param
|
|
||||||
#endif
|
|
||||||
operator()(
|
|
||||||
typename pass_through_impl::expr_param e,
|
|
||||||
typename pass_through_impl::state_param,
|
|
||||||
typename pass_through_impl::data_param
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
//
|
|
||||||
// pass_through
|
|
||||||
//
|
|
||||||
template<typename Grammar>
|
|
||||||
struct pass_through
|
|
||||||
: public sprout::breed::transform<sprout::breed::pass_through<Grammar> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::detail::pass_through_impl<Grammar, Expr, State, Data>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// is_callable
|
|
||||||
//
|
|
||||||
template<typename Grammar>
|
|
||||||
struct is_callable<sprout::breed::pass_through<Grammar> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_TRANSFORM_PASS_THROUGH_HPP
|
|
|
@ -1,126 +0,0 @@
|
||||||
#ifndef SPROUT_BREED_TRANSFORM_WHEN_HPP
|
|
||||||
#define SPROUT_BREED_TRANSFORM_WHEN_HPP
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
#include <sprout/config.hpp>
|
|
||||||
#include <sprout/type/type_tuple.hpp>
|
|
||||||
#include <sprout/type/iterator/deref.hpp>
|
|
||||||
#include <sprout/type/seq/algorithm/find_if.hpp>
|
|
||||||
#include <sprout/breed/breed_fwd.hpp>
|
|
||||||
#include <sprout/breed/traits.hpp>
|
|
||||||
#include <sprout/breed/transform/call.hpp>
|
|
||||||
#include <sprout/breed/transform/make.hpp>
|
|
||||||
#include <sprout/breed/transform/impl.hpp>
|
|
||||||
|
|
||||||
namespace sprout {
|
|
||||||
namespace breed {
|
|
||||||
//
|
|
||||||
// when
|
|
||||||
//
|
|
||||||
template<typename Grammar, typename PrimitiveTransform>
|
|
||||||
struct when
|
|
||||||
: public PrimitiveTransform
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Grammar first;
|
|
||||||
typedef PrimitiveTransform second;
|
|
||||||
typedef typename Grammar::breed_grammar breed_grammar;
|
|
||||||
};
|
|
||||||
template<typename Grammar, typename Fun>
|
|
||||||
struct when<Grammar, Fun*>
|
|
||||||
: public sprout::breed::when<Grammar, Fun>
|
|
||||||
{};
|
|
||||||
template<typename Grammar>
|
|
||||||
struct when<Grammar, sprout::breed::external_transform>
|
|
||||||
: public sprout::breed::transform<when<Grammar, sprout::breed::external_transform> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Grammar first;
|
|
||||||
typedef external_transform second;
|
|
||||||
typedef typename Grammar::breed_grammar breed_grammar;
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public Data::template when<Grammar>::template impl<Expr, State, Data>
|
|
||||||
{};
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl<Expr, State, Data&>
|
|
||||||
: public Data::template when<Grammar>::template impl<Expr, State, Data&>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
template<typename Grammar, typename R, typename... Args>
|
|
||||||
struct when<Grammar, R(Args...)>
|
|
||||||
: public sprout::breed::transform<when<Grammar, R(Args...)> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef Grammar first;
|
|
||||||
typedef R second(Args...);
|
|
||||||
typedef typename Grammar::breed_grammar breed_grammar;
|
|
||||||
public:
|
|
||||||
template<typename Expr, typename State, typename Data>
|
|
||||||
struct impl
|
|
||||||
: public sprout::breed::transform_impl<Expr, State, Data>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename std::conditional<
|
|
||||||
sprout::breed::is_callable<R>::value,
|
|
||||||
sprout::breed::call<R(Args...)>,
|
|
||||||
sprout::breed::make<R(Args...)>
|
|
||||||
>::type which;
|
|
||||||
typedef typename which::template impl<Expr, State, Data>::result_type result_type;
|
|
||||||
public:
|
|
||||||
SPROUT_CONSTEXPR result_type operator()(
|
|
||||||
typename impl::expr_param e,
|
|
||||||
typename impl::state_param s,
|
|
||||||
typename impl::data_param d
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return typename which::template impl<Expr, State, Data>()(e, s, d);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// is_callable
|
|
||||||
//
|
|
||||||
template<typename Grammar, typename Transform>
|
|
||||||
struct is_callable<sprout::breed::when<Grammar, Transform> >
|
|
||||||
: public std::true_type
|
|
||||||
{};
|
|
||||||
//
|
|
||||||
// otherwise
|
|
||||||
//
|
|
||||||
template<typename Fun>
|
|
||||||
struct otherwise
|
|
||||||
: public sprout::breed::when<sprout::breed::_, Fun>
|
|
||||||
{};
|
|
||||||
//
|
|
||||||
// external_transforms
|
|
||||||
//
|
|
||||||
template<typename... Args>
|
|
||||||
struct external_transforms {
|
|
||||||
public:
|
|
||||||
typedef sprout::types::type_tuple<Args...> map_type;
|
|
||||||
private:
|
|
||||||
template<typename Rule>
|
|
||||||
struct map_pred {
|
|
||||||
public:
|
|
||||||
template<typename T>
|
|
||||||
struct apply
|
|
||||||
: public std::is_same<Rule, typename T::first>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Rule>
|
|
||||||
struct when
|
|
||||||
: public sprout::breed::when<
|
|
||||||
sprout::breed::_,
|
|
||||||
sprout::types::deref<
|
|
||||||
typename sprout::types::find_if<map_type, map_pred<Rule> >::type
|
|
||||||
>::type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
} // namespace breed
|
|
||||||
} // namespace sprout
|
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_BREED_TRANSFORM_WHEN_HPP
|
|
Loading…
Add table
Reference in a new issue