description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ms.custom | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: basic_istringstream Class |
basic_istringstream Class |
06/10/2022 |
|
|
1d5bb4b5-793d-4833-98e5-14676c451915 |
devdivchpfy22 |
Describes an object that controls extraction of elements and encoded objects from a stream buffer of class basic_stringbuf< Elem, Tr, Alloc
>.
template <class Elem, class Tr = char_traits<Elem>, class Alloc = allocator<Elem>>
class basic_istringstream : public basic_istream<Elem, Tr>
Alloc
The allocator class.
Elem
The type of the basic element of the string.
Tr
The character traits specialized on the basic element of the string.
The class template describes an object that controls extraction of elements and encoded objects from a stream buffer of class basic_stringbuf< Elem, Tr, Alloc
>, with elements of type Elem, whose character traits are determined by the class Tr, and whose elements are allocated by an allocator of class Alloc. The object stores an object of class basic_stringbuf< Elem, Tr, Alloc
>.
Constructor | Description |
---|---|
basic_istringstream | Constructs an object of type basic_istringstream . |
Type name | Description |
---|---|
allocator_type | The type is a synonym for the template parameter Alloc . |
Member function | Description |
---|---|
rdbuf | Returns the address of the stored stream buffer of type pointer to basic_stringbuf< Elem , Tr , Alloc >. |
str | Sets or gets the text in a string buffer without changing the write position. |
swap | Exchanges the values in this basic_istringstream object for the provided object. |
Operator | Description |
---|---|
operator= | Assigns the values to this basic_istringstream object from the object parameter. |
Header: <sstream>
Namespace: std
The type is a synonym for the template parameter Alloc
.
typedef Alloc allocator_type;
Constructs an object of type basic_istringstream
.
explicit basic_istringstream(
ios_base::openmode _Mode = ios_base::in);
explicit basic_istringstream(
const basic_string<Elem, Tr, Alloc>& str,
ios_base::openmode _Mode = ios_base::in);
basic_istringstream(
basic_istringstream&& right);
_Mode
One of the enumerations in ios_base::openmode.
str
An object of type basic_string
.
right
An rvalue reference of a basic_istringstream
object.
The first constructor initializes the base class by calling basic_istream]( sb )
, where sb
is the stored object of class basic_stringbuf< Elem, Tr, Alloc>
. It also initializes sb
by calling basic_stringbuf< Elem, Tr, Alloc >( _Mode | ios_base::in )
. For more information, see basic_istream
and basic_stringbuf
.
The second constructor initializes the base class by calling basic_istream( sb )
. It also initializes sb
by calling basic_stringbuf< Elem, Tr, Alloc >( str, _Mode | ios_base::in )
.
The third constructor initializes the object with the contents of right, treated as an rvalue reference.
Assigns the values to this basic_istringstream
object from the object parameter.
basic_istringstream& operator=(basic_istringstream&& right);
right
An rvalue reference to a basic_istringstream
object.
The member operator replaces the contents of the object with the contents of right, treated as an rvalue reference move assignment.
Returns the address of the stored stream buffer of type pointer
to basic_stringbuf< Elem, Tr, Alloc
>.
basic_stringbuf<Elem, Tr, Alloc> *rdbuf() const;
The address of the stored stream buffer of type pointer
to basic_stringbuf< Elem, Tr, Alloc
>.
See basic_filebuf::close for an example that uses rdbuf
.
Sets or gets the text in a string buffer without changing the write position.
basic_string<Elem, Tr, Alloc> str() const;
void str(
const basic_string<Elem, Tr, Alloc>& _Newstr);
_Newstr
The new string.
Returns an object of class basic_string< Elem, Tr, Alloc
>, whose controlled sequence is a copy of the sequence controlled by *this
.
The first member function returns rdbuf -> str. The second member function calls rdbuf
-> str( _Newstr
).
See basic_stringbuf::str for an example that uses str
.
Exchanges the values of two basic_istringstream
objects.
void swap(basic_istringstream& right);
right
An lvalue reference to a basic_istringstream
object.
The member function exchanges the values of this object and the values of right.
Thread Safety in the C++ Standard Library
iostream Programming
iostreams Conventions