Short answer: using a remote function makes the program poorly formed, and you are notified at compile time, it uses a function that is not defined by end in an odd error that leaves the linker.
As an example, there is a relevant part of the standard that states:
A program that refers to a remote function implicitly or explicitly, except for the declaration, is poorly formed.
Therefore, the following compiles just fine :
struct S { void f(); }; template<typename T, void (T::*M)() = &T::f> void g() {} int main() { g<S>(); }
So far , the code below is :
struct S { void f() = delete; }; template<typename T, void (T::*M)() = &T::f> void g() {} int main() { g<S>(); }
This is because in the second case, the code is poorly formed, and in any case, you have a compile-time error, regardless of whether you intend to use M
or not. In the second case, you receive an error message from the linker only if you try to use it:
template<typename T, void (T::*M)() = &T::f> void g() { T t; (t.*M)(); }
Of course, errors during compilation prevent problems much better. The example uses public functions, but closing them does not prevent them from being used in the class in the same way. This is just a toy example to show a possible difference.