std::pair has no member named: end

Hi everyone,
I have a pair list stored in a vector; I try to enter in the first column of the list to count the number of lists stored for each element in the vector;
I try with this code;

1
2
3
4
5
6
7
8
9
for (std::vector<std::pair <uint32_t,uint32_t> >::iterator it = NeigborsNumber (GetDevice ()).begin(); it != NeigborsNumber (GetDevice ()).end (); it++)

        {
typedef std::list <std::pair <uint32_t,uint32_t> >  d_lista;
for (d_lista::iterator itt = it->begin(); itt != it->end(); itt++)
{
           std::cout <<"{ "<<itt->first<<" }"<< std::endl;
}
}


I get this error:

1
2
 error: struct std::pair<unsigned int, unsigned int>’ has no member named:end
error: struct std::pair<unsigned int, unsigned int>’ has no member named:begin


Any Help thanks in advance
Last edited on
it is an iterator.

it->begin() What did you expect this to do? It is trying to call the function begin on the object the iterator is pointing at, which is a std::pair. What did you expect the non-existent function std::pair::begin() to do?
Thanks for ur reply;
I have a vector of std::pair , so how can I have the access to each std :: pair for a given vector element?

do u have any idea ;
Each vector element is a single std::pair. You iterate over the vector, to get each pair in turn. You don't iterate over a pair - you just use the first and second members to access the data in a pair.
1
2
3
4
5
6
7
for (int i = 0; i < vector_of_pairs.size(); i++)
{
  std::pair<unsigned int, unsigned int> current_pair = vector_of_pairs[i];

  // now do something with current_pair
}
  
thanks a lot for ur help;now its works whit ur proposition;
Topic archived. No new replies allowed.