Need lots of help with STL =[

Started by
11 comments, last by Brobanx 22 years, 4 months ago
quote:Original post by null_pointer
Why not use a project namespace? Then divy it up into namespaces for organizational purposes. I would think that this approach would cut down on the possibilities of name conflicts within the project, too.

We do that too. None of the project files are allowed to say "using prj" in their headers, but they may in the .cpp files (following the rule in my last post).
Advertisement
What about the idea of matching filenames to namespaces, with each file pair having one namespace. Then it would not matter if the header file contains using statements, because no matter which file is included in which other files, no using expressions would conflict.

Here is an example where one part of a project is using the version of the standard library provided with the compiler, and another part is using the SGI version of the standard library:
// ide_cpp_preprocessor.h#include <string>#include <istream>#include <ostream>namespace ide {  namespace cpp {    namespace preprocessor {      using std::string;      using std::istream;      using std::ostream;      namespace symbol {        bool check  (const string& name);        void replace(const string& name, const ostream& out);      }    }  }}// ide_cpp_parser.cpp#include "ide_cpp_preprocessor.h"#include <sgi/string>#include <sgi/istream>#include <sgi/ostream>namespace ide {  namespace cpp {    namespace parser {      using sgi::string;      using sgi::istream;      using sgi::ostream;      namespace read {        name(istream& in, ostream& out) { /* ... */ } // no conflict      }    }  }}


Edited by - null_pointer on December 18, 2001 2:27:52 PM
That''s alot of bookkeeping...
I also force myself to make typedef for every STL class I create:

typedef std::vector tyVectorMyStuff;tyVectorMyStuff m_vMyStuff; 


Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

"What I see is a system that _could do anything - but currently does nothing !" - Anonymous CEO
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement