This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: template parameters cannot be friends
- From: "naje" <najeiv at ukr dot net>
- To: "Eljay Love-Jensen" <eljay at adobe dot com>,gcc-help at gcc dot gnu dot org
- Date: Fri, 21 May 2004 19:47:49 +0300
- Subject: Re: template parameters cannot be friends
- Reply-to: "naje" <najeiv at ukr dot net>
Hi, Eljay
> 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.
how can i do this, only i've considered is
template<typename T>
struct Type2Type{};
template<typename T>
void DrawHlpr(const Button<T>& t, const Type2Type<T>&)
{
const T& tmp=static_cast<const T&>(t);
tmp.Draw();
}
template<typename T>
void Draw(const T& t)
{
DrawHlpr(t,Type2Type<T>());
}
it looks very ugly, and need to be in every template such as Draw
can you advice me something else?
Thank you.