Ось помилка:
In file included from /usr/include/c++/6/bits/stl_algobase.h:71:0,
from /usr/include/c++/6/vector:60,
from prog.cpp:1:
/usr/include/c++/6/bits/predefined_ops.h: In instantiation of ‘constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<const EdgeData1<int>*, std::vector<EdgeData1<int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<const EdgeData1<int>*, std::vector<EdgeData1<int> > >]’:
/usr/include/c++/6/bits/stl_algo.h:3234:12: required from ‘_ForwardIterator std::__is_sorted_until(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<const EdgeData1<int>*, std::vector<EdgeData1<int> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:3258:36: required from ‘_FIter std::is_sorted_until(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<const EdgeData1<int>*, std::vector<EdgeData1<int> > >]’
/usr/include/c++/6/bits/stl_algo.h:3207:34: required from ‘bool std::is_sorted(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<const EdgeData1<int>*, std::vector<EdgeData1<int> > >]’
prog.cpp:23:44: required from here
/usr/include/c++/6/bits/predefined_ops.h:43:23: error: no match for ‘operator<’ (operand types are ‘const EdgeData1<int>’ and ‘const EdgeData1<int>’)
{ return *__it1 < *__it2; }
~~~~~~~^~~~~~~~
prog.cpp:6:14: note: candidate: bool EdgeData1<ED>::operator<(const EdgeData1<ED>&) [with ED = int] <near match>
bool operator< (const EdgeData1<ED>& other) { return indexTo < other.indexTo; }
^~~~~~~~
prog.cpp:6:14: note: passing ‘const EdgeData1<int>*’ as ‘this’ argument discards qualifiers
Основне тут - в останньому рядку: передача const EdgeData1<int>* як аргументу this скидає специфікатор. Тобто this має бути константним, а в операторі він не константний. Виправляємо:
- bool operator<(const EdgeData1<ED>& other) { return indexTo < other.indexTo; }
+ bool operator<(const EdgeData1<ED>& other) const { return indexTo < other.indexTo; }
Все гаразд.