Jump to content
  • Advertisement
Sign in to follow this  
f1restar

problem with std map

This topic is 4847 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

Hi all, im creating my own 3d engine, its comming along, but now im kinda stuck. I'm trying to create a management system for geometry used within the engine. I'm trying to use a hashmap to store geometry and want to retreve it using its key (a string). My problem comes with retreving the geometry again. Im getting a could not deduce template error. What am I doing wrong here? CGeometryManager.h:
class CGeometryManager : public DeuceUtils::CSingleton<CGeometryManager>
{
public:
	CGeometryManager();
	~CGeometryManager();
	int render();
	void addGeometry(std::string geometryID, CGeometryBase*);
	CGeometryBase* getGeometry(std::string geometryID);
	void removeGeometry(std::string geometryID);
	void clear();
protected:
private:
	typedef std::map<std::string, CGeometryBase*> geometryType;
	std::map<std::string, CGeometryBase*> geometryMap;
};
CGeometryManager.cpp:
CGeometryBase* CGeometryManager::getGeometry(std::string geometryID){
        //This gives me a template error
	geometryType::iterator geoIter = geometryMap.find(geometryID);
	return (*geoIter).second;
        //This also doesnt work?
	//return geometryMap[geometryID];
}
The error given: error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string' There are a lot more errors following that. My question is, why doesnt this work? It should juist return my geometry pointer shouldnt it? Is there a better way to manage geometry? Which is generic? I want all types of geometry to be added, and dont want to hard code everything.

Share this post


Link to post
Share on other sites
Advertisement
You can get errors like that if you include a header that defines std::string but doesn't actually include <string>. On MSVC an example of that is the <iostream> header. Try including <string> and see if that clears up the error.

Share this post


Link to post
Share on other sites
Doh! you where right, weird that both gcc and msvc dont tell me that std::string isnt defined, oh well its fixed ^_^

As for my other question? Is there a beter way to manage geometry? I was planning on using this system, and have a seperate system that checks the culling on all the geometry. Or is having a hashmap and getting the key using a string, a performance problem?

I've tried searching but havent found a lot of links that deal with the subject of managing meshes/geometry using a single system (so that I can easily add caching and various other stuff)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!