epoc32/include/stdapis/boost/range/begin.hpp
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 // Boost.Range library
       
     2 //
       
     3 //  Copyright Thorsten Ottosen 2003-2004. Use, modification and
       
     4 //  distribution is subject to the Boost Software License, Version
       
     5 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
       
     6 //  http://www.boost.org/LICENSE_1_0.txt)
       
     7 //
       
     8 // For more information, see http://www.boost.org/libs/range/
       
     9 //
       
    10 
       
    11 #ifndef BOOST_RANGE_BEGIN_HPP
       
    12 #define BOOST_RANGE_BEGIN_HPP
       
    13 
       
    14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
       
    15 # pragma once
       
    16 #endif
       
    17 
       
    18 #include <boost/type_traits/remove_const.hpp>
       
    19 #include <boost/range/config.hpp>
       
    20 
       
    21 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
       
    22 #include <boost/range/detail/begin.hpp>
       
    23 #else
       
    24 
       
    25 #include <boost/range/iterator.hpp>
       
    26 #include <boost/range/const_iterator.hpp>
       
    27 
       
    28 namespace boost
       
    29 {
       
    30 
       
    31 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
       
    32     !BOOST_WORKAROUND(__GNUC__, < 3) \
       
    33     /**/
       
    34 namespace range_detail
       
    35 {
       
    36 #endif
       
    37 
       
    38     //////////////////////////////////////////////////////////////////////
       
    39     // primary template
       
    40     //////////////////////////////////////////////////////////////////////
       
    41 
       
    42     template< typename C >
       
    43     inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
       
    44     boost_range_begin( const C& c )
       
    45     {
       
    46         return c.begin();
       
    47     }
       
    48 
       
    49     template< typename C >
       
    50     inline BOOST_DEDUCED_TYPENAME range_iterator<
       
    51                                                                         typename remove_const<C>::type >::type
       
    52     boost_range_begin( C& c )
       
    53     {
       
    54         return c.begin();
       
    55     }
       
    56 
       
    57     //////////////////////////////////////////////////////////////////////
       
    58     // pair
       
    59     //////////////////////////////////////////////////////////////////////
       
    60 
       
    61     template< typename Iterator >
       
    62     inline Iterator boost_range_begin( const std::pair<Iterator,Iterator>& p )
       
    63     {
       
    64         return p.first;
       
    65     }
       
    66 
       
    67     template< typename Iterator >
       
    68     inline Iterator boost_range_begin( std::pair<Iterator,Iterator>& p )
       
    69     {
       
    70         return p.first;
       
    71     }
       
    72 
       
    73     //////////////////////////////////////////////////////////////////////
       
    74     // array
       
    75     //////////////////////////////////////////////////////////////////////
       
    76 
       
    77     template< typename T, std::size_t sz >
       
    78     inline const T* boost_range_begin( const T (&array)[sz] )
       
    79     {
       
    80         return array;
       
    81     }
       
    82 
       
    83     template< typename T, std::size_t sz >
       
    84     inline T* boost_range_begin( T (&array)[sz] )
       
    85     {
       
    86         return array;
       
    87     }
       
    88 
       
    89 
       
    90     //////////////////////////////////////////////////////////////////////
       
    91     // string
       
    92     //////////////////////////////////////////////////////////////////////
       
    93 
       
    94 #if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
       
    95 // CW up to 9.3 and borland have troubles with function ordering
       
    96     inline const char* boost_range_begin( const char* s )
       
    97     {
       
    98         return s;
       
    99     }
       
   100 
       
   101     inline char* boost_range_begin( char* s )
       
   102     {
       
   103         return s;
       
   104     }
       
   105 
       
   106     inline const wchar_t* boost_range_begin( const wchar_t* s )
       
   107     {
       
   108         return s;
       
   109     }
       
   110 
       
   111     inline wchar_t* boost_range_begin( wchar_t* s )
       
   112     {
       
   113         return s;
       
   114     }
       
   115 #else
       
   116     inline const char* boost_range_begin( const char*& s )
       
   117     {
       
   118         return s;
       
   119     }
       
   120 
       
   121     inline char* boost_range_begin( char*& s )
       
   122     {
       
   123         return s;
       
   124     }
       
   125 
       
   126     inline const wchar_t* boost_range_begin( const wchar_t*& s )
       
   127     {
       
   128         return s;
       
   129     }
       
   130 
       
   131     inline wchar_t* boost_range_begin( wchar_t*& s )
       
   132     {
       
   133         return s;
       
   134     }
       
   135 #endif
       
   136 
       
   137 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
       
   138     !BOOST_WORKAROUND(__GNUC__, < 3) \
       
   139     /**/
       
   140 } // namespace 'range_detail'
       
   141 #endif
       
   142 
       
   143 
       
   144 template< class T >
       
   145 inline BOOST_DEDUCED_TYPENAME range_iterator<
       
   146                         typename remove_const<T>::type >::type begin( T& r )
       
   147 {
       
   148 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
       
   149     !BOOST_WORKAROUND(__GNUC__, < 3) \
       
   150     /**/
       
   151     using namespace range_detail;
       
   152 #endif
       
   153     return boost_range_begin( r );
       
   154 }
       
   155 
       
   156 template< class T >
       
   157 inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type begin( const T& r )
       
   158 {
       
   159 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
       
   160     !BOOST_WORKAROUND(__GNUC__, < 3) \
       
   161     /**/
       
   162     using namespace range_detail;
       
   163 #endif
       
   164     return boost_range_begin( r );
       
   165 }
       
   166 
       
   167 #if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
       
   168 // BCB and CW are not able to overload pointer when class overloads are also available.
       
   169 template<>
       
   170 inline range_const_iterator<const char*>::type begin<const char*>( const char*& r )
       
   171 {
       
   172     return r;
       
   173 }
       
   174 
       
   175 template<>
       
   176 inline range_const_iterator<const wchar_t*>::type begin<const wchar_t*>( const wchar_t*& r )
       
   177 {
       
   178     return r;
       
   179 }
       
   180 
       
   181 #endif
       
   182 
       
   183 } // namespace boost
       
   184 
       
   185 #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
       
   186 
       
   187 namespace boost
       
   188 {
       
   189     template< class T >
       
   190     inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
       
   191     const_begin( const T& r )
       
   192     {
       
   193         return boost::begin( r );
       
   194     }
       
   195 }
       
   196 
       
   197 #endif