This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

82
cppdraft/ifstream/cons.md Normal file
View File

@@ -0,0 +1,82 @@
[ifstream.cons]
# 31 Input/output library [[input.output]](./#input.output)
## 31.10 File-based streams [[file.streams]](file.streams#ifstream.cons)
### 31.10.4 Class template basic_ifstream [[ifstream]](ifstream#cons)
#### 31.10.4.2 Constructors [ifstream.cons]
[🔗](#lib:basic_ifstream,constructor)
`basic_ifstream();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11843)
*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream.cons]](istream.cons "31.7.5.2.2Constructors"))
and *sb* withbasic_filebuf<charT, traits>() ([[filebuf.cons]](filebuf.cons "31.10.3.2Constructors"))[.](#1.sentence-1)
[🔗](#lib:basic_ifstream,constructor_)
`explicit basic_ifstream(const char* s,
ios_base::openmode mode = ios_base::in);
explicit basic_ifstream(const filesystem::path::value_type* s,
ios_base::openmode mode = ios_base::in); // wide systems only; see [[fstream.syn]](fstream.syn "31.10.1Header <fstream> synopsis")
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11860)
*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream.cons]](istream.cons "31.7.5.2.2Constructors"))
and *sb* withbasic_filebuf<charT, traits>() ([[filebuf.cons]](filebuf.cons "31.10.3.2Constructors")),
then callsrdbuf()->open(s, mode | ios_base::in)[.](#2.sentence-1)
If that function returns a null pointer, callssetstate(failbit)[.](#2.sentence-2)
[🔗](#lib:basic_ifstream,constructor__)
`explicit basic_ifstream(const string& s,
ios_base::openmode mode = ios_base::in);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11879)
*Effects*: Equivalent to basic_ifstream(s.c_str(), mode)[.](#3.sentence-1)
[🔗](#lib:basic_ifstream,constructor___)
`template<class T>
explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11891)
*Constraints*: is_same_v<T, filesystem::path> is true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11895)
*Effects*: Equivalent to basic_ifstream(s.c_str(), mode)[.](#5.sentence-1)
[🔗](#lib:basic_ifstream,constructor____)
`basic_ifstream(basic_ifstream&& rhs);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11906)
*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)

View File

@@ -0,0 +1,38 @@
[ifstream.general]
# 31 Input/output library [[input.output]](./#input.output)
## 31.10 File-based streams [[file.streams]](file.streams#ifstream.general)
### 31.10.4 Class template basic_ifstream [[ifstream]](ifstream#general)
#### 31.10.4.1 General [ifstream.general]
[🔗](#lib:basic_ifstream)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_ifstream : public basic_istream<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; // [[ifstream.cons]](ifstream.cons "31.10.4.2Constructors"), constructors basic_ifstream(); explicit basic_ifstream(const char* s,
ios_base::openmode mode = ios_base::in); explicit basic_ifstream(const filesystem::path::value_type* s,
ios_base::openmode mode = ios_base::in);// wide systems only; see [[fstream.syn]](fstream.syn "31.10.1Header <fstream> synopsis")explicit basic_ifstream(const string& s,
ios_base::openmode mode = ios_base::in); template<class T>explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in);
basic_ifstream(const basic_ifstream&) = delete;
basic_ifstream(basic_ifstream&& rhs);
basic_ifstream& operator=(const basic_ifstream&) = delete;
basic_ifstream& operator=(basic_ifstream&& rhs); // [[ifstream.swap]](ifstream.swap "31.10.4.3Swap"), swapvoid swap(basic_ifstream& rhs); // [[ifstream.members]](ifstream.members "31.10.4.4Member functions"), members basic_filebuf<charT, traits>* rdbuf() const;
native_handle_type native_handle() const noexcept; bool is_open() const; void open(const char* s, ios_base::openmode mode = ios_base::in); void open(const filesystem::path::value_type* s,
ios_base::openmode mode = ios_base::in); // wide systems only; see [[fstream.syn]](fstream.syn "31.10.1Header <fstream> synopsis")void open(const string& s, ios_base::openmode mode = ios_base::in); void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in); void close(); private: basic_filebuf<charT, traits> *sb*; // *exposition only*};}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11821)
The classbasic_ifstream<charT, traits> supports reading from named files[.](#1.sentence-1)
It uses abasic_filebuf<charT, traits> object to control the associated
sequence[.](#1.sentence-2)
For the sake of exposition, the maintained data is presented here as:
- [(1.1)](#1.1)
*sb*, the filebuf object[.](#1.sentence-3)

View File

@@ -0,0 +1,84 @@
[ifstream.members]
# 31 Input/output library [[input.output]](./#input.output)
## 31.10 File-based streams [[file.streams]](file.streams#ifstream.members)
### 31.10.4 Class template basic_ifstream [[ifstream]](ifstream#members)
#### 31.10.4.4 Member functions [ifstream.members]
[🔗](#lib:rdbuf,basic_ifstream)
`basic_filebuf<charT, traits>* rdbuf() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11949)
*Returns*: const_cast<basic_filebuf<charT, traits>*>(addressof(*sb*))[.](#1.sentence-1)
[🔗](#lib:native_handle,basic_ifstream)
`native_handle_type native_handle() const noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11960)
*Effects*: Equivalent to: return rdbuf()->native_handle();
[🔗](#lib:is_open,basic_ifstream)
`bool is_open() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11971)
*Returns*: rdbuf()->is_open()[.](#3.sentence-1)
[🔗](#lib:open,basic_ifstream)
`void open(const char* s, ios_base::openmode mode = ios_base::in);
void open(const filesystem::path::value_type* s,
ios_base::openmode mode = ios_base::in); // wide systems only; see [[fstream.syn]](fstream.syn "31.10.1Header <fstream> synopsis")
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11984)
*Effects*: Callsrdbuf()->open(s, mode | ios_base::in)[.](#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.4Flags functions"))[.](#4.sentence-2)
[🔗](#lib:open,basic_ifstream_)
`void open(const string& s, ios_base::openmode mode = ios_base::in);
void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12003)
*Effects*: Calls open(s.c_str(), mode)[.](#5.sentence-1)
[🔗](#lib:close,basic_ifstream)
`void close();
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L12014)
*Effects*: Callsrdbuf()->close() and, if that function returns
a null pointer,
callssetstate(failbit) (which may throwios_base::failure) ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions"))[.](#6.sentence-1)

32
cppdraft/ifstream/swap.md Normal file
View File

@@ -0,0 +1,32 @@
[ifstream.swap]
# 31 Input/output library [[input.output]](./#input.output)
## 31.10 File-based streams [[file.streams]](file.streams#ifstream.swap)
### 31.10.4 Class template basic_ifstream [[ifstream]](ifstream#swap)
#### 31.10.4.3 Swap [ifstream.swap]
[🔗](#lib:swap,basic_ifstream)
`void swap(basic_ifstream& rhs);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11921)
*Effects*: Exchanges the state of *this and rhs by callingbasic_istream<charT, traits>::swap(rhs) and*sb*.swap(rhs.*sb*)[.](#1.sentence-1)
[🔗](#lib:swap,basic_ifstream_)
`template<class charT, class traits>
void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L11936)
*Effects*: Equivalent to x.swap(y)[.](#2.sentence-1)