| (1) | (since C++20) |
| (2) | (since C++20) |
| | |
Compares the iterators and/or sentinels held by underlyingstd::variant member objectsvar. Two incomparable iterators or two sentinels are considered equal.
The behavior is undefined if eitherx ory is in an invalid state, i.e.x.var.valueless_by_exception()|| y.var.valueless_by_exception() is equal totrue.
Leti bex.var.index() andj bey.var.index().
1) Ifi== j (i.e. bothx andy hold iterators or both hold sentinels), returnstrue, otherwise returnsstd::get<i>(x.var)== std::get<j>(y.var).
2) Ifi==1&& j==1 (i.e. bothx andy hold sentinels), returnstrue, otherwise returnsstd::get<i>(x.var)== std::get<j>(y.var).
The!= operator issynthesized fromoperator==.
These function templates are not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup when std::common_iterator<I> is an associated class of the arguments.
[edit]Parameters
| x, y | - | iterator adaptors to compare |
[edit]Return value
true if underlying iterators and/or sentinels are equal.
[edit]Example
[edit]Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|
| LWG 3574 | C++20 | variant was fully constexpr (P2231R1) butcommon_iterator was not | also made constexpr |
[edit]See also
| computes the distance between two iterator adaptors (function template)[edit] |