Adding to a vector of pair

后端 未结 10 1434
悲哀的现实
悲哀的现实 2021-01-30 05:19

I have a vector of pair like such:

vector> revenue;

I want to add a string and a doub

10条回答
  •  感情败类
    2021-01-30 05:34

    IMHO, a very nice solution is to use c++11 emplace_back function:

    revenue.emplace_back("string", map[i].second);
    

    It just creates a new element in place.

提交回复
热议问题