How can I copy one map into another using std::copy?
Posted
by Frank
on Stack Overflow
See other posts from Stack Overflow
or by Frank
Published on 2010-04-30T23:56:50Z
Indexed on
2010/05/01
0:07 UTC
Read the original article
Hit count: 199
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() {
typedef std::map<int,double> Map;
Map m1;
m1[3] = 0.3;
m1[5] = 0.5;
Map m2;
m2[1] = 0.1;
std::copy(m1.begin(), m1.end(), m2.begin());
return 0;
}
Is there any way to make it work with std::copy
?
Thanks!
© Stack Overflow or respective owner