File indexing completed on 2025-01-18 09:41:38
0001
0002 #ifndef BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
0003 #define BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <boost/mpl/iterator_tags.hpp>
0018 #include <boost/mpl/advance_fwd.hpp>
0019 #include <boost/mpl/distance_fwd.hpp>
0020 #include <boost/mpl/next_prior.hpp>
0021 #include <boost/mpl/deref.hpp>
0022 #include <boost/mpl/int.hpp>
0023 #include <boost/mpl/aux_/nttp_decl.hpp>
0024 #include <boost/mpl/aux_/value_wknd.hpp>
0025 #include <boost/mpl/aux_/config/ctps.hpp>
0026
0027 namespace boost { namespace mpl {
0028
0029 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0030
0031 namespace aux {
0032
0033 template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, is_last_) >
0034 struct sel_iter;
0035
0036 template< typename T >
0037 struct sel_iter<T,0>
0038 {
0039 typedef random_access_iterator_tag category;
0040 typedef sel_iter<T,1> next;
0041 typedef T type;
0042 };
0043
0044 template< typename T >
0045 struct sel_iter<T,1>
0046 {
0047 typedef random_access_iterator_tag category;
0048 typedef sel_iter<T,0> prior;
0049 };
0050
0051 }
0052
0053 template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, is_last_), typename Distance >
0054 struct advance< aux::sel_iter<T,is_last_>,Distance>
0055 {
0056 typedef aux::sel_iter<
0057 T
0058 , ( is_last_ + BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Distance) )
0059 > type;
0060 };
0061
0062 template<
0063 typename T
0064 , BOOST_MPL_AUX_NTTP_DECL(int, l1)
0065 , BOOST_MPL_AUX_NTTP_DECL(int, l2)
0066 >
0067 struct distance< aux::sel_iter<T,l1>, aux::sel_iter<T,l2> >
0068 : int_<( l2 - l1 )>
0069 {
0070 };
0071
0072 #else
0073
0074 namespace aux {
0075
0076 struct sel_iter_tag;
0077
0078 template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, is_last_) >
0079 struct sel_iter
0080 {
0081 enum { pos_ = is_last_ };
0082 typedef aux::sel_iter_tag tag;
0083 typedef random_access_iterator_tag category;
0084
0085 typedef sel_iter<T,(is_last_ + 1)> next;
0086 typedef sel_iter<T,(is_last_ - 1)> prior;
0087 typedef T type;
0088 };
0089
0090 }
0091
0092 template<> struct advance_impl<aux::sel_iter_tag>
0093 {
0094 template< typename Iterator, typename N > struct apply
0095 {
0096 enum { pos_ = Iterator::pos_, n_ = N::value };
0097 typedef aux::sel_iter<
0098 typename Iterator::type
0099 , (pos_ + n_)
0100 > type;
0101 };
0102 };
0103
0104 template<> struct distance_impl<aux::sel_iter_tag>
0105 {
0106 template< typename Iter1, typename Iter2 > struct apply
0107 {
0108 enum { pos1_ = Iter1::pos_, pos2_ = Iter2::pos_ };
0109 typedef int_<( pos2_ - pos1_ )> type;
0110 BOOST_STATIC_CONSTANT(int, value = ( pos2_ - pos1_ ));
0111 };
0112 };
0113
0114 #endif
0115
0116 }}
0117
0118 #endif