std::basic_ifstream<CharT,Traits>:: basic_ifstream
|
basic_ifstream
(
)
;
|
(1) | |
|
explicit
basic_ifstream
(
const
char
*
filename,
std::
ios_base
::
openmode
mode
|
(2) | |
|
explicit
basic_ifstream
(
const
std
::
filesystem
::
path
::
value_type
*
filename,
std::
ios_base
::
openmode
mode
|
(3) | (C++17以降) |
|
explicit
basic_ifstream
(
const
std::
string
&
filename,
std::
ios_base
::
openmode
mode
|
(4) | (C++11以降) |
|
template
<
class
FsPath
>
explicit
basic_ifstream
(
const
FsPath
&
filename,
|
(5) | (C++17以降) |
|
basic_ifstream
(
basic_ifstream
&&
other
)
;
|
(6) | (C++11以降) |
|
basic_ifstream
(
const
basic_ifstream
&
rhs
)
=
delete
;
|
(7) | (C++11以降) |
新しいファイルストリームを構築します。
open()
の呼び出しがnullポインタを返した場合、
setstate
(
failbit
)
を設定します。
オーバーロード
(3)
は
std
::
filesystem
::
path
::
value_type
が
char
でない場合にのみ提供されます。
(C++17以降)
FsPath
が
std::filesystem::path
である場合にのみオーバーロード解決に参加する。
(C++17以降)
rdbuf()
ポインタに影響しない)、次に
std::basic_filebuf
メンバをムーブ構築し、その後
this
-
>
set_rdbuf
(
)
を呼び出して、新しい
basic_filebuf
を基底クラスの
rdbuf()
ポインタとして設定する。
目次 |
パラメータ
| filename | - | 開くファイルの名前 | ||||||||||||||||
| mode | - |
ストリームのオープンモードを指定します。以下の定数とそれらのビット単位ORを使用できます:
|
||||||||||||||||
| other | - | ソースとして使用する別のファイルストリーム |
例
#include <fstream> #include <string> #include <utility> int main() { std::ifstream f0; std::ifstream f1("test.bin", std::ios::binary); std::string name = "example.txt"; std::ifstream f2(name); std::ifstream f3(std::move(f1)); }
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3430 | C++17 | std::filesystem::path オーバーロードが望ましくない変換を引き起こした | テンプレート化することで回避 |
関連項目
|
ファイルを開き、ストリームに関連付ける
(public member function) |
|
|
ファイルを開き、関連付けられた文字シーケンスとして設定する
(
std::basic_filebuf<CharT,Traits>
のpublic member function)
|
|
rdbuf
を置き換える(エラー状態はクリアしない)
(protected member function) |
|
|
オブジェクトを構築する
(
std::basic_istream<CharT,Traits>
のpublic member function)
|