>but it's working with typedef's can anybody explain need of this?
It is? It shouldn't!
A typedef is a simple alias.
My GCC fails. (OS & GCC details below.)
- - - - - - - - - - - - - class Bar; class Quux; template <typename T> class Foo { typedef T T2; friend T2; // fail friend class Bar; // OK typedef Quux T3; friend class T3; // Hmmm. }; - - - - - - - - - - - - -
The "friend class T3" worked on my GCC. I expected it to introduce (forward declare) a "class T3", not use the T3 alias to Quux... but it did, so there you go. I haven't needed or used "friend" for many years.
Another thought...
You may be able to get away with using a BOOST static assert in a two-stage template Draw function, which compares the T class to Button<T2> class, to make sure that T and T2 are the same.
But I think what you really have a misapplication of the static polymorphism paradigm.
HTH, --Eljay
------ system details -------
$ uname -a
CYGWIN_NT-5.1 mn-eljayet 1.5.9(0.112/4/2) 2004-03-18 23:05 i686 unknown unknown Cygwin
$ gcc --version gcc (GCC) 3.3.1 (cygming special) Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.