Advertisement Jump to content
Sign in to follow this  

problem with std map

This topic is 4918 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>
	int render();
	void addGeometry(std::string geometryID, CGeometryBase*);
	CGeometryBase* getGeometry(std::string geometryID);
	void removeGeometry(std::string geometryID);
	void clear();
	typedef std::map<std::string, CGeometryBase*> geometryType;
	std::map<std::string, CGeometryBase*> geometryMap;
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
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!