This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: template parameters cannot be friends


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]