[英]Implicitly-declared boost::iostreams::mapped_file_source is deprecated
I'm defining a struct as follows:我正在定义一个结构如下:
struct memory_dump {
filesystem::path path;
boost::iostreams::mapped_file_source mapped_file;
memory_dump_type type;
long long int offset;
};
However, gcc
generates the following warning:但是,
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 {
| ^~~~~~~~~~~
This warning only occurred after upgrading my Boost
version from 1.62.0
or so to 1.72.0
.此警告仅在将我的
Boost
版本从1.62.0
左右升级到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.我重新搜索了警告,但没有找到有关此特定
Boost
类的任何信息、警告生成的原因以及如何修复它。 My goal is to store an instance of the mapped_file_source
so I can access the contents of a memory mapped file efficiently.我的目标是存储
mapped_file_source
一个实例,以便我可以有效地访问内存映射文件的内容。
As you can se here: https://en.cppreference.com/w/cpp/language/copy_assignment你可以在这里看到: 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.
如果 T 具有用户声明的析构函数或用户声明的复制构造函数,则不推荐生成隐式定义的复制赋值运算符 (C++11 起)。
Which is the case in boost 1.72, as you can see:如您所见,boost 1.72 就是这种情况:
// Copy Constructor
mapped_file_source(const mapped_file_source& other);
There is this copy constructor on line 187 of boost\\iostreams\\device\\mapped_file.hpp
boost\\iostreams\\device\\mapped_file.hpp
第 187 行有这个复制构造函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.