PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

C++ question

Pejo Software - Per · 30 Aug 2004, 16:20 UTC
I am using a template function that is defined like this (using a trait concept):
Code:
template <class T>
f(T t)
{
f_trait::DoSomething(t);
..
}


The default trait looks like this:
Code:
template <class T>
class f_trait
{
void DoSomething(T t) {blah();}
};


Normally if you want to change the behaviour here for a certain type you do a specialization like this:
Code:
template <>
class f_trait
{
void DoSomething(int t) {DoSomethingElse();}
};


My problem is that I want to define a class like this:
Code:
template <class T>
class C
{
void SomeOtherStuff();
};


and then create a trait for that class so that I can use the function f with an object of type C as parameter. Does anyone know how I can do this?
Pejo Software - Per · 31 Aug 2004, 05:42 UTC
Anyone? Thierry!?

Please excuse me for not being patient!
It would be enough if someone says its not doable.
Perhaps I haven't explained the problem well enough, please tell!
I understand what you are asking and I don't think there is (an easy) way. When I see templates like that I can only wonder what you are trying to solve. It seems to me that you are addressing some design issue the wrong way. This is especially true on PPC. What are you exactly trying to accomplish?

Note that the EVC3/4 compiler is basically using the VC6 frontend and that templates are quite limited (no partial specialization and a few other issues).
Pejo Software - Per · 31 Aug 2004, 07:27 UTC
Thank you for your time Thierry! I did try some ways to get around the problem but the best I could acheive was an INTERNAL COMPILER ERROR (Visual C++ 2002).

I guess we discuss the design issue for a long time but this time it is nothing that I can do anything about since I am using external sw. This is also not a Windows CE project it is a problem I have at work.
VC++ 2002 doesn't exist. Do you mean VC++ 2003 (7.0)?
Thierry wrote:VC++ 2002 doesn't exist. Do you mean VC++ 2003 (7.0)?

That might actually be the probem. Compiler version 7.0 (which comes with VS.NET 2002) is still a bit buggy when used for "advanced C++". The fixes were included in compiler version 7.1, which comes with VS.NET 2003.

- hm
I got confused, of course. VS2002 had VC 7.0 and VS2003 had VC 7.1.