Make a function unusable by appending = delete to a function declaration. Calling a deleted function is a compile error.
Function overloads can be deleted to prevent implicit conversion:
void set_age(int age);
void set_age(double) = delete;
set_age(30); // OK.
set_age(30.5); // ERROR.Special member functions can be deleted to restrict the class interface:
class Foo {
public:
Foo() = delete;
Foo(const Foo&) = delete;
Foo(Foo&&) = delete;
Foo& operator=(const Foo&) = delete;
Foo& operator=(Foo&&) = delete;
~Foo() = delete;
};
Foo f; // ERROR.
Dan