endian: use three-way comparison for endian types

This commit is contained in:
Danny Robson 2020-03-21 13:17:18 +11:00
parent 272e8f286a
commit a69df0ae02

View File

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
* *
* Copyright 2010-2019 Danny Robson <danny@nerdcruft.net> * Copyright 2010-2020, Danny Robson <danny@nerdcruft.net>
*/ */
#pragma once #pragma once
@ -12,11 +12,11 @@
#include "types/bits.hpp" #include "types/bits.hpp"
#include "cast.hpp" #include "cast.hpp"
#include <cstring> #include <compare>
#include <cstdint> #include <cstdint>
#include <type_traits> #include <cstring>
#include <iosfwd> #include <iosfwd>
#include <type_traits>
namespace cruft { namespace cruft {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -252,21 +252,27 @@ namespace cruft {
RawT raw; RawT raw;
}; };
template <scheme StorageV, typename RawT, typename OperandT>
constexpr decltype(auto) operator== (value<StorageV,RawT> const &a, OperandT const &b)
{
return a.native () == b;
}
template <scheme StorageV, typename RawT, typename OperandT> template <scheme StorageV, typename RawT, typename OperandT>
constexpr decltype(auto) operator== (OperandT const &a, value<StorageV,RawT> const &b) constexpr decltype(auto)
operator<=> (value<StorageV,RawT> const &a, OperandT const &b)
{ {
return a == b.native (); return a.native () <=> b;
}
template <scheme StorageV, typename RawT, typename OperandT>
constexpr decltype(auto)
operator<=> (OperandT const &a, value<StorageV,RawT> const &b)
{
return a <=> b.native ();
} }
template <typename ValueT> using little = value<scheme::little,ValueT>; template <typename ValueT> using little = value<scheme::little,ValueT>;
template <typename ValueT> using big = value<scheme::big ,ValueT>; template <typename ValueT>
using big = value<scheme::big,ValueT>;
template <scheme StorageV, typename ValueT> template <scheme StorageV, typename ValueT>