LuB said:
Not sure what you mean. Both our compilers failed. Why is mine wrong
and yours right or vice versa? Did you notice the error at the end of
the post?
Please quote what you're replying to, as a matter of standard Usenet
courtesy.
Both compilers did not "fail," in the sense of doing something wrong.
They each produced errors. However, my compiler produced an error at
an earlier point -- if it was correct to do so, then your compiler may
have been incorrect to *not* produce an error at the same point. Based
on the reasoning I provided (which you ignored?), and the fact that gcc
is has a reputation for being far more standards-compliant than MSVC,
it seems far more likely that your compiler is doing the wrong thing
here, in the sense of providing nonstandard behavior. If that's the
case, it's useless and/or off-topic to speculate further about the
consequences of said nonstandard behavior.
At any rate, after a bit more trial and error, substitute
friend typename T;
for
friend class T;
That successfully compiles in MSVC 2005.
I don't have my copy of the standard with me (keep it at work), but I
suspect that while this works on your compiler, it's not correct
according to the standard. My reasoning is based on the fact that only
certain types (classes and functions) can be friends. Since your T can
be anything, including types which are not eligible for friendship, the
compiler objects. This is kind of a nitpick, but it's the sort of
nitpick C++ compilers tend to make. It's also the sort of thing MSVC
implementors are apt to ignore.
Anyway, it's nice that you got it working on your compiler. If you
don't need your code to be portable between platforms, compilers, or
compiler versions, or be standards-compliant, then you're all set.
Does the standard even allow "friend typename" used in this way? I'm a
little suspicious of that, too.
...Sorry if this is a TOP post. Google only has so much flexibility.
You didn't top-post, you failed to quote entirely. If you click
"options" at the top of the message, and click "reply" from there,
you'll get a proper quote to work with. I'm posting this from Google
as well, and as you can see I quote just fine.
Luke