blob: f2b5e590a86ca75d6da8e139ddc0ca288720b428 [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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070011#ifndef NDNBOOST_RANGE_DETAIL_BEGIN_HPP
12#define NDNBOOST_RANGE_DETAIL_BEGIN_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070013
Jeff Thompson3d613fd2013-10-15 15:39:04 -070014#include <ndnboost/config.hpp> // NDNBOOST_MSVC
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070015#include <ndnboost/detail/workaround.hpp>
16#include <ndnboost/range/iterator.hpp>
17#include <ndnboost/range/detail/common.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070019# 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 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038 static NDNBOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070039 {
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 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070052 static NDNBOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070053 {
54 return p.first;
55 }
56 };
57
58 //////////////////////////////////////////////////////////////////////
59 // array
60 //////////////////////////////////////////////////////////////////////
61
62 template<>
63 struct range_begin<array_>
64 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065 #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070066 template< typename T, std::size_t sz >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067 static T* fun( T NDNBOOST_RANGE_ARRAY_REF()[sz] )
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070068 {
69 return boost_range_array;
70 }
71 #else
72 template<typename T>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070073 static NDNBOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070074 {
75 return t;
76 }
77 #endif
78 };
79
80 } // namespace 'range_detail'
81
82 namespace range_adl_barrier
83 {
84 template< typename C >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070085 inline NDNBOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070086 begin( C& c )
87 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070088 return range_detail::range_begin< NDNBOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070089 }
90 }
91} // namespace 'boost'
92
93
94#endif