]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <HTML> |
2 | <!-- | |
3 | Copyright (c) Jeremy Siek 2000 | |
4 | ||
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) | |
8 | --> | |
9 | <Head> | |
10 | <Title>LvaluePropertyMap</Title> | |
11 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" | |
12 | ALINK="#ff0000"> | |
13 | <IMG SRC="../../../boost.png" | |
14 | ALT="C++ Boost" width="277" height="86"> | |
15 | ||
16 | <BR Clear> | |
17 | ||
18 | <H2><A NAME="concept:LvaluePropertyMap"></A> | |
19 | LvaluePropertyMap | |
20 | </H2> | |
21 | ||
22 | The LvaluePropertyMap provides <code>operator[]</code> and function <code>get()</code> for accessing a | |
23 | reference to a value object. The return type refines that of function <code>get()</code>in <a | |
24 | href="./ReadablePropertyMap.html">ReadablePropertyMap</a>; it can only be a reference (for a <I>mutable</I> LvaluePropertyMap) or a const reference (for a <I>non-mutable</I> LvaluePropertyMap). | |
25 | ||
26 | <H3>Refinement of</H3> | |
27 | ||
28 | <a href="./ReadablePropertyMap.html">ReadablePropertyMap</a> | |
29 | for non-mutable or <a href="./ReadWritePropertyMap.html">ReadWritePropertyMap</a> for mutable property map. | |
30 | ||
31 | <h3>Notation</h3> | |
32 | ||
33 | <Table> | |
34 | <TR> | |
35 | <TD><tt>PMap</tt></TD> | |
36 | <TD>A type that is a model of LvaluePropertyMap.</TD> | |
37 | </TR> | |
38 | <TR> | |
39 | <TD><tt>pmap</tt></TD> | |
40 | <TD>An object of type <tt>PMap</tt>.</td> | |
41 | </TR> | |
42 | <TR> | |
43 | <TD><tt>key</tt></TD> | |
44 | <TD>An object of type <tt>boost::property_traits<PMap>::key_type</tt>.</td> | |
45 | </TR> | |
46 | ||
47 | </table> | |
48 | ||
49 | ||
50 | <h3>Associated Types</h3> | |
51 | ||
52 | <table border> | |
53 | ||
54 | <tr> | |
55 | <td>Reference Type</td> | |
56 | <td><TT>boost::property_traits<PMap>::reference</TT></td> | |
57 | <td> | |
58 | The reference type, which must be a reference or const reference to | |
59 | the value type of the property map. | |
60 | </td> | |
61 | </tr> | |
62 | ||
63 | <tr> | |
64 | <td>Property Map Category | |
65 | <td><TT>boost::property_traits<PMap>::category</TT></td> | |
66 | <td> | |
67 | The category of the property: a type convertible to | |
68 | <TT>boost::lvalue_property_map_tag</TT>. | |
69 | </td> | |
70 | </tr> | |
71 | ||
72 | </table> | |
73 | ||
74 | <h3>Valid Expressions</h3> | |
75 | ||
76 | <table border> | |
77 | <tr> | |
78 | <th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th> | |
79 | </tr> | |
80 | ||
81 | ||
82 | <tr> | |
83 | <td>Access Property Value </td> | |
84 | <TD><TT>pmap[key]</TT></TD> | |
85 | <TD> | |
86 | <TT>value_type&</TT> for mutable, <TT>const value_type&</TT> | |
87 | otherwise. | |
88 | </TD> | |
89 | <TD>Obtain a reference to the value associated with <TT>key</TT>.</TD> | |
90 | </TR> | |
91 | </TABLE> | |
92 | ||
93 | <h3>Concept Checking Class</h3> | |
94 | ||
95 | <pre> template <class PMap, class Key> | |
96 | struct LvaluePropertyMapConcept | |
97 | { | |
98 | typedef typename property_traits<PMap>::category Category; | |
99 | typedef boost::lvalue_property_map_tag LvalueTag; | |
100 | typedef const typename property_traits<PMap>::value_type& const_reference; | |
101 | void constraints() { | |
102 | function_requires< ReadWritePropertyMapConcept<PMap, Key> >(); | |
103 | function_requires< ConvertibleConcept<Category, LvalueTag> >(); | |
104 | ||
105 | const_reference ref = pmap[k]; | |
106 | } | |
107 | PMap pmap; | |
108 | Key k; | |
109 | }; | |
110 | ||
111 | template <class PMap, class Key> | |
112 | struct Mutable_LvaluePropertyMapConcept | |
113 | { | |
114 | typedef typename property_traits<PMap>::category Category; | |
115 | typedef boost::lvalue_property_map_tag LvalueTag; | |
116 | typedef typename property_traits<PMap>::value_type& reference; | |
117 | void constraints() { | |
118 | function_requires< ReadWritePropertyMapConcept<PMap, Key> >(); | |
119 | function_requires<ConvertibleConcept<Category, LvalueTag> >(); | |
120 | ||
121 | reference ref = pmap[k]; | |
122 | } | |
123 | PMap pmap; | |
124 | Key k; | |
125 | };</pre> | |
126 | ||
127 | <h3>See Also</h3> | |
128 | ||
129 | <a href="./property_map.html">Property map concepts</a> | |
130 | ||
131 | ||
132 | <br> | |
133 | <HR> | |
134 | <TABLE> | |
135 | <TR valign=top> | |
136 | <TD nowrap>Copyright © 2000</TD><TD> | |
137 | <a HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>) | |
138 | </TD></TR></TABLE> | |
139 | ||
140 | </BODY> | |
141 | </HTML> |