1. I know I can use *s.begin(), but same argument can be used for vector, which has front/back
  2. often I use the ordered property of set/map to get "smallest" element/key - ofc the fact that I do it is not the reason to have it, just a example :)

Here I'm talking about design reasons why front/back would be bad design, so please skip obvious reasons like committee forgot about it...

有帮助吗?

解决方案

I imagine that the words "front" and "back" are reserved for sequence containers (i.e. those where the order of elements is determined by the order of insertion), and the words are meant to suggest a physical position in that sequence.

Since set is not a sequence container (but instead an associative container), this isn't appropriate. In particular, note that the meaning of "front" can change by later insertions of an unrelated element.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top