Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-10-29 09:48:36


----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>

> "Paul Mensonides" <pmenso57_at_[hidden]> writes:
> > What do you mean by "membership test"? It doesn't have any analogy to a
> > mathematical set if that's what you're getting at.
>
> It is.

Yeah, nothing to do with a mathematical "set." It's just a "set" of
elements:

(x)(y)(z)

...in the plain ol' English sense.

> > As far as a comparison against lists goes, a "set" (or whatever) doesn't
> > directly support a nil state, so lists are still viable until C++ gets
the
> > C99 macro rules (You can pass nothing as a macro parameter in C99.).
>
> Ah, then by analogy to C++ types it should be called "ARRAY" ;-)
> And ARRAY should be called "VECTOR".

I'm wary of analogies to runtime counterparts for several reasons. First,
the characteristics are not the same. Second, nothing is an exact match
except maybe "list." Therefore we have names like "array" for "(3, (a, b,
c))." I can't change the name "array" now, but your right, "vector" would
have been a better choice if I had had the foresight.

However, I'm all in favor of changing "set" to "seq." Short and simple,
doesn't directly relate to a runtime counterpart, etc..

> > I've been tooling around with an "includer" that uses both (for
example):
> >
> > #define HEADERS (..., (iostream)(iomanip)(vector)(map)(fstream))
> > #include ANGLED_INCLUDE()
> >
> > Which basically includes all the headers in the "set." The ...
specifies
> > "no directory."
>
> Yikes! How does ... turn into nothing here?

Magic. :)

Actually, it just detects whether it is parenthesized or not:

(path, files)

(where "path" is (dir/dir) or ...)

If "path" is ..., a unary macro placed immediately in front of it won't
expand:

#define CHECK(x) 1

CHECK...

CHECK(path)

I can just concatenate to the result, which (to simplify slightly) is just
RESULT_1 or RESULT_CHECK.

> > #define HEADERS \
> > ((boost/preprocessor),
> > (cat.hpp)(stringize.hpp)(tuple/elem.hpp)(control/if.hpp))
> > #include ANGLED_INCLUDE()
> >
> > ...effectively does this:
> >
> > #include <boost/preprocessor/cat.hpp>
> > #include <boost/preprocessor/stringize.hpp>
> > #include <boost/preprocessor/tuple/elem.hpp>
> > #include <boost/preprocessor/control/if.hpp>
> >
> That's too cool!

This was part of a backend for a "using" mechanism that I'm tooling around
with. Something like:

#define BOOST_PP_USING (CAT)(INC)(DEC)
#include BOOST_PP_SCOPE()

    CAT(INC(2), DEC(3)) // short names defined

#include BOOST_PP_ENDSCOPE()

CAT(a, b) // short names *not* defined anymore

Paul Mensonides


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk