STL container function return values

后端 未结 8 1139
名媛妹妹
名媛妹妹 2021-01-05 03:41

When looking over the member functions of the STL containers, an odd thought occurred to me. Why don\'t functions like std::vector::push_back(T) not ha

8条回答
  •  抹茶落季
    2021-01-05 04:44

    v.insert(v.end(),x);
    

    Would be equivalent to push_back with returning an iterator. Why push_back itself doesn't return an iterator is beyond me.

提交回复
热议问题