Hi Jacek,
This is usually accomplish with
template <class T> MyTemplate {
public:
typedef T value_type;
};
Then you can do
sizeof(MyTemplate<MyClass>::value_type)
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
On Behalf Of Jacek M. Holeczek
Sent: Thursday, January 20, 2005 8:05 AM
To: RootTalk
Subject: [ROOT] the sizeof "internal class" ... a question to C++ gurus
Hi,
I've got a stupid C++ question ...
Assume there are two templated classes "MyTemplate1<MyClass1>" and "MyTemplate2<MyClass2>" ...
Is there any possibility to get informations about the internal "MyClass1" from inside of the "MyTemplate2<MyTemplate1<MyClass1>>" ?
In principle, in the "MyTemplate2" I would like to create an array :
MyClass1 internal_array[(sizeof(MyTemplate1<MyClass1>) / sizeof(MyClass1))];
In other words ... inside of "MyTemplate2" I would like to "generate" ... 1. for ... MyTemplate2<float> ... :
float internal_array[1];
2. for ... MyTemplate2<double> ... :
double internal_array[1];
3. for ... MyTemplate2<MyTemplate1<float>> ... :
float internal_array[(sizeof(MyTemplate1<float>) / sizeof(float))]; 4. for ... MyTemplate2<MyTemplate1<double>> ... :
double internal_array[(sizeof(MyTemplate1<double>) / sizeof(double))];
Thanks in advance,
Best regards,
Jacek.
Received on Thu Jan 20 2005 - 21:30:14 MET
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET