Which operator needs to be overridden in order to use std::set in the C++ code?

前端 未结 4 782
滥情空心
滥情空心 2021-01-27 09:34

This is an interview question.

Referring to the sample code, which one of the operators needs to be overridden in order to use st

4条回答
  •  攒了一身酷
    2021-01-27 10:20

    A set keeps out the duplicates without needing operator= or operator!= by using the notion of equivalence. Two items are equivalent if neither is less than the other:

    if (!(a < b || b < a))
        // equivalent!
    

提交回复
热议问题