83 lines
2.6 KiB
Markdown
83 lines
2.6 KiB
Markdown
[ofstream.members]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.10 File-based streams [[file.streams]](file.streams#ofstream.members)
|
||
|
||
### 31.10.5 Class template basic_ofstream [[ofstream]](ofstream#members)
|
||
|
||
#### 31.10.5.4 Member functions [ofstream.members]
|
||
|
||
[ð](#lib:rdbuf,basic_ofstream)
|
||
|
||
`basic_filebuf<charT, traits>* rdbuf() const;
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12208)
|
||
|
||
*Returns*: const_cast<basic_filebuf<charT, traits>*>(addressof(*sb*))[.](#1.sentence-1)
|
||
|
||
[ð](#lib:native_handle,basic_ofstream)
|
||
|
||
`native_handle_type native_handle() const noexcept;
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12219)
|
||
|
||
*Effects*: Equivalent to: return rdbuf()->native_handle();
|
||
|
||
[ð](#lib:is_open,basic_ofstream)
|
||
|
||
`bool is_open() const;
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12230)
|
||
|
||
*Returns*: rdbuf()->is_open()[.](#3.sentence-1)
|
||
|
||
[ð](#lib:open,basic_ofstream)
|
||
|
||
`void open(const char* s, ios_base::openmode mode = ios_base::out);
|
||
void open(const filesystem::path::value_type* s,
|
||
ios_base::openmode mode = ios_base::out); // wide systems only; see [[fstream.syn]](fstream.syn "31.10.1 Header <fstream> synopsis")
|
||
`
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12243)
|
||
|
||
*Effects*: Callsrdbuf()->open(s, mode | ios_base::out)[.](#4.sentence-1)
|
||
|
||
If that function does not return a null pointer
|
||
calls clear(),
|
||
otherwise callssetstate(failbit) (which may throwios_base::failure) ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions"))[.](#4.sentence-2)
|
||
|
||
[ð](#lib:close,basic_ofstream)
|
||
|
||
`void close();
|
||
`
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12261)
|
||
|
||
*Effects*: Callsrdbuf()->close() and, if that function fails (returns a null pointer), callssetstate(failbit) (which may throwios_base::failure) ([[iostate.flags]](iostate.flags "31.5.4.4 Flags functions"))[.](#5.sentence-1)
|
||
|
||
[ð](#lib:open,basic_ofstream_)
|
||
|
||
`void open(const string& s, ios_base::openmode mode = ios_base::out);
|
||
void open(const filesystem::path& s, ios_base::openmode mode = ios_base::out);
|
||
`
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12278)
|
||
|
||
*Effects*: Calls open(s.c_str(), mode)[.](#6.sentence-1)
|