Modernes C++ programmieren

Okt 23, 2024

lst-0434-book.cpp

// https://godbolt.org/z/6xjeYWe7c 
#include <vector>
class Image {
    std::vector<std::byte> data_;              // byte gibt es seit C++17
public:
    explicit Image(const char *fn) { /*...*/ }
    Image(Image&& other) noexcept              // Verschiebekonstruktor
        : data_{} // leer erzeugen
    {
        using std::swap;
        swap(data_, other.data_);
    }
    Image& operator=(Image&& other) noexcept { // Verschiebeoperator
        using std::swap;
        swap(data_, other.data_);
        return *this;
    }
};