Considering how the comma expression in a decltype()
trailing return type can be used to check if a function can be applied:
template <class A>
auto f(A a) -> decltype(check_if_possible(a), return_type(a))
How can I negate the part before the comma to exclude cases in which check_if_possible(a)
is defined?
Context:
f()
is an overloaded function for different A
. I want to resolve an ambiguous overload between two implementations. One of them uses check_if_possible(a)
, the other works in cases where this cannot be applied to a
.
Edit:
Using std::enable_if
and related things is welcome as well, but I would like to avoid additional helper functions / templates, because there are several functions similar to f()
with different enable criteria.
If this is not possible, then that is an answer as well ;)
requires
. – Impudicity