Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 1999-09-29 13:36:33


Beman Dawes wrote:
>
> Ed Brey wrote:
>
> >we could use using declarations to quickly pick up the names:
> >
> >#ifdef BOOST_NO_NAMESPACE_FOR_STDC
> > #include <cstddef>
> > #include <cstdlib>
> > #include <cmath>
> > namespace std {
> > using ::size_t; using ::ptrdiff_t;
> > using ::div_t; using ::ldiv_t;
> > using ::abs; using ::labs;
> > using ::srand; using ::div; using ::ldiv; using ::rand;
> > using ::acos; using ::asin; using ::atan; using ::atan2; using ::ceil;
> > using ::cos; using ::cosh; using ::exp; using ::fabs; using ::floor;
> > using ::fmod; using ::frexp; using ::ldexp; using ::log; using ::log10;
> > using ::modf; using ::pow; using ::sin; using ::sinh; using ::sqrt;
> > using ::tan; using ::tanh;
> > }
> >#endif
>
> Ed, I think your solution above is a really good one.
>
> Typo: the #ifdef should be after rather than before the #includes.

Actually, the #include location is by design, reason being that for
conforming implementations, the "large compiler vendor" workaround has
absolutely zero effect. In particular, libraries should never count
on config.hpp including any headers; they should merrily assume that
the implementation is conforming. So if a library uses std::size_t,
it should include <cstdlib>. If the implementation on which the
library is compiled happens to be buggy, <cstdlib> will end up getting
#included twice, which is fine.

In general, if a translation unit includes library L that needs
headers A and B, on a conforming compiler we want only headers A and B
to be included, since that is what we'd naturally do if all compilers
were conferment. Only when working with a buggy compiler do we want
to fall back to workarounds, which may involve extra includes. This
is strict adherence to the policy of writing for conferment compilers,
with workarounds for buggy compilers taking a non-intrusive back seat.

> One nit; I would prefer BOOST_NO_STDC_NAMESPACE as a bit shorter.

Good nit (well picked). I couldn't think of a macro name, so I used
mine basically as a place holder.


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