5#ifndef DUNE_COMMON_OVERLOADSET_HH
6#define DUNE_COMMON_OVERLOADSET_HH
16 template<
typename... F>
23 template<
typename... FF>
24 OverloadSet(FF&&... ff)
25 : F(
std::forward<FF>(ff))...
28 using F::operator()...;
63 return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
70 template<
class F0,
class... F>
71 class OrderedOverloadSet:
public OrderedOverloadSet<F...>, F0
73 using Base = OrderedOverloadSet<F...>;
76 template<
class FF0,
class... FF>
77 OrderedOverloadSet(FF0&& f0, FF&&... ff) :
78 Base(
std::forward<FF>(ff)...),
79 F0(
std::forward<FF0>(f0))
83 template<
class... Args,
84 std::enable_if_t<IsCallable<F0(Args&&...)>::value,
int> = 0>
85 decltype(
auto)
operator()(Args&&... args)
87 return F0::operator()(std::forward<Args>(args)...);
93 template<
class... Args,
94 std::enable_if_t<not IsCallable<F0(Args&&...)>::value,
int> = 0>
95 decltype(
auto)
operator()(Args&&... args)
97 return Base::operator()(std::forward<Args>(args)...);
103 class OrderedOverloadSet<F0>:
public F0
108 OrderedOverloadSet(FF0&& f0) :
109 F0(
std::forward<FF0>(f0))
114 template<
class... Args>
115 decltype(
auto)
operator()(Args&&... args)
117 static_assert(IsCallable<F0(Args&&...)>::value,
118 "No matching overload found in OrderedOverloadSet");
119 return F0::operator()(std::forward<Args>(args)...);
152 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:150
auto overload(F &&... f)
Create an overload set.
Definition: overloadset.hh:61
Dune namespace.
Definition: alignedallocator.hh:13