is_assignable<T,U>
is true if:
The expression declval<T>() = declval<U>()
is well-formed
declval<T>
is declared as a function returning a reference to T
:
template <class T>
typename add_rvalue_reference<T>::type declval() noexcept;
where add_rvalue_reference<T>::type
is an rvalue reference type (T&&
) if T
is an object or function type, or T
itself if it is a reference type.
This means that is_assignable<T,U>
can only be true if T
is a non-const lvalue reference type. If it's an object type, then add_rvalue_reference<T>::type
is an rvalue reference type; so the expression declval<T>()
is an xvalue, which cannot be assigned to.
So, unless I've misread the standard, GCC is correct and VS2012 is wrong. Even if it might seem to make more sense for is_assignable<int,int>
to be true, it is not.