Jump to content
  • Advertisement
Sign in to follow this  
clapton

STL map container

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

Hello! I am having some difficulties with STL map container. I get some weird errors in the following piece of code.

#include <map>
#include <vector>

template <class T> class CMemoryManager
{

	// tMemoryPage structure
	class	 tMemoryPage
	{
		CMemoryBlock <T>	MemoryBlock;	// CMemoryBlock for the page

		std::vector <unsigned int> MagicVec;	// Vector of magic numbers
		std::vector <unsigned int> FreeVec;	// Vector of free slots in the memory block
	};

	// ... some typedefs for STL
        typedef std::map <string, tMemoryPage>		ResourceMap;	
	typedef ResourceMap::value_type				mapValue;
/* error C2146: syntax error : missing ';' before identifier 'mapValue' */ 
        typedef ResourceMap::iterator				mapItor;

    // *** rest of the class *** //
};

Do you notice anything suspicious ? :) If so, I would be thankful if you help me. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Try this instead:


// ... some typedefs for STL
typedef typename std::map <string, tMemoryPage> ResourceMap;
typedef typename ResourceMap::value_type mapValue;
typedef typename ResourceMap::iterator mapItor;



- Houdini

Share this post


Link to post
Share on other sites
I don't think you should need to use the typename keyword there, although admittedly my understanding of when typename is required is a little flaky (I also don't have access to all my compilers at the moment so I can't test this). It looks to me as if you should be #includeing <string> and namespace qualifying string in the std::map typedef, i.e. typedef std::map<std::string, tMemoryPage> ResourceMap; (assuming your string is the standard string class).

Enigma

Share this post


Link to post
Share on other sites
Quote:
Original post by Houdini
Try this instead:


// ... some typedefs for STL
typedef typename std::map <string, tMemoryPage> ResourceMap;
typedef typename ResourceMap::value_type mapValue;
typedef typename ResourceMap::iterator mapItor;


- Houdini


It works! :D Great thanks!

Bye!

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!