Unverified Commit 0b6cb299 authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #641 from kuzkry/optional-operator==

optional::operator== improvements
parents 394b17c0 97e32357
......@@ -240,13 +240,15 @@ public:
}
}
template<typename U = T, typename = typename std::enable_if<types::has_equalto_operator<U>::value>::type>
bool operator==(const Optional<T>& other) const {
static_assert(types::has_equalto_operator<T>::value,
"optional<T> requires T to be comparable by equal to operator");
return (isEmpty() && other.isEmpty()) || (!isEmpty() && !other.isEmpty() && get() == other.get());
}
template<typename U = T, typename = typename std::enable_if<types::has_equalto_operator<U>::value>::type>
bool operator!=(const Optional<T>& other) const {
static_assert(types::has_equalto_operator<T>::value,
"optional<T> requires T to be comparable by equal to operator");
return !(*this == other);
}
......
......@@ -163,7 +163,7 @@ struct not_comparable
bool operator==(const not_comparable& other) const = delete;
};
TEST(optional, is_comparable_type)
TEST(has_equalto_operator, is_comparable_type)
{
using Pistache::types::has_equalto_operator;
EXPECT_FALSE(has_equalto_operator<not_comparable>::value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment