'std::map'에 해당되는 글 1건

  1. 2015.09.23 std::vector 복사와 std::map 복사
카테고리 없음2015. 9. 23. 11:27

* std::vector 복사


#include <vector>

#include <algorithm>


if( 0 < vectorSource.size() )

{

    vectorTarget.resize(vectorSource.size());

    std::copy(vectorSource.begin(), vectorSource.end(), vectorTarget.begin());

}


* std::map 복사


#include <map>


if( 0 < mapSource.size() )

{

    mapTarget.insert(mapSource.begin(), mapSource.end());

}


또는 


#include <map>

#include <algorithm>


if( 0 < mapSource.size() )

{

    std::copy(mapSource.begin(), mapSource.end(), std::inserter(mapTarget,mapTarget.begin()));

}



Posted by 좋은나무