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_DIFFERENCE_TYPE_HPP |
---|
12 | #define BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP |
---|
13 | |
---|
14 | #include <boost/range/detail/common.hpp> |
---|
15 | #include <boost/iterator/iterator_traits.hpp> |
---|
16 | |
---|
17 | ////////////////////////////////////////////////////////////////////////////// |
---|
18 | // missing partial specialization workaround. |
---|
19 | ////////////////////////////////////////////////////////////////////////////// |
---|
20 | |
---|
21 | namespace boost |
---|
22 | { |
---|
23 | namespace range_detail |
---|
24 | { |
---|
25 | template< typename T > |
---|
26 | struct range_difference_type_; |
---|
27 | |
---|
28 | template<> |
---|
29 | struct range_difference_type_<std_container_> |
---|
30 | { |
---|
31 | template< typename C > |
---|
32 | struct pts |
---|
33 | { |
---|
34 | typedef BOOST_DEDUCED_TYPENAME C::difference_type type; |
---|
35 | }; |
---|
36 | }; |
---|
37 | |
---|
38 | template<> |
---|
39 | struct range_difference_type_<std_pair_> |
---|
40 | { |
---|
41 | template< typename P > |
---|
42 | struct pts |
---|
43 | { |
---|
44 | typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type; |
---|
45 | }; |
---|
46 | }; |
---|
47 | |
---|
48 | template<> |
---|
49 | struct range_difference_type_<array_> |
---|
50 | { |
---|
51 | template< typename A > |
---|
52 | struct pts |
---|
53 | { |
---|
54 | typedef std::ptrdiff_t type; |
---|
55 | }; |
---|
56 | }; |
---|
57 | |
---|
58 | template<> |
---|
59 | struct range_difference_type_<char_array_> |
---|
60 | { |
---|
61 | template< typename A > |
---|
62 | struct pts |
---|
63 | { |
---|
64 | typedef std::ptrdiff_t type; |
---|
65 | }; |
---|
66 | }; |
---|
67 | |
---|
68 | template<> |
---|
69 | struct range_difference_type_<char_ptr_> |
---|
70 | { |
---|
71 | template< typename S > |
---|
72 | struct pts |
---|
73 | { |
---|
74 | typedef std::ptrdiff_t type; |
---|
75 | }; |
---|
76 | }; |
---|
77 | |
---|
78 | template<> |
---|
79 | struct range_difference_type_<const_char_ptr_> |
---|
80 | { |
---|
81 | template< typename S > |
---|
82 | struct pts |
---|
83 | { |
---|
84 | typedef std::ptrdiff_t type; |
---|
85 | }; |
---|
86 | }; |
---|
87 | |
---|
88 | template<> |
---|
89 | struct range_difference_type_<wchar_t_ptr_> |
---|
90 | { |
---|
91 | template< typename S > |
---|
92 | struct pts |
---|
93 | { |
---|
94 | typedef std::ptrdiff_t type; |
---|
95 | }; |
---|
96 | }; |
---|
97 | |
---|
98 | template<> |
---|
99 | struct range_difference_type_<const_wchar_t_ptr_> |
---|
100 | { |
---|
101 | template< typename S > |
---|
102 | struct pts |
---|
103 | { |
---|
104 | typedef std::ptrdiff_t type; |
---|
105 | }; |
---|
106 | }; |
---|
107 | |
---|
108 | } |
---|
109 | |
---|
110 | template< typename C > |
---|
111 | class range_difference |
---|
112 | { |
---|
113 | typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type; |
---|
114 | public: |
---|
115 | typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; |
---|
116 | }; |
---|
117 | |
---|
118 | } |
---|
119 | |
---|
120 | #endif |
---|
121 | |
---|