I am just reading a (printed, German) article about C++ concepts (C++20 that is).
The article gives an example for a function template, using the Sortable
concept:
template<typename Cont>
requires Sortable<Cont>()
void sort(Cont& container) { ... }
And it claims that a compiler would reject the following code:
std::list<int> lst = { 1, 7, 5, 12 };
sort(lst);
with an error like:
ERROR: lst is not random-access container with <
Assuming that the article is correct - why exactly is a list of int values not sortable? To me, a list of whole numbers is like the canonical example when thinking about something "sortable"?!
And no, I am not asking about std::sort. I am asking: why does the concept Sortable not work for a std::list<int>
?