Not a very template solution, but instead, you can rely on an outdated compiler attribute that will generate a warning if the function is used anywhere.
In the case of MSVC, you use the __declspec (deprecated) attribute:
__declspec(deprecated("Don't use this")) void foo();
g ++:
void foo() __attribute__((deprecated));
If you have the option “handle warnings as errors” (which you usually should), you will get the desired behavior.
int main() { foo();
source share