|
|
|
|
|
by account42
1757 days ago
|
|
> The above definition of add is equivalent to the one using static_assert. They are not though - the equivalent C++17 would be template<typename T>
std::enable_if_t<std::is_intregral_v<T>, T> add(T a, T b)
{
return a + b;
}
The difference is that these make the function unavailable for overload resolution for non-integral T but another implementation might still cover them while the static_assert version leaves the function available for overload resolution but then errors if it is selected. |
|