gpt4 book ai didi

c++ - boost mapped_file_source 抛出什么异常?

转载 作者:搜寻专家 更新时间:2023-10-31 01:02:46 27 4
gpt4 key购买 nike

Boost mapped_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

Expands to std::ios_base::failure if available, and to a suitable derived class of std::exception otherwise.

引用:http://www.boost.org/doc/libs/1_41_0/libs/iostreams/src/mapped_file.cpp

关于c++ - boost mapped_file_source 抛出什么异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26608264/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com