not_placeholder_expr.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* Copyright 2006-2025 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/flyweight for library home page.
  7. */
  8. #ifndef BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
  9. #define BOOST_FLYWEIGHT_DETAIL_NOT_PLACEHOLDER_EXPR_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/mpl/aux_/lambda_arity_param.hpp>
  15. #include <boost/mpl/bool.hpp>
  16. #include <boost/mpl/lambda_fwd.hpp>
  17. /* BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION can be inserted at the end
  18. * of a class template parameter declaration:
  19. * template<
  20. * typename X0,...,typename Xn
  21. * BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION
  22. * >
  23. * struct foo...
  24. * to prevent instantiations from being treated as MPL placeholder
  25. * expressions in the presence of placeholder arguments; this is useful
  26. * to avoid masking of a metafunction class nested ::apply during
  27. * MPL invocation.
  28. */
  29. namespace boost{
  30. namespace flyweights{
  31. namespace detail{
  32. struct not_a_ph_expr;
  33. } /* namespace flyweights::detail */
  34. } /* namespace flyweights */
  35. } /* namespace boost */
  36. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG \
  37. (boost::flyweights::detail::not_a_ph_expr*)0
  38. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION \
  39. ,boost::flyweights::detail::not_a_ph_expr* = \
  40. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG
  41. #define BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF \
  42. ,boost::flyweights::detail::not_a_ph_expr*
  43. /* Even though, under the definition given by Boost.MPL, the inclusion of a
  44. * non-type template parameter makes a class template instantiation not a
  45. * placeholder expression, https://wg21.link/p0522r0, which allows
  46. * template-parameters to bind ignoring default arguments, causes
  47. * boost::mpl::lambda to fail to properly honor
  48. * BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION (in P0552R0-compliant
  49. * compilers). We fix this by specializing boost::mpl::lambda accordingly.
  50. */
  51. namespace boost{
  52. namespace mpl{
  53. template<
  54. template<
  55. typename
  56. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
  57. > class F,
  58. typename T1,
  59. typename Tag
  60. >
  61. struct lambda<
  62. F<T1,BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG>,
  63. Tag
  64. BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<1>)
  65. >
  66. {
  67. typedef false_ is_le;
  68. typedef F<
  69. T1,
  70. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG
  71. > result_;
  72. typedef result_ type;
  73. };
  74. template<
  75. template<
  76. typename,typename
  77. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
  78. > class F,
  79. typename T1,typename T2,
  80. typename Tag
  81. >
  82. struct lambda<
  83. F<T1,T2,BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG>,
  84. Tag
  85. BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<2>)
  86. >
  87. {
  88. typedef false_ is_le;
  89. typedef F<
  90. T1,T2,
  91. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG
  92. > result_;
  93. typedef result_ type;
  94. };
  95. template<
  96. template<
  97. typename,typename,typename
  98. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
  99. > class F,
  100. typename T1,typename T2,typename T3,
  101. typename Tag
  102. >
  103. struct lambda<
  104. F<T1,T2,T3,BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG>,
  105. Tag
  106. BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<3>)
  107. >
  108. {
  109. typedef false_ is_le;
  110. typedef F<
  111. T1,T2,T3,
  112. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG
  113. > result_;
  114. typedef result_ type;
  115. };
  116. template<
  117. template<
  118. typename,typename,typename,typename
  119. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
  120. > class F,
  121. typename T1,typename T2,typename T3,typename T4,
  122. typename Tag
  123. >
  124. struct lambda<
  125. F<T1,T2,T3,T4,BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG>,
  126. Tag
  127. BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<4>)
  128. >
  129. {
  130. typedef false_ is_le;
  131. typedef F<
  132. T1,T2,T3,T4,
  133. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG
  134. > result_;
  135. typedef result_ type;
  136. };
  137. template<
  138. template<
  139. typename,typename,typename,typename,typename
  140. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
  141. > class F,
  142. typename T1,typename T2,typename T3,typename T4,typename T5,
  143. typename Tag
  144. >
  145. struct lambda<
  146. F<T1,T2,T3,T4,T5,BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG>,
  147. Tag
  148. BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<5>)
  149. >
  150. {
  151. typedef false_ is_le;
  152. typedef F<
  153. T1,T2,T3,T4,T5,
  154. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_ARG
  155. > result_;
  156. typedef result_ type;
  157. };
  158. } /* namespace mpl */
  159. } /* namespace boost */
  160. #endif