153 lines
3.9 KiB
Markdown
153 lines
3.9 KiB
Markdown
[iostate.flags]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#iostate.flags)
|
||
|
||
### 31.5.4 Class template basic_ios [[ios]](ios#iostate.flags)
|
||
|
||
#### 31.5.4.4 Flags functions [iostate.flags]
|
||
|
||
[ð](#lib:operator_bool,basic_ios)
|
||
|
||
`explicit operator bool() const;
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2236)
|
||
|
||
*Returns*: !fail()[.](#1.sentence-1)
|
||
|
||
[ð](#lib:operator!,basic_ios)
|
||
|
||
`bool operator!() const;
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2247)
|
||
|
||
*Returns*: fail()[.](#2.sentence-1)
|
||
|
||
[ð](#lib:rdstate,basic_ios)
|
||
|
||
`iostate rdstate() const;
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2258)
|
||
|
||
*Returns*: The error state of the stream buffer[.](#3.sentence-1)
|
||
|
||
[ð](#lib:clear,basic_ios)
|
||
|
||
`void clear(iostate state = goodbit);
|
||
`
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2269)
|
||
|
||
*Effects*: If ((state | (rdbuf() ? goodbit : badbit)) & exceptions()) == 0,
|
||
returns[.](#4.sentence-1)
|
||
|
||
Otherwise, the function throws an object of classios_base::failure ([[ios.failure]](ios.failure "31.5.2.2.1 Class ios_base::failure")),
|
||
constructed withimplementation-defined
|
||
argument values[.](#4.sentence-2)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2279)
|
||
|
||
*Postconditions*: Ifrdbuf() != 0 thenstate == rdstate();
|
||
otherwiserdstate() == (state | ios_base::badbit)[.](#5.sentence-1)
|
||
|
||
[ð](#lib:setstate,basic_ios)
|
||
|
||
`void setstate(iostate state);
|
||
`
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2295)
|
||
|
||
*Effects*: Callsclear(rdstate() | state) (which may throwios_base::failure ([[ios.failure]](ios.failure "31.5.2.2.1 Class ios_base::failure")))[.](#6.sentence-1)
|
||
|
||
[ð](#lib:good,basic_ios)
|
||
|
||
`bool good() const;
|
||
`
|
||
|
||
[7](#7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2309)
|
||
|
||
*Returns*: rdstate() == 0[.](#7.sentence-1)
|
||
|
||
[ð](#lib:eof,basic_ios)
|
||
|
||
`bool eof() const;
|
||
`
|
||
|
||
[8](#8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2320)
|
||
|
||
*Returns*: true ifeofbit is set inrdstate()[.](#8.sentence-1)
|
||
|
||
[ð](#lib:fail,basic_ios)
|
||
|
||
`bool fail() const;
|
||
`
|
||
|
||
[9](#9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2335)
|
||
|
||
*Returns*: true iffailbit orbadbit is set inrdstate()[.](#9.sentence-1)[264](#footnote-264 "Checking badbit also for fail() is historical practice.")
|
||
|
||
[ð](#lib:bad,basic_ios)
|
||
|
||
`bool bad() const;
|
||
`
|
||
|
||
[10](#10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2359)
|
||
|
||
*Returns*: true ifbadbit is set inrdstate()[.](#10.sentence-1)
|
||
|
||
[ð](#lib:exceptions,basic_ios)
|
||
|
||
`iostate exceptions() const;
|
||
`
|
||
|
||
[11](#11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2374)
|
||
|
||
*Returns*: A mask that determines what elements set inrdstate() cause exceptions to be thrown[.](#11.sentence-1)
|
||
|
||
[ð](#lib:exceptions,basic_ios_)
|
||
|
||
`void exceptions(iostate except);
|
||
`
|
||
|
||
[12](#12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2387)
|
||
|
||
*Effects*: Callsclear(rdstate())[.](#12.sentence-1)
|
||
|
||
[13](#13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2392)
|
||
|
||
*Postconditions*: except == exceptions()[.](#13.sentence-1)
|
||
|
||
[264)](#footnote-264)[264)](#footnoteref-264)
|
||
|
||
Checkingbadbit also forfail() is historical practice[.](#footnote-264.sentence-1)
|