| Document Number: | P0393r3, ISO/IEC JTC1 SC22 WG21 |
| Audience: | LWG |
| Date: | 2016-06-21 |
| Author: | Tony Van Eerd (variant at forecode.com) |
These edits align variant with optional in making the relational operators delegate to the relational operators of the underlying types
Other fixes, noticed when editing and/or suggested by LWG during review
operator<() was defined as if index() was signed. It is not.
template <class... Types> constexpr bool operator==(const variant<Types...>& v, const variant<Types...>& w);
get<i>(v) == get<i>(w) is a valid expression returning a type that is convertible to bool, for all i.
return (v.valueless_by_exception() && w.valueless_by_exception()) || (v.index() == w.index() && get<i>(v) == get<i>(w) with i being v.index().v.index() != w.index(), false; otherwise if v.valueless_by_exception(), true; otherwise get<i>(v) == get<i>(w) with i being v.index().
template <class... Types> constexpr bool operator!=(const variant<Types...>& v, const variant<Types...>& w);
get<i>(v) != get<i>(w) is a valid expression returning a type that is convertible to bool, for all i.
return !(v == w).v.index() != w.index(), true; otherwise if v.valueless_by_exception(), false; otherwise get<i>(v) != get<i>(w) with i being v.index().
template <class... Types> constexpr bool operator<(const variant<Types...>& v, const variant<Types...>& w);
get<i>(v) < get<i>(w) is a valid expression returning a type that is convertible to bool, for all i.
return (v.index() < w.index()) || (v.index() == w.index() && !v.valueless_by_exception() && get<i>(v) < get<i>(w) with i being v.index()w.valueless_by_exception(), false; otherwise if v.valueless_by_exception(), true; otherwise, if v.index() < w.index(), true; otherwise if v.index() > w.index(), false; otherwise get<i>(v) < get<i>(w) with i being v.index().
template <class... Types> constexpr bool operator>(const variant<Types...>& v, const variant<Types...>& w);
get<i>(v) > get<i>(w) is a valid expression returning a type that is convertible to bool, for all i.
return w < vv.valueless_by_exception(), false; otherwise if w.valueless_by_exception(), true; otherwise, if v.index() > w.index(), true; otherwise if v.index() < w.index(), false; otherwise get<i>(v) > get<i>(w) with i being v.index().
template <class... Types> constexpr bool operator<=(const variant<Types...>& v, const variant<Types...>& w);
get<i>(v) <= get<i>(w) is a valid expression returning a type that is convertible to bool, for all i.
return !(v > w)v.valueless_by_exception(), true; otherwise if w.valueless_by_exception(), false; otherwise, if v.index() < w.index(), true; otherwise if v.index() > w.index(), false; otherwise get<i>(v) <= get<i>(w) with i being v.index().
template <class... Types> constexpr bool operator>=(const variant<Types...>& v, const variant<Types...>& w);
get<i>(v) >= get<i>(w) is a valid expression returning a type that is convertible to bool, for all i.
return !(v < w).w.valueless_by_exception(), true; otherwise if v.valueless_by_exception(), false; otherwise, if v.index() > w.index(), true; otherwise if v.index() < w.index(), false; otherwise get<i>(v) >= get<i>(w) with i being v.index().