When researching an answer to a question (based on this answer) I tried to do the following:
template <class T>
class friendly {
friend class T;
};
friendly<string> howdy;
This fails to compile with the following error:
error: template parameter "T" may not be used in an elaborated type specifier friend class T;
From what I can understand from my good friend Google this is so that I won't accidentally try to instantiate friendly<int>
but why should this be an error when compiling the template? Should't it be an error when instantiating the template with an invalid type (such as had I written int f() { return T::foo(); }
)