Re: cout vs std::cout
On Sep 30, 1:05 pm, Gennaro Prota <gennaro/pr...@yahoo.com> wrote:
James Kanze wrote:
What do you mean exactly by "a local context"? One general
rule I've seen is that the length of entity names should be
inversely proportional to their scope
"Directly", you mean :-)
Yes.
[snip]
but to take Juha's example, if you have a 10 line function
that invokes std::replace in 5 different places, I'd see nothing
objectionable to a:
using std::replace ;
at the top of the function. I'll also use such declarations
when writing unit tests for the class.
Could you please elaborate on this latter sentence?
Well, my test code tends to be a lot different from normal code.
To begin with, it often contains very long functions, which are
just a linear succession of tests. And if I'm writing a test
suite for a class in a nested namespace, that class is very much
the center of attention of the test (which is never the case
otherwise). So I don't mind something like "using
Outer::Innter::ClassBeingTested" at the top of the function, or
even in the test header (which specifies the harness for this
particular class). It's a special case.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34