list.sort(students.begin(), students.end(), sortByLastName); //std:: list.
cout << "Sorted names: \n" << endl;
while (i != students.end())
cout << *i << endl;
++i;
}
}
error: missing template arguments before ‘.’ token
list.sort(students.begin(), students.end(), sortByLastName);
if I use Std::sort with
#include <algorithm> it gives me a
Compilation failed due to following error(s).
In file included from /usr/include/c++/5/algorithm:62:0,
from main.cpp:14:
/usr/include/c++/5/bits/stl_algo.h: In instantiation of ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::_List_iterator<DataType>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(DataType, DataType)>]’:
/usr/include/c++/5/bits/stl_algo.h:4729:18: required from ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::_List_iterator<DataType>; _Compare = bool (*)(DataType, DataType)]’
<span class="error_line" onclick="ide.gotoLine('main.cpp',79)">main.cpp:79:67</span>: required from here
/usr/include/c++/5/bits/stl_algo.h:1964:22: error: no match for ‘operator-’ (operand types are ‘std::_List_iterator’ and ‘std::_List_iterator’)
std::__lg(__last - __first) * 2,
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from main.cpp:10:
/usr/include/c++/5/bits/stl_iterator.h:333:5: note: candidate: template decltype ((__x.base() - __y.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator-(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:333:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/algorithm:62:0,
from main.cpp:14:
/usr/include/c++/5/bits/stl_algo.h:1964:22: note: ‘std::_List_iterator’ is not derived from ‘const std::reverse_iterator<_Iterator>’
std::__lg(__last - __first) * 2,
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from main.cpp:10:
/usr/include/c++/5/bits/stl_iterator.h:387:5: note: candidate: template decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator-(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:387:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/algorithm:62:0,
from main.cpp:14:
/usr/include/c++/5/bits/stl_algo.h:1964:22: note: ‘std::_List_iterator’ is not derived from ‘const std::reverse_iterator<_Iterator>’
std::__lg(__last - __first) * 2,
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from main.cpp:10:
/usr/include/c++/5/bits/stl_iterator.h:1145:5: note: candidate: template decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator-(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1145:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/algorithm:62:0,
from main.cpp:14:
/usr/include/c++/5/bits/stl_algo.h:1964:22: note: ‘std::_List_iterator’ is not derived from ‘const std::move_iterator<_Iterator>’
std::__lg(__last - __first) * 2,
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from main.cpp:10:
/usr/include/c++/5/bits/stl_iterator.h:1152:5: note: candidate: template decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator-(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1152:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/algorithm:62:0,
from main.cpp:14:
/usr/include/c++/5/bits/stl_algo.h:1964:22: note: ‘std::_List_iterator’ is not derived from ‘const std::move_iterator<_Iterator>’
std::__lg(__last - __first) * 2,