Chris@16
|
1 // Boost.Range library
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
Chris@16
|
4 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // For more information, see http://www.boost.org/libs/range/
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
|
Chris@16
|
12 #define BOOST_RANGE_DETAIL_BEGIN_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/config.hpp> // BOOST_MSVC
|
Chris@16
|
15 #include <boost/detail/workaround.hpp>
|
Chris@16
|
16 #include <boost/range/iterator.hpp>
|
Chris@16
|
17 #include <boost/range/detail/common.hpp>
|
Chris@16
|
18 #if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
|
Chris@16
|
19 # include <boost/range/value_type.hpp>
|
Chris@16
|
20 #endif
|
Chris@16
|
21
|
Chris@16
|
22 namespace boost
|
Chris@16
|
23 {
|
Chris@16
|
24
|
Chris@16
|
25 namespace range_detail
|
Chris@16
|
26 {
|
Chris@16
|
27 template< typename T >
|
Chris@16
|
28 struct range_begin;
|
Chris@16
|
29
|
Chris@16
|
30 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
31 // default
|
Chris@16
|
32 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
33
|
Chris@16
|
34 template<>
|
Chris@16
|
35 struct range_begin<std_container_>
|
Chris@16
|
36 {
|
Chris@16
|
37 template< typename C >
|
Chris@16
|
38 static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
|
Chris@16
|
39 {
|
Chris@16
|
40 return c.begin();
|
Chris@16
|
41 };
|
Chris@16
|
42 };
|
Chris@16
|
43
|
Chris@16
|
44 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
45 // pair
|
Chris@16
|
46 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
47
|
Chris@16
|
48 template<>
|
Chris@16
|
49 struct range_begin<std_pair_>
|
Chris@16
|
50 {
|
Chris@16
|
51 template< typename P >
|
Chris@16
|
52 static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
|
Chris@16
|
53 {
|
Chris@16
|
54 return p.first;
|
Chris@16
|
55 }
|
Chris@16
|
56 };
|
Chris@16
|
57
|
Chris@16
|
58 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
59 // array
|
Chris@16
|
60 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
61
|
Chris@16
|
62 template<>
|
Chris@16
|
63 struct range_begin<array_>
|
Chris@16
|
64 {
|
Chris@16
|
65 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
|
Chris@16
|
66 template< typename T, std::size_t sz >
|
Chris@16
|
67 static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
Chris@16
|
68 {
|
Chris@16
|
69 return boost_range_array;
|
Chris@16
|
70 }
|
Chris@16
|
71 #else
|
Chris@16
|
72 template<typename T>
|
Chris@16
|
73 static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
|
Chris@16
|
74 {
|
Chris@16
|
75 return t;
|
Chris@16
|
76 }
|
Chris@16
|
77 #endif
|
Chris@16
|
78 };
|
Chris@16
|
79
|
Chris@16
|
80 } // namespace 'range_detail'
|
Chris@16
|
81
|
Chris@16
|
82 namespace range_adl_barrier
|
Chris@16
|
83 {
|
Chris@16
|
84 template< typename C >
|
Chris@16
|
85 inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
Chris@16
|
86 begin( C& c )
|
Chris@16
|
87 {
|
Chris@16
|
88 return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
|
Chris@16
|
89 }
|
Chris@16
|
90 }
|
Chris@16
|
91 } // namespace 'boost'
|
Chris@16
|
92
|
Chris@16
|
93
|
Chris@16
|
94 #endif
|