unordered/doc/src_code/intro.cpp
Daniel James e07e7e889d Merge new changes to unordered & hash.
- Unordered tests can run lightweight test or Boost.Test (at least
   theoretically).
 - Workaround Open BSD's incorrect numeric_limits.
 - Move the hash extensions in their own file.
 - Various small improvements to the unordered docs.
 - Fix some unordered examples.

Merged revisions 43117-43837 via svnmerge from 
https://svn.boost.org/svn/boost/branches/unordered/trunk


[SVN r43838]
2008-03-24 17:03:15 +00:00

31 lines
677 B
C++

// Copyright 2006-2008 Daniel James.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//[intro_example1_1
#include <boost/unordered_map.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <iostream>
//]
int main() {
//[intro_example1_2
typedef boost::unordered_map<std::string, int> map;
map x;
x["one"] = 1;
x["two"] = 2;
x["three"] = 3;
assert(x.at("one") == 1);
assert(x.find("missing") == x.end());
//]
//[intro_example1_3
BOOST_FOREACH(map::value_type i, x) {
std::cout<<i.first<<","<<i.second<<"\n";
}
//]
}