3#ifndef DUNE_COMMON_OVERLOADSET_HH
4#define DUNE_COMMON_OVERLOADSET_HH
14 template<
typename... F>
21 template<
typename... FF>
22 OverloadSet(FF&&... ff)
23 : F(
std::forward<FF>(ff))...
26 using F::operator()...;
61 return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
68 template<
class F0,
class... F>
69 class OrderedOverloadSet:
public OrderedOverloadSet<F...>, F0
71 using Base = OrderedOverloadSet<F...>;
74 template<
class FF0,
class... FF>
75 OrderedOverloadSet(FF0&& f0, FF&&... ff) :
76 Base(
std::forward<FF>(ff)...),
77 F0(
std::forward<FF0>(f0))
81 template<
class... Args,
82 std::enable_if_t<IsCallable<F0(Args&&...)>::value,
int> = 0>
83 decltype(
auto)
operator()(Args&&... args)
85 return F0::operator()(std::forward<Args>(args)...);
91 template<
class... Args,
92 std::enable_if_t<not IsCallable<F0(Args&&...)>::value,
int> = 0>
93 decltype(
auto)
operator()(Args&&... args)
95 return Base::operator()(std::forward<Args>(args)...);
101 class OrderedOverloadSet<F0>:
public F0
106 OrderedOverloadSet(FF0&& f0) :
107 F0(
std::forward<FF0>(f0))
112 template<
class... Args>
113 decltype(
auto)
operator()(Args&&... args)
115 static_assert(IsCallable<F0(Args&&...)>::value,
116 "No matching overload found in OrderedOverloadSet");
117 return F0::operator()(std::forward<Args>(args)...);
150 return Impl::OrderedOverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
Traits for type conversions and type information.
auto orderedOverload(F &&... f)
Create an ordered overload set.
Definition: overloadset.hh:148
auto overload(F &&... f)
Create an overload set.
Definition: overloadset.hh:59
Dune namespace.
Definition: alignedallocator.hh:11