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
12template <typename ConstAddressMap>
13void 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
29int
30main()
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(x: make_pair(x: std::string("Fred"),
37 y: std::string("710 West 13th Street")));
38 name2address.insert(x: make_pair(x: std::string("Joe"),
39 y: std::string("710 West 13th Street")));
40
41 display(address: address_map);
42
43 return EXIT_SUCCESS;
44}
45
46
47

source code of boost/libs/property_map/example/example2.cpp