c++ - 不推荐使用隐式声明的 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
如果 T 具有用户声明的析构函数或用户声明的复制构造函数,则不推荐生成隐式定义的复制赋值运算符(C++11 起)。
如您所见,在 boost 1.72 中就是这种情况:
// Copy Constructor
mapped_file_source(const mapped_file_source& other);
在第 187 行有这个复制构造函数boost\iostreams\device\mapped_file.hpp
推荐阅读
- php - 用于将一个表中的字段值与另一表匹配的连接函数
- javascript - this.$route 在 VueJS 中未定义(不使用箭头)
- java - 对象映射器无法序列化对象类的引用
- machine-learning - 当你在不同的类中有不同数量的数据时该怎么办?
- python - 模型更改时 Django-channels 发送消息
- ios - Flutter iOS App 在 Xcode 中崩溃,添加 FirebaseApp.configure() 以实现 Firebase 集成
- reactjs - React-native 使用灯箱弹出图像
- python - 如何循环数据框列以迭代地对数据框进行排序
- c# - Unity,如何仅更改 GameObject 矩形变换的“顶部”
- regex - 正则表达式捕获 CSV 文件中的单元格