C++ SFINAE not failing

I thought that nullptr_vt<decltype(std::declval<T>() + std::declval<T>())> from the first overload would be an error for not_addable and it would discard it from the overload set, thus choosing the second overload.

The idea is actually fine, the problem is just with GCC and nullptr_vt

This line:

nullptr_vt<decltype(std::declval<T>() + std::declval<T>())> TSfinae = nullptr

works where you don't want it to on GCC 10.2 but is correct on Clang 11.0.1. Changing it to

nullptr_vt<decltype(std::declval<T>() + std::declval<T>())> *TSfinae = nullptr

is correct on both, as are the simpler

typename TSfinae = nullptr_vt<decltype(std::declval<T>() + std::declval<T>())>
typename _ = decltype(std::declval<T>() + std::declval<T>())

And finally the make_void trick

template<typename... T> struct make_nullptr_vt { using type = nullptr_t; };

template<typename T>
using nullptr_vt = typename make_nullptr_vt<T>::type;

fixes the original version on GCC as well.