我认为题解中有关set的做法是不符合语言规范的
查看原帖
我认为题解中有关set的做法是不符合语言规范的
53151
Edgaru089楼主2024/10/30 22:19

我们来看cppreference:

std::set is an associative container ... Sorting is done using the key comparison function Compare. ... Everywhere the standard library uses the Compare requirements, uniqueness is determined by using the equivalence relation .

Compare is a set of requirements expected by some of the standard library facilities from the user-provided function object types. ...

我们往下看:

我们看到,_Compare_对两个元素相等的定义是不小于也不大于,而_Compare_对相等的要求是要有传递性的

但是这个题解里面的没有传递性,所以这不符合规范 :(

只是杠精而已,请勿认真

2024/10/30 22:19
加载中...