Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Brobanx

Need lots of help with STL =[

This topic is 6148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!