C++ Logo

std-discussion

Advanced search

Overloading standard functions cmp_equal, cmp_not_equal, cmp_less, cmp_greater, cmp_less_equal, cmp_greater_equal

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Sat, 23 Nov 2024 00:48:13 +0300
Could standard functions cmp_equal, cmp_not_equal, cmp_less, cmp_greater, cmp_less_equal, cmp_greater_equal be overloaded for enumerations?
 
Something like for example
 
template <typename T, typename U>
requires std::is_enum_v<T> && std::is_same_v<T, U>
constexpr bool cmp_less( T t, U u ) noexcept
{
    return std::to_underlying( t ) < std::to_underlying( u );
}
 
With best regards,
Vlad from Moscow
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2024-11-22 21:48:29