Ticket #6311: foo.cc

File foo.cc, 732 bytes (added by Akim Demaille <akim.demaille@…>, 11 years ago)

Demonstrate the bug

Line 
1#include <iostream>
2#include <boost/foreach.hpp>
3#include <boost/unordered_map.hpp>
4
5typedef boost::unordered_map<std::string, std::string> map_type;
6
7std::ostream&
8operator<<(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
16map_type
17make_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
26map_type
27return_map()
28{
29 const map_type& res = make_map();
30 std::cerr << "return_map: " << res << std::endl;
31 return res;
32}
33
34int
35main()
36{
37 map_type map = return_map();
38 std::cerr << "main: " << map << std::endl;
39}