Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2005-01-06 08:38:38


The following section of code in utf8_codecvt_factet.hpp seems to be rather
mixed up:

#if BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x551))
#ifndef _RWSTD_NO_NAMESPACE
using std::codecvt;
using std::min;
#ifdef _RWSTD_NO_MBSTATE_T
using std::mbstate_t;
#endif
#endif

This section imports codecvt, min and mbstate_t into the *global namespace*,
why?

Isn't this a "bad thing" in general?

I can't see why it would be necessary anyway.

#elif defined(__COMO__) || defined(_MSC_VER) && _MSC_VER <= 1300
typedef ::mbstate_t mbstate_t;

Surely this has no effect at best, or is illegal at worst? Remember we're
in the global namespace here. Commenting this out has no effect on VC7 BTW
(and VC6 doesn't build the lib anyway), can't comment on Commeau though.

#elif defined(BOOST_NO_STDC_NAMESPACE)
typedef std::mbstate_t mbstate_t;
namespace std{
using ::codecvt;

Again why import mbstate_t into the global namespace, especially as this
does not happen for std conforming compilers?

Finally importing codecvt into namespace std:: is almost always likely to be
an error: BOOST_NO_STDC_NAMESPACE refers to C library code, I don't know of
any std lib that has codecvt, but doesn't put it in namespace std already.

In any case it doesn't build as is with gcc-2.95 (with or without STLport),
but changing that to:

#elif defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::mbstate_t;
} // namespace std

and likewise changing the similar workaround convert.hpp to:

#if BOOST_WORKAROUND(__ICL, <= 700) || defined(BOOST_NO_STDC_NAMESPACE)
#include <wchar.h>
namespace std
{
using ::mbstate_t;
}
#endif

Gets it compiling with gcc-2.95 + STLport.

Hope this helps,

John.


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