mardi 26 mars 2019

Conversion type error when chaining method

I'm lost on this piece of c++ code that involves iterating over a list contained in a struct RouteInfo. How come the code shows this compilation error: Severity Code Description Project File Line Suppression State Error (active) E0312 no suitable user-defined conversion from "std::_List_const_iterator<std::_List_val<std::conditional_t<true, std::_List_simple_types<int>, std::_List_iter_types<int, size_t, ptrdiff_t, int *, const int *, int &, const int &, std::_List_node<int, void *> *>>>>" to "std::_List_iterator<std::_List_val<std::conditional_t<true, std::_List_simple_types<int>, std::_List_iter_types<int, size_t, ptrdiff_t, int *, const int *, int &, const int &, std::_List_node<int, void *> *>>>>" ...

Problem code

void iterateOverListInStruct(std::multimap<RouteInfo,int> aMap)
{
     std::list<int>::iterator itr = it->first.secList.begin();
}

and this code doesn't show any compiler errors?

void iterateOverListInStruct(std::multimap<RouteInfo,int> aMap)
{
     std::list<int> list= it->first.secList;
     std::list<int>::iteartor itr = list.begin();
}

Here is the class RouteInfo:

class RouteInfo{
    public:
        list<int>secList;}

Aucun commentaire:

Enregistrer un commentaire