|
From: Christophe Prud'h. <pru...@MI...> - 2000-09-06 21:05:54
|
Hie
my understanding of the requirements for meta class is that
it provides :
1- traits: static features of a type (traits were originally defined by
Nathan Meyers)
2- more sophisticated RTTI
it my codes I have, I think, something like that for point 2
all objects are clearly defined within a hierarchy of class and each of them
defines isTypeOf(char*), getClassName() , isA(char*) and the parent,child is
defined.
for point 1 traits are a very powerful and simple technique to store static
features and I use them very often.
here is a simple example
template<int Dim, int charSize=8, typename T=double>
class traits
{
public:
enum { dimension = Dim };
enum { char_size = charSize };
typedef T T_numtype;
};
template<typename Traits>
class A
{
public:
enum { dimension = Traits::dimension };
enum { char_size = Traits::char_size };
typedef typename Traits::T_numtype T_numtype;
};
template<int Dim>
class B: public A<traits<Dim> >
{
public:
typedef A<Traits<Dim> > super;
enum { dimension = super::dimension };
enum { char_size = super::char_size };
typedef typename super::T_numtype T_numtype;
};
am I correct in that it is providing 1 and 2 ?
C.
--
Christophe Prud'homme |
MIT, 77, Mass Ave, Rm 3-243 | C'est de la buche?
Cambridge MA 02139 | Non c'est kloug!
Tel (Office) : (00 1) (617) 253 0229 | C'est colmatté avec du schpountz...
Fax (Office) : (00 1) (617) 258 8559 | -- Le Pere Noel est une ordure
http://augustine.mit.edu/~prudhomm |
Following the hacker spirit
|