Why not overload operator+=() for std::vector?

前端 未结 4 1793
别那么骄傲
别那么骄傲 2020-12-06 16:18

I\'ve started learning C++, so I don\'t know in my lack of knowledge/experience why something so seemingly simple to a rookie as what I\'m about to describe isn\'t already i

4条回答
  •  余生分开走
    2020-12-06 17:02

    This is actually a case where I would like to see this functionality in the form of an overload of append(). operator+= is kinda ambiguous, do you mean to add the elements of each vector to each other? Or you mean to append?

    However, like I said, I would have welcomed: v1.append(v2); It is clear and simple, I don't know why it isn't there.

提交回复
热议问题