Clang compiles this fine, but GCC and MSVC complain that operator=
cannot be defaulted:
#include <type_traits>
template<class T>
struct S
{
typedef typename std::enable_if<!std::is_enum<T>::value, S>::type Me;
S &operator=(Me const &) = default;
};
int main()
{
S<int> s1, s2;
s1 = s2;
}
Is this code legal? If not, would it be legal if Me
had been defined as typedef S Me;
?
Given the lack of any indications to the contrary, I'm going to answer my own question and say that, as far as I've been able to find relevant clauses in the standard, I think the code is legal and thus GCC and MSVC are complaining erroneously.
As someone pointed out above, there appears to be a bug report tracking this issue.