is_view.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 sequence_facade_tag;
  15. struct boost_tuple_tag; // boost::tuples::tuple tag
  16. struct boost_array_tag; // boost::array tag
  17. struct mpl_sequence_tag; // mpl sequence tag
  18. struct std_pair_tag; // std::pair tag
  19. namespace extension
  20. {
  21. template<typename Tag>
  22. struct is_view_impl
  23. {
  24. template <typename T>
  25. struct apply
  26. {
  27. typedef typename T::is_view type;
  28. };
  29. };
  30. template <>
  31. struct is_view_impl<sequence_facade_tag>
  32. {
  33. template <typename Sequence>
  34. struct apply : Sequence::is_view {};
  35. };
  36. template <>
  37. struct is_view_impl<boost_tuple_tag>;
  38. template <>
  39. struct is_view_impl<boost_array_tag>;
  40. template <>
  41. struct is_view_impl<mpl_sequence_tag>;
  42. template <>
  43. struct is_view_impl<std_pair_tag>;
  44. }
  45. namespace traits
  46. {
  47. template <typename T>
  48. struct is_view :
  49. mpl::bool_<
  50. (bool)extension::is_view_impl<typename fusion::detail::tag_of<T>::type>::
  51. template apply<T>::type::value
  52. >
  53. {};
  54. }
  55. }}
  56. #endif