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



我定义一个结构如下:

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

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

正如你所看到的,提升 1.72 就是这种情况:

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

boostiostreamsdevicemapped_file.hpp的第 187 行上有这个复制构造函数

相关内容

最新更新