Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / mpl / aux_ / insert_range_impl.hpp
1
2 #ifndef BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
3 #define BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
4
5 // Copyright Aleksey Gurtovoy 2000-2004
6 //
7 // Distributed under the Boost Software License, Version 1.0. 
8 // (See accompanying file LICENSE_1_0.txt or copy at 
9 // http://www.boost.org/LICENSE_1_0.txt)
10 //
11 // See http://www.boost.org/libs/mpl for documentation.
12
13 // $Id$
14 // $Date$
15 // $Revision$
16
17 #include <boost/mpl/copy.hpp>
18 #include <boost/mpl/clear.hpp>
19 #include <boost/mpl/front_inserter.hpp>
20 #include <boost/mpl/joint_view.hpp>
21 #include <boost/mpl/iterator_range.hpp>
22 #include <boost/mpl/aux_/na_spec.hpp>
23 #include <boost/mpl/aux_/iter_push_front.hpp>
24 #include <boost/mpl/aux_/traits_lambda_spec.hpp>
25 #include <boost/mpl/aux_/config/forwarding.hpp>
26
27 #include <boost/type_traits/same_traits.hpp>
28
29 namespace boost { namespace mpl {
30
31 // default implementation; conrete sequences might override it by 
32 // specializing either the 'insert_range_impl' or the primary 
33 // 'insert_range' template
34
35
36 template< typename Tag >
37 struct insert_range_impl
38 {
39     template<
40           typename Sequence
41         , typename Pos
42         , typename Range
43         >
44     struct apply
45 #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
46         : reverse_copy<
47               joint_view< 
48                   iterator_range<typename begin<Sequence>::type,Pos>
49                 , joint_view< 
50                       Range
51                     , iterator_range<Pos,typename end<Sequence>::type>
52                     >
53                 >
54             , front_inserter< typename clear<Sequence>::type >
55             >
56     {
57 #else
58     {
59         typedef typename reverse_copy<
60               joint_view< 
61                   iterator_range<typename begin<Sequence>::type,Pos>
62                 , joint_view< 
63                       Range
64                     , iterator_range<Pos,typename end<Sequence>::type>
65                     >
66                 >
67             , front_inserter< typename clear<Sequence>::type >
68             >::type type;
69 #endif
70     };
71 };
72
73 BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(3,insert_range_impl)
74
75 }}
76
77 #endif // BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED