stable_partition.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef BOOST_MPL_STABLE_PARTITION_HPP_INCLUDED
  2. #define BOOST_MPL_STABLE_PARTITION_HPP_INCLUDED
  3. // Copyright Eric Friedman 2002-2003
  4. // Copyright Aleksey Gurtovoy 2004
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/fold.hpp>
  15. #include <boost/mpl/reverse_fold.hpp>
  16. #include <boost/mpl/protect.hpp>
  17. #include <boost/mpl/aux_/partition_op.hpp>
  18. #include <boost/mpl/aux_/inserter_algorithm.hpp>
  19. #include <boost/mpl/aux_/na.hpp>
  20. namespace boost { namespace mpl {
  21. namespace aux {
  22. template <
  23. typename Sequence
  24. , typename Pred
  25. , typename In
  26. , typename In2
  27. , typename In1 = typename if_na<In,In2>::type
  28. >
  29. struct stable_partition_impl
  30. : fold<
  31. Sequence
  32. , pair< typename In1::state, typename In2::state >
  33. , protect< partition_op<
  34. Pred
  35. , typename In1::operation
  36. , typename In2::operation
  37. > >
  38. >
  39. {
  40. };
  41. template <
  42. typename Sequence
  43. , typename Pred
  44. , typename In
  45. , typename In2
  46. , typename In1 = typename if_na<In,In2>::type
  47. >
  48. struct reverse_stable_partition_impl
  49. : reverse_fold<
  50. Sequence
  51. , pair< typename In1::state, typename In2::state >
  52. , protect< partition_op<
  53. Pred
  54. , typename In1::operation
  55. , typename In2::operation
  56. > >
  57. >
  58. {
  59. };
  60. } // namespace aux
  61. BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(4, stable_partition)
  62. }}
  63. #endif // BOOST_MPL_STABLE_PARTITION_HPP_INCLUDED