extends.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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/extends.hpp">
  9. <para>Macros and a base class for defining end-user expression types </para>
  10. <namespace name="boost">
  11. <namespace name="proto">
  12. <!-- proto::is_proto_expr -->
  13. <struct name="is_proto_expr">
  14. <purpose>Empty type to be used as a dummy template parameter of POD expression wrappers. It allows
  15. argument-dependent lookup to find Proto's operator overloads.</purpose>
  16. <description>
  17. <para>
  18. <computeroutput>proto::is_proto_expr</computeroutput> allows argument-dependent lookup to find Proto's operator overloads. For example:
  19. </para>
  20. <para>
  21. <programlisting> template&lt;typename T, typename Dummy = <classname>proto::is_proto_expr</classname>&gt;
  22. struct my_terminal
  23. {
  24. <macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>(
  25. typename <classname>proto::terminal</classname>&lt;T&gt;::type
  26. , my_terminal&lt;T&gt;
  27. , <classname>proto::default_domain</classname>
  28. )
  29. };
  30. // ...
  31. my_terminal&lt;int&gt; _1, _2;
  32. _1 + _2; // OK, uses proto::operator+</programlisting>
  33. </para>
  34. <para>
  35. Without the second <computeroutput>Dummy</computeroutput> template parameter, Proto's operator overloads
  36. would not be considered by name lookup.
  37. </para>
  38. </description>
  39. </struct>
  40. <!-- proto::extends -->
  41. <struct name="extends">
  42. <template>
  43. <template-type-parameter name="Expr"/>
  44. <template-type-parameter name="Derived"/>
  45. <template-type-parameter name="Domain">
  46. <default><classname>proto::default_domain</classname></default>
  47. </template-type-parameter>
  48. </template>
  49. <purpose>For adding behaviors to a Proto expression template.</purpose>
  50. <description>
  51. <para>
  52. Use <computeroutput>proto::extends&lt;&gt;</computeroutput> to give expressions in your
  53. domain custom data members and member functions.
  54. </para>
  55. <para>
  56. Conceptually, using <computeroutput>proto::extends&lt;&gt;</computeroutput> is akin
  57. to inheriting from <computeroutput><classname>proto::expr</classname>&lt;&gt;</computeroutput>
  58. and adding your own members. Using <computeroutput>proto::extends&lt;&gt;</computeroutput> is
  59. generally preferrable to straight inheritance because the members that would be inherited from
  60. <computeroutput><classname>proto::expr</classname>&lt;&gt;</computeroutput> would
  61. be wrong; they would incorrectly slice off your additional members when building
  62. larger expressions from smaller ones. <computeroutput>proto::extends&lt;&gt;</computeroutput>
  63. automatically gives your expression types the appropriate operator overloads that
  64. preserve your domain-specific members when composing expression trees.
  65. </para>
  66. <para>
  67. Expression extensions are typically defined as follows:
  68. </para>
  69. <para>
  70. <programlisting>template&lt; typename Expr &gt;
  71. struct my_expr
  72. : proto::extends&lt;
  73. Expr // The expression type we're extending
  74. , my_expr&lt; Expr &gt; // The type we're defining
  75. , my_domain // The domain associated with this expression extension
  76. &gt;
  77. {
  78. // An expression extension is constructed from the expression
  79. // it is extending.
  80. my_expr( Expr const &amp; e = Expr() )
  81. : my_expr::proto_extends( e )
  82. {}
  83. // Unhide proto::extends::operator=
  84. // (This is only necessary if a lazy assignment operator
  85. // makes sense for your domain-specific language.)
  86. BOOST_PROTO_EXTENDS_USING_ASSIGN(my_expr)
  87. /*
  88. ... domain-specific members go here ...
  89. */
  90. };</programlisting>
  91. </para>
  92. <para>
  93. See also:
  94. <itemizedlist>
  95. <listitem>
  96. <computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>
  97. </listitem>
  98. <listitem>
  99. <computeroutput><macroname>BOOST_PROTO_EXTENDS_USING_ASSIGN</macroname>()</computeroutput>
  100. </listitem>
  101. <listitem>
  102. <computeroutput><macroname>BOOST_PROTO_EXTENDS_USING_ASSIGN_NON_DEPENDENT</macroname>()</computeroutput>
  103. </listitem>
  104. </itemizedlist>
  105. </para>
  106. </description>
  107. <struct name="result">
  108. <template>
  109. <template-type-parameter name="Signature"/>
  110. </template>
  111. <typedef name="type">
  112. <type><replaceable>unspecified</replaceable></type>
  113. </typedef>
  114. <description>
  115. <para>So that <computeroutput>boost::result_of&lt;&gt;</computeroutput>
  116. can compute the return type of <computeroutput>proto::extends::operator()</computeroutput>.
  117. </para>
  118. </description>
  119. </struct>
  120. <typedef name="proto_base_expr">
  121. <type>typename Expr::proto_base_expr</type>
  122. </typedef>
  123. <typedef name="proto_domain">
  124. <type>Domain</type>
  125. </typedef>
  126. <typedef name="proto_derived_expr">
  127. <type>Derived</type>
  128. </typedef>
  129. <typedef name="proto_extends">
  130. <type>extends</type>
  131. </typedef>
  132. <typedef name="proto_tag">
  133. <type>typename proto_base_expr::proto_tag</type>
  134. </typedef>
  135. <typedef name="proto_args">
  136. <type>typename proto_base_expr::proto_args</type>
  137. </typedef>
  138. <typedef name="proto_arity">
  139. <type>typename proto_base_expr::proto_arity</type>
  140. </typedef>
  141. <typedef name="proto_grammar">
  142. <type>typename proto_base_expr::proto_grammar</type>
  143. </typedef>
  144. <typedef name="proto_childN">
  145. <purpose>For each <replaceable>N</replaceable> in <replaceable>[0,max(1,proto_arity_c))</replaceable></purpose>
  146. <type>typename proto_base_expr::proto_child<replaceable>N</replaceable></type>
  147. </typedef>
  148. <!-- constructors -->
  149. <constructor/>
  150. <constructor>
  151. <parameter name="that">
  152. <paramtype><classname>extends</classname> const &amp;</paramtype>
  153. </parameter>
  154. </constructor>
  155. <constructor>
  156. <parameter name="expr_">
  157. <paramtype>Expr const &amp;</paramtype>
  158. </parameter>
  159. </constructor>
  160. <method-group name="public static functions">
  161. <method name="make" specifiers="static">
  162. <type>Derived const</type>
  163. <parameter name="expr">
  164. <paramtype>Expr const &amp;</paramtype>
  165. </parameter>
  166. <description>
  167. <para>Construct an expression extension from the base expression.</para>
  168. </description>
  169. <return>Derived(expr)</return>
  170. </method>
  171. </method-group>
  172. <method-group name="public member functions">
  173. <!-- proto_base() -->
  174. <method name="proto_base">
  175. <type>proto_base_expr &amp;</type>
  176. <returns><computeroutput>proto_expr_.proto_base()</computeroutput></returns>
  177. <throws><simpara>Will not throw.</simpara></throws>
  178. </method>
  179. <method name="proto_base" cv="const">
  180. <type>proto_base_expr const &amp;</type>
  181. <returns><computeroutput>proto_expr_.proto_base()</computeroutput></returns>
  182. <throws><simpara>Will not throw.</simpara></throws>
  183. </method>
  184. <!-- operator= -->
  185. <method name="operator=">
  186. <type><replaceable>unspecified</replaceable></type>
  187. <template>
  188. <template-type-parameter name="A"/>
  189. </template>
  190. <parameter name="a">
  191. <paramtype>A &amp;</paramtype>
  192. </parameter>
  193. <description>
  194. <para>Lazy assignment expression</para>
  195. </description>
  196. <returns>
  197. <para>A new expression node representing the assignment operation.</para>
  198. </returns>
  199. </method>
  200. <method name="operator=">
  201. <type><replaceable>unspecified</replaceable></type>
  202. <template>
  203. <template-type-parameter name="A"/>
  204. </template>
  205. <parameter name="a">
  206. <paramtype>A const &amp;</paramtype>
  207. </parameter>
  208. <description>
  209. <para>
  210. This is an overloaded member function, provided for convenience. It differs from
  211. the above function only in what argument(s) it accepts.
  212. </para>
  213. </description>
  214. </method>
  215. <method name="operator=" cv="const">
  216. <type><replaceable>unspecified</replaceable></type>
  217. <template>
  218. <template-type-parameter name="A"/>
  219. </template>
  220. <parameter name="a">
  221. <paramtype>A &amp;</paramtype>
  222. </parameter>
  223. <description>
  224. <para>
  225. This is an overloaded member function, provided for convenience. It differs from
  226. the above function only in what argument(s) it accepts.
  227. </para>
  228. </description>
  229. </method>
  230. <method name="operator=" cv="const">
  231. <type><replaceable>unspecified</replaceable></type>
  232. <template>
  233. <template-type-parameter name="A"/>
  234. </template>
  235. <parameter name="a">
  236. <paramtype>A const &amp;</paramtype>
  237. </parameter>
  238. <description>
  239. <para>
  240. This is an overloaded member function, provided for convenience. It differs from
  241. the above function only in what argument(s) it accepts.
  242. </para>
  243. </description>
  244. </method>
  245. <!-- operator[] -->
  246. <method name="operator[]">
  247. <type><replaceable>unspecified</replaceable></type>
  248. <template>
  249. <template-type-parameter name="A"/>
  250. </template>
  251. <parameter name="a">
  252. <paramtype>A &amp;</paramtype>
  253. </parameter>
  254. <description>
  255. <para>Lazy subscript expression</para>
  256. </description>
  257. <returns>
  258. <para>A new expression node representing the subscript operation.</para>
  259. </returns>
  260. </method>
  261. <method name="operator[]">
  262. <type><replaceable>unspecified</replaceable></type>
  263. <template>
  264. <template-type-parameter name="A"/>
  265. </template>
  266. <parameter name="a">
  267. <paramtype>A const &amp;</paramtype>
  268. </parameter>
  269. <description>
  270. <para>
  271. This is an overloaded member function, provided for convenience. It differs from
  272. the above function only in what argument(s) it accepts.
  273. </para>
  274. </description>
  275. </method>
  276. <method name="operator[]" cv="const">
  277. <type><replaceable>unspecified</replaceable></type>
  278. <template>
  279. <template-type-parameter name="A"/>
  280. </template>
  281. <parameter name="a">
  282. <paramtype>A &amp;</paramtype>
  283. </parameter>
  284. <description>
  285. <para>
  286. This is an overloaded member function, provided for convenience. It differs from
  287. the above function only in what argument(s) it accepts.
  288. </para>
  289. </description>
  290. </method>
  291. <method name="operator[]" cv="const">
  292. <type><replaceable>unspecified</replaceable></type>
  293. <template>
  294. <template-type-parameter name="A"/>
  295. </template>
  296. <parameter name="a">
  297. <paramtype>A const &amp;</paramtype>
  298. </parameter>
  299. <description>
  300. <para>
  301. This is an overloaded member function, provided for convenience. It differs from
  302. the above function only in what argument(s) it accepts.
  303. </para>
  304. </description>
  305. </method>
  306. <!-- operator() -->
  307. <method name="operator()">
  308. <type><replaceable>unspecified</replaceable></type>
  309. <template>
  310. <template-type-parameter name="A" pack="1"/>
  311. </template>
  312. <parameter name="a" pack="1">
  313. <paramtype>A const &amp;</paramtype>
  314. </parameter>
  315. <description>
  316. <para>Lazy function call</para>
  317. </description>
  318. <returns>
  319. <para>A new expression node representing the function call operation.</para>
  320. </returns>
  321. </method>
  322. <method name="operator()" cv="const">
  323. <type><replaceable>unspecified</replaceable></type>
  324. <template>
  325. <template-type-parameter name="A" pack="1"/>
  326. </template>
  327. <parameter name="a" pack="1">
  328. <paramtype>A const &amp;</paramtype>
  329. </parameter>
  330. <description>
  331. <para>
  332. This is an overloaded member function, provided for convenience. It differs from
  333. the above function only in what argument(s) it accepts.
  334. </para>
  335. </description>
  336. </method>
  337. </method-group>
  338. <data-member name="proto_expr_">
  339. <type>Expr</type>
  340. <purpose>For exposition only.</purpose>
  341. </data-member>
  342. <data-member name="proto_arity_c" specifiers="static">
  343. <type>const long</type>
  344. <purpose><computeroutput>= proto_base_expr::proto_arity_c;</computeroutput></purpose>
  345. </data-member>
  346. </struct>
  347. </namespace>
  348. </namespace>
  349. <macro name="BOOST_PROTO_EXTENDS" kind="functionlike">
  350. <macro-parameter name="Expr"/>
  351. <macro-parameter name="Derived"/>
  352. <macro-parameter name="Domain"/>
  353. <purpose>For creating expression wrappers that add behaviors to a Proto expression template, like
  354. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>,
  355. but while retaining POD-ness of the expression wrapper.</purpose>
  356. <description>
  357. <para>
  358. Equivalent to:
  359. <programlisting><macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>(Expr, Derived, Domain)
  360. <macroname>BOOST_PROTO_EXTENDS_ASSIGN</macroname>()
  361. <macroname>BOOST_PROTO_EXTENDS_SUBSCRIPT</macroname>()
  362. <macroname>BOOST_PROTO_EXTENDS_FUNCTION</macroname>()</programlisting>
  363. </para>
  364. <para>If the <computeroutput>Domain</computeroutput> parameter is dependent, you can specify it as
  365. <computeroutput>typename Domain</computeroutput>, as in
  366. <computeroutput>BOOST_PROTO_EXTENDS(Expr, Derived, typename Domain)</computeroutput>
  367. </para>
  368. <para>
  369. <emphasis role="bold">Example:</emphasis><programlisting>template&lt; class Expr &gt;
  370. struct my_expr;
  371. struct my_domain
  372. : <classname alt="boost::proto::domain">proto::domain</classname>&lt; <classname alt="boost::proto::pod_generator">proto::pod_generator</classname>&lt; my_expr &gt; &gt;
  373. {};
  374. template&lt; class Expr &gt;
  375. struct my_expr
  376. {
  377. // OK, this makes my_expr&lt;&gt; a valid Proto expression extension.
  378. // my_expr&lt;&gt; has overloaded assignment, subscript,
  379. // and function call operators that build expression templates.
  380. <macroname>BOOST_PROTO_EXTENDS</macroname>(Expr, my_expr, my_domain)
  381. };
  382. // OK, my_expr&lt;&gt; is POD, so this is statically initialized:
  383. my_expr&lt; <classname alt="boost::proto::terminal">proto::terminal</classname>&lt;int&gt;::type &gt; const _1 = {{1}};</programlisting>
  384. </para>
  385. </description>
  386. </macro>
  387. <macro name="BOOST_PROTO_BASIC_EXTENDS" kind="functionlike">
  388. <macro-parameter name="Expr"/>
  389. <macro-parameter name="Derived"/>
  390. <macro-parameter name="Domain"/>
  391. <purpose>For creating expression wrappers that add members to a Proto expression template, like
  392. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>,
  393. but while retaining POD-ness of the expression wrapper.</purpose>
  394. <description>
  395. <para>
  396. <computeroutput>BOOST_PROTO_BASIC_EXTENDS()</computeroutput> adds the basic typedefs, member functions, and
  397. data members necessary to make a struct a valid Proto expression extension. It does <emphasis>not</emphasis>
  398. add any constructors, virtual functions or access control blocks that would render the containing
  399. struct non-POD.
  400. </para>
  401. <para>
  402. <computeroutput>Expr</computeroutput> is the Proto expression that the enclosing struct extends.
  403. <computeroutput>Derived</computeroutput> is the type of the enclosing struct.
  404. <computeroutput>Domain</computeroutput> is the Proto domain to which this expression extension belongs.
  405. (See <computeroutput><classname alt="boost::proto::domain">proto::domain&lt;&gt;</classname></computeroutput>.)
  406. Can be preceeded with "<computeroutput>typename</computeroutput>" if the specified domain is a dependent type.
  407. </para>
  408. <para><computeroutput>BOOST_PROTO_BASIC_EXTENDS()</computeroutput> adds to its enclosing struct
  409. exactly one data member of type <computeroutput>Expr</computeroutput>.
  410. </para>
  411. <para>If the <computeroutput>Domain</computeroutput> parameter is dependent, you can specify it as
  412. <computeroutput>typename Domain</computeroutput>, as in
  413. <computeroutput>BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, typename Domain)</computeroutput>
  414. </para>
  415. <para>
  416. <emphasis role="bold">Example:</emphasis><programlisting>template&lt; class Expr &gt;
  417. struct my_expr;
  418. struct my_domain
  419. : <classname alt="boost::proto::domain">proto::domain</classname>&lt; <classname alt="boost::proto::pod_generator">proto::pod_generator</classname>&lt; my_expr &gt; &gt;
  420. {};
  421. template&lt; class Expr &gt;
  422. struct my_expr
  423. {
  424. // OK, this makes my_expr&lt;&gt; a valid Proto expression extension.
  425. // my_expr&lt;&gt; does /not/ have overloaded assignment, subscript,
  426. // and function call operators that build expression templates, however.
  427. <macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>(Expr, my_expr, my_domain)
  428. };
  429. // OK, my_expr&lt;&gt; is POD, so this is statically initialized:
  430. my_expr&lt; <classname alt="boost::proto::terminal">proto::terminal</classname>&lt;int&gt;::type &gt; const _1 = {{1}};</programlisting>
  431. </para>
  432. <para>
  433. See also:
  434. <itemizedlist>
  435. <listitem>
  436. <computeroutput><macroname>BOOST_PROTO_EXTENDS_ASSIGN</macroname>()</computeroutput>
  437. </listitem>
  438. <listitem>
  439. <computeroutput><macroname>BOOST_PROTO_EXTENDS_SUBSCRIPT</macroname>()</computeroutput>
  440. </listitem>
  441. <listitem>
  442. <computeroutput><macroname>BOOST_PROTO_EXTENDS_FUNCTION</macroname>()</computeroutput>
  443. </listitem>
  444. <listitem>
  445. <computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>
  446. </listitem>
  447. </itemizedlist>
  448. </para>
  449. </description>
  450. </macro>
  451. <macro name="BOOST_PROTO_EXTENDS_ASSIGN" kind="functionlike">
  452. <purpose>For adding to an expression extension class an overloaded assignment operator that
  453. builds an expression template.</purpose>
  454. <description>
  455. <para>
  456. Use <computeroutput>BOOST_PROTO_EXTENDS_ASSIGN()</computeroutput> after <computeroutput>
  457. <macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>()</computeroutput> to give an expression
  458. extension class an overloaded assignment operator that builds an expression template.
  459. </para>
  460. <para>
  461. See also:
  462. <itemizedlist>
  463. <listitem>
  464. <computeroutput><macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>()</computeroutput>
  465. </listitem>
  466. <listitem>
  467. <computeroutput><macroname>BOOST_PROTO_EXTENDS_SUBSCRIPT</macroname>()</computeroutput>
  468. </listitem>
  469. <listitem>
  470. <computeroutput><macroname>BOOST_PROTO_EXTENDS_FUNCTION</macroname>()</computeroutput>
  471. </listitem>
  472. <listitem>
  473. <computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>
  474. </listitem>
  475. </itemizedlist>
  476. </para>
  477. </description>
  478. </macro>
  479. <macro name="BOOST_PROTO_EXTENDS_FUNCTION" kind="functionlike">
  480. <purpose>For adding to an expression extension class a set of overloaded function call operators
  481. that build expression templates.</purpose>
  482. <description>
  483. <para>
  484. Use <computeroutput>BOOST_PROTO_EXTENDS_FUNCTION()</computeroutput> after <computeroutput>
  485. <macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>()</computeroutput> to give an expression
  486. extension class a set of overloaded function call operators that build expression templates.
  487. In addition, <computeroutput>BOOST_PROTO_EXTENDS_FUNCTION()</computeroutput> adds a nested
  488. <computeroutput>result&lt;&gt;</computeroutput> class template that is a metafunction for
  489. calculating the return type of the overloaded function call operators.
  490. </para>
  491. <para>
  492. See also:
  493. <itemizedlist>
  494. <listitem>
  495. <computeroutput><macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>()</computeroutput>
  496. </listitem>
  497. <listitem>
  498. <computeroutput><macroname>BOOST_PROTO_EXTENDS_ASSIGN</macroname>()</computeroutput>
  499. </listitem>
  500. <listitem>
  501. <computeroutput><macroname>BOOST_PROTO_EXTENDS_SUBSCRIPT</macroname>()</computeroutput>
  502. </listitem>
  503. <listitem>
  504. <computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>
  505. </listitem>
  506. </itemizedlist>
  507. </para>
  508. </description>
  509. </macro>
  510. <macro name="BOOST_PROTO_EXTENDS_SUBSCRIPT" kind="functionlike">
  511. <purpose>For adding to an expression extension class an overloaded subscript operator that
  512. builds an expression template.</purpose>
  513. <description>
  514. <para>
  515. Use <computeroutput>BOOST_PROTO_EXTENDS_SUBSCRIPT()</computeroutput> after <computeroutput>
  516. <macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>()</computeroutput> to give an expression
  517. extension class an overloaded subscript operator that builds an expression template.
  518. </para>
  519. <para>
  520. See also:
  521. <itemizedlist>
  522. <listitem>
  523. <computeroutput><macroname>BOOST_PROTO_BASIC_EXTENDS</macroname>()</computeroutput>
  524. </listitem>
  525. <listitem>
  526. <computeroutput><macroname>BOOST_PROTO_EXTENDS_ASSIGN</macroname>()</computeroutput>
  527. </listitem>
  528. <listitem>
  529. <computeroutput><macroname>BOOST_PROTO_EXTENDS_FUNCTION</macroname>()</computeroutput>
  530. </listitem>
  531. <listitem>
  532. <computeroutput><macroname>BOOST_PROTO_EXTENDS</macroname>()</computeroutput>
  533. </listitem>
  534. </itemizedlist>
  535. </para>
  536. </description>
  537. </macro>
  538. <macro name="BOOST_PROTO_EXTENDS_USING_ASSIGN" kind="functionlike">
  539. <macro-parameter name="Derived"/>
  540. <purpose>For exposing in classes that inherit from
  541. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>
  542. the overloaded assignment operators defined therein.</purpose>
  543. <description>
  544. <para>
  545. The standard usage of
  546. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>
  547. is to inherit from it. However, the derived class automatically gets a compiler-generated assignment
  548. operator that will hide the ones defined in
  549. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>.
  550. Use <code>BOOST_PROTO_EXTENDS_USING_ASSIGN()</code> in the derived class to unhide the assignment
  551. operators defined in
  552. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>.
  553. </para>
  554. <para>
  555. See <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>
  556. for an example that demonstrates usage of <code>BOOST_PROTO_EXTENDS_USING_ASSIGN()</code>.
  557. </para>
  558. </description>
  559. </macro>
  560. <macro name="BOOST_PROTO_EXTENDS_USING_ASSIGN_NON_DEPENDENT" kind="functionlike">
  561. <macro-parameter name="Derived"/>
  562. <purpose>For exposing in classes that inherit from
  563. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>
  564. the overloaded assignment operators defined therein. Unlike the
  565. <computeroutput><macroname>BOOST_PROTO_EXTENDS_USING_ASSIGN</macroname>()</computeroutput> macro,
  566. <code>BOOST_PROTO_EXTENDS_USING_ASSIGN_NON_DEPENDENT()</code> is for use in non-dependent
  567. contexts.
  568. </purpose>
  569. <description>
  570. <para>
  571. The standard usage of
  572. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>
  573. is to define a class template that inherits from it. The derived class template automatically gets a
  574. compiler-generated assignment operator that hides the ones defined in
  575. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>.
  576. Using <code>BOOST_PROTO_EXTENDS_USING_ASSIGN()</code> in the derived class solves this problem.
  577. </para>
  578. <para>
  579. However, if the expression extension is an ordinary class and not a class template, the usage of
  580. <code>BOOST_PROTO_EXTENDS_USING_ASSIGN()</code> is in a so-called non-dependent context. In plain English,
  581. it means it is illegal to use <code>typename</code> in some places where it is required in a class template.
  582. In those cases, you should use <code>BOOST_PROTO_EXTENDS_USING_ASSIGN_NON_DEPENDENT()</code> instead.
  583. </para>
  584. <para>
  585. See also:
  586. <itemizedlist>
  587. <listitem>
  588. <computeroutput><classname alt="boost::proto::extends">proto::extends&lt;&gt;</classname></computeroutput>
  589. </listitem>
  590. <listitem>
  591. <computeroutput><macroname>BOOST_PROTO_EXTENDS_USING_ASSIGN</macroname>()</computeroutput>
  592. </listitem>
  593. </itemizedlist>
  594. </para>
  595. </description>
  596. </macro>
  597. </header>