1#ifndef NEFORCE_CORE_INTERFACE_ICOMMON_HPP__
2#define NEFORCE_CORE_INTERFACE_ICOMMON_HPP__
13NEFORCE_BEGIN_NAMESPACE__
32 constexpr const T& derived()
const noexcept {
return static_cast<const T&
>(*this); }
41 NEFORCE_NODISCARD
constexpr size_t to_hash() const noexcept(noexcept(derived().
to_hash())) {
42 return derived().to_hash();
59 NEFORCE_NODISCARD
constexpr size_t operator()(
const T& obj)
const noexcept(
noexcept(obj.to_hash())) {
82 constexpr const T& derived()
const noexcept {
return static_cast<const T&
>(*this); }
92 NEFORCE_NODISCARD
constexpr bool operator==(
const T& rhs)
const noexcept(
noexcept(derived() == rhs)) {
93 return derived() == rhs;
103 NEFORCE_NODISCARD
constexpr bool operator!=(
const T& rhs)
const noexcept(
noexcept(!(*
this == rhs))) {
104 return !(*
this == rhs);
114 NEFORCE_NODISCARD
constexpr bool operator<(
const T& rhs)
const noexcept(
noexcept(derived() < rhs)) {
115 return derived() < rhs;
125 NEFORCE_NODISCARD
constexpr bool operator>(
const T& rhs)
const noexcept(
noexcept(rhs < derived())) {
126 return rhs < derived();
136 NEFORCE_NODISCARD
constexpr bool operator<=(
const T& rhs)
const noexcept(
noexcept(!(derived() > rhs))) {
137 return !(derived() > rhs);
147 NEFORCE_NODISCARD
constexpr bool operator>=(
const T& rhs)
const noexcept(
noexcept(!(derived() < rhs))) {
148 return !(derived() < rhs);
167NEFORCE_END_NAMESPACE__
typename enable_if< Test, T >::type enable_if_t
enable_if的便捷别名
NEFORCE_NODISCARD constexpr bool operator<(const T &rhs) const noexcept(noexcept(derived()< rhs))
小于比较运算符
NEFORCE_NODISCARD constexpr bool operator>=(const T &rhs) const noexcept(noexcept(!(derived()< rhs)))
大于等于比较运算符
NEFORCE_NODISCARD constexpr bool operator>(const T &rhs) const noexcept(noexcept(rhs< derived()))
大于比较运算符
NEFORCE_NODISCARD constexpr bool operator==(const T &rhs) const noexcept(noexcept(derived()==rhs))
相等比较运算符
NEFORCE_NODISCARD constexpr bool operator!=(const T &rhs) const noexcept(noexcept(!(*this==rhs)))
不等比较运算符
NEFORCE_NODISCARD constexpr bool operator<=(const T &rhs) const noexcept(noexcept(!(derived() > rhs)))
小于等于比较运算符
NEFORCE_NODISCARD constexpr size_t to_hash() const noexcept(noexcept(derived().to_hash()))
获取对象的哈希值