Permalink
Browse files

compile-time perf tweaks to various utility metafunctions from dave a…

…., guard more calls with try_call, s/sfinae_error/substitution_failure/
  • Loading branch information...
1 parent 4f1efce commit c8d6d2bc0529c0a85d9deb08464fffa22b28a7a3 @ericniebler committed Aug 22, 2012
View
@@ -1,18 +1,18 @@
Implement proper lexical scoping for let expressions.
- - Can the call action be modified to automatically create a proper lexical scope?
+ - Can the call action be modified to automatically create a proper lexical scope?
Think about basic actions.
- - Is the interface correct?
- - Maybe the environment should be the second parameter and state should be third.
- - Should the local variable scope be part of the environment, or should it be a
- fourth parameter?
- - Should *all* environment variables be part of a scope? Should we allow
- non-environments in the environments parameter as Proto-current does?
+ - Is the interface correct?
+ - Maybe the environment should be the second parameter and state should be third.
+ - Should the local variable scope be part of the environment, or should it be a
+ fourth parameter?
+ - Should *all* environment variables be part of a scope? Should we allow
+ non-environments in the environments parameter as Proto-current does?
Thoughts about construct(foo<some_action<int>>())
- - It doesn't invoke some_action. Should it? With what semantics? Is it right to be looking
- for a nested ::type after substitution, or should it be checking for action-ness instead
- (or in addtion to)? What would that break?
+ - It doesn't invoke some_action. Should it? With what semantics? Is it right to be looking
+ for a nested ::type after substitution, or should it be checking for action-ness instead
+ (or in addtion to)? What would that break?
How about a static_cast_ function object?
@@ -26,3 +26,11 @@ Should or_/when be renamed match/case_?
Everyplace where we directly return an rvalue reference is potentially creating a dangling
reference.
+
+Crazy thought: what if the tags (e.g. proto::plus) were aliases for proto::op
+(proto::op<proto::some_plus_tag>). It could be used in actions to add stuff, and an action
+like plus(transform(_left), transform(_right)) would find proto's overloaded operator+
+and naturally be like the pass-through transform.
+ - Problem: plus(transform, transform) wouldn't be "right" since it would apply transform
+ twice to the current expression and build a plus node out of that instead of out of the
+ transformed children.
@@ -36,7 +36,7 @@ namespace boost
template<typename ...Args>
auto operator()(Args &&... args) const
BOOST_PROTO_AUTO_RETURN(
- utility::back(
+ BOOST_PROTO_TRY_CALL(utility::functional::back())(
(action<Actions>()(static_cast<Args &&>(args)...), utility::void_)...
)
)
@@ -29,7 +29,7 @@ namespace boost
template<typename ...Args>
auto operator()(Args &&... args) const
BOOST_PROTO_AUTO_RETURN(
- detail::call_1_<Actions...>()(
+ BOOST_PROTO_TRY_CALL(detail::call_1_<Actions...>())(
action<Fun>()(static_cast<Args &&>(args)...)
, static_cast<Args &&>(args)...
)
@@ -72,10 +72,10 @@ namespace boost
>
auto operator()(Action &&act, Args &&... args) const
BOOST_PROTO_AUTO_RETURN(
- call_2_<
+ BOOST_PROTO_TRY_CALL(call_2_<
(sizeof...(Args) <= sizeof...(Actions))
, decltype(action<Actions>()(static_cast<Args &&>(args)...))...
- >()(
+ >())(
static_cast<Action &&>(act)
, action<Actions>()(static_cast<Args &&>(args)...)...
, static_cast<Args &&>(args)...
@@ -138,7 +138,7 @@ namespace boost
auto operator()(Expr && expr, Rest &&... rest) const
BOOST_PROTO_AUTO_RETURN(
this->impl(
- utility::make_indices<0, arity_of<Expr>::value>()
+ utility::make_indices<arity_of<Expr>::value>()
, static_cast<Expr &&>(expr)
, static_cast<Rest &&>(rest)...
)
@@ -17,8 +17,6 @@ namespace boost
{
namespace proto
{
- // TODO: I think this implementation allows non-local scope variables to be
- // accessed from with the action of other let statements. That would be a bug.
namespace detail
{
template<typename Local>
@@ -92,7 +92,7 @@ namespace boost
auto operator()(E && e, Rest &&... rest) const
BOOST_PROTO_AUTO_RETURN(
detail::pass_through_0_<
- utility::make_indices<0, arity_of<E>::value>
+ utility::make_indices<arity_of<E>::value>
, Actions
>()(static_cast<E &&>(e), static_cast<Rest &&>(rest)...)
)
@@ -106,7 +106,7 @@ namespace boost
: std::conditional<
Arity0 == 0
, utility::indices<(std::size_t)-1>
- , utility::make_indices<0, Arity0>
+ , utility::make_indices<Arity0>
>
{
static_assert(
@@ -52,10 +52,10 @@ namespace boost
: domain_<not_a_domain>
{};
- utility::sized_type<1>::type default_test(void*, void*);
- utility::sized_type<2>::type default_test(domain_<default_domain>*, void*);
- utility::sized_type<3>::type default_test(void*, domain_<default_domain>*);
- utility::sized_type<4>::type default_test(domain_<default_domain>*, domain_<default_domain>*);
+ utility::sized_type<1> default_test(void*, void*);
+ utility::sized_type<2> default_test(domain_<default_domain>*, void*);
+ utility::sized_type<3> default_test(void*, domain_<default_domain>*);
+ utility::sized_type<4> default_test(domain_<default_domain>*, domain_<default_domain>*);
////////////////////////////////////////////////////////////////////////////////////////
// common_domain2
@@ -25,7 +25,7 @@ namespace boost
template<typename Expr, typename Cases>
struct matches<Expr, proto::switch_(Cases)>
: matches<
- Expr
+ Expr
, typename Cases::template case_<typename tag_of<Expr>::type>
>
{};
View
@@ -97,6 +97,9 @@ namespace boost
{
typedef void type;
};
+
+ template<typename Ignored = void>
+ struct any;
}
namespace utility
@@ -108,7 +111,7 @@ namespace boost
////////////////////////////////////////////////////////////////////////////////////////
// any
- struct any;
+ typedef detail::any<> any;
////////////////////////////////////////////////////////////////////////////////////////
// static_const
@@ -123,12 +126,12 @@ namespace boost
////////////////////////////////////////////////////////////////////////////////////////
// sized_type
template<int N>
- struct sized_type;
+ using sized_type = char(&)[N];
////////////////////////////////////////////////////////////////////////////////////////
- // sfinae_error
+ // substitution_failure
template<typename Sig>
- struct sfinae_error;
+ struct substitution_failure;
}
///////////////////////////////////////////////////////////////////////////////
View
@@ -173,13 +173,13 @@ namespace boost
// Abstract expression tags
struct nullary_expr
{};
-
+
struct unary_expr
{};
-
+
struct binary_expr
{};
-
+
struct nary_expr
{};
@@ -222,22 +222,22 @@ namespace boost
// Miscelaneous tags
struct or_
{};
-
+
struct not_
{};
-
+
struct and_
{};
-
+
struct if_
{};
-
+
struct switch_
{};
-
+
struct when
{};
-
+
struct match
{};
Oops, something went wrong.

0 comments on commit c8d6d2b

Please sign in to comment.