Consider the following template class
template<typename T>
struct Caller {
void func(const T &t) { t.func(); }
void gunc(const T &t) { t.gunc(); }
};
Now let some class Target
only provide the member function func()
but not gunc()
, i.e.
struct Target {
void func() const { /* ... /* }
};
is the template instantiation Caller<Target>
valid?
GCC, clang as well as VC++ accept such template instantiations. Of course, calling Caller<Target>::gunc()
leads to an error but Caller<Target>::func()
works just fine and as intended.
Now the question: What is the background for this permissive behavior and where are the relevant paragraphs in C++ standard.