blob: aea43cf0eae4d01352f9b8c584de73298dbcd45a [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// 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 <ndnboost/config.hpp> // BOOST_MSVC
15#include <ndnboost/detail/workaround.hpp>
16#include <ndnboost/range/iterator.hpp>
17#include <ndnboost/range/detail/common.hpp>
18#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
19# include <ndnboost/range/value_type.hpp>
20#endif
21
22namespace ndnboost
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 namespace range_adl_barrier
83 {
84 template< typename C >
85 inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
86 begin( C& c )
87 {
88 return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
89 }
90 }
91} // namespace 'boost'
92
93
94#endif