Commit 7373aef2 authored by Dominik Charousset's avatar Dominik Charousset

added `gval` (enforces lazy evaluation)

parent b361e0e7
...@@ -338,6 +338,14 @@ struct guard_placeholder { ...@@ -338,6 +338,14 @@ struct guard_placeholder {
}; };
template<typename T>
struct ge_value {
T value;
};
template<typename T>
ge_value<T> gval(T val) { return {std::move(val)}; }
// result type computation // result type computation
template<typename T, class Tuple> template<typename T, class Tuple>
...@@ -352,6 +360,9 @@ struct ge_unbound<std::reference_wrapper<T>, Tuple> { typedef T type; }; ...@@ -352,6 +360,9 @@ struct ge_unbound<std::reference_wrapper<T>, Tuple> { typedef T type; };
template<typename T, class Tuple> template<typename T, class Tuple>
struct ge_unbound<std::reference_wrapper<const T>, Tuple> { typedef T type; }; struct ge_unbound<std::reference_wrapper<const T>, Tuple> { typedef T type; };
template<typename T, class Tuple>
struct ge_unbound<ge_value<T>, Tuple> { typedef T type; };
// unbound type of placeholder // unbound type of placeholder
template<int X, typename... Ts> template<int X, typename... Ts>
struct ge_unbound<guard_placeholder<X>, detail::tdata<Ts...> > { struct ge_unbound<guard_placeholder<X>, detail::tdata<Ts...> > {
...@@ -386,6 +397,11 @@ struct is_ge_type<guard_expr<OP, First, Second> > { ...@@ -386,6 +397,11 @@ struct is_ge_type<guard_expr<OP, First, Second> > {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template<typename T>
struct is_ge_type<ge_value<T>> {
static constexpr bool value = true;
};
template<operator_id OP, typename T1, typename T2> template<operator_id OP, typename T1, typename T2>
guard_expr<OP, typename detail::strip_and_convert<T1>::type, guard_expr<OP, typename detail::strip_and_convert<T1>::type,
typename detail::strip_and_convert<T2>::type> typename detail::strip_and_convert<T2>::type>
...@@ -516,6 +532,11 @@ inline const T& ge_resolve(const Tuple&, const util::rebindable_reference<const ...@@ -516,6 +532,11 @@ inline const T& ge_resolve(const Tuple&, const util::rebindable_reference<const
return value.get(); return value.get();
} }
template<class Tuple, typename T>
inline const T& ge_resolve(const Tuple&, const ge_value<T>& wrapped_value) {
return wrapped_value.value;
}
template<class Tuple, int X> template<class Tuple, int X>
inline auto ge_resolve(const Tuple& tup, guard_placeholder<X>) inline auto ge_resolve(const Tuple& tup, guard_placeholder<X>)
-> decltype(get<X>(tup).get()) { -> decltype(get<X>(tup).get()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment