partition_op.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef BOOST_MPL_AUX_PARTITION_OP_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_PARTITION_OP_HPP_INCLUDED
  3. // Copyright Eric Friedman 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/apply.hpp>
  15. #include <boost/mpl/eval_if.hpp>
  16. #include <boost/mpl/if.hpp>
  17. #include <boost/mpl/pair.hpp>
  18. #include <boost/mpl/aux_/lambda_spec.hpp>
  19. namespace boost { namespace mpl {
  20. namespace aux {
  21. template< typename Pred, typename In1Op, typename In2Op >
  22. struct partition_op
  23. {
  24. template< typename State, typename T >
  25. struct apply
  26. {
  27. typedef typename State::first first_;
  28. typedef typename State::second second_;
  29. typedef typename apply1< Pred,T >::type pred_;
  30. typedef typename eval_if<
  31. pred_
  32. , apply2<In1Op,first_,T>
  33. , apply2<In2Op,second_,T>
  34. >::type result_;
  35. typedef typename if_<
  36. pred_
  37. , pair< result_,second_ >
  38. , pair< first_,result_ >
  39. >::type type;
  40. };
  41. };
  42. } // namespace aux
  43. BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(3, aux::partition_op)
  44. }}
  45. #endif // BOOST_MPL_AUX_PARTITION_OP_HPP_INCLUDED