Suppose we have some SFINAE member function:
class foo{
template <class S, class = std::enable_if_t<std::is_integral<S>, S>
void bar(S&& s);
template <class S, class = std::enable_if_t<!std::is_integral<S>, S>
void bar(S&& s);
}
If we declared it as above, then how can we define them? Both of their function signatures would look like:
template <class S, class>
inline void foo::bar(S&& s){ ... do something ... }
I have seen examples where one returns an std::enable_if_t<...>
like:
template <class S, class>
decltype(auto) bar(S&& s) -> std::enable_if_t<!std::is_integral<S>, S>(...){
... do something ...
}
To disambiguate based off of the return type. But I don't want to return anything.
Aucun commentaire:
Enregistrer un commentaire