svn commit: r268491 - head/usr.bin/users

John Baldwin jhb at freebsd.org
Fri Jul 11 21:26:34 UTC 2014


On Friday, July 11, 2014 3:38:16 pm David Chisnall wrote:
> On 11 Jul 2014, at 15:03, John Baldwin <jhb at FreeBSD.org> wrote:
> 
> > 
> > http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
> > 
> > is a decent start on the multitude of reasons to avoid using it.
> > 
> > I also avoid 'import * from foo' in Python for similar reasons.
> > 
> > OTOH, most of the C++ code bases I've had to work with do have a global
> > 'using namespace std'.  Great fun when someone decides it would be
> > convenient to add 'using namespace boost' to the mix.
> 
> Note that, even though 'using namespace std' is a bad idea, 'using std::vector; using std::string' and so on is not so bad. 

Agreed, I have used 'import Foo from Bar' in python as well.

> For things that live in the base system, there's not much danger of boost conflicts.  'using namespace std' is mostly a problem when it's in headers (especially 
library headers), because it can break large amounts of code.  In a tiny utility, it's probably the right thing to do.

The original question was about a general style rule for C++ code in FreeBSD.
I suppose it would be fine to permit it in small utilities and only in .cc
files but not otherwise?

-- 
John Baldwin


More information about the svn-src-all mailing list