The principle of SFINAE is that if the substitution of the calculated template argument leads to poorly formed code, then this function template is reset from the set overload resolution, instead of causing a hard error.
In your case, there is no template argument output or replacement, so you get compilation errors. All you need is
constexpr static size_t defaultSize = is_same<size_t, uint32_t>::value ? (( (size_t) 1 << 30 ) / 2 * 5) : numeric_limits<size_t>::max() / 2;
For curiosity, if you want to use SFINAE, you can do something like this
namespace detail { template<typename T, typename enable_if<is_same<T, uint32_t>::value,void*>::type = nullptr> constexpr static const T defaultSizeHelper(T) { return ( (size_t) 1 << 30 ) / 2 * 5;
source share