default.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Copyright 2012 Eric Niebler
  4. Distributed under the Boost
  5. Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <header name="boost/proto/context/default.hpp">
  9. <namespace name="boost">
  10. <namespace name="proto">
  11. <namespace name="context">
  12. <struct name="default_eval">
  13. <template>
  14. <template-type-parameter name="Expr"/>
  15. <template-type-parameter name="Context"/>
  16. </template>
  17. <purpose>
  18. A BinaryFunction that accepts a Proto expression and a context, evaluates
  19. each child expression with the context, and combines the result using the
  20. standard C++ meaning for the operator represented by the current expression
  21. node.
  22. </purpose>
  23. <description>
  24. <para>
  25. Let <computeroutput><computeroutput>OP</computeroutput></computeroutput> be the C++ operator
  26. corresponding to <computeroutput>Expr::proto_tag</computeroutput>. (For example, if
  27. <computeroutput>Tag</computeroutput> is <computeroutput>
  28. <classname>proto::tag::plus</classname></computeroutput>, let <computeroutput>
  29. <computeroutput>OP</computeroutput></computeroutput> be <computeroutput>+</computeroutput>.)
  30. </para>
  31. <para>
  32. The behavior of this class is specified in terms of the C++0x <computeroutput>decltype</computeroutput>
  33. keyword. In systems where this keyword is not available, Proto uses the Boost.Typeof library to
  34. approximate the behavior.
  35. </para>
  36. </description>
  37. <typedef name="Tag">
  38. <purpose>For exposition only</purpose>
  39. <type>typename Expr::tag_type</type>
  40. </typedef>
  41. <data-member name="s_expr" specifiers="static">
  42. <purpose>For exposition only</purpose>
  43. <type>Expr &amp;</type>
  44. </data-member>
  45. <data-member name="s_context" specifiers="static">
  46. <purpose>For exposition only</purpose>
  47. <type>Context &amp;</type>
  48. </data-member>
  49. <typedef name="result_type">
  50. <type><emphasis>see-below</emphasis></type>
  51. <description>
  52. <itemizedlist>
  53. <listitem>
  54. <para>
  55. If <computeroutput>Tag</computeroutput> corresponds to a unary prefix operator,
  56. then the result type is
  57. <programlisting>decltype(
  58. OP <functionname>proto::eval</functionname>(<functionname>proto::child</functionname>(s_expr), s_context)
  59. )</programlisting>
  60. </para>
  61. </listitem>
  62. <listitem>
  63. <para>
  64. If <computeroutput>Tag</computeroutput> corresponds to a unary postfix operator,
  65. then the result type is
  66. <programlisting>decltype(
  67. <functionname>proto::eval</functionname>(<functionname>proto::child</functionname>(s_expr), s_context) OP
  68. )</programlisting>
  69. </para>
  70. </listitem>
  71. <listitem>
  72. <para>
  73. If <computeroutput>Tag</computeroutput> corresponds to a binary infix operator,
  74. then the result type is
  75. <programlisting>decltype(
  76. <functionname>proto::eval</functionname>(<functionname>proto::left</functionname>(s_expr), s_context) OP
  77. <functionname>proto::eval</functionname>(<functionname>proto::right</functionname>(s_expr), s_context)
  78. )</programlisting>
  79. </para>
  80. </listitem>
  81. <listitem>
  82. <para>
  83. If <computeroutput>Tag</computeroutput> is <computeroutput>
  84. <classname>proto::tag::subscript</classname>
  85. </computeroutput>,
  86. then the result type is
  87. <programlisting>decltype(
  88. <functionname>proto::eval</functionname>(<functionname>proto::left</functionname>(s_expr), s_context) [
  89. <functionname>proto::eval</functionname>(<functionname>proto::right</functionname>(s_expr), s_context) ]
  90. )</programlisting>
  91. </para>
  92. </listitem>
  93. <listitem>
  94. <para>
  95. If <computeroutput>Tag</computeroutput> is <computeroutput>
  96. <classname>proto::tag::if_else_</classname>
  97. </computeroutput>,
  98. then the result type is
  99. <programlisting>decltype(
  100. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;0&gt;(s_expr), s_context) ?
  101. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;1&gt;(s_expr), s_context) :
  102. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;2&gt;(s_expr), s_context)
  103. )</programlisting>
  104. </para>
  105. </listitem>
  106. <listitem>
  107. <para>
  108. If <computeroutput>Tag</computeroutput> is <computeroutput>
  109. <classname>proto::tag::function</classname>
  110. </computeroutput>,
  111. then the result type is
  112. <programlisting>decltype(
  113. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;0&gt;(s_expr), s_context) (
  114. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;1&gt;(s_expr), s_context),
  115. ...
  116. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;N&gt;(s_expr), s_context) )
  117. )</programlisting>
  118. </para>
  119. </listitem>
  120. </itemizedlist>
  121. </description>
  122. </typedef>
  123. <method-group name="public member functions">
  124. <method name="operator()" cv="const">
  125. <type>result_type</type>
  126. <parameter name="expr">
  127. <paramtype>Expr &amp;</paramtype>
  128. <description>
  129. <para>The current expression </para>
  130. </description>
  131. </parameter>
  132. <parameter name="context">
  133. <paramtype>Context &amp;</paramtype>
  134. <description>
  135. <para>The evaluation context </para>
  136. </description>
  137. </parameter>
  138. <description>
  139. <itemizedlist>
  140. <listitem>
  141. <para>
  142. If <computeroutput>Tag</computeroutput> corresponds to a unary prefix operator,
  143. then return
  144. <programlisting>OP <functionname>proto::eval</functionname>(<functionname>proto::child</functionname>(expr), context)</programlisting>
  145. </para>
  146. </listitem>
  147. <listitem>
  148. <para>
  149. If <computeroutput>Tag</computeroutput> corresponds to a unary postfix operator,
  150. then return
  151. <programlisting><functionname>proto::eval</functionname>(<functionname>proto::child</functionname>(expr), context) OP</programlisting>
  152. </para>
  153. </listitem>
  154. <listitem>
  155. <para>
  156. If <computeroutput>Tag</computeroutput> corresponds to a binary infix operator,
  157. then return
  158. <programlisting><functionname>proto::eval</functionname>(<functionname>proto::left</functionname>(expr), context) OP
  159. <functionname>proto::eval</functionname>(<functionname>proto::right</functionname>(expr), context)</programlisting>
  160. </para>
  161. </listitem>
  162. <listitem>
  163. <para>
  164. If <computeroutput>Tag</computeroutput> is <computeroutput>
  165. <classname>proto::tag::subscript</classname>
  166. </computeroutput>,
  167. then return
  168. <programlisting><functionname>proto::eval</functionname>(<functionname>proto::left</functionname>(expr), context) [
  169. <functionname>proto::eval</functionname>(<functionname>proto::right</functionname>(expr), context) ]</programlisting>
  170. </para>
  171. </listitem>
  172. <listitem>
  173. <para>
  174. If <computeroutput>Tag</computeroutput> is <computeroutput>
  175. <classname>proto::tag::if_else_</classname>
  176. </computeroutput>,
  177. then return
  178. <programlisting><functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;0&gt;(expr), context) ?
  179. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;1&gt;(expr), context) :
  180. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;2&gt;(expr), context)</programlisting>
  181. </para>
  182. </listitem>
  183. <listitem>
  184. <para>
  185. If <computeroutput>Tag</computeroutput> is <computeroutput>
  186. <classname>proto::tag::function</classname>
  187. </computeroutput>,
  188. then return
  189. <programlisting><functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;0&gt;(expr), context) (
  190. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;1&gt;(expr), context),
  191. ...
  192. <functionname>proto::eval</functionname>(<functionname>proto::child_c</functionname>&lt;N&gt;(expr), context) )</programlisting>
  193. </para>
  194. </listitem>
  195. </itemizedlist>
  196. </description>
  197. </method>
  198. </method-group>
  199. </struct>
  200. <struct name="default_context">
  201. <purpose>An evaluation context that gives the operators their normal C++ semantics.</purpose>
  202. <description>
  203. <para>An evaluation context that gives the operators their normal C++ semantics.</para>
  204. </description>
  205. <struct name="eval">
  206. <template>
  207. <template-type-parameter name="Expr"/>
  208. <template-type-parameter name="ThisContext">
  209. <default>default_context const</default>
  210. </template-type-parameter>
  211. </template>
  212. <inherit><classname>proto::context::default_eval</classname>&lt; Expr, ThisContext &gt;</inherit>
  213. </struct>
  214. </struct>
  215. </namespace>
  216. </namespace>
  217. </namespace>
  218. </header>