Chris@16: Chris@16: #ifndef BOOST_MPL_PAIR_VIEW_HPP_INCLUDED Chris@16: #define BOOST_MPL_PAIR_VIEW_HPP_INCLUDED Chris@16: Chris@16: // Copyright David Abrahams 2003-2004 Chris@16: // Copyright Aleksey Gurtovoy 2004 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: Chris@101: // $Id$ Chris@101: // $Date$ Chris@101: // $Revision$ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: namespace aux { Chris@16: struct pair_iter_tag; Chris@16: Chris@16: #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: template< typename Iter1, typename Iter2, typename Category > Chris@16: struct pair_iter; Chris@16: Chris@16: template< typename Category > struct prior_pair_iter Chris@16: { Chris@16: template< typename Iter1, typename Iter2 > struct apply Chris@16: { Chris@16: typedef typename mpl::prior::type i1_; Chris@16: typedef typename mpl::prior::type i2_; Chris@16: typedef pair_iter type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> struct prior_pair_iter Chris@16: { Chris@16: template< typename Iter1, typename Iter2 > struct apply Chris@16: { Chris@16: typedef pair_iter type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: #endif Chris@16: } Chris@16: Chris@16: template< Chris@16: typename Iter1 Chris@16: , typename Iter2 Chris@16: , typename Category Chris@16: > Chris@16: struct pair_iter Chris@16: { Chris@16: typedef aux::pair_iter_tag tag; Chris@16: typedef Category category; Chris@16: typedef Iter1 first; Chris@16: typedef Iter2 second; Chris@16: Chris@16: #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: typedef pair< Chris@16: typename deref::type Chris@16: , typename deref::type Chris@16: > type; Chris@16: Chris@16: typedef typename mpl::next::type i1_; Chris@16: typedef typename mpl::next::type i2_; Chris@16: typedef pair_iter next; Chris@16: Chris@16: typedef apply_wrap2< aux::prior_pair_iter,Iter1,Iter2 >::type prior; Chris@16: #endif Chris@16: }; Chris@16: Chris@16: Chris@16: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: template< typename Iter1, typename Iter2, typename C > Chris@16: struct deref< pair_iter > Chris@16: { Chris@16: typedef pair< Chris@16: typename deref::type Chris@16: , typename deref::type Chris@16: > type; Chris@16: }; Chris@16: Chris@16: template< typename Iter1, typename Iter2, typename C > Chris@16: struct next< pair_iter > Chris@16: { Chris@16: typedef typename mpl::next::type i1_; Chris@16: typedef typename mpl::next::type i2_; Chris@16: typedef pair_iter type; Chris@16: }; Chris@16: Chris@16: template< typename Iter1, typename Iter2, typename C > Chris@16: struct prior< pair_iter > Chris@16: { Chris@16: typedef typename mpl::prior::type i1_; Chris@16: typedef typename mpl::prior::type i2_; Chris@16: typedef pair_iter type; Chris@16: }; Chris@16: Chris@16: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: Chris@16: Chris@16: template<> struct advance_impl Chris@16: { Chris@16: template< typename Iter, typename D > struct apply Chris@16: { Chris@16: typedef typename mpl::advance< typename Iter::first,D >::type i1_; Chris@16: typedef typename mpl::advance< typename Iter::second,D >::type i2_; Chris@16: typedef pair_iter type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> struct distance_impl Chris@16: { Chris@16: template< typename Iter1, typename Iter2 > struct apply Chris@16: { Chris@16: // agurt, 10/nov/04: MSVC 6.5 ICE-s on forwarding Chris@16: typedef typename mpl::distance< Chris@16: typename first::type Chris@16: , typename first::type Chris@16: >::type type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(Sequence1) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(Sequence2) Chris@16: > Chris@16: struct pair_view Chris@16: { Chris@16: typedef nested_begin_end_tag tag; Chris@16: Chris@16: typedef typename begin::type iter1_; Chris@16: typedef typename begin::type iter2_; Chris@16: typedef typename min< Chris@16: typename iterator_category::type Chris@16: , typename iterator_category::type Chris@16: >::type category_; Chris@16: Chris@16: typedef pair_iter begin; Chris@16: Chris@16: typedef pair_iter< Chris@16: typename end::type Chris@16: , typename end::type Chris@16: , category_ Chris@16: > end; Chris@16: }; Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC(2, pair_view) Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_PAIR_VIEW_HPP_INCLUDED