PageRenderTime 39ms CodeModel.GetById 27ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/fusion/algorithm/transformation/insert.hpp

http://hadesmem.googlecode.com/
C++ Header | 63 lines | 50 code | 7 blank | 6 comment | 0 complexity | a076326a138e425666b7362482fa74c5 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2006 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_07222005_0730)
 8#define FUSION_INSERT_07222005_0730
 9
10#include <boost/fusion/support/detail/as_fusion_element.hpp>
11#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
12#include <boost/fusion/container/vector/vector10.hpp>
13#include <boost/fusion/view/joint_view/joint_view.hpp>
14#include <boost/fusion/view/single_view/single_view.hpp>
15#include <boost/fusion/view/iterator_range/iterator_range.hpp>
16#include <boost/fusion/sequence/intrinsic/begin.hpp>
17#include <boost/fusion/sequence/intrinsic/end.hpp>
18#include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
19
20namespace boost { namespace fusion
21{
22    namespace result_of
23    {
24        template <typename Sequence, typename Position, typename T>
25        struct insert
26        {
27            typedef typename detail::as_fusion_element<T>::type element_type;
28            typedef typename convert_iterator<Position>::type pos_type;
29            typedef typename result_of::begin<Sequence>::type first_type;
30            typedef typename result_of::end<Sequence>::type last_type;
31
32            typedef iterator_range<first_type, pos_type> left_type;
33            typedef iterator_range<pos_type, last_type> right_type;
34            typedef fusion::single_view<element_type> single_view;
35            typedef joint_view<left_type, single_view const> left_insert_type;
36            typedef joint_view<left_insert_type, right_type> type;
37        };
38    }
39
40    template <typename Sequence, typename Position, typename T>
41    inline typename result_of::insert<
42        Sequence const, Position, T>::type
43    insert(Sequence const& seq, Position const& pos, T const& x)
44    {
45        typedef result_of::insert<
46            Sequence const, Position, T>
47        result_of;
48        typedef typename result_of::left_type left_type;
49        typedef typename result_of::right_type right_type;
50        typedef typename result_of::single_view single_view;
51        typedef typename result_of::left_insert_type left_insert_type;
52        typedef typename result_of::type result;
53
54        left_type left(fusion::begin(seq), convert_iterator<Position>::call(pos));
55        right_type right(convert_iterator<Position>::call(pos), fusion::end(seq));
56        single_view insert(x);
57        left_insert_type left_insert(left, insert);
58        return result(left_insert, right);
59    }
60}}
61
62#endif
63