~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to libs/boost-lib/boost/range/detail/begin.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_DETAIL_BEGIN_HPP
 
12
#define BOOST_RANGE_DETAIL_BEGIN_HPP
 
13
 
 
14
#include <boost/config.hpp> // BOOST_MSVC
 
15
#include <boost/detail/workaround.hpp>
 
16
#include <boost/range/iterator.hpp>
 
17
#include <boost/range/detail/common.hpp>
 
18
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
 
19
# include <boost/range/value_type.hpp>
 
20
#endif
 
21
 
 
22
namespace boost 
 
23
{
 
24
    
 
25
    namespace range_detail
 
26
    {
 
27
        template< typename T >
 
28
        struct range_begin;
 
29
 
 
30
        //////////////////////////////////////////////////////////////////////
 
31
        // default
 
32
        //////////////////////////////////////////////////////////////////////
 
33
        
 
34
        template<>
 
35
        struct range_begin<std_container_>
 
36
        {
 
37
            template< typename C >
 
38
            static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
 
39
            {
 
40
                return c.begin();
 
41
            };
 
42
        };
 
43
                    
 
44
        //////////////////////////////////////////////////////////////////////
 
45
        // pair
 
46
        //////////////////////////////////////////////////////////////////////
 
47
        
 
48
        template<>
 
49
        struct range_begin<std_pair_>
 
50
        {
 
51
            template< typename P >
 
52
            static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
 
53
            {
 
54
                return p.first;
 
55
            }
 
56
        };
 
57
 
 
58
        //////////////////////////////////////////////////////////////////////
 
59
        // array
 
60
        //////////////////////////////////////////////////////////////////////
 
61
        
 
62
        template<>
 
63
        struct range_begin<array_>
 
64
        {
 
65
        #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
 
66
            template< typename T, std::size_t sz >
 
67
            static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
 
68
            {
 
69
                return boost_range_array;
 
70
            }
 
71
        #else
 
72
            template<typename T>
 
73
            static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
 
74
            {
 
75
                return t;
 
76
            }
 
77
        #endif
 
78
        };
 
79
 
 
80
    } // namespace 'range_detail'
 
81
    
 
82
    template< typename C >
 
83
    inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type 
 
84
    begin( C& c )
 
85
    {
 
86
        return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
 
87
    }
 
88
    
 
89
} // namespace 'boost'
 
90
 
 
91
 
 
92
#endif