std::basic_fstream<CharT,Traits>:: basic_fstream
|
basic_fstream
(
)
;
|
(1) | |
|
explicit
basic_fstream
(
const
char
*
filename,
std::
ios_base
::
openmode
mode
|
(2) | |
|
explicit
basic_fstream
(
const
std
::
filesystem
::
path
::
value_type
*
filename,
std::
ios_base
::
openmode
mode
|
(3) | (C++17부터) |
|
explicit
basic_fstream
(
const
std::
string
&
filename,
std::
ios_base
::
openmode
mode
|
(4) | (C++11부터) |
|
template
<
class
FsPath
>
explicit
basic_fstream
(
const
FsPath
&
filename,
|
(5) | (C++17부터) |
|
basic_fstream
(
basic_fstream
&&
other
)
;
|
(6) | (C++11부터) |
|
basic_fstream
(
const
basic_fstream
&
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::fstream f0; std::fstream f1("test.bin", std::ios::binary); std::string name = "example.txt"; std::fstream f2(name); std::fstream f3(std::move(f1)); }
결함 보고서
다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 460 | C++98 |
오버로드
(2)
에서
mode
의 기본 인자가 누락됨
(해당 내용은 개요 에 존재함) |
추가됨 |
| LWG 3430 | C++17 | std::filesystem::path 오버로드가 원치 않는 변환을 유발함 | 템플릿으로 만들어 회피함 |
참고 항목
|
파일을 열고 스트림과 연결합니다
(public member function) |
|
|
파일을 열고 연결된 문자 시퀀스로 구성합니다
(public member function of
std::basic_filebuf<CharT,Traits>
)
|
|
rdbuf
를 교체하되 오류 상태를 지우지 않습니다
(protected member function) |
|
|
객체를 생성합니다
(public member function of
std::basic_iostream<CharT,Traits>
)
|