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<k, v>::insert
instead.
m2.insert(m1.begin(), m1.end());
More Related Contents:
- c++ push reference node to stl list
- How can I use std::maps with user-defined types as key?
- Why use iterators instead of array indices?
- Why are Standard iterator ranges [begin, end) instead of [begin, end]?
- What happens if you call erase() on a map element while iterating from begin to end?
- Const map element access
- How to find if a given key exists in a C++ std::map
- Removing item from vector while iterating?
- In STL maps, is it better to use map::insert than []?
- Why use non-member begin and end functions in C++11?
- Sorting a vector in descending order
- std::map emplace without copying value
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Custom Iterator in C++
- how portable is end iterator decrement?
- Can std::begin work with array parameters and if so, how?
- std::vector iterator invalidation
- How do you copy the contents of an array to a std::vector in C++ without looping?
- Checking if an iterator is valid
- How does std::copy work with stream iterators
- Can raw pointers be used instead of iterators with STL algorithms for containers with linear storage?
- How to remove constness of const_iterator?
- Copying std::vector: prefer assignment or std::copy?
- Do STL iterators guarantee validity after collection was changed?
- Incrementing iterators: Is ++it more efficient than it++? [duplicate]
- what is the difference between const_iterator and iterator? [duplicate]
- iterator for 2d vector
- Insert into an STL queue using std::copy
- STL map containing references does not compile
- C++ inserting unique_ptr in map