STD::MOVE_ITERATOR(3)
π NAME π
std::move_iterator< _Iterator > β bestie, it's an iterator adaptor that yields an rvalue reference. that's it, that's the whole vibe π¦
β¨ SYNOPSIS β¨
okay so first you gotta bring it in:
#include <iterator>
πΈ Public Types πΈ
difference_typeβusing difference_type, the type that tells you how far apart two of these are π«iterator_conceptβusing iterator_concept, the concept tag situation π·οΈiterator_typeβusing iterator_type, aka the underlying iterator type you wrapped up πpointerβusing pointerπ«Άreferenceβusing reference, and bestie, this one's the whole point of the class β¨value_typeβusing value_typeπ
π₯ Public Member Functions π₯
one bullet per function, no skips, we keep every single one:
template<typename _Iter> constexpr move_iterator (const move_iterator< _Iter > &__i)β copy-constructs from anothermove_iteratorover a different_Iterπconstexpr move_iterator (iterator_type __i)β constructs from an underlying iterator,iterator_type __iπconstexpr iterator_type base () &&β hands you back the underlying iterator (rvalue-qualified version) πconstexpr const iterator_type & base () const &noexceptβ hands you back the underlying iterator as a const ref, and it'snoexceptβconstexpr reference operator* () constβ dereference, and this is the iconic one, it gives you an rvalue reference π₯constexpr move_iterator operator+ (difference_type __n) constβ slide forward by__nβ¨constexpr move_iterator & operator++ ()β pre-increment, returns a ref π«constexpr void operator++ (int)β post-increment returningvoidπconstexpr move_iterator operator++ (int)β post-increment returning amove_iteratorπ¦constexpr move_iterator & operator+= (difference_type __n)β add__nin place, ref back at ya πconstexpr move_iterator operator- (difference_type __n) constβ slide back by__nπΈconstexpr move_iterator & operator-- ()β pre-decrement, ref again πconstexpr move_iterator operator-- (int)β post-decrement returning amove_iteratorπconstexpr move_iterator & operator-= (difference_type __n)β subtract__nin place π«Άconstexpr pointer operator-> () constβ the arrow, it's giving pointer πΉtemplate<typename _Iter> constexpr move_iterator & operator= (const move_iterator< _Iter > &__i)β assign from amove_iterator< _Iter >over a different_Iterβ¨constexpr reference operator[] (difference_type __n) constβ index it by__n, still yielding that rvalue reference π
π Friends π
constexpr iter_rvalue_reference_t< _Iterator > iter_move (const move_iterator &__i) noexcept(noexcept(ranges::iter_move(__i._M_current)))β theiter_movebestie, with that exactnoexceptclause π₯template<indirectly_swappable< _Iterator > _Iter2> constexpr void iter_swap (const move_iterator &__x, const move_iterator< _Iter2 > &__y) noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current)))β swaps two of these,_Iter2must beindirectly_swappable< _Iterator >, and yes thenoexceptis spelled out π«template<sized_sentinel_for< _Iterator > _Sent> constexpr iter_difference_t< _Iterator > operator- (const move_iterator &__x, const move_sentinel< _Sent > &__y)β iterator minus sentinel, gives you a difference πΈtemplate<sized_sentinel_for< _Iterator > _Sent> constexpr iter_difference_t< _Iterator > operator- (const move_sentinel< _Sent > &__x, const move_iterator &__y)β sentinel minus iterator, also a difference πtemplate<sentinel_for< _Iterator > _Sent> constexpr bool operator== (const move_iterator &__x, const move_sentinel< _Sent > &__y)β compare an iterator against a sentinel, returnsboolβ
Detailed Description β¨
template<typename _Iterator>
class std::move_iterator< _Iterator >
"An iterator adaptor that yields an rvalue reference.
okay so here's the tea, bestie β β class template move_iterator is an iterator adapter. it has the same behavior as the underlying iterator, with one glow-up: its dereference operator implicitly converts the value returned by the underlying iterator's dereference operator into an rvalue reference. that's the whole personality π
and the payoff? some generic algorithms can be called with move iterators to replace copying with moving. no cap, that's free performance. π₯
βοΈ Author βοΈ
Generated automatically by Doxygen for libstdc++ from the source code. π€ (not a human girlie wrote this one, it's a robot, but she ate fr fr)
π that's the whole page bestie, go forth and move instead of copy, ily π«Ά
libstdc++ Β· std::move_..._Iterator >(3) β mwah, that's the version and the page number, stan libstdc++, periodt π
β¨π
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms