epoc32/include/stdapis/boost/range/sub_range.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/range/sub_range.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,170 @@
     1.4 +// Boost.Range library
     1.5 +//
     1.6 +//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
     1.7 +//  distribution is subject to the Boost Software License, Version
     1.8 +//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
     1.9 +//  http://www.boost.org/LICENSE_1_0.txt)
    1.10 +//
    1.11 +// For more information, see http://www.boost.org/libs/range/
    1.12 +//
    1.13 +
    1.14 +#ifndef BOOST_RANGE_SUB_RANGE_HPP
    1.15 +#define BOOST_RANGE_SUB_RANGE_HPP
    1.16 +
    1.17 +#include <boost/range/config.hpp>
    1.18 +#include <boost/range/iterator_range.hpp>
    1.19 +#include <boost/range/value_type.hpp>
    1.20 +#include <boost/range/result_iterator.hpp>
    1.21 +#include <boost/range/size_type.hpp>
    1.22 +#include <boost/range/difference_type.hpp>
    1.23 +#include <boost/assert.hpp>
    1.24 +
    1.25 +namespace boost
    1.26 +{
    1.27 +    
    1.28 +    template< class ForwardRange > 
    1.29 +    class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type > 
    1.30 +    {
    1.31 +        typedef BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type iterator_t;
    1.32 +        typedef iterator_range< iterator_t  > base;
    1.33 +
    1.34 +        typedef BOOST_DEDUCED_TYPENAME base::impl impl;
    1.35 +    public:
    1.36 +        typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type            value_type;
    1.37 +        typedef BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type  iterator;
    1.38 +        typedef BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type   const_iterator;
    1.39 +        typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type       difference_type;
    1.40 +        typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type             size_type;
    1.41 +        typedef BOOST_DEDUCED_TYPENAME base::reference                            reference;
    1.42 +        typedef BOOST_DEDUCED_TYPENAME iterator_reference<const_iterator>::type   const_reference;
    1.43 +
    1.44 +    public:
    1.45 +        sub_range() : base() 
    1.46 +        { }
    1.47 +
    1.48 +/*        
    1.49 +        template< class ForwardRange2 >
    1.50 +        sub_range( sub_range<ForwardRange2> r ) :
    1.51 +
    1.52 +#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
    1.53 +            base( impl::adl_begin( r ), impl::adl_end( r ) )
    1.54 +#else
    1.55 +            base( r )
    1.56 +#endif */
    1.57 +
    1.58 +        template< class ForwardRange2 >
    1.59 +        sub_range( ForwardRange2& r ) : 
    1.60 +            
    1.61 +#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
    1.62 +            base( impl::adl_begin( r ), impl::adl_end( r ) )
    1.63 +#else
    1.64 +            base( r )
    1.65 +#endif        
    1.66 +        { }
    1.67 +        
    1.68 +        template< class ForwardRange2 >
    1.69 +        sub_range( const ForwardRange2& r ) : 
    1.70 +
    1.71 +#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
    1.72 +            base( impl::adl_begin( r ), impl::adl_end( r ) )
    1.73 +#else
    1.74 +            base( r )
    1.75 +#endif                
    1.76 +        { }
    1.77 +
    1.78 +        template< class Iter >
    1.79 +        sub_range( Iter first, Iter last ) :
    1.80 +            base( first, last )
    1.81 +        { }
    1.82 +        
    1.83 +        template< class ForwardRange2 >
    1.84 +        sub_range& operator=( ForwardRange2& r )
    1.85 +        {
    1.86 +            base::operator=( r );
    1.87 +            return *this;
    1.88 +        }
    1.89 +
    1.90 +        template< class ForwardRange2 >
    1.91 +        sub_range& operator=( const ForwardRange2& r )
    1.92 +        {
    1.93 +            base::operator=( r );
    1.94 +            return *this;
    1.95 +        }
    1.96 +
    1.97 +        sub_range& operator=( sub_range r )
    1.98 +        {
    1.99 +            //
   1.100 +            // argument passed by value to avoid 
   1.101 +            // const_iterator to iterator conversion
   1.102 +            //
   1.103 +            base::operator=( r );
   1.104 +            return *this;            
   1.105 +        }
   1.106 +        
   1.107 +    public:
   1.108 +        
   1.109 +        iterator        begin()          { return base::begin(); }
   1.110 +        const_iterator  begin() const    { return base::begin(); }
   1.111 +        iterator        end()            { return base::end();   }
   1.112 +        const_iterator  end() const      { return base::end();   }
   1.113 +        size_type       size() const     { return base::size();  }   
   1.114 +
   1.115 +        
   1.116 +    public: // convenience
   1.117 +        reference front()
   1.118 +        {
   1.119 +            return base::front();
   1.120 +        }
   1.121 +
   1.122 +        const_reference front() const
   1.123 +        {
   1.124 +            return base::front();
   1.125 +        }
   1.126 +
   1.127 +        reference back()
   1.128 +        {
   1.129 +            return base::back();
   1.130 +        }
   1.131 +
   1.132 +        const_reference back() const
   1.133 +        {
   1.134 +            return base::back();
   1.135 +        }
   1.136 +
   1.137 +        reference operator[]( size_type sz )
   1.138 +        {
   1.139 +            return base::operator[](sz);
   1.140 +        }
   1.141 +
   1.142 +        const_reference operator[]( size_type sz ) const
   1.143 +        {
   1.144 +            return base::operator[](sz);
   1.145 +        }
   1.146 +
   1.147 +    };
   1.148 +
   1.149 +    template< class ForwardRange, class ForwardRange2 >
   1.150 +    inline bool operator==( const sub_range<ForwardRange>& l,
   1.151 +                            const sub_range<ForwardRange2>& r )
   1.152 +    {
   1.153 +        return iterator_range_detail::equal( l, r );
   1.154 +    }
   1.155 +
   1.156 +    template< class ForwardRange, class ForwardRange2 >
   1.157 +    inline bool operator!=( const sub_range<ForwardRange>& l,
   1.158 +                            const sub_range<ForwardRange2>& r )
   1.159 +    {
   1.160 +        return !iterator_range_detail::equal( l, r );
   1.161 +    }
   1.162 +
   1.163 +    template< class ForwardRange, class ForwardRange2 >
   1.164 +    inline bool operator<( const sub_range<ForwardRange>& l,
   1.165 +                           const sub_range<ForwardRange2>& r )
   1.166 +    {
   1.167 +        return iterator_range_detail::less_than( l, r );
   1.168 +    }
   1.169 +
   1.170 +
   1.171 +} // namespace 'boost'
   1.172 +
   1.173 +#endif