Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why doesn maps operator< use the maps comparison function?

comparison function map
0
Posted

Why doesn maps operator< use the maps comparison function?

0

A map has a notion of comparison, since one of its template parameters is a comparison function. However, operator< for maps uses the elements' operator< rather than that comparison function. This appears odd, but it is deliberate and we believe that it is correct. At the most trivial level, this isn't a bug in our implementation because it's what's mandated by the C++ standard. (The behavior of operator< is described in Table 65, in section 23.1.

0

A map has a notion of comparison, since one of its template parameters is a comparison function. However, operator< for maps uses the elements' operator< rather than that comparison function. This appears odd, but it is deliberate and we believe that it is correct. At the most trivial level, this isn't a bug in our implementation because it's what's mandated by the C++ standard.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123