I would need to know what exactly namespace contains in order to know where to do it. |
Everything in standard library. And standard library has a lot of names. If you dump namespace std in global space, you will have a lot of opportunities to run into problems.
You want to name your class
plus? Too bad, there already a class with that name. Function measuring distance with the name
distance? Well, make sure that call to it will not pick standard library function
distance. Forward? Exchange? Already exist. Find, reverse, rotate? It is in here too.
Other namespaces can pose a problem too.
using namespace boost
and
optional? What will happen when
optional will be a part of standard library?
I personally against
using directive.
Using declarations are fine in limited scope when they are needed to make use of ADL (usually affect only a small number of functions). For long namespaces I use namespace aliaces:
1 2
|
//I would use "time" if not for clashes with C heritage
namespace aeon = std::chrono;
|
If there are several types I use often, ot they migh change in future, I make type alias:
1 2 3 4 5
|
using clock_type = aeon::system_clock;
//or even
using clock_type = typename std::conditional_t<aeon::high_resolution_clock::is_steady,
aeon::high_resolution_clock,
aeon::steady_clock>;
|
http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice