Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added `gval` (enforces lazy evaluation)

  • Loading branch information...
commit 7373aef27f23cee57e8bdb77c166c2a3721602fb 1 parent b361e0e
Dominik Charousset authored

Showing 1 changed file with 21 additions and 0 deletions. Show diff stats Hide diff stats

  1. +21 0 cppa/guard_expr.hpp
21 cppa/guard_expr.hpp
@@ -338,6 +338,14 @@ struct guard_placeholder {
338 338
339 339 };
340 340
  341 +template<typename T>
  342 +struct ge_value {
  343 + T value;
  344 +};
  345 +
  346 +template<typename T>
  347 +ge_value<T> gval(T val) { return {std::move(val)}; }
  348 +
341 349 // result type computation
342 350
343 351 template<typename T, class Tuple>
@@ -352,6 +360,9 @@ struct ge_unbound<std::reference_wrapper<T>, Tuple> { typedef T type; };
352 360 template<typename T, class Tuple>
353 361 struct ge_unbound<std::reference_wrapper<const T>, Tuple> { typedef T type; };
354 362
  363 +template<typename T, class Tuple>
  364 +struct ge_unbound<ge_value<T>, Tuple> { typedef T type; };
  365 +
355 366 // unbound type of placeholder
356 367 template<int X, typename... Ts>
357 368 struct ge_unbound<guard_placeholder<X>, detail::tdata<Ts...> > {
@@ -386,6 +397,11 @@ struct is_ge_type<guard_expr<OP, First, Second> > {
386 397 static constexpr bool value = true;
387 398 };
388 399
  400 +template<typename T>
  401 +struct is_ge_type<ge_value<T>> {
  402 + static constexpr bool value = true;
  403 +};
  404 +
389 405 template<operator_id OP, typename T1, typename T2>
390 406 guard_expr<OP, typename detail::strip_and_convert<T1>::type,
391 407 typename detail::strip_and_convert<T2>::type>
@@ -516,6 +532,11 @@ inline const T& ge_resolve(const Tuple&, const util::rebindable_reference<const
516 532 return value.get();
517 533 }
518 534
  535 +template<class Tuple, typename T>
  536 +inline const T& ge_resolve(const Tuple&, const ge_value<T>& wrapped_value) {
  537 + return wrapped_value.value;
  538 +}
  539 +
519 540 template<class Tuple, int X>
520 541 inline auto ge_resolve(const Tuple& tup, guard_placeholder<X>)
521 542 -> decltype(get<X>(tup).get()) {

0 comments on commit 7373aef

Please sign in to comment.
Something went wrong with that request. Please try again.