1/*=============================================================================
2 Copyright (c) 2011 Eric Niebler
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7#if !defined(BOOST_FUSION_SEGMENTED_SEQUENCE_HPP_INCLUDED)
8#define BOOST_FUSION_SEGMENTED_SEQUENCE_HPP_INCLUDED
9
10#include <boost/fusion/support/config.hpp>
11#include <boost/mpl/bool.hpp>
12#include <boost/type_traits/remove_reference.hpp>
13#include <boost/fusion/support/tag_of.hpp>
14#include <boost/fusion/sequence/intrinsic_fwd.hpp>
15
16#ifdef _MSC_VER
17# pragma warning(push)
18# pragma warning(disable: 4512) // assignment operator could not be generated.
19#endif
20
21namespace boost { namespace fusion { namespace detail
22{
23 struct segment_sequence_tag {};
24
25 // Here, Sequence is a sequence of ranges (which may or may not be
26 // segmented).
27 template<typename Sequence>
28 struct segment_sequence
29 : sequence_base<segment_sequence<Sequence> >
30 {
31 typedef fusion_sequence_tag tag;
32 typedef segment_sequence_tag fusion_tag;
33 typedef typename Sequence::is_view is_view;
34 typedef typename Sequence::category category;
35 typedef Sequence sequence_type;
36 sequence_type sequence;
37
38 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit segment_sequence(Sequence const & seq)
39 : sequence(seq)
40 {}
41 };
42}
43
44#ifdef _MSC_VER
45# pragma warning(pop)
46#endif
47
48namespace extension
49{
50 template<typename Tag>
51 struct is_segmented_impl;
52
53 template<>
54 struct is_segmented_impl<detail::segment_sequence_tag>
55 {
56 template<typename Sequence>
57 struct apply
58 : mpl::true_
59 {};
60 };
61
62 template<typename Tag>
63 struct segments_impl;
64
65 template<>
66 struct segments_impl<detail::segment_sequence_tag>
67 {
68 template<typename Sequence>
69 struct apply
70 {
71 typedef typename Sequence::sequence_type type;
72
73 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
74 static type call(Sequence & seq)
75 {
76 return seq.sequence;
77 }
78 };
79 };
80}}}
81
82#endif
83