개요
예제
- 코드
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
map<int, string> m{{1, "a"}, {2, "b"}, {3, "c"}};
auto node = m.extract(3);
for (const auto &iter : m) {
cout << iter.first << ", " << iter.second << endl;
}
cout << "------ 1" << endl;
cout << node.key() << endl;
cout << "------ 2" << endl;
node.key() = 5;
m.insert(move(node));
for (const auto &iter : m) {
cout << iter.first << ", " << iter.second << endl;
}
return 0;
}
- 실행 결과
1, a
2, b
------ 1
3
------ 2
1, a
2, b
5, c