lazy_construction.html 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <html>
  2. <head>
  3. <!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc -->
  4. <title>Lazy Construction and Conversions</title>
  5. <link rel="stylesheet" href="theme/style.css" type="text/css">
  6. <link rel="prev" href="adaptable_closures.html">
  7. <link rel="next" href="efficiency.html">
  8. </head>
  9. <body>
  10. <table width="100%" height="48" border="0" background="theme/bkd2.gif" cellspacing="2">
  11. <tr>
  12. <td width="10">
  13. </td>
  14. <td width="85%">
  15. <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Lazy Construction and Conversions</b></font>
  16. </td>
  17. <td width="112"><a href="http://spirit.sf.net"><img src="theme/spirit.gif" align="right" border="0"></a></td>
  18. </tr>
  19. </table>
  20. <br>
  21. <table border="0">
  22. <tr>
  23. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  24. <td width="30"><a href="adaptable_closures.html"><img src="theme/l_arr.gif" border="0"></a></td>
  25. <td width="20"><a href="efficiency.html"><img src="theme/r_arr.gif" border="0"></a></td>
  26. </tr>
  27. </table>
  28. <a name="lazy_c___casts"></a><h2>Lazy C++ Casts</h2><p>
  29. The set of lazy C++ cast template classes and functions provide a way of lazily casting certain type to another during parsing. The lazy C++ templates are (syntactically) used very much like the well known C++ casts:</p>
  30. <code><pre>
  31. <span class=identifier>A </span><span class=special>*</span><span class=identifier>a </span><span class=special>= </span><span class=identifier>static_cast_</span><span class=special>&lt;</span><span class=identifier>A </span><span class=special>*&gt;(</span><span class=identifier>_a_lambda_expression_</span><span class=special>);
  32. </span></pre></code>
  33. <p>
  34. These casts parallel the ones in the C++ language. Take note however that the <i>lazy</i> versions have a trailing underscore.</p>
  35. <ul><li>static_cast_&lt;T&gt;(lambda_expression)</li><li>dynamic_cast_&lt;T&gt;(lambda_expression)</li><li>const_cast_&lt;T&gt;(lambda_expression)</li><li>reinterpret_cast_&lt;T&gt;(lambda_expression)</li></ul><table width="80%" border="0" align="center">
  36. <tr>
  37. <td class="note_box">
  38. <img src="theme/note.gif"></img> <b>Acknowledgement:</b><br><br><b>Hartmut Kaiser</b> implemented the lazy casts and constructors based on his original work on <a href="http://spirit.sourceforge.net">
  39. Spirit</a> SE &quot;semantic expressions&quot; (the precursor of Phoenix). </td>
  40. </tr>
  41. </table>
  42. <a name="lazy_object_construction"></a><h2>Lazy object construction</h2><p>
  43. A set of lazy constructor template classes and functions provide a way of lazily constructing an object of a type from an arbitrary set of lazy arguments in the form of lambda expressions. The construct_ templates are (syntactically) used very much like the well known C++ casts:</p>
  44. <code><pre>
  45. <span class=identifier>A </span><span class=identifier>a </span><span class=special>= </span><span class=identifier>construct_</span><span class=special>&lt;</span><span class=identifier>A</span><span class=special>&gt;(</span><span class=identifier>lambda_arg1</span><span class=special>, </span><span class=identifier>lambda_arg2</span><span class=special>, ..., </span><span class=identifier>lambda_argN</span><span class=special>);
  46. </span></pre></code>
  47. <p>
  48. where the given parameters are become the parameters to the contructor of the object of type A. (This implies, that type A is expected to have a constructor with a corresponsing set of parameter types.)</p>
  49. <table width="80%" border="0" align="center">
  50. <tr>
  51. <td class="note_box">
  52. <img src="theme/bulb.gif"></img> The ultimate maximum number of actual parameters is limited by the preprocessor constant PHOENIX_CONSTRUCT_LIMIT. Note though, that this limit should not be greater than PHOENIX_LIMIT. </td>
  53. </tr>
  54. </table>
  55. <table border="0">
  56. <tr>
  57. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  58. <td width="30"><a href="adaptable_closures.html"><img src="theme/l_arr.gif" border="0"></a></td>
  59. <td width="20"><a href="efficiency.html"><img src="theme/r_arr.gif" border="0"></a></td>
  60. </tr>
  61. </table>
  62. <br>
  63. <hr size="1">
  64. <p class="copyright">Copyright &copy; 2001-2002 Joel de Guzman<br>
  65. <br>
  66. <font size="2">Use, modification and distribution is subject to the Boost Software
  67. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  68. http://www.boost.org/LICENSE_1_0.txt) </font> </p>
  69. </body>
  70. </html>