mercredi 18 novembre 2020

How to use sfinae to exclude types for which a function is defined?

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.

Aucun commentaire:

Enregistrer un commentaire