简体   繁体   中英

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:

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 . 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. My goal is to store an instance of the mapped_file_source so I can access the contents of a memory mapped file efficiently.

As you can se here: 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.

Which is the case in boost 1.72, as you can see:

    // 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM