erase_impl.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef BOOST_MPL_AUX_ERASE_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_ERASE_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/clear.hpp>
  14. #include <boost/mpl/push_front.hpp>
  15. #include <boost/mpl/reverse_fold.hpp>
  16. #include <boost/mpl/iterator_range.hpp>
  17. #include <boost/mpl/next.hpp>
  18. #include <boost/mpl/aux_/na.hpp>
  19. namespace boost { namespace mpl {
  20. // default implementation; conrete sequences might override it by
  21. // specializing either the 'erase_impl' or the primary 'erase' template
  22. template< typename Tag >
  23. struct erase_impl
  24. {
  25. template<
  26. typename Sequence
  27. , typename First
  28. , typename Last
  29. >
  30. struct apply
  31. {
  32. typedef typename if_na< Last,typename next<First>::type >::type last_;
  33. // 1st half: [begin, first)
  34. typedef iterator_range<
  35. typename begin<Sequence>::type
  36. , First
  37. > first_half_;
  38. // 2nd half: [last, end) ... that is, [last + 1, end)
  39. typedef iterator_range<
  40. last_
  41. , typename end<Sequence>::type
  42. > second_half_;
  43. typedef typename reverse_fold<
  44. second_half_
  45. , typename clear<Sequence>::type
  46. , push_front<_,_>
  47. >::type half_sequence_;
  48. typedef typename reverse_fold<
  49. first_half_
  50. , half_sequence_
  51. , push_front<_,_>
  52. >::type type;
  53. };
  54. };
  55. }}
  56. #endif // BOOST_MPL_AUX_ERASE_IMPL_HPP_INCLUDED