std::common_iterator<I,S>::operator=
Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Member functions | ||||
common_iterator::operator= | ||||
Non-member functions | ||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)
|
||||
(C++20)
|
||||
Helper classes | ||||
template
<
class I2, class S2 >
requires std::convertible_to
<
const I2&, I>
&&
|
(since C++20) | |
Assigns the underlying std::variant member object var
from that of x
Let i
is x.var.index()
- std:: get <i> (var) = std:: get <i> (x.var ) , if var.index() == i
- var.emplace <i> (std:: get <i> (x.var ) )
The behavior is undefined if x is in an invalid state, that is, x.var.valueless_by_exception() is equal to true
Parameters
x | - | iterator adaptor to assign from |
Return value
*this
Example
#include <algorithm> #include <initializer_list> #include <iostream> #include <iterator> int main() { const auto il = {1, 2, 3, 4, 5, 6}; using CI = std::common_iterator< std::counted_iterator<std::initializer_list<int>::iterator>, std::default_sentinel_t>; CI first{std::counted_iterator{std::next(begin(il), 1), ssize(il) - 1}}; const CI first2{std::counted_iterator{std::next(begin(il), 2), ssize(il) - 2}}; const CI last{std::default_sentinel}; std::copy(first, last, std::ostream_iterator<int>{std::cout, " "}); std::cout << '\n'; first = first2; std::copy(first, last, std::ostream_iterator<int>{std::cout, " "}); std::cout << '\n'; }
Output:
2 3 4 5 6 3 4 5 6
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) but common_iterator was not
|
also made constexpr |
See also
(C++20)
|
constructs a new iterator adaptor (public member function) |