3 Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
10 <Title>Constant Associative Property Map Adaptor
</Title>
11 <BODY BGCOLOR=
"#ffffff" LINK=
"#0000ee" TEXT=
"#000000" VLINK=
"#551a8b"
13 <IMG SRC=
"../../../boost.png"
14 ALT=
"C++ Boost" width=
"277" height=
"86">
19 <H2><A NAME=
"sec:const-associative-property-map"></A>
22 const_associative_property_map
<UniquePairAssociativeContainer
>
26 This property map is an adaptor that converts any type that is a model
28 href=
"http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
29 Associative Container
</a> and
<a
30 href=
"http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
31 Associative Container
</a> such as
<a
32 href=
"http://www.sgi.com/tech/stl/Map.html"><tt>std::map
</tt></a> into
33 a constant
<a href=
"./LvaluePropertyMap.html">Lvalue Property Map
</a>.
34 Note that the adaptor only retains a reference to the container, so
35 the lifetime of the container must encompass the use of the adaptor.
40 <a href=
"../example/example1.cpp">example1.cpp
</a>:
42 <font color=
"#008040">#include
<iostream
></font>
43 <font color=
"#008040">#include
<map
></font>
44 <font color=
"#008040">#include
<string
></font>
45 <font color=
"#008040">#include
<boost/property_map/property_map.hpp
></font>
48 <B>template
</B> <<B>typename
</B> ConstAddressMap
>
49 <B>void
</B> display(ConstAddressMap address)
51 <B>typedef
</B> <B>typename
</B> boost::property_traits
<ConstAddressMap
>::value_type
53 <B>typedef
</B> <B>typename
</B> boost::property_traits
<ConstAddressMap
>::key_type key_type;
55 key_type fred =
<font color=
"#0000FF">"Fred"</font>;
56 key_type joe =
<font color=
"#0000FF">"Joe"</font>;
58 value_type freds_address = get(address, fred);
59 value_type joes_address = get(address, joe);
61 std::cout
<< fred
<< <font color=
"#0000FF">": "</font> << freds_address
<< <font color=
"#0000FF">"\n"</font>
62 << joe
<< <font color=
"#0000FF">": "</font> << joes_address
<< <font color=
"#0000FF">"\n"</font>;
68 std::map
<std::string, std::string
> name2address;
69 boost::const_associative_property_map
< std::map
<std::string, std::string
> >
70 address_map(name2address);
72 name2address.insert(make_pair(std::string(
<font color=
"#0000FF">"Fred"</font>),
73 std::string(
<font color=
"#0000FF">"710 West 13th Street"</font>)));
74 name2address.insert(make_pair(std::string(
<font color=
"#0000FF">"Joe"</font>),
75 std::string(
<font color=
"#0000FF">"710 West 13th Street"</font>)));
79 <B>return
</B> EXIT_SUCCESS;
85 <H3>Where Defined
</H3>
88 <a href=
"../../../boost/property_map/property_map.hpp"><TT>boost/property_map/property_map.hpp
</TT></a>
93 <a href=
"./LvaluePropertyMap.html">Lvalue Property Map
</a>
97 <H3>Template Parameters
</H3>
103 <th>Parameter
</th><th>Description
</th><th>Default
</th>
108 <TD><TT>UniquePairAssociativeContainer
</TT></TD>
109 <TD>Must be a model of both
<a
110 href=
"http://www.sgi.com/tech/stl/PairAssociativeContainer.html">Pair
111 Associative Container
</a> and
<a
112 href=
"http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html">Unique
113 Associative Container
</a> .
</TD>
123 In addition to the methods and functions required by
<a
124 href=
"./LvaluePropertyMap.html">Lvalue Property Map
</a>, this
125 class has the following members.
130 property_traits
<const_associative_property_map
>::value_type
132 This is the same type as
133 <TT>UniquePairAssociativeContainer::data_type
</TT>.
138 const_associative_property_map()
143 const_associative_property_map(const UniquePairAssociativeContainer
& c)
150 const data_type
& operator[](const key_type
& k) const
152 The operator bracket for property access.
153 The
<TT>key_type
</TT> and
154 <TT>data_type
</TT> types are from the typedefs inside of
155 <TT>UniquePairAssociativeContainer
</TT>.
159 <h3>Non-Member functions
</h3>
164 template
<typename UniquePairAssociativeContainer
>
165 const_associative_property_map
<UniquePairAssociativeContainer
>
166 make_assoc_property_map(const UniquePairAssociativeContainer
& c);
168 A function for conveniently creating an associative property map.
179 <TD nowrap
>Copyright ©
2002</TD><TD>
180 <a HREF=
"http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek
</a>,
181 Indiana University (
<A
182 HREF=
"mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu
</A>)
<br>
183 <A HREF=
"http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee
</A>, Indiana University (
<A HREF=
"mailto:llee1@osl.iu.edu">llee1@osl.iu.edu
</A>)
<br>
184 <A HREF=
"http://www.osl.iu.edu/~lums">Andrew Lumsdaine
</A>,
185 Indiana University (
<A
186 HREF=
"mailto:lums@osl.iu.edu">lums@osl.iu.edu
</A>)