xtd 0.2.0
comparison_operators.hpp
Go to the documentation of this file.
1
4#pragma once
5#define __XTD_STD_INTERNAL__
7#undef __XTD_STD_INTERNAL__
8#include <compare>
9
11namespace xtd {
13 namespace extensions {
30 template<class type_t, class comparable_t>
31 class comparison_operators {
32 public:
34
40 friend bool operator <(const type_t& lhs, const type_t& rhs) noexcept {return lhs.compare_to(rhs) < 0;}
41
46 friend bool operator <=(const type_t& lhs, const type_t& rhs) noexcept {return lhs.compare_to(rhs) <= 0;}
47
52 friend bool operator >(const type_t& lhs, const type_t& rhs) noexcept {return lhs.compare_to(rhs) > 0;}
53
58 friend bool operator >=(const type_t& lhs, const type_t& rhs) noexcept {return lhs.compare_to(rhs) >= 0;}
59
67 friend std::strong_ordering operator <=>(const type_t& lhs, const type_t& rhs) noexcept {
68 if (lhs.compare_to(rhs) < 0) return std::strong_ordering::less;
69 if (lhs.compare_to(rhs) > 0) return std::strong_ordering::greater;
70 return std::strong_ordering::equivalent;
71 }
72
73
74 private:
75 friend comparable_t;
76 comparison_operators() = default;
77 };
78 }
79}
Contains __xtd_std_version definitions.
Internal comparable operators definition.
Definition comparison_operators.hpp:31
friend std::strong_ordering operator<=>(const type_t &lhs, const type_t &rhs) noexcept
Three-way comparison operator with specidied lhs ans rhs values.
Definition comparison_operators.hpp:67
friend bool operator<(const type_t &lhs, const type_t &rhs) noexcept
Less than comparison operator with specidied lhs ans rhs values.
Definition comparison_operators.hpp:40
friend bool operator>=(const type_t &lhs, const type_t &rhs) noexcept
Less than comparison operator with specidied lhs ans rhs values.
Definition comparison_operators.hpp:58
friend bool operator<=(const type_t &lhs, const type_t &rhs) noexcept
Less than or equal to comparison operator with specidied lhs ans rhs values.
Definition comparison_operators.hpp:46
friend bool operator>(const type_t &lhs, const type_t &rhs) noexcept
Greater than or equal to comparison operator with specidied lhs ans rhs values.
Definition comparison_operators.hpp:52
The xtd::extensions namespace contains interface extensions.
Definition comparison_operators.hpp:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8