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 another move_iterator over 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's noexcept ⭐
  • 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 returning void πŸ‘€
  • constexpr move_iterator operator++ (int) β€” post-increment returning a move_iterator πŸ¦‹
  • constexpr move_iterator & operator+= (difference_type __n) β€” add __n in 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 a move_iterator πŸ’…
  • constexpr move_iterator & operator-= (difference_type __n) β€” subtract __n in 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 a move_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))) β€” the iter_move bestie, with that exact noexcept clause πŸ”₯
  • 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, _Iter2 must be indirectly_swappable< _Iterator >, and yes the noexcept is 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, returns bool βœ…

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