Home

basicistream

basic_istream is a class template in the C++ Standard Library that provides the input side of iostreams. It is defined as template<class Elem, class Traits = std::char_traits<Elem>> class basic_istream and serves as the common base for input streams such as std::istream and std::wistream. The Elem parameter denotes the character type, and Traits defines how characters are handled; by default Traits is std::char_traits<Elem>.

As part of the iostreams framework, basic_istream operates in conjunction with a stream buffer (std::basic_streambuf<Elem, Traits>)

The class uses a sentry object to streamline common input setup tasks, perform initial state checks, and

basic_istream also exposes state and positioning facilities inherited from the iostream framework, including access to the

In practice, basic_istream is the foundational base for input streams in C++. std::istream is an instantiation

to
read
data.
It
offers
a
variety
of
input
operations,
including
formatted
extraction
via
operator>>
and
unformatted
reads
such
as
get,
read,
getline,
and
ignore.
It
also
provides
access
to
unformatted
peeking
and
character-by-character
reading
through
functions
like
peek
and
get.
The
extraction
operators
work
together
with
locale
and
traits
to
convert
characters
into
values
of
arithmetic
types,
strings,
and
user-defined
types,
typically
using
operator>>
overloads.
manage
whitespace-skipping
and
synchronization
with
the
buffer.
This
sentry
helps
establish
a
valid
reading
state
before
actual
extraction
begins
and
influences
the
stream’s
error
state
in
case
of
failures.
underlying
stream
buffer
via
rdbuf(),
and
position
interfaces
such
as
tellg
and
seekg
through
the
associated
stream.
It
maintains
and
exposes
the
usual
ios_base
state
flags
(eof,
fail,
bad,
good).
of
basic_istream<char>
and
std::wistream
is
an
instantiation
of
basic_istream<wchar_t>,
providing
the
primary
interfaces
used
when
reading
from
standard
input,
files,
or
other
input
sources.