Is there a way to prevent usage of unimplemented functions during compile time?

c++, compile-time

Solution

If it is non-virtual function then you can simply comment out the definition.

If it is a virtual function declared in a base class, then you can't control the calls at compile time, so then your only option is some run-time error or exception.

Problem

often I encounter hacks like ``` //lets say this is some class that still doesnt support... //...all the functionality that it should based on the design docs void MyClass::MyFunction() { throw std::exception("not implemented"); } ``` I guess this is a bad practice, but that aside: Is there a way to do the same thing during compilation, but only if the function is used (aka if it is unused compile should succeed). Edit: Im also interested in virtual mem functions.

Original source