IO库
iostream:定义了读写流的基本类型
- istream,wistream 从流读取数据
- ostream,wostream 从流写入数据
- iostream,wiostream 读写流
fstream:定义了读写命名文件的类型
- ifstream,wifstream 从文件读取数据
- ofstream,wofstream 向文件写入数据
- fstream,wfstream 读写文件
sstream:定义了读写内存string对象的类型
- istringstream,wistringstream 从string读取数据
- ostringstream,wostringstream 向string写入数据
- stringstream,wstringstream 读写string
IO对象无拷贝或赋值
条件状态(condition state)
strm::iostate 提供了表达条件状态的完整功能
strm::badbit 流已崩溃
strm::failbit IO操作失败
strm::eofbit 流到达了文件末尾
strm::goodbit 流未处于错误状态
s.eof() 若流s的eofbit置位,返回true
s.fail() 若failbit或badbit置位,返回true
s.bad() 若badbit置位,返回true
s.good() 若s处于有效状态,返回true
s.clear() 将所有条件状态位复位,返回void
s.clear(flags)
s.setstate(flags)
s.rdstate() 返回当前条件状态
刷新缓冲
unitbuf 每次输出后都刷新缓冲区
nounitbuf 重置流,使用正常的刷新机制
文件模式(file mode)
顺序容器(sequential container)
vector 可变大小数组,通常使用vector
deque 双端队列
list 双向列表
forward_list 单项列表
array 固定大小数组
string 字符容器,与vector类似
迭代器范围(iterator range) [begin,end)
swap(c1,c2); 交换c1,c2中的元素
c1.swap(c2); 拷贝c2的元素
assign
push_back
push_front
insert
emplace_front
emplace
emplace_back
pop_back
pop_front
erase
clear
resize
capacity
shrink_to_fit
reserve
size
substr
compare
适配器(adaptor)
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!