Skip to content

Commit a3bdc19

Browse files
authored
Merge pull request #21 from dermojo/main
Issue #10: sources for "how to read template error messages"
2 parents 6285554 + 0874d7d commit a3bdc19

19 files changed

+2834
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <algorithm>
2+
#include <string>
3+
#include <vector>
4+
5+
struct UserName
6+
{
7+
std::string name;
8+
};
9+
10+
int main()
11+
{
12+
std::vector<UserName> users;
13+
std::sort(users.begin(), users.end());
14+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
In file included from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algobase.h:71,
2+
from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/algorithm:60,
3+
from <source>:1:
4+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/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<UserName*, std::vector<UserName> >; _Iterator2 = __gnu_cxx::__normal_iterator<UserName*, std::vector<UserName> >]':
5+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1819:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
6+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1859:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
7+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1950:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
8+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:4861:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >]'
9+
<source>:13:14: required from here
10+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'UserName' and 'UserName')
11+
45 | { return *__it1 < *__it2; }
12+
| ~~~~~~~^~~~~~~~
13+
In file included from /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algobase.h:67:
14+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1250:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
15+
1250 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
16+
| ^~~~~~~~
17+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1250:5: note: template argument deduction/substitution failed:
18+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:45:23: note: 'UserName' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
19+
45 | { return *__it1 < *__it2; }
20+
| ~~~~~~~^~~~~~~~
21+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1258:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
22+
1258 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
23+
| ^~~~~~~~
24+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1258:5: note: template argument deduction/substitution failed:
25+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:45:23: note: 'UserName' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
26+
45 | { return *__it1 < *__it2; }
27+
| ~~~~~~~^~~~~~~~
28+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = UserName; _Iterator = __gnu_cxx::__normal_iterator<UserName*, std::vector<UserName> >]':
29+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1799:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Val_less_iter]'
30+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1827:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
31+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1859:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
32+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1950:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
33+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:4861:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >]'
34+
<source>:13:14: required from here
35+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:98:22: error: no match for 'operator<' (operand types are 'UserName' and 'UserName')
36+
98 | { return __val < *__it; }
37+
| ~~~~~~^~~~~~~
38+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1250:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
39+
1250 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
40+
| ^~~~~~~~
41+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1250:5: note: template argument deduction/substitution failed:
42+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:98:22: note: 'UserName' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
43+
98 | { return __val < *__it; }
44+
| ~~~~~~^~~~~~~
45+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1258:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
46+
1258 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
47+
| ^~~~~~~~
48+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1258:5: note: template argument deduction/substitution failed:
49+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:98:22: note: 'UserName' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
50+
98 | { return __val < *__it; }
51+
| ~~~~~~^~~~~~~
52+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<UserName*, std::vector<UserName> >; _Value = UserName]':
53+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Distance = long int; _Tp = UserName; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
54+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Distance = long int; _Tp = UserName; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
55+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
56+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1635:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
57+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1910:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
58+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1926:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
59+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:1947:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
60+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_algo.h:4861:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<UserName*, vector<UserName> >]'
61+
<source>:13:14: required from here
62+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'UserName' and 'UserName')
63+
69 | { return *__it < __val; }
64+
| ~~~~~~^~~~~~~
65+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1250:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
66+
1250 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
67+
| ^~~~~~~~
68+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1250:5: note: template argument deduction/substitution failed:
69+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:69:22: note: 'UserName' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
70+
69 | { return *__it < __val; }
71+
| ~~~~~~^~~~~~~
72+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1258:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
73+
1258 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
74+
| ^~~~~~~~
75+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator.h:1258:5: note: template argument deduction/substitution failed:
76+
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/predefined_ops.h:69:22: note: 'UserName' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
77+
69 | { return *__it < __val; }
78+
| ~~~~~~^~~~~~~
79+
Compiler returned: 1

0 commit comments

Comments
 (0)