xcode - “attempt to use a deleted function” - what does that mean?

前端 未结 5 1916
一向
一向 2021-01-18 12:36

I am writing a C++ library in Xcode 4.2

One of my classes won\'t compile with this error : \"attempt to use a deleted function\".

There is no specific indica

5条回答
  •  余生分开走
    2021-01-18 13:38

    In C++11 you can declare functions as deleted:

    struct Foo {
        Foo(const Foo &) = delete;
    };
    

    Attempting to use such a function is an error. The purpose of doing this is so that, in this example, copy construction of this type is not possible. This is a more direct replacement for the non-copyable trick used pre-C++11.

    Also, there are rules in the C++ spec that lead to member functions being implicitly deleted.

    The error is telling you that your program attempts to use a deleted function. You'll have to post the error you're getting for more detailed help.

提交回复
热议问题