is_sequence.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(FUSION_IS_SEQUENCE_05052005_1002)
  7. #define FUSION_IS_SEQUENCE_05052005_1002
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/sequence_base.hpp>
  10. #include <boost/fusion/support/tag_of.hpp>
  11. #include <boost/fusion/support/detail/is_native_fusion_sequence.hpp>
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/mpl/is_sequence.hpp>
  14. #include <boost/type_traits/is_convertible.hpp>
  15. namespace boost { namespace fusion
  16. {
  17. // Special tags:
  18. struct non_fusion_tag;
  19. struct boost_tuple_tag; // boost::tuples::tuple tag
  20. struct boost_array_tag; // boost::array tag
  21. struct mpl_sequence_tag; // mpl sequence tag
  22. struct std_pair_tag; // std::pair tag
  23. namespace extension
  24. {
  25. template <typename T>
  26. struct is_sequence_impl
  27. {
  28. template <typename Sequence>
  29. struct apply
  30. : is_convertible<Sequence, fusion::detail::from_sequence_convertible_type>
  31. {};
  32. };
  33. template <>
  34. struct is_sequence_impl<non_fusion_tag>
  35. {
  36. template <typename T>
  37. struct apply : mpl::false_ {};
  38. };
  39. template <>
  40. struct is_sequence_impl<boost_tuple_tag>;
  41. template <>
  42. struct is_sequence_impl<boost_array_tag>;
  43. template <>
  44. struct is_sequence_impl<mpl_sequence_tag>;
  45. template <>
  46. struct is_sequence_impl<std_pair_tag>;
  47. }
  48. namespace traits
  49. {
  50. template <typename T>
  51. struct is_sequence
  52. : mpl::bool_<
  53. (bool)extension::is_sequence_impl<
  54. typename fusion::detail::tag_of<T>::type
  55. >::template apply<T>::type::value
  56. >
  57. {};
  58. using detail::is_native_fusion_sequence;
  59. }
  60. }}
  61. #endif