std::move_iterator<Iter>::operator*,->
From cppreference.com
< cpp | iterator | move iterator
(1) | ||
reference operator* () const; |
(until C++17) | |
constexpr reference operator* () const; |
(since C++17) | |
(2) | ||
pointer operator->() const; |
(until C++17) | |
constexpr pointer operator->() const; |
(since C++17) (deprecated in C++20) |
|
Returns a rvalue-reference or pointer to the current element.
1) Equivalent to static_cast<reference>(*base()).
2) Equivalent to
base()
.Parameters
(none)
Return value
1) Rvalue-reference to the current element or its copy.
2) Copy of the underlying iterator. A pointer to the current element is eventually returned if
->
is directly used.Notes
Note that (2) eventually returns a pointer if ->
is directly used. When dereferencing a pointer the returned value is an lvalue. This may lead to unintended behavior.
Example
This section is incomplete Reason: no example |
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 2106 | C++11 | dereferencing a move_iterator could return a dangling referenceif the dereferencing the underlying iterator returns a prvalue |
returns the object instead |
See also
accesses an element by index (public member function) |