繁体   English   中英

隐式声明的 boost::iostreams::mapped_file_source 已弃用

[英]Implicitly-declared boost::iostreams::mapped_file_source is deprecated

我正在定义一个结构如下:

struct memory_dump {
    filesystem::path path;
    boost::iostreams::mapped_file_source mapped_file;
    memory_dump_type type;
    long long int offset;
};

但是, gcc生成以下警告:

warning: implicitly-declared ‘boost::iostreams::mapped_file_source& boost::iostreams::mapped_file_source::operator=(const boost::iostreams::mapped_file_source&)’ is deprecated [-Wdeprecated-copy]
   39 | struct memory_dump {
      |        ^~~~~~~~~~~

此警告仅在将我的Boost版本从1.62.0左右升级到1.72.0 我重新搜索了警告,但没有找到有关此特定Boost类的任何信息、警告生成的原因以及如何修复它。 我的目标是存储mapped_file_source一个实例,以便我可以有效地访问内存映射文件的内容。

你可以在这里看到: https : //en.cppreference.com/w/cpp/language/copy_assignment

如果 T 具有用户声明的析构函数或用户声明的复制构造函数,则不推荐生成隐式定义的复制赋值运算符 (C++11 起)。

如您所见,boost 1.72 就是这种情况:

    // Copy Constructor
    mapped_file_source(const mapped_file_source& other);

boost\\iostreams\\device\\mapped_file.hpp第 187 行有这个复制构造函数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM