std::basic_istringstream<CharT,Traits,Allocator>:: basic_istringstream
| (1) | ||
|
explicit
basic_istringstream
(
std::
ios_base
::
openmode
mode
=
std:: ios_base :: in ) ; |
(C++11以前) | |
|
explicit
basic_istringstream
(
std::
ios_base
::
openmode
mode
)
;
|
(C++11以降) | |
|
basic_istringstream
(
)
: basic_istringstream ( std:: ios_base :: in ) { } |
(2) | (C++11以降) |
|
explicit
basic_istringstream
(
const
std::
basic_string
<
CharT, Traits, Allocator
>
&
str,
|
(3) | |
|
explicit
basic_istringstream
(
std::
basic_string
<
CharT, Traits, Allocator
>
&&
str,
|
(4) | (C++20以降) |
|
basic_istringstream
(
std::
ios_base
::
openmode
mode,
const
Allocator
&
a
)
;
|
(5) | (C++20以降) |
|
template
<
class
SAlloc
>
basic_istringstream
(
const
std::
basic_string
<
CharT, Traits, SAlloc
>
&
str,
|
(6) | (C++20以降) |
|
template
<
class
SAlloc
>
basic_istringstream
(
const
std::
basic_string
<
CharT, Traits, SAlloc
>
&
str,
|
(7) | (C++20以降) |
|
template
<
class
SAlloc
>
explicit
basic_istringstream
|
(8) | (C++20以降) |
|
template
<
class
StringViewLike
>
explicit
basic_istringstream
|
(9) | (C++26以降) |
|
template
<
class
StringViewLike
>
basic_istringstream
(
const
StringViewLike
&
t,
|
(10) | (C++26以降) |
|
template
<
class
StringViewLike
>
basic_istringstream ( const StringViewLike & t, const Allocator & a ) ; |
(11) | (C++26以降) |
|
basic_istringstream
(
basic_istringstream
&&
other
)
;
|
(12) | (C++11以降) |
新しい文字列ストリームを構築します。
与えられた
-
base_typeを std:: basic_istream < CharT, Traits > として、および -
buf_typeを std:: basic_stringbuf < CharT, Traits, Allocator > として、
std::basic_istream
基底クラスと
説明専用データメンバ
sb
は以下のように初期化されます。
|
オーバーロード
番号 |
std::basic_istream 基底クラス |
sb
|
|---|---|---|
| (1) | base_type ( std:: addressof ( sb ) ) [1] | buf_type ( mode | std:: ios_base :: in ) |
| (2) | buf_type ( std:: ios_base :: in ) | |
| (3) | buf_type ( str, mode | std:: ios_base :: in ) | |
| (4) | buf_type ( std :: move ( str ) , mode | std:: ios_base :: in ) | |
| (5) | buf_type ( mode | std:: ios_base :: in , a ) | |
| (6) | buf_type ( str, mode | std:: ios_base :: in , a ) | |
| (7) | buf_type ( str, std:: ios_base :: in , a ) | |
| (8) | buf_type ( str, mode | std:: ios_base :: in ) | |
| (9) | std:: addressof ( sb ) | { t, mode | std:: ios_base :: in , Allocator ( ) } |
| (10) | { t, mode | std:: ios_base :: in , a } | |
| (11) | { t, std:: ios_base :: in , a } | |
| (12) | other の std::basic_istream 基底クラスからムーブ構築 | other. sb からムーブ構築 |
- ↑ std::basic_iostream 基底クラスはC++11まで base_type ( & sb ) で初期化されていました(オーバーロード (1,3) の場合)。
目次 |
パラメータ
| str | - | 文字列ストリームの初期内容として使用する文字列 | ||||||||||||||||
| t | - | 文字列ストリームの初期内容として使用するオブジェクト( std::basic_string_view に変換可能) | ||||||||||||||||
| a | - | 文字列ストリームの内容の割り当てに使用するアロケータ | ||||||||||||||||
| mode | - |
ストリームのオープンモードを指定。
BitmaskType
であり、以下の定数が定義されている:
|
||||||||||||||||
| other | - | ソースとして使用する別の文字列ストリーム |
注記
文字列変換などで使用される際のタイトなループ内での一回限りの
basic_istringstream
オブジェクトの構築は、
str()
を呼び出して同じオブジェクトを再利用するよりも大幅にコストがかかる可能性があります。
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_sstream_from_string_view
|
202306L
|
(C++26) | std::stringstream と std::string_view の連携 ( 9-11 ) |
例
#include <iostream> #include <sstream> int main() { // デフォルトコンストラクタ(入出力ストリーム) std::stringstream buf1; buf1 << 7; int n = 0; buf1 >> n; std::cout << "buf1 = " << buf1.str() << " n = " << n << '\n'; // 入力ストリーム std::istringstream inbuf("-10"); inbuf >> n; std::cout << "n = " << n << '\n'; // 追加モードでの出力ストリーム (C++11) std::ostringstream buf2("test", std::ios_base::ate); buf2 << '1'; std::cout << buf2.str() << '\n'; }
出力:
buf1 = 7 n = 7 n = -10 test1
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| P0935R0 | C++11 | デフォルトコンストラクタはexplicitであった | 暗黙的(implicit)に変更 |
関連項目
|
基盤となる文字列デバイスオブジェクトの内容を取得または設定する
(public member function) |
|
basic_stringbuf
オブジェクトを構築する
(
std::basic_stringbuf<CharT,Traits,Allocator>
のpublic member function)
|