call.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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/transform/call.hpp">
  9. <para>Contains definition of the call&lt;&gt; transform. </para>
  10. <namespace name="boost">
  11. <namespace name="proto">
  12. <struct name="call">
  13. <template>
  14. <template-type-parameter name="T"/>
  15. </template>
  16. <purpose>Make the given <conceptname>CallableTransform</conceptname> into a <conceptname>PrimitiveTransform</conceptname>.</purpose>
  17. <description>
  18. <para>
  19. The purpose of <computeroutput>proto::call&lt;&gt;</computeroutput> is to annotate a transform as callable
  20. so that <computeroutput><classname alt="proto::when">proto::when&lt;&gt;</classname></computeroutput> knows
  21. how to apply it. The template parameter must be either a <conceptname>PrimitiveTransform</conceptname> or a
  22. <conceptname>CallableTransform</conceptname>; that is, a function type for which the return type is a callable
  23. <conceptname>PolymorphicFunctionObject</conceptname>.
  24. </para>
  25. <para>
  26. For the complete description of the behavior of the <computeroutput>proto::call&lt;&gt;</computeroutput>
  27. transform, see the documentation for the nested
  28. <computeroutput>
  29. <classname alt="proto::call::impl">proto::call::impl&lt;&gt;</classname>
  30. </computeroutput>
  31. class template.
  32. </para>
  33. </description>
  34. <inherit><type><classname>proto::transform</classname>&lt; call&lt;T&gt; &gt;</type></inherit>
  35. <struct name="impl">
  36. <template>
  37. <template-type-parameter name="Expr"/>
  38. <template-type-parameter name="State"/>
  39. <template-type-parameter name="Data"/>
  40. </template>
  41. <inherit><type><classname>proto::transform_impl</classname>&lt;Expr, State, Data&gt;</type></inherit>
  42. <typedef name="result_type">
  43. <type><replaceable>see-below</replaceable></type>
  44. <description>
  45. <para>
  46. In the description that follows, a type <computeroutput>T</computeroutput> is determined to model the
  47. <conceptname>PrimitiveTransform</conceptname> concept if
  48. <computeroutput><classname>proto::is_transform</classname>&lt;T&gt;::value</computeroutput> is
  49. <computeroutput>true</computeroutput>.
  50. </para>
  51. <para>
  52. <computeroutput><classname>proto::call</classname>&lt;T&gt;::impl&lt;Expr,State,Data&gt;::result_type</computeroutput>
  53. is computed as follows:
  54. <itemizedlist>
  55. <listitem>
  56. <para>
  57. If <computeroutput>T</computeroutput> if of the form
  58. <computeroutput><conceptname>PrimitiveTransform</conceptname></computeroutput> or
  59. <computeroutput><conceptname>PrimitiveTransform</conceptname>()</computeroutput>, then
  60. <computeroutput>result_type</computeroutput> is:
  61. <programlisting>typename boost::result_of&lt;PrimitiveTransform(Expr, State, Data)&gt;::type</programlisting>
  62. </para>
  63. </listitem>
  64. <listitem>
  65. <para>
  66. If <computeroutput>T</computeroutput> is of the form
  67. <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>)</computeroutput>, then
  68. <computeroutput>result_type</computeroutput> is:
  69. <programlisting>typename boost::result_of&lt;PrimitiveTransform(
  70. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
  71. State,
  72. Data
  73. )&gt;::type</programlisting>
  74. </para>
  75. </listitem>
  76. <listitem>
  77. <para>
  78. If <computeroutput>T</computeroutput> is of the form
  79. <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>)</computeroutput>, then
  80. <computeroutput>result_type</computeroutput> is:
  81. <programlisting>typename boost::result_of&lt;PrimitiveTransform(
  82. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
  83. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;(Expr, State, Data)&gt;::type,
  84. Data
  85. )&gt;::type</programlisting>
  86. </para>
  87. </listitem>
  88. <listitem>
  89. <para>
  90. If <computeroutput>T</computeroutput> is of the form
  91. <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>, A<subscript>2</subscript>)</computeroutput>, then
  92. <computeroutput>result_type</computeroutput> is:
  93. <programlisting>typename boost::result_of&lt;PrimitiveTransform(
  94. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
  95. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;(Expr, State, Data)&gt;::type,
  96. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>2</subscript>&gt;(Expr, State, Data)&gt;::type
  97. )&gt;::type</programlisting>
  98. </para>
  99. </listitem>
  100. <listitem>
  101. <para>
  102. If <computeroutput>T</computeroutput> is of the form
  103. <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript>)</computeroutput>, then
  104. <computeroutput>result_type</computeroutput> is:
  105. <programlisting>typename boost::result_of&lt;PolymorphicFunctionObject(
  106. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
  107. typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>n</subscript>&gt;(Expr, State, Data)&gt;::type
  108. &gt;::type</programlisting>
  109. </para>
  110. </listitem>
  111. <listitem>
  112. <para>
  113. If <computeroutput>T</computeroutput> is of the form
  114. <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript> ...)</computeroutput>, then
  115. let <computeroutput>T&apos;</computeroutput> be <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n-1</subscript>, <replaceable>S</replaceable>)</computeroutput>,
  116. where <replaceable>S</replaceable> is a type sequence computed from the unpacking expression <computeroutput>A<subscript>n</subscript></computeroutput>
  117. as described in the reference for <computeroutput><classname>proto::pack</classname></computeroutput>.
  118. Then, <computeroutput>result_type</computeroutput> is:
  119. <programlisting><computeroutput>typename <classname>proto::call</classname>&lt;T&apos;&gt;::impl&lt;Expr,State,Data&gt;::result_type</computeroutput></programlisting>
  120. </para>
  121. </listitem>
  122. </itemizedlist>
  123. </para>
  124. </description>
  125. </typedef>
  126. <method-group name="public member functions">
  127. <method name="operator()" cv="const">
  128. <type>result_type</type>
  129. <parameter name="expr">
  130. <paramtype>typename impl::expr_param</paramtype>
  131. </parameter>
  132. <parameter name="state">
  133. <paramtype>typename impl::state_param</paramtype>
  134. </parameter>
  135. <parameter name="data">
  136. <paramtype>typename impl::data_param</paramtype>
  137. </parameter>
  138. <description>
  139. <para>
  140. In the description that follows, a type <computeroutput>T</computeroutput> is determined to model the
  141. <conceptname>PrimitiveTransform</conceptname> concept if
  142. <computeroutput><classname>proto::is_transform</classname>&lt;T&gt;::value</computeroutput> is
  143. <computeroutput>true</computeroutput>.
  144. </para>
  145. <para>
  146. <computeroutput><classname>proto::call</classname>&lt;T&gt;::impl&lt;Expr,State,Data&gt;::operator()</computeroutput> behaves as follows:
  147. <itemizedlist>
  148. <listitem>
  149. <para>
  150. If <computeroutput>T</computeroutput> if of the form
  151. <computeroutput><conceptname>PrimitiveTransform</conceptname></computeroutput> or
  152. <computeroutput><conceptname>PrimitiveTransform</conceptname>()</computeroutput>, then
  153. return
  154. <programlisting>PrimitiveTransform()(expr, state, data)</programlisting>
  155. </para>
  156. </listitem>
  157. <listitem>
  158. <para>
  159. If <computeroutput>T</computeroutput> is of the form
  160. <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>)</computeroutput>, then
  161. return
  162. <programlisting>PrimitiveTransform()(
  163. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
  164. state,
  165. sata
  166. )</programlisting>
  167. </para>
  168. </listitem>
  169. <listitem>
  170. <para>
  171. If <computeroutput>T</computeroutput> is of the form
  172. <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>)</computeroutput>, then
  173. return:
  174. <programlisting>PrimitiveTransform()(
  175. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
  176. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;()(expr, state, data),
  177. Data
  178. )</programlisting>
  179. </para>
  180. </listitem>
  181. <listitem>
  182. <para>
  183. If <computeroutput>T</computeroutput> is of the form
  184. <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>, A<subscript>2</subscript>)</computeroutput>, then
  185. return
  186. <programlisting>PrimitiveTransform()(
  187. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
  188. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;()(expr, state, data),
  189. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>2</subscript>&gt;()(expr, state, data)
  190. )</programlisting>
  191. </para>
  192. </listitem>
  193. <listitem>
  194. <para>
  195. If <computeroutput>T</computeroutput> is of the form
  196. <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript>)</computeroutput>, then
  197. return:
  198. <programlisting>PolymorphicFunctionObject()(
  199. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
  200. ...
  201. <classname>when</classname>&lt;<classname>_</classname>,A<subscript>n</subscript>&gt;()(expr, state, data)
  202. )</programlisting>
  203. </para>
  204. </listitem>
  205. <listitem>
  206. <para>
  207. If <computeroutput>T</computeroutput> is of the form
  208. <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript> ...)</computeroutput>, then
  209. let <computeroutput>T&apos;</computeroutput> be <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n-1</subscript>, <replaceable>S</replaceable>)</computeroutput>,
  210. where <replaceable>S</replaceable> is a type sequence computed from the unpacking expression <computeroutput>A<subscript>n</subscript></computeroutput>
  211. as described in the reference for <computeroutput><classname>proto::pack</classname></computeroutput>.
  212. Then, return:
  213. <programlisting><computeroutput><classname>proto::call</classname>&lt;T&apos;&gt;()(expr, state, data)</computeroutput></programlisting>
  214. </para>
  215. </listitem>
  216. </itemizedlist>
  217. </para>
  218. </description>
  219. </method>
  220. </method-group>
  221. </struct>
  222. </struct>
  223. </namespace>
  224. </namespace>
  225. </header>