This is from an example from a tutorial on std::enable_if.
Here is more context:
// handle signed types
template<typename Int>
auto incr1(Int& target, Int amount)
-> std::void_t<int[static_cast<Int>(-1) < static_cast<Int>(0)]>;
- Shouldn't
std::void_tbe accepting a type as template argument? - What is the purpose of
int[]in this context?
If
static_cast<Int>(-1) < static_cast<Int>(0)yieldstrue,int[static_cast<Int>(-1) < static_cast<Int>(0)]leads toint[1](truecould be converted toint(and thenstd::size_t) implicitly with value1), which is an array type.If
static_cast<Int>(-1) < static_cast<Int>(0)yieldsfalse,int[static_cast<Int>(-1) < static_cast<Int>(0)]leads toint[0](falsecould be converted toint(and thenstd::size_t) implicitly with value0), which is an invalid array type and SFINAE would discard the specialization from the overload set. (The size of array must be greater than zero (unless using in new[]-expression)).