SpECTRE  v2024.04.12
Overloader< Fs > Struct Template Reference

Used for overloading lambdas, useful for lambda-SFINAE. More...

#include <Overloader.hpp>

Detailed Description

template<class... Fs>
struct Overloader< Fs >

Used for overloading lambdas, useful for lambda-SFINAE.

struct my_type1 {
int func(int a) { return 2 * a; }
};
struct my_type2 {};
template <class T, class = std::void_t<>>
struct has_func : std::false_type {};
template <class T>
struct has_func<
T, std::void_t<decltype(std::declval<T>().func(std::declval<int>()))>>
template <class T>
void func(T t) {
auto my_lambdas =
CHECK(static_cast<int>(has_func<T>::value) ==
(my_lambdas(t, std::integral_constant<bool, has_func<T>::value>{},
CHECK(2 + static_cast<int>(has_func<T>::value) ==
(my_lambdas(t, std::integral_constant<bool, has_func<T>::value>{},
}
void caller() {
func(my_type1{});
func(my_type2{});
}
constexpr T & value(T &t)
Returns t.value() if t is a std::optional otherwise returns t.
Definition: OptionalHelpers.hpp:32
Used for overloading lambdas, useful for lambda-SFINAE.
Definition: Overloader.hpp:17

The documentation for this struct was generated from the following file: