0

I'm trying to get the code below to compile:

template <typename K, typename V>
static void addMapping(const K& id, const V& index, std::map<K, V>& mapset) 
{
    std::pair< std::map<K, V>::iterator, bool > ret;
    // ...
}

but I get the following error message:

error: type/value mismatch at argument 1 in template parameter list for ‘template<class _T1, class _T2> struct std::pair’
     std::pair< std::map<K, V>::iterator, bool > ret;

I recall that there's something special you need to write when you want to use a template parameter as an argument to another template, but I don't remember what that was...

Zebrafish
  • 11,682
  • 3
  • 43
  • 119
gablin
  • 4,678
  • 6
  • 33
  • 47

1 Answers1

4

Change this line:

std::pair< std::map<K, V>::iterator, bool > ret;

into:

std::pair< typename std::map<K, V>::iterator, bool > ret;

As std::map<K, V>::iterator depends on the template arguments you need to tell the compiler it's a type.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55