endian: use three-way comparison for endian types
This commit is contained in:
parent
272e8f286a
commit
a69df0ae02
30
endian.hpp
30
endian.hpp
@ -3,7 +3,7 @@
|
||||
* 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/.
|
||||
*
|
||||
* Copyright 2010-2019 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2010-2020, Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -12,11 +12,11 @@
|
||||
#include "types/bits.hpp"
|
||||
#include "cast.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <compare>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
#include <cstring>
|
||||
#include <iosfwd>
|
||||
#include <type_traits>
|
||||
|
||||
namespace cruft {
|
||||
//-------------------------------------------------------------------------
|
||||
@ -252,21 +252,27 @@ namespace cruft {
|
||||
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>
|
||||
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 big = value<scheme::big ,ValueT>;
|
||||
template <typename ValueT>
|
||||
using big = value<scheme::big,ValueT>;
|
||||
|
||||
|
||||
|
||||
template <scheme StorageV, typename ValueT>
|
||||
|
Loading…
Reference in New Issue
Block a user