push_back vs emplace_back

后端 未结 7 2441
南旧
南旧 2020-11-22 03:41

I\'m a bit confused regarding the difference between push_back and emplace_back.

void emplace_back(Type&& _Val);
void push_         


        
7条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 04:00

    One more in case of lists:

    // constructs the elements in place.                                                
    emplace_back("element");
    
    
    //It will create new object and then copy(or move) its value of arguments.
    push_back(explicitDataType{"element"});
    

提交回复
热议问题