Hey guys, I have what I would consider a fairly unique problem. I'm not even sure where to start looking for a solution. I have template class that uses a typedef to define a map. But when I go to make an iterator for that map, I get a compile errors. Here's my class (it's fairly simple):

template<class S>
class RangeValidatorDependency : public Dependency{
public:
    typedef std::map<std::pair<S,S>, Teuchos::RCP<const Teuchos::ParameterEntryValidator> > RangeToValidatorMap;

      
        RangeValidatorDependency(std::string dependent, std::string dependee, RangeToValidatorMap rangesAndValidators,
        Teuchos::RCP<const Teuchos::ParameterEntryValidator> defaultValidator)
                :Dependency(dependent, dependee, Dependency::RangeValiDep)
        {
                this->defaultValidator = defaultValidator;
                this->rangesAndValidators = rangesAndValidators;
        }

        virtual Teuchos::RCP<const Teuchos::ParameterEntryValidator> getValidatorFor(S value) const{
                RangeToValidatorMap::const_iterator it;
                for(it = rangesAndValidators.begin(); it != rangesAndValidators.end(); it++){
                        S min = it->first.first;
                        S max = it->first.second;
                        if(value >= min && value <=max)
                                return it->second;
                }
                return defaultValidator;
        }
private:
        Teuchos::RCP<const Teuchos::ParameterEntryValidator> defaultValidator;
        RangeToValidatorMap rangesAndValidators;
};

The problem occurs on this line

RangeToValidatorMap::const_iterator it;

This is the compile error I get.

TivaBuena_StandardDependencies.hpp:16: error: expected `;' before ‘it’

I'm not sure what to do. Anyone know what the problem is?

Just add typname before RangeToValidatorMap::const_iterator it; to make it typename RangeToValidatorMap::const_iterator it; Now try to find out using web, why this fixed the problem. Get back here if you don't find anything.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.