c++ - Declaring using statement after namespace declaration -


i writing utility library made of several "packages". classes in each package contained in various namespaces. have idea how can simplify situation automatically declaring using statements @ end of class declarations (see below), avoid having programmer in cpp file.

namespace utility {     class string     {         // class implementation     }; }  using utility::string; 

my understanding if user includes header string.h , string in utility programmer want use string. bad if there outside classes chain including bunch of files dirty namespace thought how making #define instead.

namespace utility {     class string     {         // class implementation     }; }  #ifdef auto_declare_namespace     using utility::string; #endif 

that way, programmers want extended functionality can it.

would idea or there i'm overlooking?

there no point in using namespaces if going add using declaration each , every name declared in namespace.

let users of header files decide how want use headers. if wants use using declaration, let him in .cpp file directly; make code in .cpp file clearer since apparent name originated.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -