make_expr.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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/make_expr.hpp">
  9. <para>
  10. Definition of the <computeroutput><functionname alt="boost::proto::make_expr">proto::make_expr()</functionname>
  11. </computeroutput> and <computeroutput><functionname alt="boost::proto::unpack_expr">proto::unpack_expr()</functionname>
  12. </computeroutput> utilities for building Proto expression nodes from child nodes or from a Fusion sequence of child
  13. nodes, respectively.
  14. </para>
  15. <namespace name="boost">
  16. <namespace name="proto">
  17. <namespace name="functional">
  18. <!-- proto::functional::make_expr -->
  19. <struct name="make_expr">
  20. <template>
  21. <template-type-parameter name="Tag"/>
  22. <template-type-parameter name="Domain">
  23. <default><classname>proto::deduce_domain</classname></default>
  24. </template-type-parameter>
  25. </template>
  26. <purpose>A <conceptname>PolymorphicFunctionObject</conceptname> equivalent to the <computeroutput>
  27. <functionname alt="proto::make_expr">proto::make_expr()</functionname></computeroutput> function.</purpose>
  28. <description>
  29. <para>
  30. In all cases, <computeroutput>proto::functional::make_expr&lt;Tag, Domain&gt;()(a...)</computeroutput>
  31. is equivalent to <computeroutput><functionname>proto::make_expr</functionname>&lt;Tag, Domain&gt;(a...)</computeroutput>.
  32. </para>
  33. <para>
  34. <computeroutput>proto::functional::make_expr&lt;Tag&gt;()(a...)</computeroutput> is equivalent to
  35. <computeroutput><functionname>proto::make_expr</functionname>&lt;Tag&gt;(a...)</computeroutput>.
  36. </para>
  37. </description>
  38. <inherit>
  39. <type><classname>proto::callable</classname></type>
  40. </inherit>
  41. <struct-specialization name="result">
  42. <template>
  43. <template-type-parameter name="This"/>
  44. <template-type-parameter name="A" pack="1"/>
  45. </template>
  46. <specialization>
  47. <template-arg>This(A...)</template-arg>
  48. </specialization>
  49. <inherit>
  50. <type>
  51. <classname>proto::result_of::make_expr</classname>&lt; Tag, Domain, A... &gt;</type>
  52. </inherit>
  53. </struct-specialization>
  54. <method-group name="public member functions">
  55. <method name="operator()" cv="const">
  56. <type>typename <classname>proto::result_of::make_expr</classname>&lt; Tag, Domain, A const... &gt;::type const</type>
  57. <template>
  58. <template-type-parameter name="A" pack="1"/>
  59. </template>
  60. <parameter name="a" pack="1">
  61. <paramtype>A const &amp;</paramtype>
  62. </parameter>
  63. <description>
  64. <para>
  65. Construct an expression node with tag type <computeroutput>Tag</computeroutput> and in the
  66. domain <computeroutput>Domain</computeroutput>.
  67. </para>
  68. <para>
  69. </para>
  70. </description>
  71. <returns>
  72. <para>
  73. <computeroutput><functionname>proto::make_expr</functionname>&lt;Tag, Domain&gt;(a...)</computeroutput>
  74. </para>
  75. </returns>
  76. </method>
  77. </method-group>
  78. </struct>
  79. <!-- proto::functional::unpack_expr -->
  80. <struct name="unpack_expr">
  81. <template>
  82. <template-type-parameter name="Tag"/>
  83. <template-type-parameter name="Domain">
  84. <default><classname>proto::deduce_domain</classname></default>
  85. </template-type-parameter>
  86. </template>
  87. <purpose>A <conceptname>PolymorphicFunctionObject</conceptname> equivalent to the
  88. <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname></computeroutput> function.
  89. </purpose>
  90. <description>
  91. <para>
  92. In all cases, <computeroutput>proto::functional::unpack_expr&lt;Tag, Domain&gt;()(seq)</computeroutput> is
  93. equivalent to <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname>&lt;Tag,
  94. Domain&gt;(seq)</computeroutput>.
  95. </para>
  96. <para>
  97. <computeroutput>proto::functional::unpack_expr&lt;Tag&gt;()(seq)</computeroutput> is equivalent to
  98. <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname>&lt;Tag&gt;(seq)</computeroutput>.
  99. </para>
  100. </description>
  101. <inherit>
  102. <type><classname>proto::callable</classname></type>
  103. </inherit>
  104. <struct-specialization name="result">
  105. <template>
  106. <template-type-parameter name="This"/>
  107. <template-type-parameter name="Sequence"/>
  108. </template>
  109. <specialization>
  110. <template-arg>This(Sequence)</template-arg>
  111. </specialization>
  112. <inherit>
  113. <type>
  114. <classname>proto::result_of::unpack_expr</classname>&lt;
  115. Tag,
  116. Domain,
  117. typename boost::remove_reference&lt; Sequence &gt;::type
  118. &gt;</type>
  119. </inherit>
  120. </struct-specialization>
  121. <method-group name="public member functions">
  122. <method name="operator()" cv="const">
  123. <type>typename <classname>proto::result_of::unpack_expr</classname>&lt; Tag, Domain, Sequence const &gt;::type const</type>
  124. <template>
  125. <template-type-parameter name="Sequence"/>
  126. </template>
  127. <parameter name="sequence">
  128. <paramtype>Sequence const &amp;</paramtype>
  129. <description>
  130. <para>A Fusion Forward Sequence </para>
  131. </description>
  132. </parameter>
  133. <description>
  134. <para>
  135. Construct an expression node with tag type <computeroutput>Tag</computeroutput> and in the
  136. domain <computeroutput>Domain</computeroutput>.
  137. </para>
  138. </description>
  139. <returns>
  140. <para>
  141. <computeroutput><functionname>proto::unpack_expr</functionname>&lt;Tag, Domain&gt;(sequence)</computeroutput>
  142. </para>
  143. </returns>
  144. </method>
  145. </method-group>
  146. </struct>
  147. </namespace>
  148. <namespace name="result_of">
  149. <!-- proto::result_of::make_expr -->
  150. <struct name="make_expr">
  151. <template>
  152. <template-type-parameter name="Tag"/>
  153. <template-type-parameter name="A" pack="1"/>
  154. </template>
  155. <purpose>Metafunction that computes the return type of the
  156. <computeroutput><functionname alt="proto::make_expr">proto::make_expr()</functionname></computeroutput>
  157. function, with a domain deduced from the domains of the children.</purpose>
  158. <description>
  159. <para>
  160. Computes the return type of the
  161. <computeroutput><functionname alt="proto::make_expr">proto::make_expr()</functionname></computeroutput> function.
  162. </para>
  163. <para>
  164. In this specialization, the domain is deduced from the domains of the child types.
  165. If <computeroutput><classname>proto::is_domain</classname>&lt;A<subscript>0</subscript>&gt;::value</computeroutput>
  166. is <computeroutput>true</computeroutput>, then another specialization is selected.
  167. </para>
  168. </description>
  169. <typedef name="D">
  170. <purpose>For exposition only</purpose>
  171. <type><replaceable>domain-deduced-from-child-types</replaceable></type>
  172. <description>
  173. <para>
  174. In this specialization, Proto uses the domains of the child expressions to compute the
  175. domain of the parent. See
  176. <computeroutput><classname>proto::deduce_domain</classname></computeroutput> for a full
  177. description of the procedure used.
  178. </para>
  179. </description>
  180. </typedef>
  181. <typedef name="type">
  182. <type>typename <classname>proto::result_of::make_expr</classname>&lt;Tag, D, A...&gt;::type</type>
  183. </typedef>
  184. </struct>
  185. <struct-specialization name="make_expr">
  186. <template>
  187. <template-type-parameter name="Tag"/>
  188. <template-type-parameter name="Domain"/>
  189. <template-type-parameter name="A" pack="1"/>
  190. </template>
  191. <specialization>
  192. <template-arg>Tag</template-arg>
  193. <template-arg>Domain</template-arg>
  194. <template-arg pack="1">A</template-arg>
  195. </specialization>
  196. <purpose>Metafunction that computes the return type of the
  197. <computeroutput><functionname alt="proto::make_expr">proto::make_expr()</functionname></computeroutput>
  198. function, within the specified domain.</purpose>
  199. <description>
  200. <para>
  201. Computes the return type of the
  202. <computeroutput><functionname alt="proto::make_expr">proto::make_expr()</functionname></computeroutput>
  203. function.
  204. </para>
  205. </description>
  206. <typedef name="type">
  207. <description>
  208. <para>
  209. Let <computeroutput><replaceable>WRAP&lt;X&gt;</replaceable></computeroutput> be defined such that:
  210. <itemizedlist>
  211. <listitem>
  212. <para>
  213. If <computeroutput>X</computeroutput> is <computeroutput>Y &amp;</computeroutput>
  214. or (possibly cv-qualified) <computeroutput>boost::reference_wrapper&lt;Y&gt;</computeroutput>,
  215. then <computeroutput><replaceable>WRAP&lt;X&gt;</replaceable></computeroutput> is equivalent to
  216. <computeroutput><classname>proto::result_of::as_child</classname>&lt;Y, Domain&gt;</computeroutput>.
  217. </para>
  218. </listitem>
  219. <listitem>
  220. <para>
  221. Otherwise, <computeroutput><replaceable>WRAP&lt;X&gt;</replaceable></computeroutput> is equivalent to
  222. <computeroutput><classname>proto::result_of::as_expr</classname>&lt;X, Domain&gt;</computeroutput>.
  223. </para>
  224. </listitem>
  225. </itemizedlist>
  226. </para>
  227. <para>
  228. If <computeroutput><classname>proto::wants_basic_expr</classname>&lt;typename Domain::proto_generator&gt;::value</computeroutput>
  229. is true, then let <computeroutput><replaceable>E</replaceable></computeroutput> be
  230. <computeroutput><classname>proto::basic_expr</classname></computeroutput>; otherwise,
  231. let <computeroutput><replaceable>E</replaceable></computeroutput> be
  232. <computeroutput><classname>proto::expr</classname></computeroutput>.
  233. </para>
  234. <para>
  235. If <computeroutput>Tag</computeroutput> is
  236. <computeroutput><classname>proto::tag::terminal</classname></computeroutput>, then
  237. <computeroutput>type</computeroutput> is a typedef for
  238. <computeroutput>typename <replaceable>WRAP&lt;A<subscript>0</subscript>&gt;</replaceable>::type</computeroutput>.
  239. </para>
  240. <para>
  241. Otherwise, <computeroutput>type</computeroutput> is a typedef for
  242. <computeroutput>boost::result_of&lt;Domain(<replaceable>E</replaceable>&lt;
  243. Tag, <classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname>&lt;
  244. typename <replaceable>WRAP&lt;A&gt;</replaceable>::type...&gt; &gt;)&gt;::type</computeroutput>
  245. </para>
  246. </description>
  247. <type><emphasis>see-below</emphasis></type>
  248. </typedef>
  249. </struct-specialization>
  250. <!-- proto::result_of::unpack_expr -->
  251. <struct name="unpack_expr">
  252. <template>
  253. <template-type-parameter name="Tag"/>
  254. <template-type-parameter name="Sequence"/>
  255. <template-type-parameter name="Void">
  256. <default><type>void</type></default>
  257. </template-type-parameter>
  258. </template>
  259. <purpose>Metafunction that computes the return type of the
  260. <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname></computeroutput>
  261. function, with a domain deduced from the domains of the children.
  262. </purpose>
  263. <description>
  264. <para>
  265. Compute the return type of the
  266. <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname></computeroutput>
  267. function.
  268. </para>
  269. <para>
  270. <computeroutput>Sequence</computeroutput> is a Fusion Forward Sequence.
  271. </para>
  272. <para>
  273. In this specialization, the domain is deduced from the domains of the child types.
  274. If <computeroutput><classname>proto::is_domain</classname>&lt;Sequence&gt;::value</computeroutput>
  275. is <computeroutput>true</computeroutput>, then another specialization is selected.
  276. </para>
  277. </description>
  278. <typedef name="type">
  279. <purpose>Where S is a Fusion RandomAccessSequence equivalent to Sequence, and N is the size of S.</purpose>
  280. <type>
  281. typename <classname>proto::result_of::make_expr</classname>&lt;
  282. Tag,
  283. typename fusion::result_of::value_at_c&lt;<replaceable>S</replaceable>, 0&gt;::type,
  284. ...
  285. typename fusion::result_of::value_at_c&lt;<replaceable>S</replaceable>, <replaceable>N</replaceable>-1&gt;::type
  286. &gt;::type
  287. </type>
  288. </typedef>
  289. </struct>
  290. <struct-specialization name="unpack_expr">
  291. <template>
  292. <template-type-parameter name="Tag"/>
  293. <template-type-parameter name="Domain"/>
  294. <template-type-parameter name="Sequence"/>
  295. </template>
  296. <specialization>
  297. <template-arg>Tag</template-arg>
  298. <template-arg>Domain</template-arg>
  299. <template-arg>Sequence</template-arg>
  300. </specialization>
  301. <purpose>Metafunction that computes the return type of the
  302. <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname></computeroutput>
  303. function, within the specified domain.
  304. </purpose>
  305. <description>
  306. <para>
  307. Computes the return type of the
  308. <computeroutput><functionname alt="proto::unpack_expr">proto::unpack_expr()</functionname></computeroutput>
  309. function.
  310. </para>
  311. </description>
  312. <typedef name="type">
  313. <purpose>Where S is a RandomAccessSequence equivalent to Sequence, and N is the size of S.</purpose>
  314. <type>
  315. typename <classname>proto::result_of::make_expr</classname>&lt;
  316. Tag,
  317. Domain,
  318. typename fusion::result_of::value_at_c&lt;<replaceable>S</replaceable>, 0&gt;::type,
  319. ...
  320. typename fusion::result_of::value_at_c&lt;<replaceable>S</replaceable>, <replaceable>N</replaceable>-1&gt;::type
  321. &gt;::type
  322. </type>
  323. </typedef>
  324. </struct-specialization>
  325. </namespace>
  326. <!-- proto::make_expr() -->
  327. <overloaded-function name="make_expr">
  328. <signature>
  329. <type>typename <classname>proto::result_of::make_expr</classname>&lt;Tag, A const...&gt;::type const</type>
  330. <template>
  331. <template-type-parameter name="Tag"/>
  332. <template-type-parameter name="A" pack="1"/>
  333. </template>
  334. <parameter name="a" pack="1">
  335. <paramtype>A const &amp;</paramtype>
  336. </parameter>
  337. </signature>
  338. <signature>
  339. <type>typename <classname>proto::result_of::make_expr</classname>&lt;Tag, Domain, A const...&gt;::type const</type>
  340. <template>
  341. <template-type-parameter name="Tag"/>
  342. <template-type-parameter name="Domain"/>
  343. <template-type-parameter name="A" pack="1"/>
  344. </template>
  345. <parameter name="a" pack="1">
  346. <paramtype>A const &amp;</paramtype>
  347. </parameter>
  348. </signature>
  349. <purpose>Construct an expression of the requested tag type with a domain and with the specified
  350. arguments as children.</purpose>
  351. <description>
  352. <para>
  353. This function template may be invoked either with or without specifying a
  354. <computeroutput>Domain</computeroutput> template parameter. If no domain is specified, the domain
  355. is deduced by examining domains of the given arguments. See
  356. <computeroutput><classname>proto::deduce_domain</classname></computeroutput> for a full
  357. description of the procedure used.
  358. </para>
  359. <para>
  360. Let <computeroutput><replaceable>WRAP</replaceable>(x)</computeroutput> be defined such that:
  361. <itemizedlist>
  362. <listitem>
  363. <para>
  364. If <computeroutput>x</computeroutput> is a <computeroutput>boost::reference_wrapper&lt;&gt;</computeroutput>,
  365. <computeroutput><replaceable>WRAP</replaceable>(x)</computeroutput> is equivalent to
  366. <computeroutput><functionname>proto::as_child</functionname>&lt;Domain&gt;(x.get())</computeroutput>.
  367. </para>
  368. </listitem>
  369. <listitem>
  370. <para>
  371. Otherwise, <computeroutput><replaceable>WRAP</replaceable>(x)</computeroutput> is equivalent to
  372. <computeroutput><functionname>proto::as_expr</functionname>&lt;Domain&gt;(x)</computeroutput>.
  373. </para>
  374. </listitem>
  375. </itemizedlist>
  376. </para>
  377. <para>
  378. If <computeroutput><classname>proto::wants_basic_expr</classname>&lt;typename Domain::proto_generator&gt;::value</computeroutput>
  379. is true, then let <computeroutput><replaceable>E</replaceable></computeroutput> be
  380. <computeroutput><classname>proto::basic_expr</classname></computeroutput>; otherwise,
  381. let <computeroutput><replaceable>E</replaceable></computeroutput> be
  382. <computeroutput><classname>proto::expr</classname></computeroutput>.
  383. </para>
  384. <para>
  385. Let <computeroutput><replaceable>MAKE</replaceable>(Tag, b...)</computeroutput> be defined as
  386. <computeroutput><replaceable>E</replaceable>&lt;Tag,
  387. <classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname>&lt;decltype(b)...&gt; &gt;::make(b...)</computeroutput>.
  388. </para>
  389. <para>
  390. If <computeroutput>Tag</computeroutput> is
  391. <computeroutput><classname>proto::tag::terminal</classname></computeroutput>, then return
  392. <computeroutput><replaceable>WRAP</replaceable>(a<subscript>0</subscript>)</computeroutput>.
  393. </para>
  394. <para>
  395. Otherwise, return
  396. <computeroutput>Domain()(<replaceable>MAKE</replaceable>(Tag, <replaceable>WRAP</replaceable>(a)...))</computeroutput>.
  397. </para>
  398. </description>
  399. </overloaded-function>
  400. <!-- proto::unpack_expr() -->
  401. <overloaded-function name="unpack_expr">
  402. <signature>
  403. <type>typename <classname>proto::result_of::unpack_expr</classname>&lt;Tag, Sequence const&gt;::type const</type>
  404. <template>
  405. <template-type-parameter name="Tag"/>
  406. <template-type-parameter name="Sequence"/>
  407. </template>
  408. <parameter name="sequence">
  409. <paramtype>Sequence const &amp;</paramtype>
  410. <description>
  411. <para>A Fusion Forward Sequence.</para>
  412. </description>
  413. </parameter>
  414. </signature>
  415. <signature>
  416. <type>typename <classname>proto::result_of::unpack_expr</classname>&lt;Tag, Domain, Sequence const&gt;::type const</type>
  417. <template>
  418. <template-type-parameter name="Tag"/>
  419. <template-type-parameter name="Domain"/>
  420. <template-type-parameter name="Sequence"/>
  421. </template>
  422. <parameter name="sequence">
  423. <paramtype>Sequence const &amp;</paramtype>
  424. </parameter>
  425. </signature>
  426. <purpose>Construct an expression of the requested tag type with a domain and with children
  427. from the specified Fusion Forward Sequence.</purpose>
  428. <description>
  429. <para>
  430. This function template may be invoked either with or without specifying a
  431. <computeroutput>Domain</computeroutput> argument. If no domain is specified, the domain
  432. is deduced by examining domains of each element of the sequence. See
  433. <computeroutput><classname>proto::deduce_domain</classname></computeroutput> for a full
  434. description of the procedure used.
  435. </para>
  436. <para>
  437. Let <computeroutput>s</computeroutput> be a Fusion RandomAccessSequence equivalent to
  438. <computeroutput>sequence</computeroutput>.
  439. Let <computeroutput><replaceable>WRAP</replaceable>(N, s)</computeroutput> be defined such that:
  440. <itemizedlist>
  441. <listitem>
  442. <para>
  443. If <computeroutput>fusion::result_of::value_at_c&lt;decltype(s),N&gt;::type</computeroutput> is a reference type
  444. or an instantiation of <computeroutput>boost::reference_wrapper&lt;&gt;</computeroutput>,
  445. <computeroutput><replaceable>WRAP</replaceable>(N, s)</computeroutput> is equivalent to
  446. <computeroutput><functionname>proto::as_child</functionname>&lt;Domain&gt;(fusion::at_c&lt;N&gt;(s))</computeroutput>.
  447. </para>
  448. </listitem>
  449. <listitem>
  450. <para>
  451. Otherwise, <computeroutput><replaceable>WRAP</replaceable>(N, s)</computeroutput> is equivalent to
  452. <computeroutput><functionname>proto::as_expr</functionname>&lt;Domain&gt;(fusion::at_c&lt;N&gt;(s))</computeroutput>.
  453. </para>
  454. </listitem>
  455. </itemizedlist>
  456. </para>
  457. <para>
  458. If <computeroutput><classname>proto::wants_basic_expr</classname>&lt;typename Domain::proto_generator&gt;::value</computeroutput>
  459. is true, then let <computeroutput><replaceable>E</replaceable></computeroutput> be
  460. <computeroutput><classname>proto::basic_expr</classname></computeroutput>; otherwise,
  461. let <computeroutput><replaceable>E</replaceable></computeroutput> be
  462. <computeroutput><classname>proto::expr</classname></computeroutput>.
  463. </para>
  464. <para>
  465. Let <computeroutput><replaceable>MAKE</replaceable>(Tag, b...)</computeroutput> be defined as
  466. <computeroutput><replaceable>E</replaceable>&lt;Tag,
  467. <classname alt="proto::listN">proto::list<emphasis>N</emphasis></classname>&lt;decltype(b)...&gt; &gt;::make(b...)</computeroutput>.
  468. </para>
  469. <para>
  470. If <computeroutput>Tag</computeroutput> is
  471. <computeroutput><classname>proto::tag::terminal</classname></computeroutput>, then return
  472. <computeroutput><replaceable>WRAP</replaceable>(0, s)</computeroutput>.
  473. </para>
  474. <para>
  475. Otherwise, return
  476. <computeroutput>Domain()(<replaceable>MAKE</replaceable>(Tag, <replaceable>WRAP</replaceable>(0, s),...
  477. <replaceable>WRAP</replaceable>(<replaceable>N</replaceable>-1, s)))</computeroutput>, where
  478. <replaceable>N</replaceable> is the size of <computeroutput>Sequence</computeroutput>.
  479. </para>
  480. </description>
  481. </overloaded-function>
  482. </namespace>
  483. </namespace>
  484. </header>