[variant.relops] # 22 General utilities library [[utilities]](./#utilities) ## 22.6 Variants [[variant]](variant#relops) ### 22.6.6 Relational operators [variant.relops] [🔗](#lib:operator==,variant) `template constexpr bool operator==(const variant& v, const variant& w); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6653) *Constraints*: *GET*(v) == *GET*(w) is a valid expression that is convertible to bool, for all i[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6658) *Returns*: If v.index() != w.index(), false; otherwise if v.valueless_by_exception(), true; otherwise *GET*(v) == *GET*(w) with i being v.index()[.](#2.sentence-1) [🔗](#lib:operator!=,variant) `template constexpr bool operator!=(const variant& v, const variant& w); ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6672) *Constraints*: *GET*(v) != *GET*(w) is a valid expression that is convertible to bool, for all i[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6677) *Returns*: If v.index() != w.index(), true; otherwise if v.valueless_by_exception(), false; otherwise *GET*(v) != *GET*(w) with i being v.index()[.](#4.sentence-1) [🔗](#lib:operator%3c,variant) `template constexpr bool operator<(const variant& v, const variant& w); ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6691) *Constraints*: *GET*(v) < *GET*(w) is a valid expression that is convertible to bool, for all i[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6696) *Returns*: If 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*(v) < *GET*(w) with i being v.index()[.](#6.sentence-1) [🔗](#lib:operator%3e,variant) `template constexpr bool operator>(const variant& v, const variant& w); ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6712) *Constraints*: *GET*(v) > *GET*(w) is a valid expression that is convertible to bool, for all i[.](#7.sentence-1) [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6717) *Returns*: If v.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*(v) > *GET*(w) with i being v.index()[.](#8.sentence-1) [🔗](#lib:operator%3c=,variant) `template constexpr bool operator<=(const variant& v, const variant& w); ` [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6733) *Constraints*: *GET*(v) <= *GET*(w) is a valid expression that is convertible to bool, for all i[.](#9.sentence-1) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6738) *Returns*: If 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*(v) <= *GET*(w) with i being v.index()[.](#10.sentence-1) [🔗](#lib:operator%3e=,variant) `template constexpr bool operator>=(const variant& v, const variant& w); ` [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6754) *Constraints*: *GET*(v) >= *GET*(w) is a valid expression that is convertible to bool, for all i[.](#11.sentence-1) [12](#12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6759) *Returns*: If 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*(v) >= *GET*(w) with i being v.index()[.](#12.sentence-1) [🔗](#lib:operator%3c=%3e,variant) `template requires ([three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]") && ...) constexpr common_comparison_category_t...> operator<=>(const variant& v, const variant& w); ` [13](#13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6776) *Effects*: Equivalent to:if (v.valueless_by_exception() && w.valueless_by_exception())return strong_ordering::equal;if (v.valueless_by_exception()) return strong_ordering::less;if (w.valueless_by_exception()) return strong_ordering::greater;if (auto c = v.index() <=> w.index(); c != 0) return c;return *GET*(v) <=> *GET*(w); with i being v.index()[.](#13.sentence-1)