emplace_back() does not behave as expected

后端 未结 2 1512
我在风中等你
我在风中等你 2020-12-18 18:09

I wrote a simple program to play around with in-place creation of objects inside standard library containers. This is what I wrote:

#include 
#         


        
2条回答
  •  孤城傲影
    2020-12-18 18:56

    The point of emplacement is to get rid of the COPY constructor calls. It's probably moving objects around due to resizing the vector when it's full. Moving an object is fine. Copying an object is expensive.

提交回复
热议问题