Re: [Algorithms] Complexity of new hardware
Brought to you by:
vexxed72
|
From: Will V. <wi...@se...> - 2009-04-19 03:04:27
|
On Sun, 19 Apr 2009 03:03:27 +1200, Jarkko Lempiainen <al...@gm...>
wrote:
> All I have is something like:
>struct foo
> { PFC_MONO(foo) {PFC_VAR3(x, y, z);}
> int x, y, z;
> };
That's admirably brief! I assume you're generating code rather than data
though - which tends to be more verbose, or at least it does for me.
One trick I found helpful to avoid identifier repetition was to move some
commas inside macros, to avoid having to specify the parent name twice in
IMPLEMENT_BEGIN/IMPLEMENT_END and still avoid explict arity:
// rtti.h - detail elided
#define COMPOUND(name) static const member_t members[];
#define RTTI(name, members) const member_t name::members[] = { members {
NULL, ... } };
#define MEMBER(name) { #name, ... },
// foo.h
struct foo
{
COMPOUND(foo)
int x, y, z;
};
// foo.cpp - essentially generates const member_t foo::members[] = { ... };
RTTI(foo, MEMBER(x) MEMBER(y) MEMBER(z))
Cheers,
Will
|