1 /*=============================================================================
2 Copyright (c) 2006 Eric Niebler
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_SEGMENTS_04052005_1141)
8 #define BOOST_FUSION_SEGMENTS_04052005_1141
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/type_traits/is_const.hpp>
12 #include <boost/utility/enable_if.hpp>
13 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
14 #include <boost/fusion/support/tag_of.hpp>
16 namespace boost { namespace fusion
19 struct sequence_facade_tag;
20 struct iterator_range_tag;
22 // segments: returns a sequence of sequences
25 template <typename Tag>
28 template <typename Sequence>
33 struct segments_impl<sequence_facade_tag>
35 template <typename Sequence>
36 struct apply : Sequence::template segments<Sequence> {};
40 struct segments_impl<iterator_range_tag>;
45 template <typename Sequence>
48 typedef typename traits::tag_of<Sequence>::type tag_type;
51 extension::segments_impl<tag_type>::template apply<Sequence>::type
56 template <typename Sequence>
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
61 , result_of::segments<Sequence>
63 segments(Sequence& seq)
65 typedef typename traits::tag_of<Sequence>::type tag_type;
66 return extension::segments_impl<tag_type>::template apply<Sequence>::call(seq);
69 template <typename Sequence>
70 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
71 inline typename result_of::segments<Sequence const>::type
72 segments(Sequence const& seq)
74 typedef typename traits::tag_of<Sequence const>::type tag_type;
75 return extension::segments_impl<tag_type>::template apply<Sequence const>::call(seq);