c++one-definition-ruledeleted-functions

Deleting a file scope function in a header file


I am writing a header file, in which there is a void Foo() function in file scope, and I want it to be deleted. Should it be inline?

void Foo() = delete;

or

inline void Foo() = delete;

Solution

  • Quoting cppreference.com:

    A deleted function is implicitly an inline function: its (deleted) definition can appear in more than one translation unit.

    So, to answer your question, no explicit inline-ing is needed.