Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/pending/container_traits.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
13 // is not legal. There ought to be a standard <stlfwd> header. -JGS | 13 // is not legal. There ought to be a standard <stlfwd> header. -JGS |
14 | 14 |
15 #include <boost/next_prior.hpp> | 15 #include <boost/next_prior.hpp> |
16 | 16 |
17 #include <algorithm> // for std::remove | 17 #include <algorithm> // for std::remove |
18 #include <utility> | |
18 #include <vector> | 19 #include <vector> |
19 #include <list> | 20 #include <list> |
20 #include <map> | 21 #include <map> |
21 #include <set> | 22 #include <set> |
22 #include <boost/unordered_set.hpp> | 23 #include <boost/unordered_set.hpp> |
28 # else | 29 # else |
29 # include <slist> | 30 # include <slist> |
30 # endif | 31 # endif |
31 #endif | 32 #endif |
32 | 33 |
33 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) | 34 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET |
34 // Stay out of the way of concept checking class templates | 35 #include <unordered_set> |
35 # define Container Container_ | 36 #endif |
36 # define AssociativeContainer AssociativeContainer_ | 37 |
38 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
39 #include <unordered_map> | |
40 #endif | |
41 | |
42 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES | |
43 #define BOOST_PENDING_FWD_TYPE(type) const type& | |
44 #define BOOST_PENDING_FWD_VALUE(type, var) (var) | |
45 #else | |
46 #define BOOST_PENDING_FWD_TYPE(type) type&& | |
47 #define BOOST_PENDING_FWD_VALUE(type, var) (std::forward<type>((var))) | |
37 #endif | 48 #endif |
38 | 49 |
39 // The content of this file is in 'graph_detail' because otherwise | 50 // The content of this file is in 'graph_detail' because otherwise |
40 // there will be name clashes with | 51 // there will be name clashes with |
41 // sandbox/boost/sequence_algo/container_traits.hpp | 52 // sandbox/boost/sequence_algo/container_traits.hpp |
85 struct unstable_tag { }; | 96 struct unstable_tag { }; |
86 | 97 |
87 //====================================================================== | 98 //====================================================================== |
88 // Container Traits Class and container_category() function | 99 // Container Traits Class and container_category() function |
89 | 100 |
90 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
91 // don't use this unless there is partial specialization | 101 // don't use this unless there is partial specialization |
92 template <class Container> | 102 template <class Container> |
93 struct container_traits { | 103 struct container_traits { |
94 typedef typename Container::category category; | 104 typedef typename Container::category category; |
95 typedef typename Container::iterator_stability iterator_stability; | 105 typedef typename Container::iterator_stability iterator_stability; |
96 }; | 106 }; |
97 #endif | |
98 | 107 |
99 // Use this as a compile-time assertion that X is stable | 108 // Use this as a compile-time assertion that X is stable |
100 inline void require_stable(stable_tag) { } | 109 inline void require_stable(stable_tag) { } |
101 | 110 |
102 // std::vector | 111 // std::vector |
110 | 119 |
111 template <class T, class Alloc> | 120 template <class T, class Alloc> |
112 unstable_tag iterator_stability(const std::vector<T,Alloc>&) | 121 unstable_tag iterator_stability(const std::vector<T,Alloc>&) |
113 { return unstable_tag(); } | 122 { return unstable_tag(); } |
114 | 123 |
115 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
116 template <class T, class Alloc> | 124 template <class T, class Alloc> |
117 struct container_traits< std::vector<T,Alloc> > { | 125 struct container_traits< std::vector<T,Alloc> > { |
118 typedef vector_tag category; | 126 typedef vector_tag category; |
119 typedef unstable_tag iterator_stability; | 127 typedef unstable_tag iterator_stability; |
120 }; | 128 }; |
121 #endif | |
122 | 129 |
123 // std::list | 130 // std::list |
124 struct list_tag : | 131 struct list_tag : |
125 virtual public reversible_container_tag, | 132 virtual public reversible_container_tag, |
126 virtual public back_insertion_sequence_tag | 133 virtual public back_insertion_sequence_tag |
134 | 141 |
135 template <class T, class Alloc> | 142 template <class T, class Alloc> |
136 stable_tag iterator_stability(const std::list<T,Alloc>&) | 143 stable_tag iterator_stability(const std::list<T,Alloc>&) |
137 { return stable_tag(); } | 144 { return stable_tag(); } |
138 | 145 |
139 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
140 template <class T, class Alloc> | 146 template <class T, class Alloc> |
141 struct container_traits< std::list<T,Alloc> > { | 147 struct container_traits< std::list<T,Alloc> > { |
142 typedef list_tag category; | 148 typedef list_tag category; |
143 typedef stable_tag iterator_stability; | 149 typedef stable_tag iterator_stability; |
144 }; | 150 }; |
145 #endif | |
146 | 151 |
147 | 152 |
148 // std::slist | 153 // std::slist |
149 #ifndef BOOST_NO_SLIST | 154 #ifndef BOOST_NO_SLIST |
150 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
151 template <class T, class Alloc> | 155 template <class T, class Alloc> |
152 struct container_traits<BOOST_STD_EXTENSION_NAMESPACE::slist<T,Alloc> > { | 156 struct container_traits<BOOST_STD_EXTENSION_NAMESPACE::slist<T,Alloc> > { |
153 typedef front_insertion_sequence_tag category; | 157 typedef front_insertion_sequence_tag category; |
154 typedef stable_tag iterator_stability; | 158 typedef stable_tag iterator_stability; |
155 }; | 159 }; |
156 #endif | |
157 template <class T, class Alloc> | 160 template <class T, class Alloc> |
158 front_insertion_sequence_tag container_category( | 161 front_insertion_sequence_tag container_category( |
159 const BOOST_STD_EXTENSION_NAMESPACE::slist<T,Alloc>& | 162 const BOOST_STD_EXTENSION_NAMESPACE::slist<T,Alloc>& |
160 ) | 163 ) |
161 { return front_insertion_sequence_tag(); } | 164 { return front_insertion_sequence_tag(); } |
180 | 183 |
181 template <class Key, class Cmp, class Alloc> | 184 template <class Key, class Cmp, class Alloc> |
182 stable_tag iterator_stability(const std::set<Key,Cmp,Alloc>&) | 185 stable_tag iterator_stability(const std::set<Key,Cmp,Alloc>&) |
183 { return stable_tag(); } | 186 { return stable_tag(); } |
184 | 187 |
185 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
186 template <class Key, class Cmp, class Alloc> | 188 template <class Key, class Cmp, class Alloc> |
187 struct container_traits< std::set<Key,Cmp,Alloc> > { | 189 struct container_traits< std::set<Key,Cmp,Alloc> > { |
188 typedef set_tag category; | 190 typedef set_tag category; |
189 typedef stable_tag iterator_stability; | 191 typedef stable_tag iterator_stability; |
190 }; | 192 }; |
191 #endif | |
192 | 193 |
193 // std::multiset | 194 // std::multiset |
194 struct multiset_tag : | 195 struct multiset_tag : |
195 virtual public sorted_associative_container_tag, | 196 virtual public sorted_associative_container_tag, |
196 virtual public simple_associative_container_tag, | 197 virtual public simple_associative_container_tag, |
203 | 204 |
204 template <class Key, class Cmp, class Alloc> | 205 template <class Key, class Cmp, class Alloc> |
205 stable_tag iterator_stability(const std::multiset<Key,Cmp,Alloc>&) | 206 stable_tag iterator_stability(const std::multiset<Key,Cmp,Alloc>&) |
206 { return stable_tag(); } | 207 { return stable_tag(); } |
207 | 208 |
208 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
209 template <class Key, class Cmp, class Alloc> | 209 template <class Key, class Cmp, class Alloc> |
210 struct container_traits< std::multiset<Key,Cmp,Alloc> > { | 210 struct container_traits< std::multiset<Key,Cmp,Alloc> > { |
211 typedef multiset_tag category; | 211 typedef multiset_tag category; |
212 typedef stable_tag iterator_stability; | 212 typedef stable_tag iterator_stability; |
213 }; | 213 }; |
214 #endif | |
215 | 214 |
216 // deque | 215 // deque |
217 | 216 |
218 // std::map | 217 // std::map |
219 struct map_tag : | 218 struct map_tag : |
220 virtual public sorted_associative_container_tag, | 219 virtual public sorted_associative_container_tag, |
221 virtual public pair_associative_container_tag, | 220 virtual public pair_associative_container_tag, |
222 virtual public unique_associative_container_tag | 221 virtual public unique_associative_container_tag |
223 { }; | 222 { }; |
224 | 223 |
225 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
226 template <class Key, class T, class Cmp, class Alloc> | 224 template <class Key, class T, class Cmp, class Alloc> |
227 struct container_traits< std::map<Key,T,Cmp,Alloc> > { | 225 struct container_traits< std::map<Key,T,Cmp,Alloc> > { |
228 typedef map_tag category; | 226 typedef map_tag category; |
229 typedef stable_tag iterator_stability; | 227 typedef stable_tag iterator_stability; |
230 }; | 228 }; |
231 #endif | |
232 | 229 |
233 template <class Key, class T, class Cmp, class Alloc> | 230 template <class Key, class T, class Cmp, class Alloc> |
234 map_tag container_category(const std::map<Key,T,Cmp,Alloc>&) | 231 map_tag container_category(const std::map<Key,T,Cmp,Alloc>&) |
235 { return map_tag(); } | 232 { return map_tag(); } |
236 | 233 |
243 virtual public sorted_associative_container_tag, | 240 virtual public sorted_associative_container_tag, |
244 virtual public pair_associative_container_tag, | 241 virtual public pair_associative_container_tag, |
245 virtual public multiple_associative_container_tag | 242 virtual public multiple_associative_container_tag |
246 { }; | 243 { }; |
247 | 244 |
248 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
249 template <class Key, class T, class Cmp, class Alloc> | 245 template <class Key, class T, class Cmp, class Alloc> |
250 struct container_traits< std::multimap<Key,T,Cmp,Alloc> > { | 246 struct container_traits< std::multimap<Key,T,Cmp,Alloc> > { |
251 typedef multimap_tag category; | 247 typedef multimap_tag category; |
252 typedef stable_tag iterator_stability; | 248 typedef stable_tag iterator_stability; |
253 }; | 249 }; |
254 #endif | |
255 | 250 |
256 template <class Key, class T, class Cmp, class Alloc> | 251 template <class Key, class T, class Cmp, class Alloc> |
257 multimap_tag container_category(const std::multimap<Key,T,Cmp,Alloc>&) | 252 multimap_tag container_category(const std::multimap<Key,T,Cmp,Alloc>&) |
258 { return multimap_tag(); } | 253 { return multimap_tag(); } |
259 | 254 |
284 virtual public pair_associative_container_tag, | 279 virtual public pair_associative_container_tag, |
285 virtual public multiple_associative_container_tag | 280 virtual public multiple_associative_container_tag |
286 { }; | 281 { }; |
287 | 282 |
288 | 283 |
289 #ifndef BOOST_NO_HASH | |
290 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | |
291 template <class Key, class Eq, class Hash, class Alloc> | 284 template <class Key, class Eq, class Hash, class Alloc> |
292 struct container_traits< boost::unordered_set<Key,Eq,Hash,Alloc> > { | 285 struct container_traits< boost::unordered_set<Key,Eq,Hash,Alloc> > { |
293 typedef unordered_set_tag category; | 286 typedef unordered_set_tag category; |
294 typedef unstable_tag iterator_stability; | 287 typedef unstable_tag iterator_stability; |
295 }; | 288 }; |
306 template <class Key, class T, class Eq, class Hash, class Alloc> | 299 template <class Key, class T, class Eq, class Hash, class Alloc> |
307 struct container_traits< boost::unordered_multimap<Key,T,Eq,Hash,Alloc> > { | 300 struct container_traits< boost::unordered_multimap<Key,T,Eq,Hash,Alloc> > { |
308 typedef unordered_multimap_tag category; | 301 typedef unordered_multimap_tag category; |
309 typedef unstable_tag iterator_stability; | 302 typedef unstable_tag iterator_stability; |
310 }; | 303 }; |
311 #endif | 304 |
312 template <class Key, class Eq, class Hash, class Alloc> | 305 template <class Key, class Eq, class Hash, class Alloc> |
313 unordered_set_tag | 306 unordered_set_tag |
314 container_category(const boost::unordered_set<Key,Eq,Hash,Alloc>&) | 307 container_category(const boost::unordered_set<Key,Eq,Hash,Alloc>&) |
315 { return unordered_set_tag(); } | 308 { return unordered_set_tag(); } |
316 | 309 |
343 | 336 |
344 template <class Key, class T, class Eq, class Hash, class Alloc> | 337 template <class Key, class T, class Eq, class Hash, class Alloc> |
345 unstable_tag | 338 unstable_tag |
346 iterator_stability(const boost::unordered_multimap<Key,T,Eq,Hash,Alloc>&) | 339 iterator_stability(const boost::unordered_multimap<Key,T,Eq,Hash,Alloc>&) |
347 { return unstable_tag(); } | 340 { return unstable_tag(); } |
348 #endif | 341 |
349 | 342 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET |
343 template <class Key, class Eq, class Hash, class Alloc> | |
344 struct container_traits< std::unordered_set<Key,Eq,Hash,Alloc> > { | |
345 typedef unordered_set_tag category; | |
346 typedef unstable_tag iterator_stability; | |
347 }; | |
348 #endif | |
349 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
350 template <class Key, class T, class Eq, class Hash, class Alloc> | |
351 struct container_traits< std::unordered_map<Key,T,Eq,Hash,Alloc> > { | |
352 typedef unordered_map_tag category; | |
353 typedef unstable_tag iterator_stability; | |
354 }; | |
355 #endif | |
356 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET | |
357 template <class Key, class Eq, class Hash, class Alloc> | |
358 struct container_traits< std::unordered_multiset<Key,Eq,Hash,Alloc> > { | |
359 typedef unordered_multiset_tag category; | |
360 typedef unstable_tag iterator_stability; | |
361 }; | |
362 #endif | |
363 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
364 template <class Key, class T, class Eq, class Hash, class Alloc> | |
365 struct container_traits< std::unordered_multimap<Key,T,Eq,Hash,Alloc> > { | |
366 typedef unordered_multimap_tag category; | |
367 typedef unstable_tag iterator_stability; | |
368 }; | |
369 #endif | |
370 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET | |
371 template <class Key, class Eq, class Hash, class Alloc> | |
372 unordered_set_tag | |
373 container_category(const std::unordered_set<Key,Eq,Hash,Alloc>&) | |
374 { return unordered_set_tag(); } | |
375 #endif | |
376 | |
377 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
378 template <class Key, class T, class Eq, class Hash, class Alloc> | |
379 unordered_map_tag | |
380 container_category(const std::unordered_map<Key,T,Eq,Hash,Alloc>&) | |
381 { return unordered_map_tag(); } | |
382 #endif | |
383 | |
384 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET | |
385 template <class Key, class Eq, class Hash, class Alloc> | |
386 unstable_tag iterator_stability(const std::unordered_set<Key,Eq,Hash,Alloc>&) | |
387 { return unstable_tag(); } | |
388 #endif | |
389 | |
390 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
391 template <class Key, class T, class Eq, class Hash, class Alloc> | |
392 unstable_tag iterator_stability(const std::unordered_map<Key,T,Eq,Hash,Alloc>&) | |
393 { return unstable_tag(); } | |
394 #endif | |
395 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET | |
396 template <class Key, class Eq, class Hash, class Alloc> | |
397 unordered_multiset_tag | |
398 container_category(const std::unordered_multiset<Key,Eq,Hash,Alloc>&) | |
399 { return unordered_multiset_tag(); } | |
400 #endif | |
401 | |
402 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
403 template <class Key, class T, class Eq, class Hash, class Alloc> | |
404 unordered_multimap_tag | |
405 container_category(const std::unordered_multimap<Key,T,Eq,Hash,Alloc>&) | |
406 { return unordered_multimap_tag(); } | |
407 #endif | |
408 | |
409 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET | |
410 template <class Key, class Eq, class Hash, class Alloc> | |
411 unstable_tag | |
412 iterator_stability(const std::unordered_multiset<Key,Eq,Hash,Alloc>&) | |
413 { return unstable_tag(); } | |
414 #endif | |
415 | |
416 #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP | |
417 template <class Key, class T, class Eq, class Hash, class Alloc> | |
418 unstable_tag | |
419 iterator_stability(const std::unordered_multimap<Key,T,Eq,Hash,Alloc>&) | |
420 { return unstable_tag(); } | |
421 #endif | |
350 | 422 |
351 | 423 |
352 //=========================================================================== | 424 //=========================================================================== |
353 // Generalized Container Functions | 425 // Generalized Container Functions |
354 | 426 |
419 } | 491 } |
420 | 492 |
421 // Push | 493 // Push |
422 template <class Container, class T> | 494 template <class Container, class T> |
423 std::pair<typename Container::iterator, bool> | 495 std::pair<typename Container::iterator, bool> |
424 push_dispatch(Container& c, const T& v, back_insertion_sequence_tag) | 496 push_dispatch(Container& c, BOOST_PENDING_FWD_TYPE(T) v, back_insertion_sequence_tag) |
425 { | 497 { |
426 c.push_back(v); | 498 c.push_back(BOOST_PENDING_FWD_VALUE(T, v)); |
427 return std::make_pair(boost::prior(c.end()), true); | 499 return std::make_pair(boost::prior(c.end()), true); |
428 } | 500 } |
429 | 501 |
430 template <class Container, class T> | 502 template <class Container, class T> |
431 std::pair<typename Container::iterator, bool> | 503 std::pair<typename Container::iterator, bool> |
432 push_dispatch(Container& c, const T& v, front_insertion_sequence_tag) | 504 push_dispatch(Container& c, BOOST_PENDING_FWD_TYPE(T) v, front_insertion_sequence_tag) |
433 { | 505 { |
434 c.push_front(v); | 506 c.push_front(BOOST_PENDING_FWD_VALUE(T, v)); |
435 return std::make_pair(c.begin(), true); | 507 return std::make_pair(c.begin(), true); |
436 } | 508 } |
437 | 509 |
438 template <class AssociativeContainer, class T> | 510 template <class AssociativeContainer, class T> |
439 std::pair<typename AssociativeContainer::iterator, bool> | 511 std::pair<typename AssociativeContainer::iterator, bool> |
440 push_dispatch(AssociativeContainer& c, const T& v, | 512 push_dispatch(AssociativeContainer& c, BOOST_PENDING_FWD_TYPE(T) v, |
441 unique_associative_container_tag) | 513 unique_associative_container_tag) |
442 { | 514 { |
443 return c.insert(v); | 515 return c.insert(BOOST_PENDING_FWD_VALUE(T, v)); |
444 } | 516 } |
445 | 517 |
446 template <class AssociativeContainer, class T> | 518 template <class AssociativeContainer, class T> |
447 std::pair<typename AssociativeContainer::iterator, bool> | 519 std::pair<typename AssociativeContainer::iterator, bool> |
448 push_dispatch(AssociativeContainer& c, const T& v, | 520 push_dispatch(AssociativeContainer& c, BOOST_PENDING_FWD_TYPE(T) v, |
449 multiple_associative_container_tag) | 521 multiple_associative_container_tag) |
450 { | 522 { |
451 return std::make_pair(c.insert(v), true); | 523 return std::make_pair(c.insert(BOOST_PENDING_FWD_VALUE(T, v)), true); |
452 } | 524 } |
453 | 525 |
454 template <class Container, class T> | 526 template <class Container, class T> |
455 std::pair<typename Container::iterator,bool> | 527 std::pair<typename Container::iterator,bool> |
456 push(Container& c, const T& v) | 528 push(Container& c, BOOST_PENDING_FWD_TYPE(T) v) |
457 { | 529 { |
458 return push_dispatch(c, v, container_category(c)); | 530 return push_dispatch(c, BOOST_PENDING_FWD_VALUE(T, v), container_category(c)); |
459 } | 531 } |
460 | 532 |
461 // Find | 533 // Find |
462 template <class Container, class Value> | 534 template <class Container, class Value> |
463 typename Container::iterator | 535 typename Container::iterator |
550 graph_detail::container_category(c)); | 622 graph_detail::container_category(c)); |
551 } | 623 } |
552 | 624 |
553 }} // namespace boost::graph_detail | 625 }} // namespace boost::graph_detail |
554 | 626 |
555 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) | 627 #undef BOOST_PENDING_FWD_TYPE |
556 // Stay out of the way of concept checking class templates | 628 #undef BOOST_PENDING_FWD_VALUE |
557 # undef Container | |
558 # undef AssociativeContainer | |
559 #endif | |
560 | 629 |
561 #endif // BOOST_GRAPH_DETAIL_CONTAINER_TRAITS_H | 630 #endif // BOOST_GRAPH_DETAIL_CONTAINER_TRAITS_H |