|
Boost : |
From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2002-06-28 00:30:13
----- Original Message -----
From: "Aleksey Gurtovoy" <agurtovoy_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, June 28, 2002 4:36 AM
Subject: RE: [boost] uBLAS formal review
> Beman Dawes wrote:
> > That, coupled with the tendency for each major library to have
> > "exception.hpp", etc., increases the chance of name clashes.
> > Thus give serious consideration to "boost/numerics/ublas/filename.hpp"
> > and namespace boost::numeric::ublas.
> >
> > Then, to ease use:
> >
> > namespace ub = boost::numeric::ublas;
> >
> > or whatever. It helps to always use the same alias.
>
> There is even more to it: if your global scope namespace alias happened to
> match the name of any other entity in global scope of the program, then
> you're entered the realms of undefined behavior, e.g. this
>
> [file1.cpp]
> #include "boost/numerics/ublas/filename.hpp"
>
> namespace ub = boost::numeric::ublas;
> //..
>
> [file2.cpp]
>
> namespace ub = some_other_long_namespace_name;
>
> // or struct ub { /* ... */ };
> // or void ub();
> // etc.
>
> invokes an undefined behavior if both translation units are part of the
same
> program.
>
> FWIW, MPL provides a special header, "boost/mpl/alias.hpp", that user can
> include to get an equivalent of
>
> namespace {
> namespace mpl = boost::mpl;
> }
>
> definition, e.g.
>
> #include "boost/mpl/list.hpp" // for boost::mpl::list
> #include "boost/mpl/alias.hpp" // namespace alias
>
> // now we can use 'mpl::' instead of longish 'boost::mpl::'
> typedef mpl::list<char,short,int> types;
This looks like a safe method. Thanks for the hint.
Regards
Joerg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk