This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++20 status.
optional comparisonsSection: 22.5.9[optional.comp.with.t]Status:C++20Submitter: Jonathan WakelyOpened: 2017-03-13Last modified: 2021-06-06
Priority:2
View all otherissues in [optional.comp.with.t].
View all issues withC++20 status.
Discussion:
LWG2934(i) added an additional template parameter to the comparisonoperators forstd::optional, but the ones that compareU withoptional<T> have the parameters backwards compared to the function parameters:
template <class T, class U>constexpr bool operator==(const U&, const optional<T>&);
Ville confirmed there's no particular reason for this, it's just howhe wrote the proposed resolution, but as this has normative effect weshould consider if we really want the template parameters and functionparameters to be in different orders or not.
[2017-07-13, Casey Carter provides wording]
[2016-07, Toronto Thursday night issues processing]
Status to Ready
Proposed resolution:
This wording is relative toN4659.
Modify 22.5.2[optional.syn],<optional> synopsis, as indicated:
// [optional.comp_with_t], comparison with Ttemplate <class T, class U> constexpr bool operator==(const optional<T>&, const U&);template <class T, class U> constexpr bool operator==(constUT&, const optional<TU>&);template <class T, class U> constexpr bool operator!=(const optional<T>&, const U&);template <class T, class U> constexpr bool operator!=(constUT&, const optional<TU>&);template <class T, class U> constexpr bool operator<(const optional<T>&, const U&);template <class T, class U> constexpr bool operator<(constUT&, const optional<TU>&);template <class T, class U> constexpr bool operator<=(const optional<T>&, const U&);template <class T, class U> constexpr bool operator<=(constUT&, const optional<TU>&);template <class T, class U> constexpr bool operator>(const optional<T>&, const U&);template <class T, class U> constexpr bool operator>(constUT&, const optional<TU>&);template <class T, class U> constexpr bool operator>=(const optional<T>&, const U&);template <class T, class U> constexpr bool operator>=(constUT&, const optional<TU>&);
Modify [optional.comp_with_t] as indicated:
template <class T, class U> constexpr bool operator==(constUT& v, const optional<TU>& x);-3- […]
[…]
template <class T, class U> constexpr bool operator!=(constUT& v, const optional<TU>& x);-7- […]
[…]
template <class T, class U> constexpr bool operator<(constUT& v, const optional<TU>& x);-11- […]
[…]
template <class T, class U> constexpr bool operator<=(constUT& v, const optional<TU>& x);-15- […]
[…]
template <class T, class U> constexpr bool operator>(constUT& v, const optional<TU>& x);-19- […]
[…]
template <class T, class U> constexpr bool operator>=(constUT& v, const optional<TU>& x);-23- […]
[…]