Ok, I've experimented a bit, but I'm still hazy on the correct way to do this. I'd appreciate some advice, as my searches have been mostly fruitless.
Can anyone explain which, if any, compiler has it right? (note: MSVC means 7.1 and 8.0) Is this the wrong way to go about this?
typedef T type;
typedef traits<V> traits_type;
typedef traits<V>::type friend_type;
friend class traits_type::type; // works with GCC, not with MSVC
friend typename traits_type::type; // works with MSVC, not with GCC
friend typename friend_type; // doesn't work
friend class friend_type; // doesn't work
P.S. I did find this:
IIUC, this means the "don't work" lines above are expected to break, but I'm not so sure about the other two...
According to Section 188.8.131.52 paragraph 2 of Standard C++:
3.4.4 describes how name lookup proceeds for the identifier in an elaborated-type-specifier. ... If the identifier resolves to a typedef-name or a template type-parameter, the elaborated-type-specifier is ill-formed. [Note: this implies that, within a class template with a template type-parameter T, the declaration
friend class T;
is ill-formed. ]