os/ossrv/ossrv_pub/boost_apis/boost/range/detail/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_DETAIL_BEGIN_HPP
sl@0
    12
#define BOOST_RANGE_DETAIL_BEGIN_HPP
sl@0
    13
sl@0
    14
#include <boost/config.hpp> // BOOST_MSVC
sl@0
    15
#include <boost/detail/workaround.hpp>
sl@0
    16
#include <boost/range/result_iterator.hpp>
sl@0
    17
#include <boost/range/detail/common.hpp>
sl@0
    18
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
sl@0
    19
# include <boost/range/value_type.hpp>
sl@0
    20
#endif
sl@0
    21
sl@0
    22
namespace boost 
sl@0
    23
{
sl@0
    24
    
sl@0
    25
    namespace range_detail
sl@0
    26
    {
sl@0
    27
        template< typename T >
sl@0
    28
        struct range_begin;
sl@0
    29
sl@0
    30
        //////////////////////////////////////////////////////////////////////
sl@0
    31
        // default
sl@0
    32
        //////////////////////////////////////////////////////////////////////
sl@0
    33
        
sl@0
    34
        template<>
sl@0
    35
        struct range_begin<std_container_>
sl@0
    36
        {
sl@0
    37
            template< typename C >
sl@0
    38
            static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type fun( C& c )
sl@0
    39
            {
sl@0
    40
                return c.begin();
sl@0
    41
            };
sl@0
    42
        };
sl@0
    43
                    
sl@0
    44
        //////////////////////////////////////////////////////////////////////
sl@0
    45
        // pair
sl@0
    46
        //////////////////////////////////////////////////////////////////////
sl@0
    47
        
sl@0
    48
        template<>
sl@0
    49
        struct range_begin<std_pair_>
sl@0
    50
        {
sl@0
    51
            template< typename P >
sl@0
    52
            static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type fun( const P& p )
sl@0
    53
            {
sl@0
    54
                return p.first;
sl@0
    55
            }
sl@0
    56
        };
sl@0
    57
 
sl@0
    58
        //////////////////////////////////////////////////////////////////////
sl@0
    59
        // array
sl@0
    60
        //////////////////////////////////////////////////////////////////////
sl@0
    61
        
sl@0
    62
        template<>
sl@0
    63
        struct range_begin<array_>
sl@0
    64
        {
sl@0
    65
        #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
sl@0
    66
            template< typename T, std::size_t sz >
sl@0
    67
            static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
sl@0
    68
            {
sl@0
    69
                return boost_range_array;
sl@0
    70
            }
sl@0
    71
        #else
sl@0
    72
            template<typename T>
sl@0
    73
            static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
sl@0
    74
            {
sl@0
    75
                return t;
sl@0
    76
            }
sl@0
    77
        #endif
sl@0
    78
        };
sl@0
    79
sl@0
    80
        //////////////////////////////////////////////////////////////////////
sl@0
    81
        // string
sl@0
    82
        //////////////////////////////////////////////////////////////////////
sl@0
    83
     
sl@0
    84
        template<>
sl@0
    85
        struct range_begin<char_ptr_>
sl@0
    86
        {
sl@0
    87
            static char* fun( char* s )
sl@0
    88
            {
sl@0
    89
                return s;
sl@0
    90
            }
sl@0
    91
        };
sl@0
    92
sl@0
    93
        template<>
sl@0
    94
        struct range_begin<const_char_ptr_>
sl@0
    95
        {
sl@0
    96
            static const char* fun( const char* s )
sl@0
    97
            {
sl@0
    98
                return s;
sl@0
    99
            }
sl@0
   100
        };
sl@0
   101
        
sl@0
   102
        template<>
sl@0
   103
        struct range_begin<wchar_t_ptr_>
sl@0
   104
        {
sl@0
   105
            
sl@0
   106
            static wchar_t* fun( wchar_t* s )
sl@0
   107
            {
sl@0
   108
                return s;
sl@0
   109
            }
sl@0
   110
        };
sl@0
   111
sl@0
   112
        template<>
sl@0
   113
        struct range_begin<const_wchar_t_ptr_>
sl@0
   114
        {
sl@0
   115
            static const wchar_t* fun( const wchar_t* s )
sl@0
   116
            {
sl@0
   117
                return s;
sl@0
   118
            }
sl@0
   119
        };
sl@0
   120
sl@0
   121
    } // namespace 'range_detail'
sl@0
   122
    
sl@0
   123
    template< typename C >
sl@0
   124
    inline BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type 
sl@0
   125
    begin( C& c )
sl@0
   126
    {
sl@0
   127
        return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
sl@0
   128
    }
sl@0
   129
    
sl@0
   130
} // namespace 'boost'
sl@0
   131
sl@0
   132
sl@0
   133
#endif