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 | #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
---|
21 | #include <boost/range/detail/size_type.hpp> |
---|
22 | #else |
---|
23 | |
---|
24 | #include <boost/type_traits/remove_const.hpp> |
---|
25 | #include <cstddef> |
---|
26 | #include <utility> |
---|
27 | |
---|
28 | namespace boost |
---|
29 | { |
---|
30 | namespace detail |
---|
31 | { |
---|
32 | |
---|
33 | ////////////////////////////////////////////////////////////////////////// |
---|
34 | // default |
---|
35 | ////////////////////////////////////////////////////////////////////////// |
---|
36 | |
---|
37 | template< typename C > |
---|
38 | struct range_size |
---|
39 | { |
---|
40 | typedef BOOST_DEDUCED_TYPENAME C::size_type type; |
---|
41 | }; |
---|
42 | |
---|
43 | ////////////////////////////////////////////////////////////////////////// |
---|
44 | // pair |
---|
45 | ////////////////////////////////////////////////////////////////////////// |
---|
46 | |
---|
47 | template< typename Iterator > |
---|
48 | struct range_size< std::pair<Iterator,Iterator> > |
---|
49 | { |
---|
50 | typedef std::size_t type; |
---|
51 | }; |
---|
52 | |
---|
53 | ////////////////////////////////////////////////////////////////////////// |
---|
54 | // array |
---|
55 | ////////////////////////////////////////////////////////////////////////// |
---|
56 | |
---|
57 | template< typename T, std::size_t sz > |
---|
58 | struct range_size< T[sz] > |
---|
59 | { |
---|
60 | typedef std::size_t type; |
---|
61 | }; |
---|
62 | } |
---|
63 | |
---|
64 | template< class T > |
---|
65 | struct range_size : |
---|
66 | detail::range_size<T> |
---|
67 | { }; |
---|
68 | |
---|
69 | template< class T > |
---|
70 | struct range_size<const T > |
---|
71 | : detail::range_size<T> |
---|
72 | { }; |
---|
73 | |
---|
74 | } // namespace boost |
---|
75 | |
---|
76 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
---|
77 | |
---|
78 | |
---|
79 | #endif |
---|