enable_recursive_fwd.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //-----------------------------------------------------------------------------
  2. // boost variant/detail/enable_recursive_fwd.hpp header file
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. //-----------------------------------------------------------------------------
  5. //
  6. // Copyright (c) 2003
  7. // Eric Friedman
  8. //
  9. // Distributed under the Boost Software License, Version 1.0. (See
  10. // accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt)
  12. #ifndef BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_FWD_HPP
  13. #define BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_FWD_HPP
  14. #include "boost/mpl/aux_/config/ctps.hpp"
  15. #include "boost/mpl/bool_fwd.hpp"
  16. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  17. # include "boost/mpl/bool.hpp"
  18. #else
  19. # include "boost/type_traits/is_base_and_derived.hpp"
  20. #endif
  21. namespace boost {
  22. namespace detail { namespace variant {
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // (detail) tag recursive_flag
  25. //
  26. // Signifies that the variant should perform recursive substituion.
  27. //
  28. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  29. template <typename T>
  30. struct recursive_flag
  31. {
  32. typedef T type;
  33. };
  34. #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  35. struct recursive_flag_tag
  36. {
  37. };
  38. template <typename T>
  39. struct recursive_flag
  40. : recursive_flag_tag
  41. {
  42. typedef T type;
  43. };
  44. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
  45. ///////////////////////////////////////////////////////////////////////////////
  46. // (detail) metafunction is_recursive_flag
  47. //
  48. // Signifies that the variant should perform recursive substituion.
  49. //
  50. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  51. template <typename T>
  52. struct is_recursive_flag
  53. : mpl::false_
  54. {
  55. };
  56. template <typename T>
  57. struct is_recursive_flag< recursive_flag<T> >
  58. : mpl::true_
  59. {
  60. };
  61. #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  62. template <typename T>
  63. struct is_recursive_flag
  64. : is_base_and_derived< recursive_flag_tag,T >
  65. {
  66. };
  67. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
  68. ///////////////////////////////////////////////////////////////////////////////
  69. // (detail) metafunction enable_recursive
  70. //
  71. // Attempts recursive_variant_ tag substitution, wrapping with
  72. // boost::recursive_wrapper if substituion occurs w/ non-indirect result
  73. // (i.e., not a reference or pointer) *and* NoWrapper is false_.
  74. //
  75. template <
  76. typename T
  77. , typename RecursiveVariant
  78. , typename NoWrapper = mpl::false_
  79. >
  80. struct enable_recursive;
  81. ///////////////////////////////////////////////////////////////////////////////
  82. // (detail) metafunction class quoted_enable_recursive
  83. //
  84. // Same behavior as enable_recursive metafunction (see above).
  85. //
  86. template <
  87. typename RecursiveVariant
  88. , typename NoWrapper = mpl::false_
  89. >
  90. struct quoted_enable_recursive;
  91. }} // namespace detail::variant
  92. } // namespace boost
  93. #endif // BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_FWD_HPP