How can I copy one map into another using std::copy?

前端 未结 2 1745
深忆病人
深忆病人 2020-12-02 21:17

I would like to copy the content of one std::map into another. Can I use std::copy for that? Obviously, the following code won\'t work:

int main         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 21:43

    You can use GMan's answer --- but the question is, why do you want to use std::copy? You should use the member function std::map::insert instead.

    m2.insert(m1.begin(), m1.end());
    

提交回复
热议问题