is_sequence.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef BOOST_MPL_IS_SEQUENCE_HPP_INCLUDED
  2. #define BOOST_MPL_IS_SEQUENCE_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2002-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/not.hpp>
  14. #include <boost/mpl/and.hpp>
  15. #include <boost/mpl/begin_end.hpp>
  16. #include <boost/mpl/if.hpp>
  17. #include <boost/mpl/bool.hpp>
  18. #include <boost/mpl/sequence_tag_fwd.hpp>
  19. #include <boost/mpl/identity.hpp>
  20. #include <boost/mpl/void.hpp>
  21. #include <boost/mpl/aux_/has_tag.hpp>
  22. #include <boost/mpl/aux_/has_begin.hpp>
  23. #include <boost/mpl/aux_/na_spec.hpp>
  24. #include <boost/mpl/aux_/lambda_support.hpp>
  25. #include <boost/mpl/aux_/config/eti.hpp>
  26. #include <boost/mpl/aux_/config/msvc.hpp>
  27. #include <boost/mpl/aux_/config/workaround.hpp>
  28. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  29. # include <boost/mpl/aux_/msvc_is_class.hpp>
  30. #elif BOOST_WORKAROUND(BOOST_MSVC, == 1300)
  31. # include <boost/type_traits/is_class.hpp>
  32. #endif
  33. #include <boost/type_traits/is_same.hpp>
  34. namespace boost { namespace mpl {
  35. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
  36. namespace aux {
  37. // agurt, 11/jun/03:
  38. // MSVC 6.5/7.0 fails if 'has_begin' is instantiated on a class type that has a
  39. // 'begin' member that doesn't name a type; e.g. 'has_begin< std::vector<int> >'
  40. // would fail; requiring 'T' to have _both_ 'tag' and 'begin' members workarounds
  41. // the issue for most real-world cases
  42. template< typename T > struct is_sequence_impl
  43. : and_<
  44. identity< aux::has_tag<T> >
  45. , identity< aux::has_begin<T> >
  46. >
  47. {
  48. };
  49. } // namespace aux
  50. template<
  51. typename BOOST_MPL_AUX_NA_PARAM(T)
  52. >
  53. struct is_sequence
  54. : if_<
  55. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  56. aux::msvc_is_class<T>
  57. #else
  58. boost::is_class<T>
  59. #endif
  60. , aux::is_sequence_impl<T>
  61. , bool_<false>
  62. >::type
  63. {
  64. BOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_sequence, (T))
  65. };
  66. #elif defined(BOOST_MPL_CFG_NO_HAS_XXX)
  67. template<
  68. typename BOOST_MPL_AUX_NA_PARAM(T)
  69. >
  70. struct is_sequence
  71. : bool_<false>
  72. {
  73. };
  74. #else
  75. template<
  76. typename BOOST_MPL_AUX_NA_PARAM(T)
  77. >
  78. struct is_sequence
  79. : not_< is_same< typename begin<T>::type, void_ > >
  80. {
  81. BOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_sequence, (T))
  82. };
  83. #endif // BOOST_MSVC
  84. #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
  85. template<> struct is_sequence<int>
  86. : bool_<false>
  87. {
  88. };
  89. #endif
  90. BOOST_MPL_AUX_NA_SPEC_NO_ETI(1, is_sequence)
  91. }}
  92. #endif // BOOST_MPL_IS_SEQUENCE_HPP_INCLUDED