Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map[key] = value;
- using std::cout; using std::endl;
- typedef std::map<int, std::string> MyMap;
- MyMap map;
- // ...
- std::pair<MyMap::iterator, bool> res = map.insert(std::make_pair(key,value));
- if ( ! res.second ) {
- cout << "key " << key << " already exists "
- << " with value " << (res.first)->second << endl;
- } else {
- cout << "created key " << key << " with value " << value << endl;
- }
- using namespace std;
- using namespace boost::assign; // bring 'map_list_of()' into scope
- void something()
- {
- map<int,int> my_map = map_list_of(1,2)(2,3)(3,4)(4,5)(5,6);
- }
Add Comment
Please, Sign In to add comment