MiddleDebuggingOccasionalNot answered yet
Why are template error messages so long and how do you tame them?
Calling std::sort on a container of a type with no operator< produces this diagnostic. Explain why it is so long and how to make such failures readable.
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:1820:5: required from '...__sort<...>'
/usr/include/c++/13/bits/stl_algo.h:1936:5: required from 'sort<...>'
app.cpp:14:15: required from here
/usr/include/c++/13/bits/predefined_ops.h:43:23: error:
no match for 'operator<' (operand types are 'Widget' and 'Widget')
43 | { return *__it1 < *__it2; }
| ~~~~~~~^~~~~~~~~
... 60 further 'required from' / 'note:' lines ...
Diagnose the cause.
Errors fire deep in the instantiation chain — the compiler prints every step. Tames: C++20 concepts give a one-line 'does not satisfy X', an early static_assert gives a friendly message, and cppinsights.io helps.
- ✗Reading errors top-to-bottom instead of starting from your code line
- ✗Ignoring
note:lines that show why the substitution failed - ✗Throwing more SFINAE at the problem instead of refactoring
- →How do concepts make errors more actionable?
- →What does
cppinsights.ioshow?