9
3

quote.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. ///// header body
  3. #ifndef BOOST_MPL_QUOTE_HPP_INCLUDED
  4. #define BOOST_MPL_QUOTE_HPP_INCLUDED
  5. // Copyright Aleksey Gurtovoy 2000-2008
  6. //
  7. // Distributed under the Boost Software License, Version 1.0.
  8. // (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // See http://www.boost.org/libs/mpl for documentation.
  12. // $Id$
  13. // $Date$
  14. // $Revision$
  15. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  16. # include <boost/mpl/void.hpp>
  17. # include <boost/mpl/aux_/has_type.hpp>
  18. #endif
  19. #include <boost/mpl/aux_/config/bcc.hpp>
  20. #include <boost/mpl/aux_/config/ttp.hpp>
  21. #if defined(BOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS) \
  22. && !defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS)
  23. # define BOOST_MPL_CFG_NO_QUOTE_TEMPLATE
  24. #endif
  25. #if !defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS) \
  26. && defined(BOOST_MPL_CFG_NO_HAS_XXX)
  27. # define BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS
  28. #endif
  29. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  30. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  31. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  32. # define BOOST_MPL_PREPROCESSED_HEADER quote.hpp
  33. # include <boost/mpl/aux_/include_preprocessed.hpp>
  34. #else
  35. # include <boost/mpl/limits/arity.hpp>
  36. # include <boost/mpl/aux_/preprocessor/params.hpp>
  37. # include <boost/mpl/aux_/config/ctps.hpp>
  38. # include <boost/mpl/aux_/config/workaround.hpp>
  39. # include <boost/preprocessor/iterate.hpp>
  40. # include <boost/preprocessor/cat.hpp>
  41. #if !defined(BOOST_MPL_CFG_NO_QUOTE_TEMPLATE)
  42. namespace boost { namespace mpl {
  43. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  44. template< typename T, bool has_type_ >
  45. struct quote_impl
  46. // GCC has a problem with metafunction forwarding when T is a
  47. // specialization of a template called 'type'.
  48. # if BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4)) \
  49. && BOOST_WORKAROUND(__GNUC_MINOR__, BOOST_TESTED_AT(0)) \
  50. && BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, BOOST_TESTED_AT(2))
  51. {
  52. typedef typename T::type type;
  53. };
  54. # else
  55. : T
  56. {
  57. };
  58. # endif
  59. template< typename T >
  60. struct quote_impl<T,false>
  61. {
  62. typedef T type;
  63. };
  64. #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  65. template< bool > struct quote_impl
  66. {
  67. template< typename T > struct result_
  68. : T
  69. {
  70. };
  71. };
  72. template<> struct quote_impl<false>
  73. {
  74. template< typename T > struct result_
  75. {
  76. typedef T type;
  77. };
  78. };
  79. #endif
  80. #define BOOST_PP_ITERATION_PARAMS_1 \
  81. (3,(1, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/quote.hpp>))
  82. #include BOOST_PP_ITERATE()
  83. }}
  84. #endif // BOOST_MPL_CFG_NO_QUOTE_TEMPLATE
  85. #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  86. #endif // BOOST_MPL_QUOTE_HPP_INCLUDED
  87. ///// iteration
  88. #else
  89. #define i_ BOOST_PP_FRAME_ITERATION(1)
  90. template<
  91. template< BOOST_MPL_PP_PARAMS(i_, typename P) > class F
  92. , typename Tag = void_
  93. >
  94. struct BOOST_PP_CAT(quote,i_)
  95. {
  96. template< BOOST_MPL_PP_PARAMS(i_, typename U) > struct apply
  97. #if defined(BOOST_MPL_CFG_BCC590_WORKAROUNDS)
  98. {
  99. typedef typename quote_impl<
  100. F< BOOST_MPL_PP_PARAMS(i_, U) >
  101. , aux::has_type< F< BOOST_MPL_PP_PARAMS(i_, U) > >::value
  102. >::type type;
  103. };
  104. #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  105. : quote_impl<
  106. F< BOOST_MPL_PP_PARAMS(i_, U) >
  107. , aux::has_type< F< BOOST_MPL_PP_PARAMS(i_, U) > >::value
  108. >
  109. {
  110. };
  111. #else
  112. : quote_impl< aux::has_type< F< BOOST_MPL_PP_PARAMS(i_, U) > >::value >
  113. ::template result_< F< BOOST_MPL_PP_PARAMS(i_, U) > >
  114. {
  115. };
  116. #endif
  117. };
  118. #undef i_
  119. #endif // BOOST_PP_IS_ITERATING