Commit 53a40535 authored by Krystian Kuzniarek's avatar Krystian Kuzniarek

use static_assert instead of SFINAE for better error messages

parent b30abdb4
...@@ -240,13 +240,15 @@ public: ...@@ -240,13 +240,15 @@ public:
} }
} }
template<typename = typename std::enable_if<types::has_equalto_operator<T>::value>::type>
bool operator==(const Optional<T>& other) const { 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()); return (isEmpty() && other.isEmpty()) || (!isEmpty() && !other.isEmpty() && get() == other.get());
} }
template<typename = typename std::enable_if<types::has_equalto_operator<T>::value>::type>
bool operator!=(const Optional<T>& other) const { 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); return !(*this == other);
} }
......
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