Proposed resolution:
This wording is relative to N4640.
Modify [optional.syn], header <optional> synopsis, as indicated:
[…] // [optional.relops], relational operators template <class T, class U> constexpr bool operator==(const optional<T>&, const optional<TU>&); template <class T, class U> constexpr bool operator!=(const optional<T>&, const optional<TU>&); template <class T, class U> constexpr bool operator<(const optional<T>&, const optional<TU>&); template <class T, class U> constexpr bool operator>(const optional<T>&, const optional<TU>&); template <class T, class U> constexpr bool operator<=(const optional<T>&, const optional<TU>&); template <class T, class U> constexpr bool operator>=(const optional<T>&, const optional<TU>&); […] // [optional.comp_with_t], comparison with T template <class T, class U> constexpr bool operator==(const optional<T>&, constTU&); template <class T, class U> constexpr bool operator==(constTU&, const optional<T>&); template <class T, class U> constexpr bool operator!=(const optional<T>&, constTU&); template <class T, class U> constexpr bool operator!=(constTU&, const optional<T>&); template <class T, class U> constexpr bool operator<(const optional<T>&, constTU&); template <class T, class U> constexpr bool operator<(constTU&, const optional<T>&); template <class T, class U> constexpr bool operator<=(const optional<T>&, constTU&); template <class T, class U> constexpr bool operator<=(constTU&, const optional<T>&); template <class T, class U> constexpr bool operator>(const optional<T>&, constTU&); template <class T, class U> constexpr bool operator>(constTU&, const optional<T>&); template <class T, class U> constexpr bool operator>=(const optional<T>&, constTU&); template <class T, class U> constexpr bool operator>=(constTU&, const optional<T>&);
Modify [optional.relops] as indicated:
template <class T, class U> constexpr bool operator==(const optional<T>& x, const optional<TU>& y);[…]
template <class T, class U> constexpr bool operator!=(const optional<T>& x, const optional<TU>& y);[…]
template <class T, class U> constexpr bool operator<(const optional<T>& x, const optional<TU>& y);[…]
template <class T, class U> constexpr bool operator>(const optional<T>& x, const optional<TU>& y);[…]
template <class T, class U> constexpr bool operator<=(const optional<T>& x, const optional<TU>& y);[…]
template <class T, class U> constexpr bool operator>=(const optional<T>& x, const optional<TU>& y);[…]
Modify [optional.comp_with_t] as indicated:
template <class T, class U> constexpr bool operator==(const optional<T>& x, constTU& v);-?- Requires: The expression *x == v shall be well-formed and its result shall be convertible to bool. [Note: T need not be EqualityComparable. — end note]
-1- Effects: Equivalent to: return bool(x) ? *x == v : false;
template <class T, class U> constexpr bool operator==(constTU& v, const optional<T>& x);-?- Requires: The expression v == *x shall be well-formed and its result shall be convertible to bool.
-2- Effects: Equivalent to: return bool(x) ? v == *x : false;
template <class T, class U> constexpr bool operator!=(const optional<T>& x, constTU& v);-?- Requires: The expression *x != v shall be well-formed and its result shall be convertible to bool.
-3- Effects: Equivalent to: return bool(x) ? *x != v : true;
template <class T, class U> constexpr bool operator!=(constTU& v, const optional<T>& x);-?- Requires: The expression v != *x shall be well-formed and its result shall be convertible to bool.
-4- Effects: Equivalent to: return bool(x) ? v != *x : true;
template <class T, class U> constexpr bool operator<(const optional<T>& x, constTU& v);-?- Requires: The expression *x < v shall be well-formed and its result shall be convertible to bool.
-5- Effects: Equivalent to: return bool(x) ? *x < v : true;
template <class T, class U> constexpr bool operator<(constTU& v, const optional<T>& x);-?- Requires: The expression v < *x shall be well-formed and its result shall be convertible to bool.
-6- Effects: Equivalent to: return bool(x) ? v < *x : false;
template <class T, class U> constexpr bool operator<=(const optional<T>& x, constTU& v);-?- Requires: The expression *x <= v shall be well-formed and its result shall be convertible to bool.
-7- Effects: Equivalent to: return bool(x) ? *x <= v : true;
template <class T, class U> constexpr bool operator<=(constTU& v, const optional<T>& x);-?- Requires: The expression v <= *x shall be well-formed and its result shall be convertible to bool.
-8- Effects: Equivalent to: return bool(x) ? v <= *x : false;
template <class T, class U> constexpr bool operator>(const optional<T>& x, constTU& v);-?- Requires: The expression *x > v shall be well-formed and its result shall be convertible to bool.
-9- Effects: Equivalent to: return bool(x) ? *x > v : false;
template <class T, class U> constexpr bool operator>(constTU& v, const optional<T>& x);-?- Requires: The expression v > *x shall be well-formed and its result shall be convertible to bool.
-10- Effects: Equivalent to: return bool(x) ? v > *x : true;
template <class T, class U> constexpr bool operator>=(const optional<T>& x, constTU& v);-?- Requires: The expression *x >= v shall be well-formed and its result shall be convertible to bool.
-11- Effects: Equivalent to: return bool(x) ? *x >= v : false;
template <class T, class U> constexpr bool operator>=(constTU& v, const optional<T>& x);-?- Requires: The expression v >= *x shall be well-formed and its result shall be convertible to bool.
-12- Effects: Equivalent to: return bool(x) ? v >= *x : true;