> "using namespace" statements might in some cases be justifiable if the
> name of the namespace is very long and/or there are many nested namespaces
> (which is sometimes the case). However, a common recommendation in these
> cases is to use namespace aliases instead (which is possible in C++). It's
> a bit like a typedef, but for namespaces. For example:
>
> namespace bid = boost::io::detail;
>
> After that you can use 'bid::' instead of 'boost::io::detail::' as the
> prefix for names in that namespace.
In that case what is the benefit of using 'bid::' to qualify every type
rather than simply putting "using namespace boost::io::detail" at the top?
The disadvantages are obvious - having to type bid:: before every type
(annoying if almost every line contains several types from that namespace)
and your code looks very "unoptimised" when the same string is repeated a
huge number of times.
Post a reply to this message
|