Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::pair expecting a 'type', but I am giving it a type

Tags:

c++

templates

stl

This is my code:

typedef std::hash_multimap<Vertice<VerticeType, WeightType>*, Edge<VerticeType, WeightType>*> ght;
std::pair<ght::iterator, ght::iterator> getEdgesFromVertice(Vertice<VerticeType, WeightType>*);

When I try to compile it, it gives me an error saying:

error: type/value mismatch at argument 1 in template parameter list for ‘template<class _T1, class _T2> struct std::pair’
error:   expected a type, got ‘__gnu_cxx::hash_multimap::iterator’

But isn't, std::hash_multimap::iterator a type? All the examples I've seen online use the same kind of notation for the return type of std::hash_multimap<T1, T2>::equal_range(key)

Any help is appreciated. Thanks :)

like image 626
Rohan Prabhu Avatar asked Dec 05 '22 01:12

Rohan Prabhu


1 Answers

This looks like it is in a template and VerticeType etc. are template parameters. In that case you are missing typename:

std::pair<typename ght::iterator, typename ght::iterator> ...

Dependent names are assumed to not name types unless typename is used.

like image 179
Georg Fritzsche Avatar answered Dec 09 '22 13:12

Georg Fritzsche