| 1 | |
|---|
| 2 | // Copyright Aleksey Gurtovoy 2000-2004 |
|---|
| 3 | // Copyright David Abrahams 2003-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 | |
|---|
| 11 | // $Source: /cvsroot/boost/boost/libs/mpl/test/transform.cpp,v $ |
|---|
| 12 | // $Date: 2004/09/02 15:41:35 $ |
|---|
| 13 | // $Revision: 1.6 $ |
|---|
| 14 | |
|---|
| 15 | #include <boost/mpl/transform.hpp> |
|---|
| 16 | |
|---|
| 17 | #include <boost/mpl/list.hpp> |
|---|
| 18 | #include <boost/mpl/list_c.hpp> |
|---|
| 19 | #include <boost/mpl/equal.hpp> |
|---|
| 20 | #include <boost/mpl/equal_to.hpp> |
|---|
| 21 | #include <boost/mpl/plus.hpp> |
|---|
| 22 | #include <boost/mpl/aux_/test.hpp> |
|---|
| 23 | #include <boost/mpl/aux_/config/gcc.hpp> |
|---|
| 24 | #include <boost/mpl/aux_/config/workaround.hpp> |
|---|
| 25 | |
|---|
| 26 | #include <boost/type_traits/add_pointer.hpp> |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | MPL_TEST_CASE() |
|---|
| 30 | { |
|---|
| 31 | typedef list<char,short,int,long,float,double> types; |
|---|
| 32 | typedef list<char*,short*,int*,long*,float*,double*> pointers; |
|---|
| 33 | |
|---|
| 34 | typedef transform1< types,add_pointer<_1> >::type result; |
|---|
| 35 | MPL_ASSERT(( equal<result,pointers> )); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | MPL_TEST_CASE() |
|---|
| 39 | { |
|---|
| 40 | typedef list_c<long,0,2,4,6,8,10> evens; |
|---|
| 41 | typedef list_c<long,2,3,5,7,11,13> primes; |
|---|
| 42 | typedef list_c<long,2,5,9,13,19,23> sums; |
|---|
| 43 | |
|---|
| 44 | typedef transform2< evens, primes, plus<> >::type result; |
|---|
| 45 | MPL_ASSERT(( equal< result,sums,equal_to<_1,_2> > )); |
|---|
| 46 | |
|---|
| 47 | #if !defined(BOOST_MPL_CFG_NO_HAS_XXX) |
|---|
| 48 | typedef transform< evens, primes, plus<> >::type result2; |
|---|
| 49 | MPL_ASSERT(( is_same<result2,result> )); |
|---|
| 50 | #endif |
|---|
| 51 | } |
|---|