3#ifndef DUNE_COMMON_OVERLOADSET_HH
4#define DUNE_COMMON_OVERLOADSET_HH
9#include <dune/common/std/type_traits.hh>
17#if __cpp_variadic_using >= 201611
19 template<
typename... F>
26 template<
typename... FF>
27 OverloadSet(FF&&... ff)
28 : F(
std::forward<FF>(ff))...
31 using F::operator()...;
41 template<
class F0,
class... F>
42 class OverloadSet:
public OverloadSet<F...>, F0
44 using Base = OverloadSet<F...>;
47 template<
class FF0,
class... FF>
48 OverloadSet(FF0&& f0, FF&&... ff) :
49 Base(
std::forward<FF>(ff)...),
50 F0(
std::forward<FF0>(f0))
55 using Base::operator();
59 class OverloadSet<F0>:
public F0
64 OverloadSet(FF0&& f0) :
65 F0(
std::forward<FF0>(f0))
111 return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
118 template<
class F0,
class... F>
119 class OrderedOverloadSet:
public OrderedOverloadSet<F...>, F0
121 using Base = OrderedOverloadSet<F...>;
124 template<
class FF0,
class... FF>
125 OrderedOverloadSet(FF0&& f0, FF&&... ff) :
126 Base(
std::forward<FF>(ff)...),
127 F0(
std::forward<FF0>(f0))
131 template<
class... Args,
132 std::enable_if_t<Std::is_callable<F0(Args&&...)>::value,
int> = 0>
133 decltype(
auto)
operator()(Args&&... args)
135 return F0::operator()(std::forward<Args>(args)...);
141 template<
class... Args,
142 std::enable_if_t< not Std::is_callable<F0(Args&&...)>::value,
int> = 0>
143 decltype(
auto)
operator()(Args&&... args)
145 return Base::operator()(std::forward<Args>(args)...);
151 class OrderedOverloadSet<F0>:
public F0
156 OrderedOverloadSet(FF0&& f0) :
157 F0(
std::forward<FF0>(f0))
162 template<
class... Args>
163 decltype(
auto)
operator()(Args&&... args)
165 static_assert(Std::is_callable<F0(Args&&...)>::value,
"No matching overload found in OrderedOverloadSet");
166 return F0::operator()(std::forward<Args>(args)...);
205 return Impl::OrderedOverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
auto orderedOverload(F &&... f)
Create an ordered overload set.
Definition: overloadset.hh:203
auto overload(F &&... f)
Create an overload set.
Definition: overloadset.hh:109
Dune namespace.
Definition: alignedallocator.hh:14