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