Question

i have the following code

typedef ListDigraph::NodeMap<string> Node_names;
vector<ListDigraph::Node> initial_state;
vector<Node_names*> P_names;
//some loop
{
   Node_names name;
   ListDigraph::Node state = graph.addNode();
   initial_state = state;
   name[state] = "state1";
   P_names.push_back(&name);
}

void printin()
{
    cout<<P_names[0][initial_state[0]]
} 

In printin i get the error :

error: no match for ‘operator[]’ in ‘((Translator*)this)->Translator::Process_state_name.std::vector<_Tp, _Alloc>::operator[] [with _Tp = lemon::DigraphExtender<lemon::ListDigraphBase>::NodeMap<std::basic_string<char> >*, _Alloc = std::allocator<lemon::DigraphExtender<lemon::ListDigraphBase>::NodeMap<std::basic_string<char> >*>, std::vector<_Tp, _Alloc>::reference = lemon::DigraphExtender<lemon::ListDigraphBase>::NodeMap<std::basic_string<char> >*&, std::vector<_Tp, _Alloc>::size_type = unsigned int](0u)[((Translator*)this)->Translator::Process_initial_state.std::vector<_Tp, _Alloc>::operator[] [with _Tp = lemon::ListDigraphBase::Node, _Alloc = std::allocator<lemon::ListDigraphBase::Node>, std::vector<_Tp, _Alloc>::reference = lemon::ListDigraphBase::Node&, std::vector<_Tp, _Alloc>::size_type = unsigned int](0u)]’

how do i access the names for the states....

Was it helpful?

Solution

You probably want to display P_names[0][...] or something like that. Your Node_names is a define, you probably cannot use the angle brackets like that. Think of it like if you removed your typedef, you would have to write it like that: ListDigraph::NodeMap<string>[0][P_names[0]]. Would that make sense?

We can't really help you more if you don't provide more information I'm afraid...

Edit: try (*P_names[0])["test"], maybe that would do it (providing you have all necessary elements).

One thing you can do though is using as many temp variables as you want. You really need to understand what types are P_names[0], *P_names[0], (*P_names[0])[...] etc. Try to compile the code, write class names on a paper, have a look at some diagrams in the documentation, draw diagrams (with a pencil on paper), anything that could help you understand what is going on.

You are using a library that is not well known and even if people here are trying to help you it is really hard, especially without the code or even worse with a code which is not the actual code...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top