The Comparison Criterion
Explore how C++ ordered associative containers use comparison criteria like std::less for sorting keys. Understand the importance of overloading operator < for user-defined types and the rules of strict weak ordering, which ensure correct container behavior. This lesson prepares you to implement and customize comparison functions essential for effective use of ordered associative containers.
We'll cover the following...
We'll cover the following...
The default comparison criterion of the ordered associative containers is std::less. If we want to use a user-defined type as the key, we have to overload the operator <. It’s sufficient to overload the operator < for our data type because the C++ runtime compares, with the help of the relation ...