| 1 | /*============================================================================= |
| 2 | Copyright (c) 2001-2011 Joel de Guzman |
| 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(FUSION_INSERT_RANGE_009172005_1147) |
| 8 | #define FUSION_INSERT_RANGE_009172005_1147 |
| 9 | |
| 10 | #include <boost/fusion/support/config.hpp> |
| 11 | #include <boost/fusion/iterator/mpl/convert_iterator.hpp> |
| 12 | #include <boost/fusion/view/joint_view/joint_view.hpp> |
| 13 | #include <boost/fusion/view/iterator_range/iterator_range.hpp> |
| 14 | #include <boost/fusion/support/detail/as_fusion_element.hpp> |
| 15 | #include <boost/fusion/sequence/intrinsic/begin.hpp> |
| 16 | #include <boost/fusion/sequence/intrinsic/end.hpp> |
| 17 | #include <boost/fusion/adapted/mpl/mpl_iterator.hpp> |
| 18 | |
| 19 | namespace boost { namespace fusion |
| 20 | { |
| 21 | namespace result_of |
| 22 | { |
| 23 | template <typename Sequence, typename Position, typename Range> |
| 24 | struct insert_range |
| 25 | { |
| 26 | typedef typename convert_iterator<Position>::type pos_type; |
| 27 | typedef typename result_of::begin<Sequence>::type first_type; |
| 28 | typedef typename result_of::end<Sequence>::type last_type; |
| 29 | |
| 30 | typedef iterator_range<first_type, pos_type> left_type; |
| 31 | typedef iterator_range<pos_type, last_type> right_type; |
| 32 | typedef joint_view<left_type, Range> left_insert_type; |
| 33 | typedef joint_view<left_insert_type, right_type> type; |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | template <typename Sequence, typename Position, typename Range> |
| 38 | BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 39 | inline typename result_of::insert_range<Sequence const, Position, Range const>::type |
| 40 | insert_range(Sequence const& seq, Position const& pos, Range const& range) |
| 41 | { |
| 42 | typedef result_of::insert_range<Sequence const, Position, Range const> result_of; |
| 43 | typedef typename result_of::left_type left_type; |
| 44 | typedef typename result_of::right_type right_type; |
| 45 | typedef typename result_of::left_insert_type left_insert_type; |
| 46 | typedef typename result_of::type result; |
| 47 | |
| 48 | left_type left(fusion::begin(seq), convert_iterator<Position>::call(pos)); |
| 49 | right_type right(convert_iterator<Position>::call(pos), fusion::end(seq)); |
| 50 | left_insert_type left_insert(left, range); |
| 51 | return result(left_insert, right); |
| 52 | } |
| 53 | }} |
| 54 | |
| 55 | #endif |
| 56 | |
| 57 | |