2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-10-22 14:10:11 +00:00
|
|
|
#ifndef SPROUT_OPTIONAL_COMPARISON_HPP
|
|
|
|
#define SPROUT_OPTIONAL_COMPARISON_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/utility/compare_pointees.hpp>
|
2012-10-26 08:38:48 +00:00
|
|
|
#include <sprout/optional/optional.hpp>
|
|
|
|
#include <sprout/optional/nullopt.hpp>
|
2012-10-22 14:10:11 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2012-10-26 08:38:48 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// operator==
|
|
|
|
// operator!=
|
|
|
|
// operator<
|
|
|
|
// operator>
|
|
|
|
// operator<=
|
|
|
|
// operator>=
|
|
|
|
//
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator==(sprout::optional<T> const& lhs, sprout::nullopt_t) SPROUT_NOEXCEPT {
|
|
|
|
return !lhs;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator==(sprout::nullopt_t, sprout::optional<T> const& rhs) SPROUT_NOEXCEPT {
|
|
|
|
return !rhs;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator!=(sprout::optional<T> const& lhs, sprout::nullopt_t) SPROUT_NOEXCEPT {
|
|
|
|
return bool(lhs);
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator!=(sprout::nullopt_t, sprout::optional<T> const& rhs) SPROUT_NOEXCEPT {
|
|
|
|
return bool(rhs);
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
2013-07-22 13:00:09 +00:00
|
|
|
operator<(sprout::optional<T> const&, sprout::nullopt_t) SPROUT_NOEXCEPT {
|
2012-10-26 08:38:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator<(sprout::nullopt_t, sprout::optional<T> const& rhs) SPROUT_NOEXCEPT {
|
|
|
|
return bool(rhs);
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator>(sprout::optional<T> const& lhs, sprout::nullopt_t) SPROUT_NOEXCEPT {
|
|
|
|
return bool(lhs);
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
2013-07-22 13:00:09 +00:00
|
|
|
operator>(sprout::nullopt_t, sprout::optional<T> const&) SPROUT_NOEXCEPT {
|
2012-10-26 08:38:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator<=(sprout::optional<T> const& lhs, sprout::nullopt_t) SPROUT_NOEXCEPT {
|
|
|
|
return !lhs;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
2013-07-22 13:00:09 +00:00
|
|
|
operator<=(sprout::nullopt_t, sprout::optional<T> const&) SPROUT_NOEXCEPT {
|
2012-10-26 08:38:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
2013-07-22 13:00:09 +00:00
|
|
|
operator>=(sprout::optional<T> const&, sprout::nullopt_t) SPROUT_NOEXCEPT {
|
2012-10-26 08:38:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
operator>=(sprout::nullopt_t, sprout::optional<T> const& rhs) SPROUT_NOEXCEPT {
|
|
|
|
return !rhs;
|
|
|
|
}
|
2012-10-22 14:10:11 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_OPTIONAL_COMPARISON_HPP
|