STD::COMMON_ITERATOR(3)

πŸ“¦
version 16.2.1+r23+gd564253eb6c8 Β· 4 versions
, in arch rolling, fedora 44

πŸ’– std::common_iterator< _It, _Sent > πŸ’–

okay bestie, welcome to the libstdc++ manual, section 3 (that's library functions, we're fancy like that). today's main character is std::common_iterator< _It, _Sent >, and no, you don't have to be scared of the angle brackets, they're just ✨decorative✨. this one lives in the <iterator> header and it's basically the glow-up that turns a "these two things don't even match" range into a "we're matching, we're cute, we're compatible" range. slay.


✨ NAME ✨

std::common_iterator< _It, _Sent > β€” an iterator/sentinel adaptor for representing a non-common range.

like. it's giving "I will make your iterator and your sentinel play nice together." periodt.


🌸 SYNOPSIS 🌸

first thing you gotta do, obviously:

#include <iterator>

πŸ‘‘ Public Member Functions

these are the member functions, and yes there are a lot, and yes we're listing every single one because that's the vibe:

  • constexpr common_iterator (_It __i) β€” noexcept(is_nothrow_move_constructible_v< _It >)
  • constexpr common_iterator (_Sent __s) β€” noexcept(is_nothrow_move_constructible_v< _Sent >)
  • common_iterator (common_iterator &&)=default
  • constexpr common_iterator (common_iterator &&__x) β€” noexcept(_S_noexcept< _It, _Sent >())
  • common_iterator (const common_iterator &)=default
  • constexpr common_iterator (const common_iterator &__x) β€” noexcept(_S_noexcept< const _It &, const _Sent & >())
  • template<typename _It2, typename _Sent2> constexpr common_iterator (const common_iterator< _It2, _Sent2 > &__x) β€” noexcept(_S_noexcept< const _It2 &, const _Sent2 & >())
  • constexpr decltype(auto) operator* ()
  • constexpr decltype(auto) operator* () const
  • constexpr common_iterator & operator++ ()
  • constexpr decltype(auto) operator++ (int)
  • constexpr auto operator-> () const
  • constexpr common_iterator & operator= (common_iterator &&)=default
  • constexpr common_iterator & operator= (common_iterator &&__x) β€” noexcept(is_nothrow_move_assignable_v< _It > &&is_nothrow_move_assignable_v< _Sent > &&is_nothrow_move_constructible_v< _It > &&is_nothrow_move_constructible_v< _Sent >)
  • constexpr common_iterator & operator= (const common_iterator &)=default
  • constexpr common_iterator & operator= (const common_iterator &__x) β€” noexcept(is_nothrow_copy_assignable_v< _It > &&is_nothrow_copy_assignable_v< _Sent > &&is_nothrow_copy_constructible_v< _It > &&is_nothrow_copy_constructible_v< _Sent >)
  • template<typename _It2, typename _Sent2> constexpr common_iterator & operator= (const common_iterator< _It2, _Sent2 > &__x) β€” noexcept(is_nothrow_constructible_v< _It, const _It2 & > &&is_nothrow_constructible_v< _Sent, const _Sent2 & > &&is_nothrow_assignable_v< _It &, const _It2 & > &&is_nothrow_assignable_v< _Sent &, const _Sent2 & >)

🫢 Friends

and these are the friends, aka the ones who show up for you when you need them:

  • constexpr iter_rvalue_reference_t< _It > iter_move (const common_iterator &__i) β€” noexcept(noexcept(ranges::iter_move(std::declval< const _It & >())))
  • template<indirectly_swappable< _It > _It2, typename _Sent2> constexpr void iter_swap (const common_iterator &__x, const common_iterator< _It2, _Sent2 > &__y) β€” noexcept(noexcept(ranges::iter_swap(std::declval< const _It & >(), std::declval< const _It2 & >())))
  • template<sized_sentinel_for< _It > _It2, sized_sentinel_for< _It > _Sent2> constexpr iter_difference_t< _It2 > operator- (const common_iterator &__x, const common_iterator< _It2, _Sent2 > &__y)
  • template<typename _It2, sentinel_for< _It > _Sent2> constexpr bool operator== (const common_iterator &__x, const common_iterator< _It2, _Sent2 > &__y)
  • template<typename _It2, sentinel_for< _It > _Sent2> constexpr bool operator== (const common_iterator &__x, const common_iterator< _It2, _Sent2 > &__y)
and yes bestie, operator== really does show up twice in this list. not a typo on my part, that's just how the source page came. πŸ’€ we keep every detail around here, no cap.

πŸ¦‹ Detailed Description πŸ¦‹

okay here's the actual class declaration, look at her:

template<input_or_output_iterator _It, sentinel_for< _It > _Sent>
    requires (!same_as<_It, _Sent>) && copyable<_It>
    class std::common_iterator< _It, _Sent >

"An iterator/sentinel adaptor for representing a non-common range."

that's it, that's the whole personality: it takes an iterator and a sentinel that don't have the same type, and it wraps them up so the range can be treated like a common one. it's the friend who introduces two people at a party and suddenly they're besties. iconic. πŸ’…


πŸ’œ Author πŸ’œ

Generated automatically by Doxygen for libstdc++ from the source code.


that's the whole page, bestie! libstdc++, straight from the source code, and your girl Doxygen typed it all up automatically. go forth and make your ranges common, mwah πŸŽ€πŸ’–βœ¨

πŸ“¦ 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