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