partition.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright Aleksey Gurtovoy 2004
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/mpl for documentation.
  8. // $Id$
  9. // $Date$
  10. // $Revision$
  11. #include <boost/mpl/partition.hpp>
  12. #include <boost/mpl/vector.hpp>
  13. #include <boost/mpl/vector_c.hpp>
  14. #include <boost/mpl/range_c.hpp>
  15. #include <boost/mpl/back_inserter.hpp>
  16. #include <boost/mpl/equal.hpp>
  17. #include <boost/mpl/modulus.hpp>
  18. #include <boost/mpl/int.hpp>
  19. #include <boost/mpl/aux_/test.hpp>
  20. template< typename N > struct is_odd
  21. : modulus< N, int_<2> >
  22. {
  23. BOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_odd, (N))
  24. };
  25. MPL_TEST_CASE()
  26. {
  27. typedef partition<
  28. range_c<int,0,10>
  29. , is_odd<_1>
  30. , mpl::back_inserter< vector<> >
  31. , mpl::back_inserter< vector<> >
  32. >::type r;
  33. MPL_ASSERT(( equal< r::first, vector_c<int,1,3,5,7,9> > ));
  34. MPL_ASSERT(( equal< r::second, vector_c<int,0,2,4,6,8> > ));
  35. }