Without the message, the compiler output can be very short, e.g. as short as a `required from here`. If the output includes the line of code that trigges the static_assert, the user might interpret it as "must be a standard integer", which is incorrect, because that term doesn't cover extended integers.
This commit adds a diagnostic message that states that the template argument must be a signed or unsigned integer. libstdc++-v3/ChangeLog: * include/std/utility (cmp_equal): Add message to the static_assert. (cmp_less): Ditto. (in_range): Ditto. --- libstdc++-v3/include/std/utility | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index 8a85ccfd09b..8a79ee9cc21 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -133,8 +133,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { - static_assert(__is_standard_integer<_Tp>::value); - static_assert(__is_standard_integer<_Up>::value); + static_assert(__is_standard_integer<_Tp>::value, + "T must be a signed or unsigned integer"); + static_assert(__is_standard_integer<_Up>::value, + "U must be a signed or unsigned integer"); if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) return __t == __u; @@ -153,8 +155,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { - static_assert(__is_standard_integer<_Tp>::value); - static_assert(__is_standard_integer<_Up>::value); + static_assert(__is_standard_integer<_Tp>::value, + "T must be a signed or unsigned integer"); + static_assert(__is_standard_integer<_Up>::value, + "U must be a signed or unsigned integer"); if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) return __t < __u; @@ -183,8 +187,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr bool in_range(_Tp __t) noexcept { - static_assert(__is_standard_integer<_Res>::value); - static_assert(__is_standard_integer<_Tp>::value); + static_assert(__is_standard_integer<_Res>::value, + "R must be a signed or unsigned integer"); + static_assert(__is_standard_integer<_Tp>::value, + "T must be a signed or unsigned integer"); using __gnu_cxx::__int_traits; if constexpr (is_signed_v<_Tp> == is_signed_v<_Res>) -- 2.49.0