CKTIS / C++
Deleted functions: = delete
A function definition using = delete prohibits its use. The function still participates in overload resolution, allowing it to block unwanted calls.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
return_type function_name(parameter_list) = delete;= delete; instead of a function body specifies a deleted definition (= delete function definition), not an empty implementation. It must appear on the function's first declaration. Such a function is implicitly inline.
A deleted overload still participates in overload resolution. If selected, it makes the program ill-formed; the compiler does not search for a fallback overload. Taking the deleted function's address is also forbidden. Uses include preventing copying by deleting the copy constructor and copy assignment operator.
In the example, twice(3) prints 6. Uncommenting twice(3.5); selects the deleted double overload and causes a compilation error. This entry covers C++23 syntax; the referenced document is a continuously updated standard draft.
Examples
#include <iostream>
int twice(int value) {
return value * 2;
}
int twice(double) = delete;
int main() {
std::cout << twice(3) << '\n';
// twice(3.5);
}
Result
6
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.