Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:41:54

0001 
0002 #ifndef BOOST_MPL_AUX_VECTOR_ITERATOR_HPP_INCLUDED
0003 #define BOOST_MPL_AUX_VECTOR_ITERATOR_HPP_INCLUDED
0004 
0005 // Copyright Aleksey Gurtovoy 2000-2004
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. 
0008 // (See accompanying file LICENSE_1_0.txt or copy at 
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // See http://www.boost.org/libs/mpl for documentation.
0012 
0013 // $Id$
0014 // $Date$
0015 // $Revision$
0016 
0017 #include <boost/mpl/vector/aux_/at.hpp>
0018 #include <boost/mpl/iterator_tags.hpp>
0019 #include <boost/mpl/plus.hpp>
0020 #include <boost/mpl/minus.hpp>
0021 #include <boost/mpl/advance_fwd.hpp>
0022 #include <boost/mpl/distance_fwd.hpp>
0023 #include <boost/mpl/next.hpp>
0024 #include <boost/mpl/prior.hpp>
0025 #include <boost/mpl/aux_/nttp_decl.hpp>
0026 #include <boost/mpl/aux_/value_wknd.hpp>
0027 #include <boost/mpl/aux_/config/ctps.hpp>
0028 #include <boost/mpl/aux_/config/workaround.hpp>
0029 
0030 namespace boost { namespace mpl {
0031 
0032 template<
0033       typename Vector
0034     , BOOST_MPL_AUX_NTTP_DECL(long, n_)
0035     >
0036 struct v_iter
0037 {
0038     typedef aux::v_iter_tag tag;
0039     typedef random_access_iterator_tag category;
0040     typedef typename v_at<Vector,n_>::type type;
0041 
0042     typedef Vector vector_;
0043     typedef mpl::long_<n_> pos;
0044 
0045 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0046     enum { 
0047           next_ = n_ + 1
0048         , prior_ = n_ - 1
0049         , pos_ = n_
0050     };
0051     
0052     typedef v_iter<Vector,next_> next;
0053     typedef v_iter<Vector,prior_> prior;
0054 #endif
0055 
0056 };
0057 
0058 
0059 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0060 
0061 template<
0062       typename Vector
0063     , BOOST_MPL_AUX_NTTP_DECL(long, n_)
0064     >
0065 struct next< v_iter<Vector,n_> >
0066 {
0067     typedef v_iter<Vector,(n_ + 1)> type;
0068 };
0069 
0070 template<
0071       typename Vector
0072     , BOOST_MPL_AUX_NTTP_DECL(long, n_)
0073     >
0074 struct prior< v_iter<Vector,n_> >
0075 {
0076     typedef v_iter<Vector,(n_ - 1)> type;
0077 };
0078 
0079 template<
0080       typename Vector
0081     , BOOST_MPL_AUX_NTTP_DECL(long, n_)
0082     , typename Distance
0083     >
0084 struct advance< v_iter<Vector,n_>,Distance>
0085 {
0086     typedef v_iter<
0087           Vector
0088         , (n_ + BOOST_MPL_AUX_NESTED_VALUE_WKND(long, Distance))
0089         > type;
0090 };
0091 
0092 template< 
0093       typename Vector
0094     , BOOST_MPL_AUX_NTTP_DECL(long, n_)
0095     , BOOST_MPL_AUX_NTTP_DECL(long, m_)
0096     > 
0097 struct distance< v_iter<Vector,n_>, v_iter<Vector,m_> >
0098     : mpl::long_<(m_ - n_)>
0099 {
0100 };
0101 
0102 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
0103 
0104 template<> struct advance_impl<aux::v_iter_tag>
0105 {
0106     template< typename Iterator, typename N > struct apply
0107     {
0108         enum { pos_ = Iterator::pos_, n_ = N::value };
0109         typedef v_iter<
0110               typename Iterator::vector_
0111             , (pos_ + n_)
0112             > type;
0113     };
0114 };
0115 
0116 template<> struct distance_impl<aux::v_iter_tag>
0117 {
0118     template< typename Iter1, typename Iter2 > struct apply
0119     {
0120         enum { pos1_ = Iter1::pos_, pos2_ = Iter2::pos_ };
0121         typedef long_<( pos2_ - pos1_ )> type;
0122         BOOST_STATIC_CONSTANT(long, value = ( pos2_ - pos1_ ));
0123     };
0124 };
0125 
0126 #endif
0127 
0128 }}
0129 
0130 #endif // BOOST_MPL_AUX_VECTOR_ITERATOR_HPP_INCLUDED