Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/property_map/example2.cpp @ 14

Last change on this file since 14 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.4 KB
Line 
1//  (C) Copyright Ronald Garcia, Jeremy Siek 2002.
2//  Permission to copy, use, modify,
3//  sell and distribute this software is granted provided this
4//  copyright notice appears in all copies. This software is provided
5//  "as is" without express or implied warranty, and with no claim as
6//  to its suitability for any purpose.
7
8#include <iostream>
9#include <map>
10#include <string>
11#include <boost/property_map.hpp>
12
13
14template <typename ConstAddressMap>
15void display(ConstAddressMap address)
16{
17  typedef typename boost::property_traits<ConstAddressMap>::value_type
18    value_type;
19  typedef typename boost::property_traits<ConstAddressMap>::key_type key_type;
20
21  key_type fred = "Fred";
22  key_type joe = "Joe";
23
24  value_type freds_address = get(address, fred);
25  value_type joes_address = get(address, joe);
26 
27  std::cout << fred << ": " << freds_address << "\n"
28            << joe  << ": " << joes_address  << "\n";
29}
30
31int
32main()
33{
34  std::map<std::string, std::string> name2address;
35  boost::const_associative_property_map< std::map<std::string, std::string> >
36    address_map(name2address);
37
38  name2address.insert(make_pair(std::string("Fred"), 
39                                std::string("710 West 13th Street")));
40  name2address.insert(make_pair(std::string("Joe"), 
41                                std::string("710 West 13th Street")));
42
43  display(address_map);
44 
45  return EXIT_SUCCESS;
46}
47
48
Note: See TracBrowser for help on using the repository browser.