Are pointers allowed as keys in ordered STL containers?

后端 未结 4 914
遥遥无期
遥遥无期 2020-12-19 06:33

There\'s this other question asking about how comparing pointers is supposed to be interpreted wrt the C++ Std.

So I was wondering what the C++ Std has to say about

4条回答
  •  长情又很酷
    2020-12-19 07:11

    Yes, because it uses std::less, which is required to result in a total order even if < doesn't. (< would be allowed to treat different pointers from distinct sequences as equal, which would result in an odd behaviour of map etc if you insert pointers from different sequences).

提交回复
热议问题