insert_range_impl.hpp 2.2 KB

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