gpt4 book ai didi

c++ - boost mapped_file_sink 抛出异常

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:00:39 27 4
gpt4 key购买 nike

我不知道为什么在创建 mapped_file_sink 对象时会抛出异常。

异常(exception):

terminate called after throwing an instance of 
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::exception> >'
int main(int argc,char *argv[])
{
boost::iostreams::mapped_file_sink sink(argv[1]);
char temp[] ="AAAA";
memcpy(sink.data(), temp, sizeof(temp));
sink.close();
return 1;
}

最佳答案

很可能文件 AAAA 不存在。为了创建文件,您需要使用 boost::iostreams::mapped_file_params 变量打开内存映射文件,该变量的 new_file_size 字段将设置为所需的文件大小。

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

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