• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  (C) Copyright Ronald Garcia, Jeremy Siek 2002.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 #include <iostream>
7 #include <map>
8 #include <string>
9 #include <boost/property_map/property_map.hpp>
10 
11 
12 template <typename ConstAddressMap>
display(ConstAddressMap address)13 void display(ConstAddressMap address)
14 {
15   typedef typename boost::property_traits<ConstAddressMap>::value_type
16     value_type;
17   typedef typename boost::property_traits<ConstAddressMap>::key_type key_type;
18 
19   key_type fred = "Fred";
20   key_type joe = "Joe";
21 
22   value_type freds_address = get(address, fred);
23   value_type joes_address = get(address, joe);
24 
25   std::cout << fred << ": " << freds_address << "\n"
26             << joe  << ": " << joes_address  << "\n";
27 }
28 
29 int
main()30 main()
31 {
32   std::map<std::string, std::string> name2address;
33   boost::const_associative_property_map< std::map<std::string, std::string> >
34     address_map(name2address);
35 
36   name2address.insert(make_pair(std::string("Fred"),
37                                 std::string("710 West 13th Street")));
38   name2address.insert(make_pair(std::string("Joe"),
39                                 std::string("710 West 13th Street")));
40 
41   display(address_map);
42 
43   return EXIT_SUCCESS;
44 }
45 
46 
47