vendredi 14 août 2020

Conditions to declare function deleted by c++

ALL,

What are the conditions where the compiler itself declares the function deleted?

Consider following:

class Foo
{
public:
    Foo();
    virtual void func1() = 0;
    virtual void func2() = 0;
    virtual bool func3();
}

class Bar : public Foo
{
public:
    Bar(int param1);
    virtual void func1() override;
    virtual void func2() override;
    virtual bool func3() override;
}

class Baz
{
public:
    Baz(std::unique_ptr<Foo> &foo)
    {
        m_foo = foo;
    }
private:
    std::unique_ptr<Foo> m_foo;
}

I am getting a compiler error on the assignment (MSVC 2019):

attempting to reference a deleted function

This is compiled with C++11.

TIA!

Aucun commentaire:

Enregistrer un commentaire