tags:

views:

163

answers:

2

Hi All,

I have a template class that is:

template <class identifier,class registeredObject>
class FxPairRegistry : public FxRegistry<pair<identifier,registeredObject> >
{
 public:
  registeredObject GetEntry(identifier, FxBool assertValue = true);
  void RegisterInOrder(const pair<identifier,registeredObject> &ob);

  typedef typename std::vector<pair<identifier,registeredObject> >::iterator iter;
};

I then have:

template <class identifier,class registeredObject>
registeredObject FxPairRegistry<identifier,registeredObject>::GetEntry(identifier id, FxBool 
assertValue)
{
 for (iterator iter = mRegistryList.begin(); iter != mRegistryList.end(); iter++)
 {
  if ((*iter).first == id)
  {
   return (*iter).second;
  }
 }
}

But I get errors like:

error: missing template arguments before 'iter'
error: expected `;' before 'iter'
error: expected primary-expression before '!=' token
error: 'mRegistryList' was not declared in this scope
error: expected primary-expression before '++' token
error: expected primary-expression before ')' token
error: expected primary-expression before ')' token
error: missing template arguments before 'iter'
error: expected `;' before 'iter'
error: expected primary-expression before '!=' token
error: 'mRegistryList' was not declared in this scope
error: expected primary-expression before '++' token

I dont quite get what I am doing wrong, but I am rusty a bit for sure....

+2  A: 

Check your for loop. What is iterator iter = ... supposed to do? You typedef'ed the iterators as iter so iter becomes the name of the type you want to declare.

pmr
+5  A: 

It seems that here, you are typedef'ing a type called iter:

typedef typename std::vector<pair<identifier,registeredObject> >::iterator iter;

And then here:

iterator iter = mRegistryList.begin()

You are trying to define a variable called iter of type iterator, which (from the code you've shown) is not the name of any type that exists.

Tyler McHenry