Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | #ifndef BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED |
| 3 | #define BOOST_MPL_AUX_JOINT_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: joint_iter.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 14 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 15 | // $Revision: 49267 $ |
| 16 | |
| 17 | #include <ndnboost/mpl/next_prior.hpp> |
| 18 | #include <ndnboost/mpl/deref.hpp> |
| 19 | #include <ndnboost/mpl/iterator_tags.hpp> |
| 20 | #include <ndnboost/mpl/aux_/lambda_spec.hpp> |
| 21 | #include <ndnboost/mpl/aux_/config/ctps.hpp> |
| 22 | |
| 23 | #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 24 | # include <ndnboost/type_traits/is_same.hpp> |
| 25 | #endif |
| 26 | |
| 27 | namespace ndnboost { namespace mpl { |
| 28 | |
| 29 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
| 30 | |
| 31 | template< |
| 32 | typename Iterator1 |
| 33 | , typename LastIterator1 |
| 34 | , typename Iterator2 |
| 35 | > |
| 36 | struct joint_iter |
| 37 | { |
| 38 | typedef Iterator1 base; |
| 39 | typedef forward_iterator_tag category; |
| 40 | }; |
| 41 | |
| 42 | template< |
| 43 | typename LastIterator1 |
| 44 | , typename Iterator2 |
| 45 | > |
| 46 | struct joint_iter<LastIterator1,LastIterator1,Iterator2> |
| 47 | { |
| 48 | typedef Iterator2 base; |
| 49 | typedef forward_iterator_tag category; |
| 50 | }; |
| 51 | |
| 52 | |
| 53 | template< typename I1, typename L1, typename I2 > |
| 54 | struct deref< joint_iter<I1,L1,I2> > |
| 55 | { |
| 56 | typedef typename joint_iter<I1,L1,I2>::base base_; |
| 57 | typedef typename deref<base_>::type type; |
| 58 | }; |
| 59 | |
| 60 | template< typename I1, typename L1, typename I2 > |
| 61 | struct next< joint_iter<I1,L1,I2> > |
| 62 | { |
| 63 | typedef joint_iter< typename mpl::next<I1>::type,L1,I2 > type; |
| 64 | }; |
| 65 | |
| 66 | template< typename L1, typename I2 > |
| 67 | struct next< joint_iter<L1,L1,I2> > |
| 68 | { |
| 69 | typedef joint_iter< L1,L1,typename mpl::next<I2>::type > type; |
| 70 | }; |
| 71 | |
| 72 | #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
| 73 | |
| 74 | template< |
| 75 | typename Iterator1 |
| 76 | , typename LastIterator1 |
| 77 | , typename Iterator2 |
| 78 | > |
| 79 | struct joint_iter; |
| 80 | |
| 81 | template< bool > struct joint_iter_impl |
| 82 | { |
| 83 | template< typename I1, typename L1, typename I2 > struct result_ |
| 84 | { |
| 85 | typedef I1 base; |
| 86 | typedef forward_iterator_tag category; |
| 87 | typedef joint_iter< typename mpl::next<I1>::type,L1,I2 > next; |
| 88 | typedef typename deref<I1>::type type; |
| 89 | }; |
| 90 | }; |
| 91 | |
| 92 | template<> struct joint_iter_impl<true> |
| 93 | { |
| 94 | template< typename I1, typename L1, typename I2 > struct result_ |
| 95 | { |
| 96 | typedef I2 base; |
| 97 | typedef forward_iterator_tag category; |
| 98 | typedef joint_iter< L1,L1,typename mpl::next<I2>::type > next; |
| 99 | typedef typename deref<I2>::type type; |
| 100 | }; |
| 101 | }; |
| 102 | |
| 103 | template< |
| 104 | typename Iterator1 |
| 105 | , typename LastIterator1 |
| 106 | , typename Iterator2 |
| 107 | > |
| 108 | struct joint_iter |
| 109 | : joint_iter_impl< is_same<Iterator1,LastIterator1>::value > |
| 110 | ::template result_<Iterator1,LastIterator1,Iterator2> |
| 111 | { |
| 112 | }; |
| 113 | |
| 114 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
| 115 | |
| 116 | BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(3, joint_iter) |
| 117 | |
| 118 | }} |
| 119 | |
| 120 | #endif // BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED |