![](/img/trans.png)
[英]undefined reference to `boost::iostreams::mapped_file_source::mapped_file_source()'
[英]What exceptions does boost mapped_file_source throw?
在没有找到文件的情况下,Boost mapping_file_source似乎抛出异常。 它会抛出什么异常类? 除非我缺少某些内容,否则文档中似乎没有说。
编辑:测试用例:
#include <boost/iostreams/device/mapped_file.hpp>
int main(int argc, char** argv) {
boost::iostreams::mapped_file_source file;
file.open(argv[1]);
return 0;
}
万一映射失败,代码
mapped_handle_ =
::CreateFileMappingA(
handle_,
NULL,
protect,
0,
0,
NULL );
if (mapped_handle_ == NULL)
cleanup_and_throw("failed create mapping");
最终会抛出一个
boost::iostreams::detail::throw_system_failure(msg);
即std::exception
的子类。 在这种情况下,应该为std::ios::failure
:
BOOST_IOSTREAMS_FAILURE
如果可用,扩展为std :: ios_base :: failure,否则扩展为合适的std :: exception派生类。
参考: http : //www.boost.org/doc/libs/1_41_0/libs/iostreams/src/mapped_file.cpp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.