Pete Bartlett wrote:
What about:
CLASS(Foo, FROM(Bar), CONSTRUCT(BOOST_PP_EMPTY_SEQ) CONSTRUCT((int, a, A)(bool, b, B)) int A; bool B; )
Might that not be a way to avoid the Foo repetition?
It would have to look like
CLASS( Foo, FROM(Bar) , CONSTRUCT( BOOST_PP_EMPTY_SEQ ) CONSTRUCT( (int, a, A)(bool, b, B) ) , int A ; bool B ; )
where you have
#define CONSTRUCT(sequence) sequence
Why wouldn't my example work?
and the CLASS macro does all the work. The macro implementation would be slightly more complicated because of the nested FOR_EACHs (degrading maintainability) and debuggability will be impaired, but perhaps still better than introducing an external code generator to your build setup.
You know, I just realized it's not possible after all, since I will also add enums and structs as sub-types sometimes. They contain comma's, which would break the macro-call. I'll use the END_CLASS notation and accept the Foo repetition. :-)
Nb it seems like the 'a' and 'b' are superfluous - the constructor parameters could be written something like BOOST_PP_CAT(membervarname , _ ).
Good point! How could I have missed that one? Thanks! -- Michiel Helvensteijn