Deleting a function is a C++11 feature:
The common idiom of “prohibiting copying” can now be expressed directly:
class X { // ... X& operator=(const X&) = delete; // Disallow copying X(const X&) = delete; };
[…]
The “delete” mechanism can be used for any function. For example, we can eliminate an undesired conversion like this:
struct Z { // ... Z(long long); // can initialize with an long long Z(long) = delete; // but not anything less };
Related Posts:
- error: “initializer expression list treated as compound expression”
- Getting error: ISO C++ forbids declaration of with no type
- Is “delete this” allowed in C++?
- What is a lambda expression in C++11?
- C++ — expected primary-expression before ‘ ‘
- ld: symbol(s) not found for architecture x86_64 error
- Return array in a function
- What is the ‘override’ keyword in C++ used for? [duplicate]
- What is a smart pointer and when should I use one?
- C++ std::priority_queue uses the lambda expression
- Usage and Syntax of std::function
- What exactly is nullptr?
- Difference between `constexpr` and `const`
- Split a string using C++11
- How to create timer events using C++ 11?
- What are forward declarations in C++?
- What is an ‘undeclared identifier’ error and how do I fix it?
- What does T&& (double ampersand) mean in C++11?
- What is an ‘undeclared identifier’ error and how do I fix it?
- Segmentation fault error 11 C++
- Why doesn’t C++ have a garbage collector?
- Compiling C++11 with g++
- terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi
- What exactly is std::atomic?
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- terminate called after throwing an instance of ‘std::out_of_range’
- invalid use of non-static member function
- Cleanest way to copy a constant size array in c++11
- Reverse Contents in Array
- push_back vs emplace_back
- undefined reference to ‘std::cout’
- What is move semantics?
- expression preceding parentheses of apparent call must have (pointer-to-) function type
- c++: No instance of overloaded function
- C++ error: Undefined symbols for architecture x86_64
- C++ terminate called without an active exception
- Thread pooling in C++11
- error: expected primary-expression before ‘)’ token (C)
- How does std::forward work? [duplicate]
- C++ delete vector, objects, free memory
- Difference in make_shared and normal shared_ptr in C++
- What is std::move(), and when should it be used?
- Deleting a dynamically allocated 2D array
- C++: std does not have member “string”
- C++ String Variable Declaration
- push_back vs emplace_back
- error: use of deleted function
- Call to implicitly deleted copy constructor in LLVM
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
- Function for C++ struct
- no match for ‘operator<<’ in ‘std::operator
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- Use the auto keyword in C++ STL
- c++ –
- Call to non-static member function without an object argument compiler error
- What does it mean that “a declaration shadows a parameter”?
- Does C++11 have C#-style properties?
- C++ – statement cannot resolve address for overloaded function
- How do I return a char array from a function?
- How to return a struct from a function in C++?
- Why can’t we pass arrays to function by value?
- Iterator Loop vs index loop
- initialize a vector to zeros C++/C++11
- template argument deduction/substitution failed, when using std::function and std::bind
- When is it safe to call this-> in constructor and destructor
- How to memset char array with null terminating character?
- How well is Unicode supported in C++11?
- How to automatically convert strongly typed enum into int?
- C++ Array of pointers: delete or delete []?
- Why should I use a pointer rather than the object itself?
- too many initializers for ‘int [0]’ c++
- ERROR: Control may reach end of non-void function /
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- Creating folders in C++
- C++ correct way to return pointer to array from function
- Where to declare/define class scope constants in C++?
- convert string to size_t
- Difference between function arguments declared with & and * in C++
- Is C++ Array passed by reference or by pointer?
- “cannot be used as a function error”
- Compiling C++11 with g++
- ERROR C2039: ‘vector’: is not a member of ‘std’
- Does static constexpr variable inside a function make sense?
- c++ vector bubble sort
- How to use bitmask?
- Is it still safe to delete nullptr in c++0x?
- Differences between unique_ptr and shared_ptr
- How do I print out the contents of a vector?
- Error with multiple definitions of function
- What are C++ functors and their uses?
- invalid conversion from ‘const char*’ to ‘char*’
- Returning multiple values from a C++ function
- “used without template parameters”
- Error: macro names must be identifiers using #ifdef 0
- Error: free(): invalid next size (fast):
- casting int to char using C++ style casting
- C++ Simple Dice roll – how to return multiple different random numbers [duplicate]
- How can I get a file’s size in C++?