Erik Hofman wrote:
> James Turner wrote:
>> I think this is a good example of why 'using std::xxx' is potentially  
>> problematic in headers (especially public library headers, i.e  
>> Simgear), but fine in sources. So if I'm doing future cleanups, that's  
>> the approach I'd take - remove 'using' from headers, and add it to  
>> sources, unless there's only one or two uses, in which case I'll use a  
>> std:: prefix.
>> Equally, I'm pretty sure people avoid calling things 'string' or  
>> 'vector' for exactly these reasons, so it's 99.9% unnecessary, as  
>> Melchior said.
>> Does this seem reasonable?
> Seems good to me.
To add my two cents:
I mostly favor putting "using" declarations at the top of source files instead 
of using namespace qualifiers in the code. On the other hand, I would probably 
use the namespace qualifer explicitly if the symbol in question is somewhat 
obscure, to give the reader a clue about its source. For example, I'd never 
std::string in code, but would probably type std::nth_element.

A middle ground, considered the best C++ style by many, is to explicitly use 
only the symbols you are referencing from a namespace, instead of using the 
whole namespace. This is a style and taste issue, best left to the individual 
developer and circumstances. Personally, I have typed "using namespace osg;" 
almost everywhere that there is a reference to Open Scene Graph symbols because 
there is a tendency to use many symbols from that namespace at once, but my 
thinking is now leaning towards explicit "using" declarations for individual 
symbols instead.


This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Flightgear-devel mailing list

Reply via email to