transform.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright Aleksey Gurtovoy 2000-2004
  2. // Copyright David Abrahams 2003-2004
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/mpl for documentation.
  9. // $Id$
  10. // $Date$
  11. // $Revision$
  12. #include <boost/mpl/transform.hpp>
  13. #include <boost/mpl/list.hpp>
  14. #include <boost/mpl/list_c.hpp>
  15. #include <boost/mpl/equal.hpp>
  16. #include <boost/mpl/equal_to.hpp>
  17. #include <boost/mpl/plus.hpp>
  18. #include <boost/mpl/aux_/test.hpp>
  19. #include <boost/mpl/aux_/config/gcc.hpp>
  20. #include <boost/mpl/aux_/config/workaround.hpp>
  21. #include <boost/type_traits/add_pointer.hpp>
  22. MPL_TEST_CASE()
  23. {
  24. typedef list<char,short,int,long,float,double> types;
  25. typedef list<char*,short*,int*,long*,float*,double*> pointers;
  26. typedef transform1< types,add_pointer<_1> >::type result;
  27. MPL_ASSERT(( equal<result,pointers> ));
  28. }
  29. MPL_TEST_CASE()
  30. {
  31. typedef list_c<long,0,2,4,6,8,10> evens;
  32. typedef list_c<long,2,3,5,7,11,13> primes;
  33. typedef list_c<long,2,5,9,13,19,23> sums;
  34. typedef transform2< evens, primes, plus<> >::type result;
  35. MPL_ASSERT(( equal< result,sums,equal_to<_1,_2> > ));
  36. #if !defined(BOOST_MPL_CFG_NO_HAS_XXX)
  37. typedef transform< evens, primes, plus<> >::type result2;
  38. MPL_ASSERT(( is_same<result2,result> ));
  39. #endif
  40. }