Здравствуйте, Sm0ke, Вы писали:
S>Вот они сделали, что std::strong_ordering::equal и прочие нельзя было запихнуть в switch case.
Ага, было
http://rsdn.org/forum/cpp/7733292Автор: Шахтер
Дата: 18.05.20
S>Но это не проблема, пишем враппер!
S>
S>template <typename Result>
S>constexpr Result cast_ordering(std::strong_ordering from) {
S> using t_from = decltype(from);
S> return from == t_from::less ? Result::less : (
S> from == t_from::greater ? Result::greater : Result::equal_strong
S> );
S>}
S>template <typename Result>
S>constexpr Result cast_ordering(std::weak_ordering from) {
S> using t_from = decltype(from);
S> return from == t_from::less ? Result::less : (
S> from == t_from::greater ? Result::greater : Result::equal_weak
S> );
S>}
В таком врапере следует постараться, чтобы значения энамов совпадали с внутреним представлением std::strong_ordering / std::weak_ordering, чтобы касты выродились максимально в пустышку.
Как-то подобрать underlying type равный по размеру std::strong_ordering / std::weak_ordering и бит кастами получить значения.