2 #ifndef BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
\r
3 #define BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
\r
5 // Copyright Aleksey Gurtovoy 2000-2004
\r
7 // Distributed under the Boost Software License, Version 1.0.
\r
8 // (See accompanying file LICENSE_1_0.txt or copy at
\r
9 // http://www.boost.org/LICENSE_1_0.txt)
\r
11 // See http://www.boost.org/libs/mpl for documentation.
\r
13 // $Id: single_element_iter.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
\r
14 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
\r
15 // $Revision: 49267 $
\r
17 #include <boost/mpl/iterator_tags.hpp>
\r
18 #include <boost/mpl/advance_fwd.hpp>
\r
19 #include <boost/mpl/distance_fwd.hpp>
\r
20 #include <boost/mpl/next_prior.hpp>
\r
21 #include <boost/mpl/deref.hpp>
\r
22 #include <boost/mpl/int.hpp>
\r
23 #include <boost/mpl/aux_/nttp_decl.hpp>
\r
24 #include <boost/mpl/aux_/value_wknd.hpp>
\r
25 #include <boost/mpl/aux_/config/ctps.hpp>
\r
27 namespace boost { namespace mpl {
\r
29 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
33 template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, is_last_) >
\r
36 template< typename T >
\r
37 struct sel_iter<T,0>
\r
39 typedef random_access_iterator_tag category;
\r
40 typedef sel_iter<T,1> next;
\r
44 template< typename T >
\r
45 struct sel_iter<T,1>
\r
47 typedef random_access_iterator_tag category;
\r
48 typedef sel_iter<T,0> prior;
\r
53 template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, is_last_), typename Distance >
\r
54 struct advance< aux::sel_iter<T,is_last_>,Distance>
\r
56 typedef aux::sel_iter<
\r
58 , ( is_last_ + BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Distance) )
\r
64 , BOOST_MPL_AUX_NTTP_DECL(int, l1)
\r
65 , BOOST_MPL_AUX_NTTP_DECL(int, l2)
\r
67 struct distance< aux::sel_iter<T,l1>, aux::sel_iter<T,l2> >
\r
76 struct sel_iter_tag;
\r
78 template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, is_last_) >
\r
81 enum { pos_ = is_last_ };
\r
82 typedef aux::sel_iter_tag tag;
\r
83 typedef random_access_iterator_tag category;
\r
85 typedef sel_iter<T,(is_last_ + 1)> next;
\r
86 typedef sel_iter<T,(is_last_ - 1)> prior;
\r
92 template<> struct advance_impl<aux::sel_iter_tag>
\r
94 template< typename Iterator, typename N > struct apply
\r
96 enum { pos_ = Iterator::pos_, n_ = N::value };
\r
97 typedef aux::sel_iter<
\r
98 typename Iterator::type
\r
104 template<> struct distance_impl<aux::sel_iter_tag>
\r
106 template< typename Iter1, typename Iter2 > struct apply
\r
108 enum { pos1_ = Iter1::pos_, pos2_ = Iter2::pos_ };
\r
109 typedef int_<( pos2_ - pos1_ )> type;
\r
110 BOOST_STATIC_CONSTANT(int, value = ( pos2_ - pos1_ ));
\r
114 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
\r
118 #endif // BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
\r