Brian Silverman | 598d029 | 2018-08-04 23:56:47 -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 | |
| 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 | |
| 19 | namespace boost |
| 20 | { |
| 21 | |
| 22 | namespace range_detail |
| 23 | { |
| 24 | template< typename T > |
| 25 | struct range_begin; |
| 26 | |
| 27 | ////////////////////////////////////////////////////////////////////// |
| 28 | // default |
| 29 | ////////////////////////////////////////////////////////////////////// |
| 30 | |
| 31 | template<> |
| 32 | struct range_begin<std_container_> |
| 33 | { |
| 34 | template< typename C > |
| 35 | BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c ) |
| 36 | { |
| 37 | return c.begin(); |
| 38 | }; |
| 39 | }; |
| 40 | |
| 41 | ////////////////////////////////////////////////////////////////////// |
| 42 | // pair |
| 43 | ////////////////////////////////////////////////////////////////////// |
| 44 | |
| 45 | template<> |
| 46 | struct range_begin<std_pair_> |
| 47 | { |
| 48 | template< typename P > |
| 49 | BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p ) |
| 50 | { |
| 51 | return p.first; |
| 52 | } |
| 53 | }; |
| 54 | |
| 55 | ////////////////////////////////////////////////////////////////////// |
| 56 | // array |
| 57 | ////////////////////////////////////////////////////////////////////// |
| 58 | |
| 59 | template<> |
| 60 | struct range_begin<array_> |
| 61 | { |
| 62 | template<typename T> |
| 63 | BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t) |
| 64 | { |
| 65 | return t; |
| 66 | } |
| 67 | }; |
| 68 | |
| 69 | } // namespace 'range_detail' |
| 70 | |
| 71 | namespace range_adl_barrier |
| 72 | { |
| 73 | template< typename C > |
| 74 | BOOST_CONSTEXPR inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type |
| 75 | begin( C& c ) |
| 76 | { |
| 77 | return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c ); |
| 78 | } |
| 79 | } |
| 80 | } // namespace 'boost' |
| 81 | |
| 82 | |
| 83 | #endif |