• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2006-2009 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 //[intro_example1_1
7 #include <boost/unordered_map.hpp>
8 #include <boost/foreach.hpp>
9 #include <cassert>
10 #include <iostream>
11 //]
12 
main()13 int main() {
14 //[intro_example1_2
15     typedef boost::unordered_map<std::string, int> map;
16     map x;
17     x["one"] = 1;
18     x["two"] = 2;
19     x["three"] = 3;
20 
21     assert(x.at("one") == 1);
22     assert(x.find("missing") == x.end());
23 //]
24 
25 //[intro_example1_3
26     BOOST_FOREACH(map::value_type i, x) {
27         std::cout<<i.first<<","<<i.second<<"\n";
28     }
29 //]
30 }
31