Re: svn commit: r268491 - head/usr.bin/users
On Thursday, July 10, 2014 4:57:51 pm Ian Lepore wrote:
> On Thu, 2014-07-10 at 11:27 -0400, John Baldwin wrote:
> > On Thursday, July 10, 2014 11:04:56 am Ed Schouten wrote:
> > > On 10 July 2014 14:15, Pietro Cerutti <gahr@freebsd.org> wrote:
> > > > +using namespace std;
> > >
> > > Out of curiosity, do we have any style guidelines w.r.t. C++? For
> > > example, I would personally not use things like "using namespace std".
> > > It becomes hard to figure out where symbols come from.
> >
> > I would also prefer avoiding 'using namespace' when possible, especially for
> > a short program.
> >
> > > > + sort(begin(names), end(names));
> > > > + vector<string>::iterator last(unique(begin(names), end(names)));
>
> Seriously? We want this completely readable line changed to:
>
> std::vector<std::string>::iterator last(std::unique(
> std::begin(names), std::end(names)));
>
> If so we REALLY need to revist the 80-column limitation.
>
> I think "using namespace std;" is enough of an idiom in C++ that it
> should be allowed and even encouraged unless there's a good reason not
> to use it.
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.
--
John Baldwin
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
討論串 (同標題文章)
完整討論串 (本文為第 22 之 30 篇):