include_self.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <html>
  2. <head>
  3. <title>BOOST_PP_INCLUDE_SELF</title>
  4. <link rel="stylesheet" type="text/css" href="../styles.css">
  5. </head>
  6. <body>
  7. <div style="margin-left: 0px;">
  8. The <b>BOOST_PP_INCLUDE_SELF</b> macro includes a file indirectly.
  9. </div>
  10. <h4>Usage</h4>
  11. <div class="code">
  12. #include <b>BOOST_PP_INCLUDE_SELF</b>()
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>filename</dt>
  17. <dd>
  18. A quoted or angle-bracketed filename to be included by <b>BOOST_PP_INCLUDE_SELF</b>.
  19. </dd>
  20. </dl>
  21. <h4>Remarks</h4>
  22. <div>
  23. <b>BOOST_PP_INDIRECT_SELF</b> must be defined prior to using this macro.
  24. </div>
  25. <div>
  26. Most preprocessors will not allow a file to directly include itself--even when the file protects itself from such a scenario.&nbsp;
  27. This macro, in combination with <b>BOOST_PP_INDIRECT_SELF</b> allows a file to include itself indirectly.
  28. </div>
  29. <div>
  30. While <b>BOOST_PP_INDIRECT_SELF</b> is being included, <b>BOOST_PP_INCLUDE_SELF</b> defines the macro <b>BOOST_PP_IS_SELFISH</b> to <i>1</i>.&nbsp;
  31. When it returns from the inclusion, <b>BOOST_PP_IS_SELFISH</b> is undefined.
  32. </div>
  33. <h4>See Also</h4>
  34. <ul>
  35. <li><a href="indirect_self.html">BOOST_PP_INDIRECT_SELF</a></li>
  36. <li><a href="is_selfish.html">BOOST_PP_IS_SELFISH</a></li>
  37. </ul>
  38. <h4>Requirements</h4>
  39. <div>
  40. <b>Header:</b> &nbsp;<a href="../headers/iteration/self.html">&lt;boost/preprocessor/iteration/self.hpp&gt;</a>
  41. </div>
  42. <h4>Sample Code</h4>
  43. <div><pre>
  44. // file.h
  45. #if !<a href="is_selfish.html">BOOST_PP_IS_SELFISH</a>
  46. #ifndef FILE_H_
  47. #define FILE_H_
  48. #include &lt;<a href="../headers/iteration/self.html">boost/preprocessor/iteration/self.hpp</a>&gt;
  49. #define NAME X
  50. struct NAME {
  51. // ...
  52. #define <a href="indirect_self.html">BOOST_PP_INDIRECT_SELF</a> "file.h"
  53. #include <a href="include_self.html">BOOST_PP_INCLUDE_SELF</a>()
  54. };
  55. #define NAME Y
  56. struct NAME {
  57. // ...
  58. #define <a href="indirect_self.html">BOOST_PP_INDIRECT_SELF</a> "file.h"
  59. #include <a href="include_self.html">BOOST_PP_INCLUDE_SELF</a>()
  60. };
  61. #define NAME Z
  62. struct NAME {
  63. // ...
  64. #define <a href="indirect_self.html">BOOST_PP_INDIRECT_SELF</a> "file.h"
  65. #include <a href="include_self.html">BOOST_PP_INCLUDE_SELF</a>()
  66. };
  67. #endif
  68. #else
  69. inline bool validate(NAME* p) {
  70. return true;
  71. }
  72. template&lt;class T&gt; bool validate(T* p) {
  73. return dynamic_cast&lt;NAME*&gt;(p);
  74. }
  75. #undef NAME
  76. #endif
  77. </pre></div>
  78. <hr size="1">
  79. <div style="margin-left: 0px;">
  80. <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
  81. </br><i>© Copyright Paul Mensonides 2002</i>
  82. </div>
  83. <div style="margin-left: 0px;">
  84. <p><small>Distributed under the Boost Software License, Version 1.0. (See
  85. accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  86. copy at <a href=
  87. "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  88. </div>
  89. </body>
  90. </html>