segment_sequence.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*=============================================================================
  2. Copyright (c) 2011 Eric Niebler
  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(BOOST_FUSION_SEGMENTED_SEQUENCE_HPP_INCLUDED)
  7. #define BOOST_FUSION_SEGMENTED_SEQUENCE_HPP_INCLUDED
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/mpl/bool.hpp>
  10. #include <boost/type_traits/remove_reference.hpp>
  11. #include <boost/fusion/support/tag_of.hpp>
  12. #include <boost/fusion/sequence/intrinsic_fwd.hpp>
  13. namespace boost { namespace fusion { namespace detail
  14. {
  15. struct segment_sequence_tag {};
  16. // Here, Sequence is a sequence of ranges (which may or may not be
  17. // segmented).
  18. template<typename Sequence>
  19. struct segment_sequence
  20. : sequence_base<segment_sequence<Sequence> >
  21. {
  22. typedef fusion_sequence_tag tag;
  23. typedef segment_sequence_tag fusion_tag;
  24. typedef typename Sequence::is_view is_view;
  25. typedef typename Sequence::category category;
  26. typedef Sequence sequence_type;
  27. sequence_type sequence;
  28. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit segment_sequence(Sequence const & seq)
  29. : sequence(seq)
  30. {}
  31. };
  32. }
  33. namespace extension
  34. {
  35. template<typename Tag>
  36. struct is_segmented_impl;
  37. template<>
  38. struct is_segmented_impl<detail::segment_sequence_tag>
  39. {
  40. template<typename Sequence>
  41. struct apply
  42. : mpl::true_
  43. {};
  44. };
  45. template<typename Tag>
  46. struct segments_impl;
  47. template<>
  48. struct segments_impl<detail::segment_sequence_tag>
  49. {
  50. template<typename Sequence>
  51. struct apply
  52. {
  53. typedef typename Sequence::sequence_type type;
  54. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  55. static type call(Sequence & seq)
  56. {
  57. return seq.sequence;
  58. }
  59. };
  60. };
  61. }}}
  62. #endif