Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Typelist with a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 9367 of 10104
Post > Topic >>

Typelist with a list of class identifiers

by v_golikov@[EMAIL PROTECTED] Mar 11, 2008 at 09:58 PM

Hi All

Here is the thing I want to do. There is a typelist (Modern C++
Design ...
approach and Loki). I want this type list to return a list of class
IDs for
all cl***** which are part of the typelist. Let me give an example:

class C1{

public:

enum{ class_id = 1 };

}

class C2{

public:

enum{ class_id = 2}

}

typedef TYPELIST_2( C1, C2 ) My_list;

template < typename T_list >

class Class_id_list;

template < typename H, typename T >

class Class_id_list{

public:

     // ??? static const `hypothetical data structure` list = H ::
class_id ??? Class_id_list< T > :: class_id;

}


// code for Nulltype - end of recursion
template ...

`hypothetical data structure` list = Class_id_list< My_list > :: list;
....

Since it is not possible to make static const initialization for
complex
types in the class I do not know how to make ( if it is possible at
all?)
it. It looks like if you put this recursive definition outside of
class then
it is not used during template instantiation.

The only way that comes to my mind is to use an old trick with bits
and
****fts:

static unsigned long const list = H :: class_id | class_id_list< T
> :: class_id << X; // x number of bits for class id

But that is a silly implementation for some obvious reasons. Any ideas?

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 8 Posts in Topic:
Typelist with a list of class identifiers
v_golikov@[EMAIL PROTECTE  2008-03-11 21:58:00 
Re: Typelist with a list of class identifiers
Carl Barron <cbarron41  2008-03-12 14:12:38 
Re: Typelist with a list of class identifiers
courpron@[EMAIL PROTECTED  2008-03-12 14:16:05 
Re: Typelist with a list of class identifiers
v_golikov@[EMAIL PROTECTE  2008-03-12 19:44:38 
Re: Typelist with a list of class identifiers
v_golikov@[EMAIL PROTECTE  2008-03-12 19:45:00 
Re: Typelist with a list of class identifiers
Mathias Gaunard <loufo  2008-03-12 19:45:11 
Re: Typelist with a list of class identifiers
courpron@[EMAIL PROTECTED  2008-03-13 13:12:26 
Re: Typelist with a list of class identifiers
Carl Barron <cbarron41  2008-03-13 13:12:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:43:29 CDT 2008.