标准库标头 <ios>

来自cppreference.com
< cpp‎ | header


 
 
标准库头
 

此头文件是输入/输出库的一部分。

目录

包含

输入/输出库中所有类的前置声明[编辑]

管理格式化标志和输入/输出异常
(类)[编辑]
管理任意流缓冲
(类模板)[编辑]
std::iosstd::basic_ios<char>(typedef)
std::wiosstd::basic_ios<wchar_t>(typedef)
表示流或文件中的绝对位置
(类模板)[编辑]
(C++11)
输入/输出流的错误码
(枚举)[编辑]
扩充类型特征 std::is_error_code_enum 以鉴别 iostream 错误码
(类模板特化)[编辑]
表示相对的文件/流位置(距 fpos 的偏移),足以表示任何文件大小
(typedef)[编辑]
表示一次输入/输出操作中转移的字符数或输入/输出缓冲区的大小
(typedef)[编辑]

函数

鉴别 iostream 错误类别
(函数)[编辑]
构造一个 iostream 错误码
(函数)[编辑]
构造一个 iostream error_condition
(函数)[编辑]
在布尔值的文本和数值表示间切换
(函数)[编辑]
控制是否使用前缀指示数值基数
(函数)[编辑]
控制浮点数表示是否始终包含小数点
(函数)[编辑]
控制是否将 + 号与非负数一同使用
(函数)[编辑]
控制是否跳过输入上的前导空白符
(函数)[编辑]
控制一些输出操作是否使用大写字母
(函数)[编辑]
控制是否每次操作后冲洗输出
(函数)[编辑]
设置填充字符的布置
(函数)[编辑]
更改用于整数输入/输出的基数
(函数)[编辑]
更改用数于浮点数 I/O 的格式化
(函数)[编辑]

[编辑]概要

#include <iosfwd>   namespace std {using streamoff =/* 由实现定义 */;using streamsize =/* 由实现定义 */;template<class StateT>class fpos;   class ios_base;template<class CharT, class Traits = char_traits<CharT>>class basic_ios;   // 操纵符 ios_base& boolalpha (ios_base& str); ios_base& noboolalpha(ios_base& str);   ios_base& showbase (ios_base& str); ios_base& noshowbase (ios_base& str);   ios_base& showpoint (ios_base& str); ios_base& noshowpoint(ios_base& str);   ios_base& showpos (ios_base& str); ios_base& noshowpos (ios_base& str);   ios_base& skipws (ios_base& str); ios_base& noskipws (ios_base& str);   ios_base& uppercase (ios_base& str); ios_base& nouppercase(ios_base& str);   ios_base& unitbuf (ios_base& str); ios_base& nounitbuf (ios_base& str);   // 调整域 ios_base& internal (ios_base& str); ios_base& left (ios_base& str); ios_base& right (ios_base& str);   // 基底域 ios_base& dec (ios_base& str); ios_base& hex (ios_base& str); ios_base& oct (ios_base& str);   // 浮点域 ios_base& fixed (ios_base& str); ios_base& scientific (ios_base& str); ios_base& hexfloat (ios_base& str); ios_base& defaultfloat(ios_base& str);   // 错误报告enumclass io_errc { stream =1};   template<>struct is_error_code_enum<io_errc>:public true_type {}; error_code make_error_code(io_errc e)noexcept; error_condition make_error_condition(io_errc e)noexcept;const error_category& iostream_category()noexcept;}

[编辑]std::ios_base

namespace std {class ios_base {public:class failure;// 见描述   // fmtflagsusing fmtflags =/*位掩码类型-1*/;staticconstexpr fmtflags boolalpha =/* 未指明 */;staticconstexpr fmtflags dec =/* 未指明 */;staticconstexpr fmtflags fixed =/* 未指明 */;staticconstexpr fmtflags hex =/* 未指明 */;staticconstexpr fmtflags internal =/* 未指明 */;staticconstexpr fmtflags left =/* 未指明 */;staticconstexpr fmtflags oct =/* 未指明 */;staticconstexpr fmtflags right =/* 未指明 */;staticconstexpr fmtflags scientific =/* 未指明 */;staticconstexpr fmtflags showbase =/* 未指明 */;staticconstexpr fmtflags showpoint =/* 未指明 */;staticconstexpr fmtflags showpos =/* 未指明 */;staticconstexpr fmtflags skipws =/* 未指明 */;staticconstexpr fmtflags unitbuf =/* 未指明 */;staticconstexpr fmtflags uppercase =/* 未指明 */;staticconstexpr fmtflags adjustfield =/* 见描述 */;staticconstexpr fmtflags basefield =/* 见描述 */;staticconstexpr fmtflags floatfield =/* 见描述 */;   // iostateusing iostate =/*位掩码类型-2*/;staticconstexpr iostate badbit =/* 未指明 */;staticconstexpr iostate eofbit =/* 未指明 */;staticconstexpr iostate failbit =/* 未指明 */;staticconstexpr iostate goodbit =/* 见描述 */;   // openmodeusing openmode =/*位掩码类型-3*/;staticconstexpr openmode app =/* 未指明 */;staticconstexpr openmode ate =/* 未指明 */;staticconstexpr openmode binary =/* 未指明 */;staticconstexpr openmode in =/* 未指明 */;staticconstexpr openmode out =/* 未指明 */;staticconstexpr openmode trunc =/* 未指明 */;staticconstexpr openmode noreplace =/* 未指明 */   // seekdirusing seekdir =/*位掩码类型-4*/;staticconstexpr seekdir beg =/* 未指明 */;staticconstexpr seekdir cur =/* 未指明 */;staticconstexpr seekdir end =/* 未指明 */;   class Init;   // fmtflags 状态 fmtflags flags()const; fmtflags flags(fmtflags fmtfl); fmtflags setf(fmtflags fmtfl); fmtflags setf(fmtflags fmtfl, fmtflags mask);void unsetf(fmtflags mask);   streamsize precision()const; streamsize precision(streamsize prec); streamsize width()const; streamsize width(streamsize wide);   // 本地环境 locale imbue(const locale& loc); locale getloc()const;   // 存储staticint xalloc();long& iword(int idx);void*& pword(int idx);   // 析构函数virtual ~ios_base();   // 回调enum event { erase_event, imbue_event, copyfmt_event };using event_callback =void(*)(event, ios_base&, int idx);void register_callback(event_callback fn, int idx);   ios_base(const ios_base&)= delete; ios_base& operator=(const ios_base&)= delete;   staticbool sync_with_stdio(bool sync =true);   protected: ios_base();   private:staticint index;// 仅用于阐释long* iarray;// 仅用于阐释void** parray;// 仅用于阐释};}

[编辑]std::ios_base::failure

namespace std {class ios_base::failure:public system_error {public:explicit failure(const string& msg, const error_code& ec = io_errc::stream);explicit failure(constchar* msg, const error_code& ec = io_errc::stream);};}

[编辑]std::ios_base::Init

namespace std {class ios_base::Init{public: Init(); Init(const Init&)=default; ~Init(); Init& operator=(const Init&)=default;private:staticint init_cnt;// 仅用于阐释};}

[编辑]类模板 std::fpos

namespace std {template<class StateT>class fpos {public:// 成员 StateT state()const;void state(stateT);private; StateT st;// 仅用于阐释};}

[编辑]类模板 std::basic_ios

namespace std {template<class CharT, class Traits = char_traits<CharT>>class basic_ios :public ios_base {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;   // 标志函数explicit operator bool()const;bool operator!()const; iostate rdstate()const;void clear(iostate state = goodbit);void setstate(iostate state);bool good()const;bool eof()const;bool fail()const;bool bad()const;   iostate exceptions()const;void exceptions(iostate except);   // 构造函数/析构函数explicit basic_ios(basic_streambuf<CharT, Traits>* sb);virtual ~basic_ios();   // 成员 basic_ostream<CharT, Traits>* tie()const; basic_ostream<CharT, Traits>* tie(basic_ostream<CharT, Traits>* tiestr);   basic_streambuf<CharT, Traits>* rdbuf()const; basic_streambuf<CharT, Traits>* rdbuf(basic_streambuf<CharT, Traits>* sb);   basic_ios& copyfmt(const basic_ios& rhs);   char_type fill()const; char_type fill(char_type ch);   locale imbue(const locale& loc);   char narrow(char_type c, char dfault)const; char_type widen(char c)const;   basic_ios(const basic_ios&)= delete; basic_ios& operator=(const basic_ios&)= delete;   protected: basic_ios();void init(basic_streambuf<CharT, Traits>* sb);void move(basic_ios& rhs);void move(basic_ios&& rhs);void swap(basic_ios& rhs)noexcept;void set_rdbuf(basic_streambuf<CharT, Traits>* sb);};}

[编辑]缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 出版时的行为 正确行为
LWG 35 C++98 概要中缺失了 unitbufnounitbuf 的原型 已补充
LWG 78 C++98 概要中 ios_base::register_callback
形参 fn 的类型被误写为 event_call_back
改正为 event_callback
close