Std :: set <K, C> :: operator <(const std :: set <K, C> &) does not use C (), but std :: less ()

cannot delete my own question, so rewrite it ...

+6
source share
1 answer

Actually, this is not an error in implementation, although it is probably one in the standard:

23.2.1 General requirements for containers [container.requirements.general] 13 Table 98 lists the operations that are provided for some types of containers, but not for others. Those containers for which the listed operations are intended should implement the semantics described in table 98, unless otherwise indicated.

The table contains:

a < b
convert to bool
lexicographical_compare(a.begin(),a.end(),b.begin(),b.end())
pre: <is defined for T. <is the full ordering relation.
linear

While the following sections indicate that std::set provides comparison operators, unfortunately this does not change the definition from the above.

As an aside, std::lexicographical_compare does not actually use std::less , but directly uses < . Not that it was any meaningful.

+3
source

Source: https://habr.com/ru/post/982812/


All Articles