隐式声明的 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 version from 1.62.0 or so to 1.72.0. I resarched the warning but I didn't find any information about this particular Boost class, why the warning is generated and how to fix it. My goal is to store an instance of the mapped_file_source 后出现,因此我可以有效地访问内存映射文件的内容。

如您所见:https://en.cppreference.com/w/cpp/language/copy_assignment

The generation of the implicitly-defined copy assignment operator is deprecated(since C++11) if T has a user-declared destructor or user-declared copy constructor.

在boost 1.72中是这样的,大家可以看到:

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

boost\iostreams\device\mapped_file.hpp

的第 187 行有这个拷贝构造函数