1 2 #ifndef BOOST_MPL_AUX_TRANSFORM_ITER_HPP_INCLUDED 3 #define BOOST_MPL_AUX_TRANSFORM_ITER_HPP_INCLUDED 4 5 // Copyright Aleksey Gurtovoy 2000-2004 6 // 7 // Distributed under the Boost Software License, Version 1.0. 8 // (See accompanying file LICENSE_1_0.txt or copy at 9 // http://www.boost.org/LICENSE_1_0.txt) 10 // 11 // See http://www.boost.org/libs/mpl for documentation. 12 13 // $Id$ 14 // $Date$ 15 // $Revision$ 16 17 #include <boost/mpl/apply.hpp> 18 #include <boost/mpl/iterator_tags.hpp> 19 #include <boost/mpl/next.hpp> 20 #include <boost/mpl/deref.hpp> 21 #include <boost/mpl/aux_/lambda_spec.hpp> 22 #include <boost/mpl/aux_/config/ctps.hpp> 23 #include <boost/type_traits/is_same.hpp> 24 25 namespace boost { namespace mpl { 26 27 namespace aux { 28 29 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) 30 31 template< 32 typename Iterator 33 , typename LastIterator 34 , typename F 35 > 36 struct transform_iter 37 { 38 typedef Iterator base; 39 typedef forward_iterator_tag category; 40 typedef transform_iter< typename mpl::next<base>::type,LastIterator,F > next; 41 42 typedef typename apply1< 43 F 44 , typename deref<base>::type 45 >::type type; 46 }; 47 48 template< 49 typename LastIterator 50 , typename F 51 > 52 struct transform_iter< LastIterator,LastIterator,F > 53 { 54 typedef LastIterator base; 55 typedef forward_iterator_tag category; 56 }; 57 58 #else 59 60 template< 61 typename Iterator 62 , typename LastIterator 63 , typename F 64 > 65 struct transform_iter; 66 67 template< bool > 68 struct transform_iter_impl 69 { 70 template< 71 typename Iterator 72 , typename LastIterator 73 , typename F 74 > 75 struct result_ 76 { 77 typedef Iterator base; 78 typedef forward_iterator_tag category; 79 typedef transform_iter< typename mpl::next<Iterator>::type,LastIterator,F > next; 80 81 typedef typename apply1< 82 F 83 , typename deref<Iterator>::type 84 >::type type; 85 }; 86 }; 87 88 template<> 89 struct transform_iter_impl<true> 90 { 91 template< 92 typename Iterator 93 , typename LastIterator 94 , typename F 95 > 96 struct result_ 97 { 98 typedef Iterator base; 99 typedef forward_iterator_tag category; 100 }; 101 }; 102 103 template< 104 typename Iterator 105 , typename LastIterator 106 , typename F 107 > 108 struct transform_iter 109 : transform_iter_impl< 110 ::boost::is_same<Iterator,LastIterator>::value 111 >::template result_< Iterator,LastIterator,F > 112 { 113 }; 114 115 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 116 117 } // namespace aux 118 119 BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(3, aux::transform_iter) 120 121 }} 122 123 #endif // BOOST_MPL_AUX_TRANSFORM_ITER_HPP_INCLUDED 124