| 1 | #include <iostream> | 
|---|
| 2 | #include <boost/foreach.hpp> | 
|---|
| 3 | #include <boost/unordered_map.hpp> | 
|---|
| 4 |  | 
|---|
| 5 | typedef boost::unordered_map<std::string, std::string> map_type; | 
|---|
| 6 |  | 
|---|
| 7 | std::ostream& | 
|---|
| 8 | operator<<(std::ostream& o, const map_type& m) | 
|---|
| 9 | { | 
|---|
| 10 | o << "size: " << m.size(); | 
|---|
| 11 | BOOST_FOREACH (const map_type::value_type& p, m) | 
|---|
| 12 | o << ", " << p.first << " => " << p.second; | 
|---|
| 13 | return o; | 
|---|
| 14 | } | 
|---|
| 15 |  | 
|---|
| 16 | map_type | 
|---|
| 17 | make_map() | 
|---|
| 18 | { | 
|---|
| 19 | map_type res; | 
|---|
| 20 | res["foo"] = "FOO"; | 
|---|
| 21 | res["bar"] = "BAR"; | 
|---|
| 22 | std::cerr << "make_map:   " << res << std::endl; | 
|---|
| 23 | return res; | 
|---|
| 24 | } | 
|---|
| 25 |  | 
|---|
| 26 | map_type | 
|---|
| 27 | return_map() | 
|---|
| 28 | { | 
|---|
| 29 | const map_type& res = make_map(); | 
|---|
| 30 | std::cerr << "return_map: " << res << std::endl; | 
|---|
| 31 | return res; | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | int | 
|---|
| 35 | main() | 
|---|
| 36 | { | 
|---|
| 37 | map_type map = return_map(); | 
|---|
| 38 | std::cerr << "main:       " << map << std::endl; | 
|---|
| 39 | } | 
|---|