segment_sequence.hpp 1.9 KB

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