This topic is now archived and is closed to further replies.


iterators in hash_map data

Recommended Posts

I would like to use a structure as the data for a hash_map, and I want the structure to contain iterators to elements in the hash_map, but the compiler is giving me errors. For example, this code would give an error:
#include <iostream>
#include <hash_map>

using namespace std;

template<class T>
class HashData
        hash_map<T, HashData<T>, hash<T>, equal_to<T> >::iterator it;


int main()
    HashData<int> bob;

    return 0;


stl_pair.h: In instantiation of 'pair<const int, HashData<int> >':

stl_hashtable.h:239:  instantiated from '_Select1st<pair<const int,HashData<int> > >'

stl_hashtable.h:239:  instantiated from 'hashtable.h:239:  instantiated from 'hashtable<pair<const int,HashData<int> >,int,hashallocator<HashData<int> > >'

test.cpp:11:  instantiated from 'HashData<int>'
test.cpp:18:  instantiated from here

stl_pair.h:39: invalid use of undefined type 'class HashData<int>'
test.cpp:13: forward declaration of 'class HashData<int>'
stl_pair.h:50: confused by earlier errors, bailing out

Is this just something that you can't do, or am I doing something incorrectly? Jeremy Bell [edited by - Magmai Kai Holmlor on November 3, 2002 9:10:23 PM]

Share this post

Link to post
Share on other sites