Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 indication what function it's talking about. I don't want to post the class code here, but does anybody have any idea what this error means?

like image 572
Roey Lehman Avatar asked Apr 09 '12 21:04

Roey Lehman


People also ask

What is the use of Delete function?

The delete key is a key on most computer keyboards which is typically used to delete either (in text mode) the character ahead of or beneath the cursor, or (in GUI mode) the currently-selected object. The key is sometimes referred to as the "forward delete" key.

What is a deleted function C++?

Deleted function declaration is a new form of function declaration that is introduced into the C++11 standard. To declare a function as a deleted function, you can append the =delete; specifier to the end of that function declaration. The compiler disables the usage of a deleted function.


2 Answers

I had a similar message with threads (C++11). It turned out that I was passing the wrong number of parameters to the function called by the thread so the thread did not find any function suitable and gave that message.

like image 70
Carlos Molinero Avatar answered Nov 02 '22 05:11

Carlos Molinero


To add to Carlos' answer, I had the right number of arguments but one of the arguments was being passed by reference. Adding ref() around the variable fixed it for me. See here.

like image 22
user2891659 Avatar answered Nov 02 '22 05:11

user2891659