Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Using macros to build typelists incrementally

Reply
Thread Tools

Using macros to build typelists incrementally

 
 
greek_bill@yahoo.com
Guest
Posts: n/a
 
      12-05-2006
Hi all,

I'd like to have code that looks like the following :

BEGIN(Foo)
ADD(float);
ADD(int);
ADD(char);
END()

I'd like the above code to somehow append each type into a typelist,
which is available as a symbol, i.e. something like (using Loki's
typelists):

typedef NullType FOO1;
typedef Loki::TL::Append<FOO1, float>::Result FOO2;
typedef Loki::TL::Append<FOO2, int>::Result FOO3;
typedef Loki::TL::Append<FOO3, char>::Result FOO4;
typedef FOO4 Foo;

I've been trying to think of various ways to achieve this (e.g. using
boost:reprocessor, using __LINE__, etc), but where I keep getting
stuck is the fact that I can't have 'variables' in macros. I need to
somehow use the result from one macro as input into another, to call
macros recursively, or to have a 'global' variable that keeps track of
some 'state'.

Any ideas?

Thanks,

Bill


PS I could, in theory, using __COUNTER__ to 'guess' the name of the
_previous_ result. I haven't pursued this much, because __COUNTER__ is
compiler specific

 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      12-05-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi all,
>
> I'd like to have code that looks like the following :
>
> BEGIN(Foo)
> ADD(float);
> ADD(int);
> ADD(char);
> END()
>
> I'd like the above code to somehow append each type into a typelist,
> which is available as a symbol, i.e. something like (using Loki's
> typelists):
>
> typedef NullType FOO1;
> typedef Loki::TL::Append<FOO1, float>::Result FOO2;
> typedef Loki::TL::Append<FOO2, int>::Result FOO3;
> typedef Loki::TL::Append<FOO3, char>::Result FOO4;
> typedef FOO4 Foo;
>
> I've been trying to think of various ways to achieve this (e.g. using
> boost:reprocessor, using __LINE__, etc), but where I keep getting
> stuck is the fact that I can't have 'variables' in macros. I need to
> somehow use the result from one macro as input into another, to call
> macros recursively, or to have a 'global' variable that keeps track of
> some 'state'.
>
> Any ideas?
>
> Thanks,
>
> Bill
>
>
> PS I could, in theory, using __COUNTER__ to 'guess' the name of the
> _previous_ result. I haven't pursued this much, because __COUNTER__ is
> compiler specific
>



I have done somthing like this before. Look at the "at_factory.h" header
in austria c++.

doxygen here:
http://austria.sourceforge.net/dox/h...Factories.html

code here:
http://www.google.com/codesearch?hl=...e/at_factory.h


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
macros that build macros Thant Tessman C Programming 6 09-11-2007 08:02 PM
A new approach to specifying typelists? Dave Branton C++ 0 11-02-2006 02:56 AM
Incrementally digest big xml data files using commons digester leebarman@gmail.com Java 0 10-13-2006 12:28 AM
Loki Typelists Jon Slaughter C++ 5 09-29-2005 04:36 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM



Advertisments