samedi 11 mars 2017

Decrypt upper_bound with reverse_iterator stl error

What exactly did compiler means by this:

c:\usr\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:
In function 
'_FIter std::upper_bound(_FIter, _FIter, const _Tp&)
[
  with _FIter = std::reverse_iterator<
    __gnu_cxx::__normal_iterator<ModelItem*, std::vector<ModelItem> > >,
    _Tp = Model::close_active(int)::<lambda(const t_item&)>
]':

model.cpp:58:3:   instantiated from here


c:\usr\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/stl_algo.h:2461:4:

error: no match for 'operator<' in
'__val < __middle.std::reverse_iterator<_Iterator>::operator*

[
  with _Iterator =
    __gnu_cxx::__normal_iterator<ModelItem*, std::vector<ModelItem> >,
     std::reverse_iterator<_Iterator>::reference = ModelItem&
]()'

For this peace of code:

t_itemlist::reverse_iterator rit = std::upper_bound(
  m_itemlist.rbegin(), m_itemlist.rend(),
  [&at](const t_item& item){ return item.at > at; }
);

I'd like to use reverse iterators.

(SO form ask me add more details with text as the question is too more code for its opinion. But I do not know what to say more.)

Aucun commentaire:

Enregistrer un commentaire