mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add sprout::optional
This commit is contained in:
parent
9b9956f810
commit
8cb432dee1
15 changed files with 574 additions and 81 deletions
49
sprout/optional/comparison.hpp
Normal file
49
sprout/optional/comparison.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef SPROUT_OPTIONAL_COMPARISON_HPP
|
||||
#define SPROUT_OPTIONAL_COMPARISON_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/optional/optional.hpp>
|
||||
#include <sprout/utility/compare_pointees.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// operator==
|
||||
// operator!=
|
||||
// operator<
|
||||
// operator>
|
||||
// operator<=
|
||||
// operator>=
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator==(sprout::optional<T> const& lhs, sprout::optional<T> const& rhs) {
|
||||
return sprout::equal_pointees(lhs, rhs);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator!=(sprout::optional<T> const& lhs, sprout::optional<T> const& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator<(sprout::optional<T> const& lhs, sprout::optional<T> const& rhs) {
|
||||
return sprout::less_pointees(lhs, rhs);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator>(sprout::optional<T> const& lhs, sprout::optional<T> const& rhs) {
|
||||
return rhs < lhs;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator<=(sprout::optional<T> const& lhs, sprout::optional<T> const& rhs) {
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
operator>=(sprout::optional<T> const& lhs, sprout::optional<T> const& rhs) {
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_OPTIONAL_COMPARISON_HPP
|
Loading…
Add table
Add a link
Reference in a new issue