I'd like to have two structures which point to eachother. Specifically, I'd like to have the following:
template<typename Key, typename Value>
class MyStructure {
public:
typedef map<Key, list<pair<Value, typename ListType::iterator>>> MapType;
typedef list<typename MapType::element_type::iterator> ListType;
private:
MapType map_;
ListType list_;
}
Obviously this will not work since ListType is not declared previously as a type. How could I do this? As you can see I am using the iterator types as pointers to these two structures' elements.
I was thinking of using the curiously recurring template pattern, but could not get anywhere with that. Someone on ##c++ also suggested using template aliases, but that failed as well (at least, I don't know how to use this idea).
Am I doing something wrong, conceptually? Or perhaps "not in line with C++ concepts"? I could certainly do this with void*s, but I'm trying to make things The Right Way :)
Thanks!