include: optional: add equal_to and not_equal_to operators

these will be generated only if T supports these operators
parent 5f504291
......@@ -240,6 +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 {
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 {
return !(*this == other);
}
private:
T *constData() const {
......
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