1 |
|
---|
2 | #ifndef BOOST_MPL_AUX_RANGE_C_ITERATOR_HPP_INCLUDED
|
---|
3 | #define BOOST_MPL_AUX_RANGE_C_ITERATOR_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 | // $Source: /cvsroot/boost/boost/boost/mpl/aux_/range_c/iterator.hpp,v $
|
---|
14 | // $Date: 2004/12/20 17:52:43 $
|
---|
15 | // $Revision: 1.8 $
|
---|
16 |
|
---|
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/plus.hpp>
|
---|
23 | #include <boost/mpl/minus.hpp>
|
---|
24 | #include <boost/mpl/aux_/value_wknd.hpp>
|
---|
25 | #include <boost/mpl/aux_/config/ctps.hpp>
|
---|
26 |
|
---|
27 | namespace boost { namespace mpl {
|
---|
28 |
|
---|
29 | // theoretically will work on any discrete numeric type
|
---|
30 | template< typename N > struct r_iter
|
---|
31 | {
|
---|
32 | typedef aux::r_iter_tag tag;
|
---|
33 | typedef random_access_iterator_tag category;
|
---|
34 | typedef N type;
|
---|
35 |
|
---|
36 | #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
---|
37 | typedef r_iter< typename mpl::next<N>::type > next;
|
---|
38 | typedef r_iter< typename mpl::prior<N>::type > prior;
|
---|
39 | #endif
|
---|
40 | };
|
---|
41 |
|
---|
42 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
---|
43 |
|
---|
44 | template<
|
---|
45 | typename N
|
---|
46 | >
|
---|
47 | struct next< r_iter<N> >
|
---|
48 | {
|
---|
49 | typedef r_iter< typename mpl::next<N>::type > type;
|
---|
50 | };
|
---|
51 |
|
---|
52 | template<
|
---|
53 | typename N
|
---|
54 | >
|
---|
55 | struct prior< r_iter<N> >
|
---|
56 | {
|
---|
57 | typedef r_iter< typename mpl::prior<N>::type > type;
|
---|
58 | };
|
---|
59 |
|
---|
60 | #endif
|
---|
61 |
|
---|
62 |
|
---|
63 | template<> struct advance_impl<aux::r_iter_tag>
|
---|
64 | {
|
---|
65 | template< typename Iter, typename Dist > struct apply
|
---|
66 | {
|
---|
67 | typedef typename deref<Iter>::type n_;
|
---|
68 | #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
69 | typedef typename plus_impl<integral_c_tag,integral_c_tag>
|
---|
70 | ::template apply<n_,Dist>::type m_;
|
---|
71 | #else
|
---|
72 | typedef typename plus<n_,Dist>::type m_;
|
---|
73 | #endif
|
---|
74 | // agurt, 10/nov/04: to be generic, the code have to do something along
|
---|
75 | // the lines below...
|
---|
76 | //
|
---|
77 | // typedef typename apply_wrap1<
|
---|
78 | // numeric_cast< typename m_::tag, typename n_::tag >
|
---|
79 | // , m_
|
---|
80 | // >::type result_;
|
---|
81 | //
|
---|
82 | // ... meanwhile:
|
---|
83 |
|
---|
84 | typedef integral_c<
|
---|
85 | typename aux::value_type_wknd<n_>::type
|
---|
86 | , BOOST_MPL_AUX_VALUE_WKND(m_)::value
|
---|
87 | > result_;
|
---|
88 |
|
---|
89 | typedef r_iter<result_> type;
|
---|
90 | };
|
---|
91 | };
|
---|
92 |
|
---|
93 | template<> struct distance_impl<aux::r_iter_tag>
|
---|
94 | {
|
---|
95 | template< typename Iter1, typename Iter2 > struct apply
|
---|
96 | : minus<
|
---|
97 | typename Iter2::type
|
---|
98 | , typename Iter1::type
|
---|
99 | >
|
---|
100 | {
|
---|
101 | };
|
---|
102 | };
|
---|
103 |
|
---|
104 | }}
|
---|
105 |
|
---|
106 | #endif // BOOST_MPL_AUX_RANGE_C_ITERATOR_HPP_INCLUDED
|
---|