comparison DEPENDENCIES/generic/include/boost/multi_index_container.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
1 /* Multiply indexed container. 1 /* Multiply indexed container.
2 * 2 *
3 * Copyright 2003-2013 Joaquin M Lopez Munoz. 3 * Copyright 2003-2014 Joaquin M Lopez Munoz.
4 * Distributed under the Boost Software License, Version 1.0. 4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at 5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt) 6 * http://www.boost.org/LICENSE_1_0.txt)
7 * 7 *
8 * See http://www.boost.org/libs/multi_index for library home page. 8 * See http://www.boost.org/libs/multi_index for library home page.
9 */ 9 */
10 10
11 #ifndef BOOST_MULTI_INDEX_HPP 11 #ifndef BOOST_MULTI_INDEX_HPP
12 #define BOOST_MULTI_INDEX_HPP 12 #define BOOST_MULTI_INDEX_HPP
13 13
14 #if defined(_MSC_VER)&&(_MSC_VER>=1200) 14 #if defined(_MSC_VER)
15 #pragma once 15 #pragma once
16 #endif 16 #endif
17 17
18 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ 18 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
19 #include <algorithm> 19 #include <algorithm>
35 #include <boost/multi_index/detail/do_not_copy_elements_tag.hpp> 35 #include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
36 #include <boost/multi_index/detail/converter.hpp> 36 #include <boost/multi_index/detail/converter.hpp>
37 #include <boost/multi_index/detail/header_holder.hpp> 37 #include <boost/multi_index/detail/header_holder.hpp>
38 #include <boost/multi_index/detail/has_tag.hpp> 38 #include <boost/multi_index/detail/has_tag.hpp>
39 #include <boost/multi_index/detail/no_duplicate_tags.hpp> 39 #include <boost/multi_index/detail/no_duplicate_tags.hpp>
40 #include <boost/multi_index/detail/prevent_eti.hpp>
41 #include <boost/multi_index/detail/safe_mode.hpp> 40 #include <boost/multi_index/detail/safe_mode.hpp>
42 #include <boost/multi_index/detail/scope_guard.hpp> 41 #include <boost/multi_index/detail/scope_guard.hpp>
43 #include <boost/multi_index/detail/vartempl_support.hpp> 42 #include <boost/multi_index/detail/vartempl_support.hpp>
44 #include <boost/static_assert.hpp> 43 #include <boost/static_assert.hpp>
45 #include <boost/type_traits/is_same.hpp> 44 #include <boost/type_traits/is_same.hpp>
88 Allocator, 87 Allocator,
89 typename detail::multi_index_node_type< 88 typename detail::multi_index_node_type<
90 Value,IndexSpecifierList,Allocator>::type 89 Value,IndexSpecifierList,Allocator>::type
91 >::type>, 90 >::type>,
92 BOOST_MULTI_INDEX_PRIVATE_IF_MEMBER_TEMPLATE_FRIENDS detail::header_holder< 91 BOOST_MULTI_INDEX_PRIVATE_IF_MEMBER_TEMPLATE_FRIENDS detail::header_holder<
93 typename detail::prevent_eti< 92 typename boost::detail::allocator::rebind_to<
94 Allocator, 93 Allocator,
95 typename boost::detail::allocator::rebind_to< 94 typename detail::multi_index_node_type<
96 Allocator, 95 Value,IndexSpecifierList,Allocator>::type
97 typename detail::multi_index_node_type<
98 Value,IndexSpecifierList,Allocator>::type
99 >::type
100 >::type::pointer, 96 >::type::pointer,
101 multi_index_container<Value,IndexSpecifierList,Allocator> >, 97 multi_index_container<Value,IndexSpecifierList,Allocator> >,
102 public detail::multi_index_base_type< 98 public detail::multi_index_base_type<
103 Value,IndexSpecifierList,Allocator>::type 99 Value,IndexSpecifierList,Allocator>::type
104 { 100 {
123 119
124 typedef typename detail::multi_index_base_type< 120 typedef typename detail::multi_index_base_type<
125 Value,IndexSpecifierList,Allocator>::type super; 121 Value,IndexSpecifierList,Allocator>::type super;
126 typedef typename 122 typedef typename
127 boost::detail::allocator::rebind_to< 123 boost::detail::allocator::rebind_to<
128 Allocator, 124 Allocator,
129 typename super::node_type 125 typename super::node_type
130 >::type node_allocator; 126 >::type node_allocator;
131 typedef ::boost::base_from_member< 127 typedef ::boost::base_from_member<
132 node_allocator> bfm_allocator; 128 node_allocator> bfm_allocator;
133 typedef detail::header_holder< 129 typedef detail::header_holder<
134 typename detail::prevent_eti< 130 typename node_allocator::pointer,
135 Allocator,
136 node_allocator
137 >::type::pointer,
138 multi_index_container> bfm_header; 131 multi_index_container> bfm_header;
139 132
140 #if BOOST_WORKAROUND(BOOST_MSVC,<1300)
141 /* see definition of index_type_list below */
142 typedef typename super::index_type_list super_index_type_list;
143 #endif
144 133
145 public: 134 public:
146 /* All types are inherited from super, a few are explicitly 135 /* All types are inherited from super, a few are explicitly
147 * brought forward here to save us some typename's. 136 * brought forward here to save us some typename's.
148 */ 137 */
149 138
150 typedef typename super::ctor_args_list ctor_args_list; 139 typedef typename super::ctor_args_list ctor_args_list;
151 typedef IndexSpecifierList index_specifier_type_list; 140 typedef IndexSpecifierList index_specifier_type_list;
152 141
153 #if BOOST_WORKAROUND(BOOST_MSVC,<1300)
154 /* MSVC++ 6.0 chokes on moderately long index lists (around 6 indices
155 * or more), with errors ranging from corrupt exes to duplicate
156 * comdats. The following type hiding hack alleviates this condition;
157 * best results combined with type hiding of the indexed_by construct
158 * itself, as explained in the "Compiler specifics" section of
159 * the documentation.
160 */
161
162 struct index_type_list:super_index_type_list
163 {
164 typedef index_type_list type;
165 typedef typename super_index_type_list::back back;
166 typedef mpl::v_iter<type,0> begin;
167 typedef mpl::v_iter<
168 type,
169 mpl::size<super_index_type_list>::value> end;
170 };
171 #else
172 typedef typename super::index_type_list index_type_list; 142 typedef typename super::index_type_list index_type_list;
173 #endif
174 143
175 typedef typename super::iterator_type_list iterator_type_list; 144 typedef typename super::iterator_type_list iterator_type_list;
176 typedef typename super::const_iterator_type_list const_iterator_type_list; 145 typedef typename super::const_iterator_type_list const_iterator_type_list;
177 typedef typename super::value_type value_type; 146 typedef typename super::value_type value_type;
178 typedef typename super::final_allocator_type allocator_type; 147 typedef typename super::final_allocator_type allocator_type;
270 super(args_list,bfm_allocator::member), 239 super(args_list,bfm_allocator::member),
271 node_count(0) 240 node_count(0)
272 { 241 {
273 BOOST_MULTI_INDEX_CHECK_INVARIANT; 242 BOOST_MULTI_INDEX_CHECK_INVARIANT;
274 BOOST_TRY{ 243 BOOST_TRY{
275 typedef typename std::initializer_list<Value>::iterator init_iterator; 244 typedef const Value* init_iterator;
276 245
277 iterator hint=super::end(); 246 iterator hint=super::end();
278 for(init_iterator first=list.begin(),last=list.end(); 247 for(init_iterator first=list.begin(),last=list.end();
279 first!=last;++first){ 248 first!=last;++first){
280 hint=super::make_iterator(insert_(*first,hint.get_node()).first); 249 hint=super::make_iterator(insert_(*first,hint.get_node()).first);
359 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) 328 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
360 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=( 329 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
361 std::initializer_list<Value> list) 330 std::initializer_list<Value> list)
362 { 331 {
363 BOOST_MULTI_INDEX_CHECK_INVARIANT; 332 BOOST_MULTI_INDEX_CHECK_INVARIANT;
364 typedef typename std::initializer_list<Value>::iterator init_iterator; 333 typedef const Value* init_iterator;
365 334
366 multi_index_container x(*this,detail::do_not_copy_elements_tag()); 335 multi_index_container x(*this,detail::do_not_copy_elements_tag());
367 iterator hint=x.end(); 336 iterator hint=x.end();
368 for(init_iterator first=list.begin(),last=list.end(); 337 for(init_iterator first=list.begin(),last=list.end();
369 first!=last;++first){ 338 first!=last;++first){
373 x.swap_elements_(*this); 342 x.swap_elements_(*this);
374 return*this; 343 return*this;
375 } 344 }
376 #endif 345 #endif
377 346
378 allocator_type get_allocator()const 347 allocator_type get_allocator()const BOOST_NOEXCEPT
379 { 348 {
380 return allocator_type(bfm_allocator::member); 349 return allocator_type(bfm_allocator::member);
381 } 350 }
382 351
383 /* retrieval of indices by number */ 352 /* retrieval of indices by number */
389 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value); 358 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
390 typedef typename mpl::at_c<index_type_list,N>::type type; 359 typedef typename mpl::at_c<index_type_list,N>::type type;
391 }; 360 };
392 361
393 template<int N> 362 template<int N>
394 typename nth_index<N>::type& get(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int,N)) 363 typename nth_index<N>::type& get()BOOST_NOEXCEPT
395 { 364 {
396 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value); 365 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
397 return *this; 366 return *this;
398 } 367 }
399 368
400 template<int N> 369 template<int N>
401 const typename nth_index<N>::type& get( 370 const typename nth_index<N>::type& get()const BOOST_NOEXCEPT
402 BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int,N))const
403 { 371 {
404 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value); 372 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
405 return *this; 373 return *this;
406 } 374 }
407 #endif 375 #endif
423 391
424 typedef typename mpl::deref<iter>::type type; 392 typedef typename mpl::deref<iter>::type type;
425 }; 393 };
426 394
427 template<typename Tag> 395 template<typename Tag>
428 typename index<Tag>::type& get(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag)) 396 typename index<Tag>::type& get()BOOST_NOEXCEPT
429 { 397 {
430 return *this; 398 return *this;
431 } 399 }
432 400
433 template<typename Tag> 401 template<typename Tag>
434 const typename index<Tag>::type& get( 402 const typename index<Tag>::type& get()const BOOST_NOEXCEPT
435 BOOST_EXPLICIT_TEMPLATE_TYPE(Tag))const
436 { 403 {
437 return *this; 404 return *this;
438 } 405 }
439 #endif 406 #endif
440 407
452 { 419 {
453 typedef typename nth_index<N>::type::const_iterator type; 420 typedef typename nth_index<N>::type::const_iterator type;
454 }; 421 };
455 422
456 template<int N,typename IteratorType> 423 template<int N,typename IteratorType>
457 typename nth_index_iterator<N>::type project( 424 typename nth_index_iterator<N>::type project(IteratorType it)
458 IteratorType it 425 {
459 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N)) 426 typedef typename nth_index<N>::type index_type;
460 {
461 typedef typename nth_index<N>::type index;
462 427
463 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */ 428 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
464 BOOST_STATIC_ASSERT( 429 BOOST_STATIC_ASSERT(
465 (mpl::contains<iterator_type_list,IteratorType>::value)); 430 (mpl::contains<iterator_type_list,IteratorType>::value));
466 #endif 431 #endif
467 432
468 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it); 433 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
469 BOOST_MULTI_INDEX_CHECK_IS_OWNER( 434 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
470 it,static_cast<typename IteratorType::container_type&>(*this)); 435 it,static_cast<typename IteratorType::container_type&>(*this));
471 436
472 return index::make_iterator(static_cast<node_type*>(it.get_node())); 437 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
473 } 438 }
474 439
475 template<int N,typename IteratorType> 440 template<int N,typename IteratorType>
476 typename nth_index_const_iterator<N>::type project( 441 typename nth_index_const_iterator<N>::type project(IteratorType it)const
477 IteratorType it 442 {
478 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))const 443 typedef typename nth_index<N>::type index_type;
479 {
480 typedef typename nth_index<N>::type index;
481 444
482 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */ 445 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
483 BOOST_STATIC_ASSERT(( 446 BOOST_STATIC_ASSERT((
484 mpl::contains<iterator_type_list,IteratorType>::value|| 447 mpl::contains<iterator_type_list,IteratorType>::value||
485 mpl::contains<const_iterator_type_list,IteratorType>::value)); 448 mpl::contains<const_iterator_type_list,IteratorType>::value));
486 #endif 449 #endif
487 450
488 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it); 451 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
489 BOOST_MULTI_INDEX_CHECK_IS_OWNER( 452 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
490 it,static_cast<const typename IteratorType::container_type&>(*this)); 453 it,static_cast<const typename IteratorType::container_type&>(*this));
491 return index::make_iterator(static_cast<node_type*>(it.get_node())); 454 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
492 } 455 }
493 #endif 456 #endif
494 457
495 /* projection of iterators by tag */ 458 /* projection of iterators by tag */
496 459
506 { 469 {
507 typedef typename index<Tag>::type::const_iterator type; 470 typedef typename index<Tag>::type::const_iterator type;
508 }; 471 };
509 472
510 template<typename Tag,typename IteratorType> 473 template<typename Tag,typename IteratorType>
511 typename index_iterator<Tag>::type project( 474 typename index_iterator<Tag>::type project(IteratorType it)
512 IteratorType it 475 {
513 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag)) 476 typedef typename index<Tag>::type index_type;
514 {
515 typedef typename index<Tag>::type index;
516 477
517 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */ 478 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
518 BOOST_STATIC_ASSERT( 479 BOOST_STATIC_ASSERT(
519 (mpl::contains<iterator_type_list,IteratorType>::value)); 480 (mpl::contains<iterator_type_list,IteratorType>::value));
520 #endif 481 #endif
521 482
522 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it); 483 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
523 BOOST_MULTI_INDEX_CHECK_IS_OWNER( 484 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
524 it,static_cast<typename IteratorType::container_type&>(*this)); 485 it,static_cast<typename IteratorType::container_type&>(*this));
525 return index::make_iterator(static_cast<node_type*>(it.get_node())); 486 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
526 } 487 }
527 488
528 template<typename Tag,typename IteratorType> 489 template<typename Tag,typename IteratorType>
529 typename index_const_iterator<Tag>::type project( 490 typename index_const_iterator<Tag>::type project(IteratorType it)const
530 IteratorType it 491 {
531 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))const 492 typedef typename index<Tag>::type index_type;
532 {
533 typedef typename index<Tag>::type index;
534 493
535 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */ 494 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
536 BOOST_STATIC_ASSERT(( 495 BOOST_STATIC_ASSERT((
537 mpl::contains<iterator_type_list,IteratorType>::value|| 496 mpl::contains<iterator_type_list,IteratorType>::value||
538 mpl::contains<const_iterator_type_list,IteratorType>::value)); 497 mpl::contains<const_iterator_type_list,IteratorType>::value));
539 #endif 498 #endif
540 499
541 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it); 500 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
542 BOOST_MULTI_INDEX_CHECK_IS_OWNER( 501 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
543 it,static_cast<const typename IteratorType::container_type&>(*this)); 502 it,static_cast<const typename IteratorType::container_type&>(*this));
544 return index::make_iterator(static_cast<node_type*>(it.get_node())); 503 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
545 } 504 }
546 #endif 505 #endif
547 506
548 BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS: 507 BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
549 typedef typename super::copy_map_type copy_map_type; 508 typedef typename super::copy_map_type copy_map_type;
593 } 552 }
594 553
595 template<typename Variant> 554 template<typename Variant>
596 std::pair<node_type*,bool> insert_(const Value& v,Variant variant) 555 std::pair<node_type*,bool> insert_(const Value& v,Variant variant)
597 { 556 {
598 node_type* x=allocate_node(); 557 node_type* x=0;
599 BOOST_TRY{ 558 node_type* res=super::insert_(v,x,variant);
600 node_type* res=super::insert_(v,x,variant); 559 if(res==x){
601 if(res==x){ 560 ++node_count;
602 ++node_count; 561 return std::pair<node_type*,bool>(res,true);
603 return std::pair<node_type*,bool>(res,true); 562 }
604 } 563 else{
605 else{ 564 return std::pair<node_type*,bool>(res,false);
606 deallocate_node(x); 565 }
607 return std::pair<node_type*,bool>(res,false);
608 }
609 }
610 BOOST_CATCH(...){
611 deallocate_node(x);
612 BOOST_RETHROW;
613 }
614 BOOST_CATCH_END
615 } 566 }
616 567
617 std::pair<node_type*,bool> insert_(const Value& v) 568 std::pair<node_type*,bool> insert_(const Value& v)
618 { 569 {
619 return insert_(v,detail::lvalue_tag()); 570 return insert_(v,detail::lvalue_tag());
700 651
701 template<typename Variant> 652 template<typename Variant>
702 std::pair<node_type*,bool> insert_( 653 std::pair<node_type*,bool> insert_(
703 const Value& v,node_type* position,Variant variant) 654 const Value& v,node_type* position,Variant variant)
704 { 655 {
705 node_type* x=allocate_node(); 656 node_type* x=0;
706 BOOST_TRY{ 657 node_type* res=super::insert_(v,position,x,variant);
707 node_type* res=super::insert_(v,position,x,variant); 658 if(res==x){
708 if(res==x){ 659 ++node_count;
709 ++node_count; 660 return std::pair<node_type*,bool>(res,true);
710 return std::pair<node_type*,bool>(res,true); 661 }
711 } 662 else{
712 else{ 663 return std::pair<node_type*,bool>(res,false);
713 deallocate_node(x); 664 }
714 return std::pair<node_type*,bool>(res,false);
715 }
716 }
717 BOOST_CATCH(...){
718 deallocate_node(x);
719 BOOST_RETHROW;
720 }
721 BOOST_CATCH_END
722 } 665 }
723 666
724 std::pair<node_type*,bool> insert_(const Value& v,node_type* position) 667 std::pair<node_type*,bool> insert_(const Value& v,node_type* position)
725 { 668 {
726 return insert_(v,position,detail::lvalue_tag()); 669 return insert_(v,position,detail::lvalue_tag());
884 } 827 }
885 BOOST_CATCH_END 828 BOOST_CATCH_END
886 } 829 }
887 830
888 template<typename Modifier,typename Rollback> 831 template<typename Modifier,typename Rollback>
889 bool modify_(Modifier& mod,Rollback& back,node_type* x) 832 bool modify_(Modifier& mod,Rollback& back_,node_type* x)
890 { 833 {
891 mod(const_cast<value_type&>(x->value())); 834 mod(const_cast<value_type&>(x->value()));
892 835
893 bool b; 836 bool b;
894 BOOST_TRY{ 837 BOOST_TRY{
895 b=super::modify_rollback_(x); 838 b=super::modify_rollback_(x);
896 } 839 }
897 BOOST_CATCH(...){ 840 BOOST_CATCH(...){
898 BOOST_TRY{ 841 BOOST_TRY{
899 back(const_cast<value_type&>(x->value())); 842 back_(const_cast<value_type&>(x->value()));
900 BOOST_RETHROW; 843 BOOST_RETHROW;
901 } 844 }
902 BOOST_CATCH(...){ 845 BOOST_CATCH(...){
903 this->erase_(x); 846 this->erase_(x);
904 BOOST_RETHROW; 847 BOOST_RETHROW;
907 } 850 }
908 BOOST_CATCH_END 851 BOOST_CATCH_END
909 852
910 BOOST_TRY{ 853 BOOST_TRY{
911 if(!b){ 854 if(!b){
912 back(const_cast<value_type&>(x->value())); 855 back_(const_cast<value_type&>(x->value()));
913 return false; 856 return false;
914 } 857 }
915 else return true; 858 else return true;
916 } 859 }
917 BOOST_CATCH(...){ 860 BOOST_CATCH(...){
932 typedef typename super::index_loader_type index_loader_type; 875 typedef typename super::index_loader_type index_loader_type;
933 876
934 template<class Archive> 877 template<class Archive>
935 void save(Archive& ar,const unsigned int version)const 878 void save(Archive& ar,const unsigned int version)const
936 { 879 {
937
938 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
939 const serialization::collection_size_type s(size_()); 880 const serialization::collection_size_type s(size_());
940 const detail::serialization_version<value_type> value_version; 881 const detail::serialization_version<value_type> value_version;
941 ar<<serialization::make_nvp("count",s); 882 ar<<serialization::make_nvp("count",s);
942 ar<<serialization::make_nvp("value_version",value_version); 883 ar<<serialization::make_nvp("value_version",value_version);
943 #else
944 const std::size_t s=size_();
945 const unsigned int value_version=0;
946 ar<<serialization::make_nvp("count",s);
947 #endif
948 884
949 index_saver_type sm(bfm_allocator::member,s); 885 index_saver_type sm(bfm_allocator::member,s);
950 886
951 for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){ 887 for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){
952 serialization::save_construct_data_adl(ar,&*it,value_version); 888 serialization::save_construct_data_adl(ar,&*it,value_version);
962 void load(Archive& ar,const unsigned int version) 898 void load(Archive& ar,const unsigned int version)
963 { 899 {
964 BOOST_MULTI_INDEX_CHECK_INVARIANT; 900 BOOST_MULTI_INDEX_CHECK_INVARIANT;
965 901
966 clear_(); 902 clear_();
967
968 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
969 serialization::collection_size_type s; 903 serialization::collection_size_type s;
970 detail::serialization_version<value_type> value_version; 904 detail::serialization_version<value_type> value_version;
971 if(version<1){ 905 if(version<1){
972 std::size_t sz; 906 std::size_t sz;
973 ar>>serialization::make_nvp("count",sz); 907 ar>>serialization::make_nvp("count",sz);
980 value_version=0; 914 value_version=0;
981 } 915 }
982 else{ 916 else{
983 ar>>serialization::make_nvp("value_version",value_version); 917 ar>>serialization::make_nvp("value_version",value_version);
984 } 918 }
985 #else
986 std::size_t s;
987 unsigned int value_version=0;
988 ar>>serialization::make_nvp("count",s);
989 #endif
990 919
991 index_loader_type lm(bfm_allocator::member,s); 920 index_loader_type lm(bfm_allocator::member,s);
992 921
993 for(std::size_t n=0;n<s;++n){ 922 for(std::size_t n=0;n<s;++n){
994 detail::archive_constructed<Value> value("item",ar,value_version); 923 detail::archive_constructed<Value> value("item",ar,value_version);
1048 977
1049 template<int N,typename Value,typename IndexSpecifierList,typename Allocator> 978 template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
1050 typename nth_index< 979 typename nth_index<
1051 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type& 980 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type&
1052 get( 981 get(
1053 multi_index_container<Value,IndexSpecifierList,Allocator>& m 982 multi_index_container<Value,IndexSpecifierList,Allocator>& m)BOOST_NOEXCEPT
1054 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
1055 { 983 {
1056 typedef multi_index_container< 984 typedef multi_index_container<
1057 Value,IndexSpecifierList,Allocator> multi_index_type; 985 Value,IndexSpecifierList,Allocator> multi_index_type;
1058 typedef typename nth_index< 986 typedef typename nth_index<
1059 multi_index_container< 987 multi_index_container<
1060 Value,IndexSpecifierList,Allocator>, 988 Value,IndexSpecifierList,Allocator>,
1061 N 989 N
1062 >::type index; 990 >::type index_type;
1063 991
1064 BOOST_STATIC_ASSERT(N>=0&& 992 BOOST_STATIC_ASSERT(N>=0&&
1065 N< 993 N<
1066 mpl::size< 994 mpl::size<
1067 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list 995 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list
1068 >::type::value); 996 >::type::value);
1069 997
1070 return detail::converter<multi_index_type,index>::index(m); 998 return detail::converter<multi_index_type,index_type>::index(m);
1071 } 999 }
1072 1000
1073 template<int N,typename Value,typename IndexSpecifierList,typename Allocator> 1001 template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
1074 const typename nth_index< 1002 const typename nth_index<
1075 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type& 1003 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type&
1076 get( 1004 get(
1077 const multi_index_container<Value,IndexSpecifierList,Allocator>& m 1005 const multi_index_container<Value,IndexSpecifierList,Allocator>& m
1078 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N)) 1006 )BOOST_NOEXCEPT
1079 { 1007 {
1080 typedef multi_index_container< 1008 typedef multi_index_container<
1081 Value,IndexSpecifierList,Allocator> multi_index_type; 1009 Value,IndexSpecifierList,Allocator> multi_index_type;
1082 typedef typename nth_index< 1010 typedef typename nth_index<
1083 multi_index_container< 1011 multi_index_container<
1084 Value,IndexSpecifierList,Allocator>, 1012 Value,IndexSpecifierList,Allocator>,
1085 N 1013 N
1086 >::type index; 1014 >::type index_type;
1087 1015
1088 BOOST_STATIC_ASSERT(N>=0&& 1016 BOOST_STATIC_ASSERT(N>=0&&
1089 N< 1017 N<
1090 mpl::size< 1018 mpl::size<
1091 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list 1019 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list
1092 >::type::value); 1020 >::type::value);
1093 1021
1094 return detail::converter<multi_index_type,index>::index(m); 1022 return detail::converter<multi_index_type,index_type>::index(m);
1095 } 1023 }
1096 1024
1097 /* retrieval of indices by tag */ 1025 /* retrieval of indices by tag */
1098 1026
1099 template<typename MultiIndexContainer,typename Tag> 1027 template<typename MultiIndexContainer,typename Tag>
1117 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator 1045 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator
1118 > 1046 >
1119 typename ::boost::multi_index::index< 1047 typename ::boost::multi_index::index<
1120 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type& 1048 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type&
1121 get( 1049 get(
1122 multi_index_container<Value,IndexSpecifierList,Allocator>& m 1050 multi_index_container<Value,IndexSpecifierList,Allocator>& m)BOOST_NOEXCEPT
1123 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
1124 { 1051 {
1125 typedef multi_index_container< 1052 typedef multi_index_container<
1126 Value,IndexSpecifierList,Allocator> multi_index_type; 1053 Value,IndexSpecifierList,Allocator> multi_index_type;
1127 typedef typename ::boost::multi_index::index< 1054 typedef typename ::boost::multi_index::index<
1128 multi_index_container< 1055 multi_index_container<
1129 Value,IndexSpecifierList,Allocator>, 1056 Value,IndexSpecifierList,Allocator>,
1130 Tag 1057 Tag
1131 >::type index; 1058 >::type index_type;
1132 1059
1133 return detail::converter<multi_index_type,index>::index(m); 1060 return detail::converter<multi_index_type,index_type>::index(m);
1134 } 1061 }
1135 1062
1136 template< 1063 template<
1137 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator 1064 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator
1138 > 1065 >
1139 const typename ::boost::multi_index::index< 1066 const typename ::boost::multi_index::index<
1140 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type& 1067 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type&
1141 get( 1068 get(
1142 const multi_index_container<Value,IndexSpecifierList,Allocator>& m 1069 const multi_index_container<Value,IndexSpecifierList,Allocator>& m
1143 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag)) 1070 )BOOST_NOEXCEPT
1144 { 1071 {
1145 typedef multi_index_container< 1072 typedef multi_index_container<
1146 Value,IndexSpecifierList,Allocator> multi_index_type; 1073 Value,IndexSpecifierList,Allocator> multi_index_type;
1147 typedef typename ::boost::multi_index::index< 1074 typedef typename ::boost::multi_index::index<
1148 multi_index_container< 1075 multi_index_container<
1149 Value,IndexSpecifierList,Allocator>, 1076 Value,IndexSpecifierList,Allocator>,
1150 Tag 1077 Tag
1151 >::type index; 1078 >::type index_type;
1152 1079
1153 return detail::converter<multi_index_type,index>::index(m); 1080 return detail::converter<multi_index_type,index_type>::index(m);
1154 } 1081 }
1155 1082
1156 /* projection of iterators by number */ 1083 /* projection of iterators by number */
1157 1084
1158 template<typename MultiIndexContainer,int N> 1085 template<typename MultiIndexContainer,int N>
1159 struct nth_index_iterator 1086 struct nth_index_iterator
1160 { 1087 {
1161 typedef typename detail::prevent_eti< 1088 typedef typename nth_index<MultiIndexContainer,N>::type::iterator type;
1162 nth_index<MultiIndexContainer,N>,
1163 typename nth_index<MultiIndexContainer,N>::type>::type::iterator type;
1164 }; 1089 };
1165 1090
1166 template<typename MultiIndexContainer,int N> 1091 template<typename MultiIndexContainer,int N>
1167 struct nth_index_const_iterator 1092 struct nth_index_const_iterator
1168 { 1093 {
1169 typedef typename detail::prevent_eti< 1094 typedef typename nth_index<MultiIndexContainer,N>::type::const_iterator type;
1170 nth_index<MultiIndexContainer,N>,
1171 typename nth_index<MultiIndexContainer,N>::type
1172 >::type::const_iterator type;
1173 }; 1095 };
1174 1096
1175 template< 1097 template<
1176 int N,typename IteratorType, 1098 int N,typename IteratorType,
1177 typename Value,typename IndexSpecifierList,typename Allocator> 1099 typename Value,typename IndexSpecifierList,typename Allocator>
1178 typename nth_index_iterator< 1100 typename nth_index_iterator<
1179 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type 1101 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type
1180 project( 1102 project(
1181 multi_index_container<Value,IndexSpecifierList,Allocator>& m, 1103 multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1182 IteratorType it 1104 IteratorType it)
1183 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
1184 { 1105 {
1185 typedef multi_index_container< 1106 typedef multi_index_container<
1186 Value,IndexSpecifierList,Allocator> multi_index_type; 1107 Value,IndexSpecifierList,Allocator> multi_index_type;
1187 typedef typename nth_index<multi_index_type,N>::type index; 1108 typedef typename nth_index<multi_index_type,N>::type index_type;
1188 1109
1189 #if (!defined(BOOST_MSVC)||!(BOOST_MSVC<1310))&& /* MSVC++ 6.0/7.0 fails */\ 1110 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1190 (!defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)) /* as does Sun C++ 5.7 */
1191 BOOST_STATIC_ASSERT(( 1111 BOOST_STATIC_ASSERT((
1192 mpl::contains< 1112 mpl::contains<
1193 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list, 1113 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1194 IteratorType>::value)); 1114 IteratorType>::value));
1195 #endif 1115 #endif
1201 multi_index_type, 1121 multi_index_type,
1202 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter; 1122 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1203 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m)); 1123 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1204 #endif 1124 #endif
1205 1125
1206 return detail::converter<multi_index_type,index>::iterator( 1126 return detail::converter<multi_index_type,index_type>::iterator(
1207 m,static_cast<typename multi_index_type::node_type*>(it.get_node())); 1127 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1208 } 1128 }
1209 1129
1210 template< 1130 template<
1211 int N,typename IteratorType, 1131 int N,typename IteratorType,
1212 typename Value,typename IndexSpecifierList,typename Allocator> 1132 typename Value,typename IndexSpecifierList,typename Allocator>
1213 typename nth_index_const_iterator< 1133 typename nth_index_const_iterator<
1214 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type 1134 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type
1215 project( 1135 project(
1216 const multi_index_container<Value,IndexSpecifierList,Allocator>& m, 1136 const multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1217 IteratorType it 1137 IteratorType it)
1218 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
1219 { 1138 {
1220 typedef multi_index_container< 1139 typedef multi_index_container<
1221 Value,IndexSpecifierList,Allocator> multi_index_type; 1140 Value,IndexSpecifierList,Allocator> multi_index_type;
1222 typedef typename nth_index<multi_index_type,N>::type index; 1141 typedef typename nth_index<multi_index_type,N>::type index_type;
1223 1142
1224 #if (!defined(BOOST_MSVC)||!(BOOST_MSVC<1310))&& /* MSVC++ 6.0/7.0 fails */\ 1143 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1225 (!defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)) /* as does Sun C++ 5.7 */
1226 BOOST_STATIC_ASSERT(( 1144 BOOST_STATIC_ASSERT((
1227 mpl::contains< 1145 mpl::contains<
1228 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list, 1146 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1229 IteratorType>::value|| 1147 IteratorType>::value||
1230 mpl::contains< 1148 mpl::contains<
1239 multi_index_type, 1157 multi_index_type,
1240 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter; 1158 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1241 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m)); 1159 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1242 #endif 1160 #endif
1243 1161
1244 return detail::converter<multi_index_type,index>::const_iterator( 1162 return detail::converter<multi_index_type,index_type>::const_iterator(
1245 m,static_cast<typename multi_index_type::node_type*>(it.get_node())); 1163 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1246 } 1164 }
1247 1165
1248 /* projection of iterators by tag */ 1166 /* projection of iterators by tag */
1249 1167
1266 typename Value,typename IndexSpecifierList,typename Allocator> 1184 typename Value,typename IndexSpecifierList,typename Allocator>
1267 typename index_iterator< 1185 typename index_iterator<
1268 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type 1186 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type
1269 project( 1187 project(
1270 multi_index_container<Value,IndexSpecifierList,Allocator>& m, 1188 multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1271 IteratorType it 1189 IteratorType it)
1272 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
1273 { 1190 {
1274 typedef multi_index_container< 1191 typedef multi_index_container<
1275 Value,IndexSpecifierList,Allocator> multi_index_type; 1192 Value,IndexSpecifierList,Allocator> multi_index_type;
1276 typedef typename ::boost::multi_index::index< 1193 typedef typename ::boost::multi_index::index<
1277 multi_index_type,Tag>::type index; 1194 multi_index_type,Tag>::type index_type;
1278 1195
1279 #if (!defined(BOOST_MSVC)||!(BOOST_MSVC<1310))&& /* MSVC++ 6.0/7.0 fails */\ 1196 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1280 (!defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)) /* as does Sun C++ 5.7 */
1281 BOOST_STATIC_ASSERT(( 1197 BOOST_STATIC_ASSERT((
1282 mpl::contains< 1198 mpl::contains<
1283 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list, 1199 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1284 IteratorType>::value)); 1200 IteratorType>::value));
1285 #endif 1201 #endif
1291 multi_index_type, 1207 multi_index_type,
1292 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter; 1208 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1293 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m)); 1209 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1294 #endif 1210 #endif
1295 1211
1296 return detail::converter<multi_index_type,index>::iterator( 1212 return detail::converter<multi_index_type,index_type>::iterator(
1297 m,static_cast<typename multi_index_type::node_type*>(it.get_node())); 1213 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1298 } 1214 }
1299 1215
1300 template< 1216 template<
1301 typename Tag,typename IteratorType, 1217 typename Tag,typename IteratorType,
1302 typename Value,typename IndexSpecifierList,typename Allocator> 1218 typename Value,typename IndexSpecifierList,typename Allocator>
1303 typename index_const_iterator< 1219 typename index_const_iterator<
1304 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type 1220 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type
1305 project( 1221 project(
1306 const multi_index_container<Value,IndexSpecifierList,Allocator>& m, 1222 const multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1307 IteratorType it 1223 IteratorType it)
1308 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
1309 { 1224 {
1310 typedef multi_index_container< 1225 typedef multi_index_container<
1311 Value,IndexSpecifierList,Allocator> multi_index_type; 1226 Value,IndexSpecifierList,Allocator> multi_index_type;
1312 typedef typename ::boost::multi_index::index< 1227 typedef typename ::boost::multi_index::index<
1313 multi_index_type,Tag>::type index; 1228 multi_index_type,Tag>::type index_type;
1314 1229
1315 #if (!defined(BOOST_MSVC)||!(BOOST_MSVC<1310))&& /* MSVC++ 6.0/7.0 fails */\ 1230 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1316 (!defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)) /* as does Sun C++ 5.7 */
1317 BOOST_STATIC_ASSERT(( 1231 BOOST_STATIC_ASSERT((
1318 mpl::contains< 1232 mpl::contains<
1319 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list, 1233 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1320 IteratorType>::value|| 1234 IteratorType>::value||
1321 mpl::contains< 1235 mpl::contains<
1330 multi_index_type, 1244 multi_index_type,
1331 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter; 1245 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1332 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m)); 1246 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1333 #endif 1247 #endif
1334 1248
1335 return detail::converter<multi_index_type,index>::const_iterator( 1249 return detail::converter<multi_index_type,index_type>::const_iterator(
1336 m,static_cast<typename multi_index_type::node_type*>(it.get_node())); 1250 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1337 } 1251 }
1338 1252
1339 /* Comparison. Simple forward to first index. */ 1253 /* Comparison. Simple forward to first index. */
1340 1254
1414 x.swap(y); 1328 x.swap(y);
1415 } 1329 }
1416 1330
1417 } /* namespace multi_index */ 1331 } /* namespace multi_index */
1418 1332
1419 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)&&\ 1333 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
1420 !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
1421 /* class version = 1 : we now serialize the size through 1334 /* class version = 1 : we now serialize the size through
1422 * boost::serialization::collection_size_type. 1335 * boost::serialization::collection_size_type.
1423 * class version = 2 : proper use of {save|load}_construct_data. 1336 * class version = 2 : proper use of {save|load}_construct_data.
1424 */ 1337 */
1425 1338