Boost logo

Boost :

Subject: Re: [boost] [preprocessor] Variadics suggestion
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2012-10-05 21:49:35

On Thu, 04 Oct 2012 21:31:48 -0400, Dave Abrahams wrote:

> on Wed Sep 26 2012, Paul Mensonides <> wrote:
>> Right, and what will change that sad fact? Attempting to workaround
>> forever isn't working. Similarly, is the whole world supposed to not
>> use variadic templates because VC++ doesn't implement them? At least
>> that's likely to change, but a line needs to be drawn. It is one thing
>> for a workaround to be an implementation detail. It is another when it
>> affects the interface. In the latter case, IMO, the best thing to do
>> is provide the interface that *should* exist and either not support the
>> compilers that don't work or provide some clunkier interface for those
>> compilers. Doing else cripples technological advancement.
> I'll mention again that I think we should accept some libraries that
> won't work on broken compilers (like Chaos). "Boost works on this
> compiler" is an important selling point.

1) How is the modularization/git transition going?

2) For a macro library, do we still need to have a BOOST_ prefix or could
I just keep the CHAOS_PP_ prefix? I cannot use BOOST_PP_ without bending
over backwards to find contrived names for everything, and the namespace
of brief names beginning with BOOST_ is tiny--especially when a library
provides hundreds of user-interface (i.e. not implementation detail

3) For those of you familiar with Chaos, how many actually use the lambda
mechanism? I've been internally debating whether to preserve it for
years. It complicates things. The other thing is whether C90/C++98
should be supported (i.e. variadic/placemarker-less mode). Currently,
Chaos does support these, and the lack of them in some cases leads to
interesting techniques (which is half the reason for Chaos in first place).

4) For those of you familiar with Chaos, what other things can you think
of that would need to be done to Boost-ify it?


For those of you not familiar with Chaos...

Chaos (a.k.a. chaos-pp) is a preprocessor metaprogramming library in the
vein of Boost.Preprocessor except radically expanded both in terms of
available tools and technological innovation. Its current state, which is
in the CVS library at

contains 425 interface headers which defines 567 primary interface macros
and 2161 primary and secondary interface macros. The secondary interface
macros are related interfaces such as BOOST_PP_ENUM_PARAMS (primary) vs.
BOOST_PP_ENUM_PARAMS_Z (secondary). (Without the lambda mechanism above,
the total number would be about a third less as most interface macros
define a lambda binding.)

Chaos contains *zero* workarounds for broken preprocessors so it is almost
completely unusable on VC++, for example, and probably others. It is
almost completely usable on gcc and Wave except in some very dark corners
(Hartmet: think partial spanning invocation). Last time I checked, it
worked well on EDG-based compilers (sans possibly the above), but that was
some time ago that I checked. Essentially, Chaos sets a very high mark
which a preprocessor must meet.

A quick example:

#include <chaos/preprocessor/arithmetic/dec.h>
#include <chaos/preprocessor/control/if.h>
#include <chaos/preprocessor/facilities/empty.h>
#include <chaos/preprocessor/punctuation/comma.h>
#include <chaos/preprocessor/recursion/basic.h>
#include <chaos/preprocessor/recursion/expr.h>
#include <chaos/preprocessor/tuple/eat.h>

// interface:

#define DELINEATE(c, sep, m, ...) \
    DELINEATE_S(CHAOS_PP_STATE(), c, sep, m, __VA_ARGS__) \
#define DELINEATE_S(s, c, sep, m, ...) \
    DELINEATE_I(s, c, CHAOS_PP_EMPTY, sep, m, __VA_ARGS__) \

// implementation:

#define DELINEATE_I(s, c, s1, s2, m, ...) \
    CHAOS_PP_IF(c)( \
        CHAOS_PP_DEC(c), s1, s2, m, __VA_ARGS__) \
#define DELINEATE_II(_, s, c, s1, s2, m, ...) \
        s, c, s2, s2, m, __VA_ARGS__ \
    )) \
    m _(s, c, __VA_ARGS__) s1() \

// reusable:

#define REPEAT(c, m, ...) DELINEATE(c, CHAOS_PP_EMPTY, m, __VA_ARGS__)
#define REPEAT_S(s, c, m, ...) \

#define ENUM(c, m, ...) DELINEATE(c, CHAOS_PP_COMMA, m, __VA_ARGS__)
#define ENUM_S(s, c, m, ...) \

// recursive:

#define TTP(s, n, id) \
    template<CHAOS_PP_EXPR(ENUM( \
        CHAOS_PP_INC(n), class CHAOS_PP_EAT, ~ \
    ))> class id ## n \


-> template<class> class T0 ,
    template<class, class> class T1 ,
     template<class, class, class> class T2

Complicated?...yes. But compare that to the implementation of
BOOST_PP_REPEAT. Unlike BOOST_PP_REPEAT, however, this macro can be
recursively reentered about 500 times. The actual implementations of
these in Chaos is far fancier.

A list of headers is at

of which the first link <chaos/preprocessor.h> leads to a more organized
view of the library's contents.

Alternately, a big list of primary interface macros is at

There are a lot of bits of sample code throughout the documentation,
though the topical documentation incomplete.

Paul Mensonides

Boost list run by bdawes at, gregod at, cpdaniel at, john at