Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-03-02 16:40:18


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Tobias Schwinger
> Sent: Wednesday, March 02, 2005 9:21 AM
> To: boost_at_[hidden]
> Subject: [boost] Empty sequence elements
> Paul Mensonides wrote:
> >> BOOST_PP_IF(HAS_COLOR(t), and color is COLOR(t) , );
> >
> > ^^^ This is
> > undefined behavior in C++. Should be:
> May a PP-Sequence have '()'-elements ?

Not until C++ gets placemarkers (i.e. empty arguments) from C99. Without them,
"emptiness" is not an element. '()' is just nullary parentheses. Without
variadics, a mechanism can only handle sequences in which each element is a
specific arity. In the pp-lib, they must be unary (i.e. not nullary). It is
certainly possible (in current C++) to define primitives for (e.g.) a binary
sequence, but I'd have to replicate the entire mechanism. Even if binary
sequence primitives where there, you still couldn't have (,) or (a,) or (,b)
because each "element" would be a comma-separated pair of elements, and
emptiness is not an element.

> The documentation says that "a sequence cannot be empty"
> which seems to be something different than containing empty
> elements...

Yes, when the documentation says the above it means there is no such thing as a
nil sequence. E.g.

(a)(b)(c) // 3-element, unary sequence
(a)(b) // 2-element, unary sequence
(a) // 1-element, unary sequence
          // 0-element sequence, n-ary sequence

The 0-element sequence has a representation (emptiness), but that representation
is not yet valid C++. In other words, the reason that you can't have empty
sequences and can't have empty elements is the same reason. This applies
generally: you can't have empty arguments, you can't have empty tuple elements,
you can't have empty list elements, etc.. With placemarkers, that will change,
because placemarkers are a well-defined way of saying that an entity can be
nothing. Until that happens, it is undefined behavior. :(

Paul Mensonides

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