我定义一个结构如下:
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 行上有这个复制构造函数