87 lines
2.8 KiB
Markdown
87 lines
2.8 KiB
Markdown
[fstream.cons]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.10 File-based streams [[file.streams]](file.streams#fstream.cons)
|
||
|
||
### 31.10.6 Class template basic_fstream [[fstream]](fstream#cons)
|
||
|
||
#### 31.10.6.2 Constructors [fstream.cons]
|
||
|
||
[ð](#lib:basic_fstream,constructor)
|
||
|
||
`basic_fstream();
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12369)
|
||
|
||
*Effects*: Initializes the base class withbasic_iostream<charT, traits>(addressof(*sb*)) ([[iostream.cons]](iostream.cons "31.7.5.7.2 Constructors"))
|
||
and*sb* with basic_filebuf<charT, traits>()[.](#1.sentence-1)
|
||
|
||
[ð](#lib:basic_fstream,constructor_)
|
||
|
||
`explicit basic_fstream(
|
||
const char* s,
|
||
ios_base::openmode mode = ios_base::in | ios_base::out);
|
||
explicit basic_fstream(
|
||
const filesystem::path::value_type* s,
|
||
ios_base::openmode mode = ios_base::in | ios_base::out); // wide systems only; see [[fstream.syn]](fstream.syn "31.10.1 Header <fstream> synopsis")
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12388)
|
||
|
||
*Effects*: Initializes the base class withbasic_iostream<charT, traits>(addressof(*sb*)) ([[iostream.cons]](iostream.cons "31.7.5.7.2 Constructors"))
|
||
and*sb* with basic_filebuf<charT, traits>()[.](#2.sentence-1)
|
||
|
||
Then callsrdbuf()->open(s, mode)[.](#2.sentence-2)
|
||
|
||
If that function returns a null pointer, callssetstate(failbit)[.](#2.sentence-3)
|
||
|
||
[ð](#lib:basic_fstream,constructor__)
|
||
|
||
`explicit basic_fstream(
|
||
const string& s,
|
||
ios_base::openmode mode = ios_base::in | ios_base::out);
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12408)
|
||
|
||
*Effects*: Equivalent to basic_fstream(s.c_str(), mode)[.](#3.sentence-1)
|
||
|
||
[ð](#lib:basic_fstream,constructor___)
|
||
|
||
`template<class T>
|
||
explicit basic_fstream(const T& s, ios_base::openmode mode = ios_base::in | ios_base::out);
|
||
`
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12420)
|
||
|
||
*Constraints*: is_same_v<T, filesystem::path> is true[.](#4.sentence-1)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12424)
|
||
|
||
*Effects*: Equivalent to basic_fstream(s.c_str(), mode)[.](#5.sentence-1)
|
||
|
||
[ð](#lib:basic_fstream,constructor____)
|
||
|
||
`basic_fstream(basic_fstream&& rhs);
|
||
`
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12435)
|
||
|
||
*Effects*: Move constructs the base class, and the contained basic_filebuf[.](#6.sentence-1)
|
||
|
||
Then calls basic_istream<charT, traits>::set_rdbuf(addressof(*sb*)) to install the contained basic_filebuf[.](#6.sentence-2)
|