"my_ifstream >> my_char"在哪里记录?

Where is "my_ifstream >> my_char" documented?

本文关键字:gt my 记录 char ifstream 在哪里      更新时间:2023-10-16

我正在使用"cin>> my_char"在我尝试解析的输入记录中删除":"。下面是一个最小的例子。

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main () {
    char c;
    int x, y;
    cin >> hex >> x >> hex >> c >> y;
    cout << "x = " << x << "ny = " << y << "n";
}

和示例用法:

rc@timecube:/tmp$ g++ test.cpp && echo "0000a:ffff" | ./a.out 
x = 10
y = 65535

这段代码完全符合我的需求,但我不明白为什么。我希望看到类似的东西:

istream& operator>> (char& val);

在 istream 参考中,但我没有。

那么这种行为是如何记录的呢?

在自由函数下。

并非所有运营商都是会员!