The following example:
#include <iostream>
template<typename T>
struct X {
static constexpr bool B = std::is_same_v<T, int>;
template <bool Z = B, std::enable_if_t<Z, int> = 0>
X(T t) { std::cout << t << " - int\n"; }
template <bool Z = B, std::enable_if_t<!Z, int> = 0>
X(T t) { std::cout << t << " - not int\n"; }
};
int main()
{
X x(5);
X y(5.0);
}
Results in an ambiguous deduction error when compiled using clang++ (I tried up to 11.0) with -std=c++1z. Compilation terminates successfully with g++ 9.3.0.
Who is right? Why? Is there a bug associated with this?