Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:35

0001 //
0002 // Boost.Pointer Container
0003 //
0004 //  Copyright Thorsten Ottosen 2003-2005. Use, modification and
0005 //  distribution is subject to the Boost Software License, Version
0006 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007 //  http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // For more information, see http://www.boost.org/libs/ptr_container/
0010 //
0011 
0012 #ifndef BOOST_PTR_CONTAINER_DETAIL_VOID_PTR_ITERATOR_HPP
0013 #define BOOST_PTR_CONTAINER_DETAIL_VOID_PTR_ITERATOR_HPP
0014 
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 #include <boost/iterator/iterator_traits.hpp>
0021 #include <boost/type_traits/remove_const.hpp>
0022 
0023 namespace boost
0024 {
0025         template
0026         <
0027             class VoidIter,
0028             class T
0029         >
0030         class void_ptr_iterator
0031         {
0032         public:
0033             typedef BOOST_DEDUCED_TYPENAME boost::remove_const<T>::type
0034                              value_type;
0035             typedef T&       reference;
0036             typedef T*       pointer;
0037 
0038             typedef  BOOST_DEDUCED_TYPENAME iterator_difference<VoidIter>::type
0039                              difference_type;
0040             typedef  BOOST_DEDUCED_TYPENAME iterator_category<VoidIter>::type
0041                              iterator_category;
0042         private:
0043 
0044             VoidIter iter_;
0045 
0046         public:
0047             void_ptr_iterator() : iter_()
0048             { }
0049 
0050             void_ptr_iterator( VoidIter r ) : iter_(r)
0051             { }
0052 
0053             //
0054             // Remark: passing by value breaks vc7.1
0055             //
0056             template< class MutableIterator, class MutableT >
0057             void_ptr_iterator( const void_ptr_iterator<MutableIterator,MutableT>& r )
0058 #ifdef BOOST_NO_SFINAE
0059                          : iter_( VoidIter(const_cast<void**>(&*r.base())) )
0060 #else
0061 
0062              : iter_(r.base())
0063 #endif
0064             { }
0065 
0066             T& operator*() const
0067             {
0068                 return *static_cast<T*>( *iter_ );
0069             }
0070 
0071             T* operator->() const
0072             {
0073                 return static_cast<T*>( *iter_ );
0074             }
0075 
0076             void_ptr_iterator& operator++()
0077             {
0078                 ++iter_;
0079                 return *this;
0080             }
0081 
0082             void_ptr_iterator operator++(int)
0083             {
0084                 void_ptr_iterator res = *this;
0085                 ++iter_;
0086                 return res;
0087             }
0088 
0089             void_ptr_iterator& operator--()
0090             {
0091                 --iter_;
0092                 return *this;
0093             }
0094 
0095             void_ptr_iterator operator--(int)
0096             {
0097                 void_ptr_iterator res = *this;
0098                 --iter_;
0099                 return res;
0100             }
0101 
0102             void_ptr_iterator& operator+=( difference_type n )
0103             {
0104                 iter_ += n;
0105                 return *this;
0106             }
0107 
0108             void_ptr_iterator& operator-=( difference_type n )
0109             {
0110                 iter_ -= n;
0111                 return *this;
0112             }
0113 
0114             T& operator[]( difference_type n ) const
0115             {
0116                 return *static_cast<T*>( *(iter_ + n) );
0117             }
0118 
0119             VoidIter base() const
0120             {
0121                 return iter_;
0122             }
0123 
0124         }; // class 'void_ptr_iterator'
0125 
0126         template< class VoidIter, class T >
0127         inline void_ptr_iterator<VoidIter,T>
0128         operator+( void_ptr_iterator<VoidIter,T> l,
0129                    BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n )
0130         {
0131             l += n;
0132             return l;
0133         }
0134 
0135         template< class VoidIter, class T >
0136         inline void_ptr_iterator<VoidIter,T>
0137         operator+( BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n,
0138                    void_ptr_iterator<VoidIter,T> r )
0139 
0140         {
0141             r += n;
0142             return r;
0143         }
0144 
0145         template< class VoidIter, class T >
0146         inline void_ptr_iterator<VoidIter,T>
0147         operator-( void_ptr_iterator<VoidIter,T> l,
0148                    BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n )
0149         {
0150             l -= n;
0151             return l;
0152         }
0153 
0154         template< class VoidIter, class T >
0155         inline void_ptr_iterator<VoidIter,T>
0156         operator-( BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n,
0157                    void_ptr_iterator<VoidIter,T> r )
0158 
0159         {
0160             r -= n;
0161             return r;
0162         }
0163 
0164 
0165         namespace ptr_container_detail
0166         {
0167             template<typename T, typename U>
0168             struct is_compatible
0169             {
0170                 static const bool value = boost::is_same< typename boost::remove_const<T>::type, typename boost::remove_const<U>::type >::value;
0171             };
0172         }
0173 
0174 
0175         template< class VoidIter, class T, class VoidIterU, class U >
0176         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0177             ptr_container_detail::is_compatible<T, U>,
0178             BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type
0179         >::type
0180         operator-( void_ptr_iterator<VoidIter,T> l,
0181                    void_ptr_iterator<VoidIterU,U> r )
0182 
0183         {
0184             return l.base() - r.base();
0185         }
0186 
0187 
0188 
0189         template< class VoidIterT, class T, class VoidIterU, class U >
0190         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0191             ptr_container_detail::is_compatible<T, U>,
0192             bool
0193         >::type
0194         operator==( const void_ptr_iterator<VoidIterT,T>& l,
0195                                 const void_ptr_iterator<VoidIterU,U>& r )
0196         {
0197             return l.base() == r.base();
0198         }
0199 
0200 
0201 
0202         template< class VoidIterT, class T, class VoidIterU, class U >
0203         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0204             ptr_container_detail::is_compatible<T, U>,
0205             bool
0206         >::type
0207         operator!=( const void_ptr_iterator<VoidIterT,T>& l,
0208                                 const void_ptr_iterator<VoidIterU,U>& r )
0209         {
0210             return l.base() != r.base();
0211         }
0212 
0213 
0214 
0215         template< class VoidIterT, class T, class VoidIterU, class U >
0216         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0217             ptr_container_detail::is_compatible<T, U>,
0218             bool
0219         >::type
0220         operator<( const void_ptr_iterator<VoidIterT,T>& l,
0221                                const void_ptr_iterator<VoidIterU,U>& r )
0222         {
0223             return l.base() < r.base();
0224         }
0225 
0226 
0227 
0228         template< class VoidIterT, class T, class VoidIterU, class U >
0229         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0230             ptr_container_detail::is_compatible<T, U>,
0231             bool
0232         >::type
0233         operator<=( const void_ptr_iterator<VoidIterT,T>& l,
0234                                const void_ptr_iterator<VoidIterU,U>& r )
0235         {
0236             return l.base() <= r.base();
0237         }
0238 
0239 
0240 
0241         template< class VoidIterT, class T, class VoidIterU, class U >
0242         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0243             ptr_container_detail::is_compatible<T, U>,
0244             bool
0245         >::type
0246         operator>( const void_ptr_iterator<VoidIterT,T>& l,
0247                                const void_ptr_iterator<VoidIterU,U>& r )
0248         {
0249             return l.base() > r.base();
0250         }
0251 
0252 
0253 
0254         template< class VoidIterT, class T, class VoidIterU, class U >
0255         inline BOOST_DEDUCED_TYPENAME boost::enable_if<
0256             ptr_container_detail::is_compatible<T, U>,
0257             bool
0258         >::type
0259         operator>=( const void_ptr_iterator<VoidIterT,T>& l,
0260                                const void_ptr_iterator<VoidIterU,U>& r )
0261         {
0262             return l.base() >= r.base();
0263         }
0264 
0265 }
0266 
0267 #endif