Streams中的内联忽略
Inline ignore in Streams
本文关键字:Streams 更新时间:2023-10-16
有没有一种方法可以忽略C++内联中的字符?
例如,在这个答案中,我正在阅读:
istringstream foo("2000-13-30");
foo >> year;
foo.ignore();
foo >> month;
foo.ignore();
foo >> day;
但我希望能够在线完成这一切:
foo >> year >> ignore() >> month >> ignore() >> day;
我以为这在C++中是可能的,但它绝对不是为我编译的。也许我还记得另一种语言?
foo.ignore()
是一个成员函数,因此不能用作操纵器。它也没有正确的返回类型和参数声明可以作为一个声明使用。不过,你可以很容易地制作自己的:
std::istream& skip(std::istream& is) {
return (is >> std::ws).ignore();
}
foo >> year >> skip >> month >> skip >> day;
相关文章:
- 面临分段故障 使用 ffmpeg 读取视频时,因为"pFormatCtx-> streams [i]-> codecpar"的地址0x00
- 如何创建一个 while 循环,继续循环,直到在C++中输入'using streams'键?
- C++应用程序缺少 winrt::Windows::Storage::Streams::D ataWriter
- Introduction To C++ IO Streams
- 为什么cpplint不鼓励Streams
- Streams中的内联忽略
- 在C++std::streams中,失败后,如何获得失败原因?必需:线程安全,适用于Windows和Linux(或至少M
- 从 Windows::Storage::Streams::IBuffer 中获取字节数组
- GCC, std::ctype specialisation & streams
- cstdio streams vs iostream streams?
- C++ io streams versus mmap
- C++11 File Streams
- c++ JNI在做任何IO/Streams时崩溃/挂起
- boost::streams::output过滤器的意外行为
- Including windows.storage.streams.h
- Override c++ streams
- Cython: working with C++ streams