sequence_tag.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef BOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED
  2. #define BOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/sequence_tag_fwd.hpp>
  14. #include <boost/mpl/aux_/has_tag.hpp>
  15. #include <boost/mpl/aux_/has_begin.hpp>
  16. #include <boost/mpl/aux_/na_spec.hpp>
  17. #include <boost/mpl/aux_/is_msvc_eti_arg.hpp>
  18. #include <boost/mpl/aux_/config/eti.hpp>
  19. #include <boost/mpl/aux_/yes_no.hpp>
  20. #include <boost/mpl/aux_/config/workaround.hpp>
  21. namespace boost { namespace mpl {
  22. // agurt, 27/nov/02: have to use a simplistic 'sequence_tag' implementation
  23. // on MSVC to avoid dreadful "internal structure overflow" error
  24. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
  25. || defined(BOOST_MPL_CFG_NO_HAS_XXX)
  26. template<
  27. typename BOOST_MPL_AUX_NA_PARAM(Sequence)
  28. >
  29. struct sequence_tag
  30. {
  31. typedef typename Sequence::tag type;
  32. };
  33. #elif BOOST_WORKAROUND(BOOST_MSVC, == 1300)
  34. // agurt, 07/feb/03: workaround for what seems to be MSVC 7.0-specific ETI issue
  35. namespace aux {
  36. template< bool >
  37. struct sequence_tag_impl
  38. {
  39. template< typename Sequence > struct result_
  40. {
  41. typedef typename Sequence::tag type;
  42. };
  43. };
  44. template<>
  45. struct sequence_tag_impl<false>
  46. {
  47. template< typename Sequence > struct result_
  48. {
  49. typedef int type;
  50. };
  51. };
  52. } // namespace aux
  53. template<
  54. typename BOOST_MPL_AUX_NA_PARAM(Sequence)
  55. >
  56. struct sequence_tag
  57. : aux::sequence_tag_impl< !aux::is_msvc_eti_arg<Sequence>::value >
  58. ::template result_<Sequence>
  59. {
  60. };
  61. #else
  62. namespace aux {
  63. template< bool has_tag_, bool has_begin_ >
  64. struct sequence_tag_impl
  65. {
  66. // agurt 24/nov/02: MSVC 6.5 gets confused in 'sequence_tag_impl<true>'
  67. // specialization below, if we name it 'result_' here
  68. template< typename Sequence > struct result2_;
  69. };
  70. # define AUX_CLASS_SEQUENCE_TAG_SPEC(has_tag, has_begin, result_type) \
  71. template<> struct sequence_tag_impl<has_tag,has_begin> \
  72. { \
  73. template< typename Sequence > struct result2_ \
  74. { \
  75. typedef result_type type; \
  76. }; \
  77. }; \
  78. /**/
  79. AUX_CLASS_SEQUENCE_TAG_SPEC(true, true, typename Sequence::tag)
  80. AUX_CLASS_SEQUENCE_TAG_SPEC(true, false, typename Sequence::tag)
  81. AUX_CLASS_SEQUENCE_TAG_SPEC(false, true, nested_begin_end_tag)
  82. AUX_CLASS_SEQUENCE_TAG_SPEC(false, false, non_sequence_tag)
  83. # undef AUX_CLASS_SEQUENCE_TAG_SPEC
  84. } // namespace aux
  85. template<
  86. typename BOOST_MPL_AUX_NA_PARAM(Sequence)
  87. >
  88. struct sequence_tag
  89. : aux::sequence_tag_impl<
  90. ::boost::mpl::aux::has_tag<Sequence>::value
  91. , ::boost::mpl::aux::has_begin<Sequence>::value
  92. >::template result2_<Sequence>
  93. {
  94. };
  95. #endif // BOOST_MSVC
  96. BOOST_MPL_AUX_NA_SPEC(1, sequence_tag)
  97. }}
  98. #endif // BOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED