提问人:tangy 提问时间:2/20/2019 最后编辑:tangy 更新时间:2/21/2019 访问量:31
Boost Iostreams component() 调用失败
Boost Iostreams component() call fails
问:
我正在尝试访问添加到链中的底层。根据常见问题解答,一种方法是使用 。为什么下面的代码会失败?std::ifstream
boost::iostreams::filtering_streambuf
component/component_type
std::ifstream fp{"input.txt", std::ios_base::in | std::ios_base::binary};
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::counter{});
in.push(fp);
auto *c = in.component<boost::iostreams::counter>(0); // works
std::cout << (c == nullptr) << std::endl; // 0
std::cout << c->characters() << std::endl;
std::cout << c->lines() << std::endl;
// Look into ifstream
auto *f_ptr = in.component<std::ifstream>(1); // fails
std::cout << (f_ptr == nullptr) << std::endl; // 1
答: 暂无答案
评论