How about defining:
#include<iostream>
#include<string>
#include<map>
#include<memory>
using namespace std;
int main(){
unique_ptr<map<string, int>> person(new map<string, int>);
(*person)["Tom"] = 34;
cout << (*person)["Tom"] << endl;
}
Output is:
34
See for yourself: https://wandbox.org/permlink/CNaWMLYJTxQSfKwt .
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…