Skip to main content
gamedev.net
🔒 Locked

STL map container

Started by clapton 2 replies 900+ views
Original Post
clapton
clapton
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!
___Quote: Know where basis goes, know where rest goes.
Houdini
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
Houdini
Enigma
Enigma
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 and namespace qualifying string in the std::map typedef, i.e. typedef std::map ResourceMap; (assuming your string is the standard string class).

Enigma
clapton
clapton
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!
___Quote: Know where basis goes, know where rest goes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.