LvaluePropertyMap.html 3.7 KB

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