[857] | 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_SIZE_TYPE_HPP
|
---|
| 12 | #define BOOST_RANGE_SIZE_TYPE_HPP
|
---|
| 13 |
|
---|
| 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
---|
| 15 | # pragma once
|
---|
| 16 | #endif
|
---|
| 17 |
|
---|
| 18 | #include <boost/range/config.hpp>
|
---|
| 19 | /*
|
---|
| 20 | #include <boost/range/difference_type.hpp>
|
---|
| 21 |
|
---|
| 22 | namespace boost
|
---|
| 23 | {
|
---|
| 24 | namespace range_detail
|
---|
| 25 | {
|
---|
| 26 | template< class T >
|
---|
| 27 | struct add_unsigned;
|
---|
| 28 |
|
---|
| 29 | template<>
|
---|
| 30 | struct add_unsigned<short>
|
---|
| 31 | {
|
---|
| 32 | typedef unsigned short type;
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | template<>
|
---|
| 36 | struct add_unsigned<int>
|
---|
| 37 | {
|
---|
| 38 | typedef unsigned int type;
|
---|
| 39 | };
|
---|
| 40 |
|
---|
| 41 | template<>
|
---|
| 42 | struct add_unsigned<long>
|
---|
| 43 | {
|
---|
| 44 | typedef unsigned long type;
|
---|
| 45 | };
|
---|
| 46 |
|
---|
| 47 | #ifdef BOOST_HAS_LONG_LONG
|
---|
| 48 |
|
---|
| 49 | template<>
|
---|
| 50 | struct add_unsigned<long long>
|
---|
| 51 | {
|
---|
| 52 | typedef unsigned long long type;
|
---|
| 53 | };
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | template< class T >
|
---|
| 59 | struct range_size
|
---|
| 60 | {
|
---|
| 61 | typedef BOOST_DEDUCED_TYPENAME range_detail::add_unsigned<
|
---|
| 62 | BOOST_DEDUCED_TYPENAME range_difference<T>::type >::type
|
---|
| 63 | type;
|
---|
| 64 | };
|
---|
| 65 | }
|
---|
| 66 | */
|
---|
| 67 |
|
---|
| 68 | #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 69 | #include <boost/range/detail/size_type.hpp>
|
---|
| 70 | #else
|
---|
| 71 |
|
---|
| 72 | #include <cstddef>
|
---|
| 73 | #include <utility>
|
---|
| 74 |
|
---|
| 75 | namespace boost
|
---|
| 76 | {
|
---|
| 77 | //////////////////////////////////////////////////////////////////////////
|
---|
| 78 | // default
|
---|
| 79 | //////////////////////////////////////////////////////////////////////////
|
---|
| 80 |
|
---|
| 81 | template< typename C >
|
---|
| 82 | struct range_size
|
---|
| 83 | {
|
---|
| 84 | typedef BOOST_DEDUCED_TYPENAME C::size_type type;
|
---|
| 85 | };
|
---|
| 86 |
|
---|
| 87 | //////////////////////////////////////////////////////////////////////////
|
---|
| 88 | // pair
|
---|
| 89 | //////////////////////////////////////////////////////////////////////////
|
---|
| 90 |
|
---|
| 91 | template< typename Iterator >
|
---|
| 92 | struct range_size< std::pair<Iterator,Iterator> >
|
---|
| 93 | {
|
---|
| 94 | typedef std::size_t type;
|
---|
| 95 | };
|
---|
| 96 |
|
---|
| 97 | template< typename Iterator >
|
---|
| 98 | struct range_size< const std::pair<Iterator,Iterator> >
|
---|
| 99 | {
|
---|
| 100 | typedef std::size_t type;
|
---|
| 101 | };
|
---|
| 102 |
|
---|
| 103 | //////////////////////////////////////////////////////////////////////////
|
---|
| 104 | // array
|
---|
| 105 | //////////////////////////////////////////////////////////////////////////
|
---|
| 106 |
|
---|
| 107 | template< typename T, std::size_t sz >
|
---|
| 108 | struct range_size< T[sz] >
|
---|
| 109 | {
|
---|
| 110 | typedef std::size_t type;
|
---|
| 111 | };
|
---|
| 112 |
|
---|
| 113 | template< typename T, std::size_t sz >
|
---|
| 114 | struct range_size< const T[sz] >
|
---|
| 115 | {
|
---|
| 116 | typedef std::size_t type;
|
---|
| 117 | };
|
---|
| 118 |
|
---|
| 119 | //////////////////////////////////////////////////////////////////////////
|
---|
| 120 | // string
|
---|
| 121 | //////////////////////////////////////////////////////////////////////////
|
---|
| 122 |
|
---|
| 123 | template<>
|
---|
| 124 | struct range_size< char* >
|
---|
| 125 | {
|
---|
| 126 | typedef std::size_t type;
|
---|
| 127 | };
|
---|
| 128 |
|
---|
| 129 | template<>
|
---|
| 130 | struct range_size< wchar_t* >
|
---|
| 131 | {
|
---|
| 132 | typedef std::size_t type;
|
---|
| 133 | };
|
---|
| 134 |
|
---|
| 135 | template<>
|
---|
| 136 | struct range_size< const char* >
|
---|
| 137 | {
|
---|
| 138 | typedef std::size_t type;
|
---|
| 139 | };
|
---|
| 140 |
|
---|
| 141 | template<>
|
---|
| 142 | struct range_size< const wchar_t* >
|
---|
| 143 | {
|
---|
| 144 | typedef std::size_t type;
|
---|
| 145 | };
|
---|
| 146 |
|
---|
| 147 | template<>
|
---|
| 148 | struct range_size< char* const >
|
---|
| 149 | {
|
---|
| 150 | typedef std::size_t type;
|
---|
| 151 | };
|
---|
| 152 |
|
---|
| 153 | template<>
|
---|
| 154 | struct range_size< wchar_t* const >
|
---|
| 155 | {
|
---|
| 156 | typedef std::size_t type;
|
---|
| 157 | };
|
---|
| 158 |
|
---|
| 159 | template<>
|
---|
| 160 | struct range_size< const char* const >
|
---|
| 161 | {
|
---|
| 162 | typedef std::size_t type;
|
---|
| 163 | };
|
---|
| 164 |
|
---|
| 165 | template<>
|
---|
| 166 | struct range_size< const wchar_t* const >
|
---|
| 167 | {
|
---|
| 168 | typedef std::size_t type;
|
---|
| 169 | };
|
---|
| 170 |
|
---|
| 171 | } // namespace boost
|
---|
| 172 |
|
---|
| 173 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 | #endif
|
---|