21 #ifndef RFFGEN_UTIL_EVALUATE_IF_PRESENT_HH
22 #define RFFGEN_UTIL_EVALUATE_IF_PRESENT_HH
24 #include <type_traits>
33 template <
class X,
bool Xpresent>
34 struct EvaluateIfPresentImpl
36 static constexpr
bool present =
false;
37 EvaluateIfPresentImpl(X
const&){}
41 struct EvaluateIfPresentImpl<X,true>
43 using ReturnType = std::add_const_t<decltype(std::declval<X>()())>;
44 static constexpr
bool present =
true;
46 EvaluateIfPresentImpl(X
const& x) : value(x())
49 ReturnType operator()()
const
61 struct EvaluateIfPresent :
public Detail::EvaluateIfPresentImpl<X,X::present>
63 EvaluateIfPresent(X
const& x) : Detail::EvaluateIfPresentImpl<X,X::present> (x)
66 template <
class... Args>
67 EvaluateIfPresent(
const Args&... args) : EvaluateIfPresent( X(args...) )
75 #endif // RFFGEN_UTIL_EVALUATE_IF_PRESENT_HH