Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 11 | #ifndef NDNBOOST_RANGE_DETAIL_BEGIN_HPP |
| 12 | #define NDNBOOST_RANGE_DETAIL_BEGIN_HPP |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 13 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 14 | #include <ndnboost/config.hpp> // NDNBOOST_MSVC |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 15 | #include <ndnboost/detail/workaround.hpp> |
| 16 | #include <ndnboost/range/iterator.hpp> |
| 17 | #include <ndnboost/range/detail/common.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 18 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 19 | # include <ndnboost/range/value_type.hpp> |
| 20 | #endif |
| 21 | |
| 22 | namespace 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 Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 38 | static NDNBOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c ) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 52 | static NDNBOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p ) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 53 | { |
| 54 | return p.first; |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | ////////////////////////////////////////////////////////////////////// |
| 59 | // array |
| 60 | ////////////////////////////////////////////////////////////////////// |
| 61 | |
| 62 | template<> |
| 63 | struct range_begin<array_> |
| 64 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 65 | #if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1310) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 66 | template< typename T, std::size_t sz > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 67 | static T* fun( T NDNBOOST_RANGE_ARRAY_REF()[sz] ) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 68 | { |
| 69 | return boost_range_array; |
| 70 | } |
| 71 | #else |
| 72 | template<typename T> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 73 | static NDNBOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 74 | { |
| 75 | return t; |
| 76 | } |
| 77 | #endif |
| 78 | }; |
| 79 | |
| 80 | } // namespace 'range_detail' |
| 81 | |
| 82 | namespace range_adl_barrier |
| 83 | { |
| 84 | template< typename C > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 85 | inline NDNBOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 86 | begin( C& c ) |
| 87 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 88 | return range_detail::range_begin< NDNBOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | } // namespace 'boost' |
| 92 | |
| 93 | |
| 94 | #endif |