is_view.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_VIEW_03202006_0015)
  7. #define FUSION_IS_VIEW_03202006_0015
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/mpl/bool.hpp>
  10. #include <boost/fusion/support/tag_of.hpp>
  11. namespace boost { namespace fusion
  12. {
  13. // Special tags:
  14. struct non_fusion_tag;
  15. struct sequence_facade_tag;
  16. struct boost_tuple_tag; // boost::tuples::tuple tag
  17. struct boost_array_tag; // boost::array tag
  18. struct mpl_sequence_tag; // mpl sequence tag
  19. struct std_pair_tag; // std::pair tag
  20. namespace extension
  21. {
  22. template<typename Tag>
  23. struct is_view_impl
  24. {
  25. template <typename T>
  26. struct apply
  27. {
  28. typedef typename T::is_view type;
  29. };
  30. };
  31. template <>
  32. struct is_view_impl<non_fusion_tag>
  33. {
  34. template <typename T>
  35. struct apply : mpl::false_ {};
  36. };
  37. template <>
  38. struct is_view_impl<sequence_facade_tag>
  39. {
  40. template <typename Sequence>
  41. struct apply : Sequence::is_view {};
  42. };
  43. template <>
  44. struct is_view_impl<boost_tuple_tag>;
  45. template <>
  46. struct is_view_impl<boost_array_tag>;
  47. template <>
  48. struct is_view_impl<mpl_sequence_tag>;
  49. template <>
  50. struct is_view_impl<std_pair_tag>;
  51. }
  52. namespace traits
  53. {
  54. template <typename T>
  55. struct is_view :
  56. mpl::bool_<
  57. (bool)extension::is_view_impl<typename fusion::detail::tag_of<T>::type>::
  58. template apply<T>::type::value
  59. >
  60. {};
  61. }
  62. }}
  63. #endif