STD::ISTREAM_ITERATOR(3)

✨ NAME ✨

okay so bestie, meet std::istream_iterator< _Tp, _CharT, _Traits, _Dist > β€” it's the whole vibe of Provides input iterator semantics for streams. πŸ’–

like literally, it lets you treat a stream like an iterator. iconic behaviour, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

first things first, you gotta pull it in:

#include <iterator>

and heads up β€” it Inherits from:

std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >

it's giving "I got everything from my parent class and I'm thriving". 🫢

πŸŽ€ Public Types πŸŽ€

the little type besties it brings along:

  • typedef _CharT char_type
  • typedef ptrdiff_t difference_type β€” Distance between iterators is represented as this type. (fr fr, that's literally what it's for)
  • typedef basic_istream< _CharT, _Traits > istream_type
  • typedef input_iterator_tag iterator_category β€” One of the tag types. 🏷️
  • typedef const _Tp * pointer β€” This type represents a pointer-to-value_type.
  • typedef const _Tp & reference β€” This type represents a reference-to-value_type.
  • typedef _Traits traits_type
  • typedef _Tp value_type β€” The type "pointed to" by the iterator. πŸ’…

πŸ’… Public Member Functions πŸ’…

the moves it can do:

  • constexpr istream_iterator () noexcept(/*conditional */) β€” Construct end of input stream iterator. (the classic "end" one, we love her)
  • constexpr istream_iterator (const istream_iterator &__obj) noexcept(/*conditional */)
  • constexpr istream_iterator (default_sentinel_t) noexcept(is_nothrow_default_constructible_v< _Tp >)
  • istream_iterator (istream_type &__s) β€” Construct start of input stream iterator. (the "begin" one, the main character ✨)
  • const _Tp & operator* () const noexcept
  • istream_iterator & operator++ ()
  • istream_iterator operator++ (int)
  • const _Tp * operator-> () const noexcept
  • istream_iterator & operator= (const istream_iterator &)=default

🌸 Friends 🌸

the besties it fw:

  • bool operator== (const istream_iterator &__i, default_sentinel_t) noexcept
  • bool operator== (const istream_iterator &__x, const istream_iterator &__y) noexcept β€” Return true if the iterators refer to the same stream, or are both at end-of-stream. 🫢

πŸ’– Detailed Description πŸ’–

here's the full template glow-up:

template<typename _Tp, typename _CharT = char, typename _Traits =
    char_traits<_CharT>, typename _Dist = ptrdiff_t>
class std::istream_iterator< _Tp, _CharT, _Traits, _Dist >

and what does it do? "Provides input iterator semantics for streams." that's it, that's the whole personality. 😌


🧚 Member Typedef Documentation 🧚

these ones are all inherited, so they came pre-loaded from std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >:

  • typedef ptrdiff_t std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >::difference_type [inherited] β€” Distance between iterators is represented as this type.
  • typedef input_iterator_tag std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >::iterator_category [inherited] β€” One of the tag types. 🏷️
  • typedef const _Tp * std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >::pointer [inherited] β€” This type represents a pointer-to-value_type.
  • typedef const _Tp & std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >::reference [inherited] β€” This type represents a reference-to-value_type.
  • typedef _Tp std::iterator< input_iterator_tag, _Tp, ptrdiff_t, const _Tp *, const _Tp & >::value_type [inherited] β€” The type "pointed to" by the iterator.

⭐ Constructor & Destructor Documentation ⭐

🌈 the no-arg one

template<typename _Tp, typename _CharT = char, typename _Traits =
    char_traits<_CharT>, typename _Dist = ptrdiff_t>
std::istream_iterator< _Tp, _CharT, _Traits, _Dist >::istream_iterator ()
[inline], [constexpr], [noexcept]

Construct end of input stream iterator. that's the whole job. πŸŽ€

  • Referenced by operator==.

πŸ¦‹ the stream-taking one

template<typename _Tp, typename _CharT = char, typename _Traits =
    char_traits<_CharT>, typename _Dist = ptrdiff_t>
std::istream_iterator< _Tp, _CharT, _Traits, _Dist >::istream_iterator
(istream_type & __s) [inline]

Construct start of input stream iterator. the beginning of the story, literally. ✨

  • References std::__addressof().

template<typename _Tp, typename _CharT = char, typename _Traits =
    char_traits<_CharT>, typename _Dist = ptrdiff_t>
bool operator== (const istream_iterator< _Tp, _CharT, _Traits, _Dist > & __x,
                 const istream_iterator< _Tp, _CharT, _Traits, _Dist > & __y)
[friend]

Return true if the iterators refer to the same stream, or are both at end-of-stream. so like, same stream = besties, both at the end = also besties. equality ate and left no crumbs. πŸ’…

  • References istream_iterator().

πŸ‘‘ Author πŸ‘‘

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

like, nobody hand-wrote this, the robot did it, and honestly? slay. πŸ€–βœ¨


no cap, this page came straight out of the libstdc++ manual β€” the Library Functions Manual, section (3), the one and only std::istre...s, _Dist >(3). πŸŽ€ that's the whole sign-off bestie, go read your streams. πŸ’–πŸŒΈπŸ¦‹
πŸ“¦ 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