CWG727 allowed us to explicitly specialize inside the class scope itself as discussed in this post. But when I tried to explicitly specialize a conversion function, the specialization is rejected by three major compilers(gcc, clang and msvc). It's been 9+ years since this was changed and still the three major compilers reject this while only EDG accept it. Demo
struct S {
template
constexpr operator T()
{
return 10;
}
//rejected in all compilers except EDG
template<>
constexpr operator int()
{
return 4;
}
};
/*accepted in all compilers
template<>
constexpr S::operator int()
{
return 4;
}
*/
int main()
{
S s;
int i = s;
i++;
}
We have temp.spec:
An explicit specialization may be declared in any scope in which the corresponding primary template may be defined ([dcl.meaning], [class.mem], [temp.mem]).
So, is this just the implementations being too slow to implement this or is this actually ill-formed as per the latest c++ standard.