Files
2025-10-25 03:02:53 +03:00

153 lines
3.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.1Class 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.1Class 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)