Boost logo

Boost :

From: Andy Glew (glew_at_[hidden])
Date: 1999-08-05 19:41:26


> But what about the macros in stdint.h? Since the C committee had
> foresight enough to put guards around them so they must be explicitly
> invoked, boost can use stdint.h without automatically defining
> macros. Providing a C++ traits class to get at max, min, and other
> traits is a distinct technical advantage for generic programming with
> templates, and because a traits class obeys scope rules which macros
> don't. Do you have a problem with boost providing a traits class and
> requesting boost authors use something like
> integer_traits<int32_t>::max or numeric_limits<int32_t>::max() rather
> using the stdint.h macros?

I have little or no opinion about whether traits or macros should
be used, but say this:

If standard C uses macros
and Boost uses traits
then Boost would be well advized to include a test program
that tests whether the C macros match up
to the appropriate Boost C++ traits.

Else it would be very easy, as Thomas Plum says, for the Boost
version to diverge - for the C macros to be updated for a new architecture,
but for the Boost C++ traits not be be updated.

Similarly, a version of the Boost C++ traits that defines everything
in terms of the standard C macros, so much as possible, would be
advisable.

In fact, I would be tempted to write the following program:

        #include <stdint.h> // with macros
        
        #include <boost/stdint-defined-in-terms-of-C-macros.hpp>

        FOR EACH trait class DO
                PRINT IT OUT IN TERMS OF ABSOLUTE NUMBERS
                WITH OUTPUT TO
                    boost/stdint-defined-without-C-macros-polluting-namespace.hpp

which would be a lot easier with Valentin's reflexive C++ preprocessor :-)

If writing and maintaining the above consistency checks seems like too much work,
well, maybe boost/stdint.hpp is.


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