From 596d5e132a2dee3badcd7bb68264dc37d280af01 Mon Sep 17 00:00:00 2001
From: Kohei Takahashi <flast@flast.jp>
Date: Thu, 18 Oct 2012 20:40:12 +0900
Subject: [PATCH] Specialization for std::pair
---
boost/iterator/zip_iterator.hpp | 58 +++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/boost/iterator/zip_iterator.hpp b/boost/iterator/zip_iterator.hpp
index 28785e6..d788e63 100644
a
|
b
|
|
18 | 18 | |
19 | 19 | #include <boost/iterator/detail/minimum_category.hpp> |
20 | 20 | |
| 21 | #include <utility> |
21 | 22 | #include <boost/fusion/adapted/boost_tuple.hpp> // for backward compatibility |
22 | 23 | |
23 | 24 | #include <boost/type_traits/remove_reference.hpp> |
… |
… |
namespace boost {
|
130 | 131 | { |
131 | 132 | }; |
132 | 133 | |
| 134 | // Specialization for std::pair |
| 135 | template<typename Iterator1, typename Iterator2> |
| 136 | struct tuple_of_references<std::pair<Iterator1, Iterator2> > |
| 137 | { |
| 138 | typedef std::pair< |
| 139 | typename iterator_reference<Iterator1>::type |
| 140 | , typename iterator_reference<Iterator2>::type |
| 141 | > type; |
| 142 | }; |
| 143 | |
133 | 144 | // Metafunction to obtain the minimal traversal tag in a tuple |
134 | 145 | // of iterators. |
135 | 146 | // |
… |
… |
namespace boost {
|
148 | 159 | >::type type; |
149 | 160 | }; |
150 | 161 | |
| 162 | template<typename Iterator1, typename Iterator2> |
| 163 | struct minimum_traversal_category_in_iterator_tuple<std::pair<Iterator1, Iterator2> > |
| 164 | { |
| 165 | typedef typename pure_traversal_tag< |
| 166 | typename iterator_traversal<Iterator1>::type |
| 167 | >::type iterator1_traversal; |
| 168 | typedef typename pure_traversal_tag< |
| 169 | typename iterator_traversal<Iterator2>::type |
| 170 | >::type iterator2_traversal; |
| 171 | |
| 172 | typedef typename minimum_category< |
| 173 | iterator1_traversal |
| 174 | , typename minimum_category< |
| 175 | iterator2_traversal |
| 176 | , random_access_traversal_tag |
| 177 | >::type |
| 178 | >::type type; |
| 179 | }; |
| 180 | |
151 | 181 | #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround |
152 | 182 | template <> |
153 | 183 | struct minimum_traversal_category_in_iterator_tuple<int> |
… |
… |
namespace boost {
|
204 | 234 | { |
205 | 235 | typedef int type; |
206 | 236 | }; |
| 237 | |
| 238 | template <typename reference> |
| 239 | struct converter |
| 240 | { |
| 241 | template <typename Seq> |
| 242 | static reference call(Seq seq) |
| 243 | { |
| 244 | typedef typename fusion::traits::tag_of<reference>::type tag; |
| 245 | return fusion::convert<tag>(seq); |
| 246 | } |
| 247 | }; |
| 248 | |
| 249 | template <typename Reference1, typename Reference2> |
| 250 | struct converter<std::pair<Reference1, Reference2> > |
| 251 | { |
| 252 | typedef std::pair<Reference1, Reference2> reference; |
| 253 | template <typename Seq> |
| 254 | static reference call(Seq seq) |
| 255 | { |
| 256 | return reference( |
| 257 | fusion::at_c<0>(seq) |
| 258 | , fusion::at_c<1>(seq)); |
| 259 | } |
| 260 | }; |
207 | 261 | } |
208 | 262 | |
209 | 263 | ///////////////////////////////////////////////////////////////////// |
… |
… |
namespace boost {
|
260 | 314 | typename super_t::reference dereference() const |
261 | 315 | { |
262 | 316 | typedef typename super_t::reference reference; |
263 | | typedef typename fusion::traits::tag_of<reference>::type tag; |
264 | | return fusion::convert<tag>(fusion::transform( |
| 317 | typedef detail::converter<reference> gen; |
| 318 | return gen::call(fusion::transform( |
265 | 319 | get_iterator_tuple(), |
266 | 320 | detail::dereference_iterator())); |
267 | 321 | } |