Re: Template syntax help
On 2008-08-24 01:58, cat314159@yahoo.com wrote:
Compiles w/ MSVC (2008), fails with G++ (3.4.4 under cygwin), error
message included. Not sure what I'm doing wrong, I'm assuming the
MSVC is being too permissive as usual...
#include <map>
#include <memory>
using namespace std;
template <class EventT, class StateId> class State;
template <class EventT, class StateId> class StateMachine
{
public:
typedef State<EventT, StateId> StateType;
typedef std::map<StateId, StateType*> StateMap;
void RemoveState(const StateId &stateId);
};
template <class EventT, class StateId>
class State {};
template <class EventT, class StateId>
void StateMachine<EventT, StateId>::RemoveState(
const StateId &stateId)
{
typedef StateMap::iterator StateMapIt; //Errors start here
Make that "typedef typename StateMap::iterator StateMapIt;"
--
Erik Wikstr?m
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]