In template meta programming, one can use SFINAE on the return type to choose a certain template member function, i.e.
template struct
The accepted answer is good for most cases, but fails if two such constructor overloads with different conditions are present. I'm looking for a solution in that case too.
Yes: the accepted solution works but not for two alternative constructor as, by example,
template ::type>
explicit A(A const &);
template ::type>
explicit A(A const &);
because, as stated in this page,
A common mistake is to declare two function templates that differ only in their default template arguments. This is illegal because default template arguments are not part of function template's signature, and declaring two different function templates with the same signature is illegal.
As proposed in the same page, you can go around this problem applying SFINAE, modifying the signature, to the type of a value (not type) template parameter as follows
template ::type = true>
explicit A(A const &);
template ::type = true>
explicit A(A const &);