Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-09-29 13:00:58


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.

(For anyone coming up to just coming up to speed on namespace issues, Ed's
suggestion allows you to name the C standard's size_t type "std::size_t"
even though the compiler vendor failed to place <cstdlib> contents in
namespace std, as a certain very large compiler vendor has done. It still
requires vendors to supply the <c...> headers, but that doesn't seem to be
an issue.)

It does compile correctly, too, on that large compiler vendor's latest
version. Always nice to have a fix that actually works!

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

--Beman


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