我不知道为什么在创建mapled_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 mapping_file_sink抛出异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7993049/

10-12 21:31
查看更多