segment_sequence.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifdef _MSC_VER
  14. # pragma warning(push)
  15. # pragma warning(disable: 4512) // assignment operator could not be generated.
  16. #endif
  17. namespace boost { namespace fusion { namespace detail
  18. {
  19. struct segment_sequence_tag {};
  20. // Here, Sequence is a sequence of ranges (which may or may not be
  21. // segmented).
  22. template<typename Sequence>
  23. struct segment_sequence
  24. : sequence_base<segment_sequence<Sequence> >
  25. {
  26. typedef fusion_sequence_tag tag;
  27. typedef segment_sequence_tag fusion_tag;
  28. typedef typename Sequence::is_view is_view;
  29. typedef typename Sequence::category category;
  30. typedef Sequence sequence_type;
  31. sequence_type sequence;
  32. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit segment_sequence(Sequence const & seq)
  33. : sequence(seq)
  34. {}
  35. };
  36. }
  37. #ifdef _MSC_VER
  38. # pragma warning(pop)
  39. #endif
  40. namespace extension
  41. {
  42. template<typename Tag>
  43. struct is_segmented_impl;
  44. template<>
  45. struct is_segmented_impl<detail::segment_sequence_tag>
  46. {
  47. template<typename Sequence>
  48. struct apply
  49. : mpl::true_
  50. {};
  51. };
  52. template<typename Tag>
  53. struct segments_impl;
  54. template<>
  55. struct segments_impl<detail::segment_sequence_tag>
  56. {
  57. template<typename Sequence>
  58. struct apply
  59. {
  60. typedef typename Sequence::sequence_type type;
  61. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  62. static type call(Sequence & seq)
  63. {
  64. return seq.sequence;
  65. }
  66. };
  67. };
  68. }}}
  69. #endif