简体   繁体   English

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

[英]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.

相关问题 使用 boost::iostreams::mapped_file_source 和 std::multimap - Using boost::iostreams::mapped_file_source with std::multimap 未定义的引用`boost :: iostreams :: mapped_file_source :: mapped_file_source()' - undefined reference to `boost::iostreams::mapped_file_source::mapped_file_source()' 使用带有宽字符串的 boost::iostreams::mapped_file_source - Using boost::iostreams::mapped_file_source with wide character strings 如何使用带有gzip压缩输入文件的boost :: iostreams :: mapped_file_source - how to use boost::iostreams::mapped_file_source with a gzipped input file 使用CMake对boost :: iostreams :: mapped_file_source :: init()的未定义引用 - undefined reference to boost::iostreams::mapped_file_source::init() using CMake boost :: iostreams :: mapped_file_source :: open在Windows上导致退出代码3,但可在Ubuntu中使用 - boost::iostreams::mapped_file_source::open causes exit code 3 on Windows but works in Ubuntu boost mapping_file_source会抛出哪些异常? - What exceptions does boost mapped_file_source throw? 提高mapd_file_source,对齐方式和页面大小 - Boost mapped_file_source, alignment and page size 由openfilename引起的boost mapping_file_source异常 - boost mapped_file_source exception caused by openfilename 在 GitHub 上编译 TinyMT 时,不推荐使用隐式声明的 '...' [-Wdeprecated-copy] - implicitly-declared ‘...’ is deprecated [-Wdeprecated-copy] in compiling TinyMT on GitHub
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM