]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/multi_index_container.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / multi_index_container.hpp
CommitLineData
7c673cae
FG
1/* Multiply indexed container.
2 *
11fdf7f2 3 * Copyright 2003-2018 Joaquin M Lopez Munoz.
7c673cae
FG
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 * See http://www.boost.org/libs/multi_index for library home page.
9 */
10
11#ifndef BOOST_MULTI_INDEX_HPP
12#define BOOST_MULTI_INDEX_HPP
13
14#if defined(_MSC_VER)
15#pragma once
16#endif
17
18#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
19#include <algorithm>
11fdf7f2
TL
20#include <memory>
21#include <boost/core/addressof.hpp>
7c673cae
FG
22#include <boost/detail/allocator_utilities.hpp>
23#include <boost/detail/no_exceptions_support.hpp>
24#include <boost/detail/workaround.hpp>
25#include <boost/move/core.hpp>
26#include <boost/mpl/at.hpp>
27#include <boost/mpl/contains.hpp>
28#include <boost/mpl/find_if.hpp>
29#include <boost/mpl/identity.hpp>
30#include <boost/mpl/int.hpp>
31#include <boost/mpl/size.hpp>
32#include <boost/mpl/deref.hpp>
33#include <boost/multi_index_container_fwd.hpp>
34#include <boost/multi_index/detail/access_specifier.hpp>
35#include <boost/multi_index/detail/adl_swap.hpp>
36#include <boost/multi_index/detail/base_type.hpp>
37#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
38#include <boost/multi_index/detail/converter.hpp>
39#include <boost/multi_index/detail/header_holder.hpp>
40#include <boost/multi_index/detail/has_tag.hpp>
41#include <boost/multi_index/detail/no_duplicate_tags.hpp>
42#include <boost/multi_index/detail/safe_mode.hpp>
43#include <boost/multi_index/detail/scope_guard.hpp>
44#include <boost/multi_index/detail/vartempl_support.hpp>
45#include <boost/static_assert.hpp>
46#include <boost/type_traits/is_same.hpp>
47#include <boost/utility/base_from_member.hpp>
48
49#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
50#include <initializer_list>
51#endif
52
53#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
54#include <boost/multi_index/detail/archive_constructed.hpp>
55#include <boost/multi_index/detail/serialization_version.hpp>
56#include <boost/serialization/collection_size_type.hpp>
57#include <boost/serialization/nvp.hpp>
58#include <boost/serialization/split_member.hpp>
59#include <boost/serialization/version.hpp>
60#include <boost/throw_exception.hpp>
61#endif
62
63#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
64#include <boost/multi_index/detail/invariant_assert.hpp>
65#define BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(x) \
66 detail::scope_guard BOOST_JOIN(check_invariant_,__LINE__)= \
67 detail::make_obj_guard(x,&multi_index_container::check_invariant_); \
68 BOOST_JOIN(check_invariant_,__LINE__).touch();
69#define BOOST_MULTI_INDEX_CHECK_INVARIANT \
70 BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(*this)
71#else
72#define BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(x)
73#define BOOST_MULTI_INDEX_CHECK_INVARIANT
74#endif
75
76namespace boost{
77
78namespace multi_index{
79
80#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
81#pragma warning(push)
82#pragma warning(disable:4522) /* spurious warning on multiple operator=()'s */
83#endif
84
85template<typename Value,typename IndexSpecifierList,typename Allocator>
86class multi_index_container:
87 private ::boost::base_from_member<
88 typename boost::detail::allocator::rebind_to<
89 Allocator,
90 typename detail::multi_index_node_type<
91 Value,IndexSpecifierList,Allocator>::type
92 >::type>,
93 BOOST_MULTI_INDEX_PRIVATE_IF_MEMBER_TEMPLATE_FRIENDS detail::header_holder<
11fdf7f2
TL
94#ifndef BOOST_NO_CXX11_ALLOCATOR
95 typename std::allocator_traits<
96#endif
97 typename boost::detail::allocator::rebind_to<
98 Allocator,
99 typename detail::multi_index_node_type<
100 Value,IndexSpecifierList,Allocator>::type
101 >::type
102#ifdef BOOST_NO_CXX11_ALLOCATOR
103 ::pointer,
104#else
105 >::pointer,
106#endif
7c673cae
FG
107 multi_index_container<Value,IndexSpecifierList,Allocator> >,
108 public detail::multi_index_base_type<
109 Value,IndexSpecifierList,Allocator>::type
110{
111#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\
112 BOOST_WORKAROUND(__MWERKS__,<=0x3003)
113/* The "ISO C++ Template Parser" option in CW8.3 has a problem with the
114 * lifetime of const references bound to temporaries --precisely what
115 * scopeguards are.
116 */
117
118#pragma parse_mfunc_templ off
119#endif
120
121private:
122 BOOST_COPYABLE_AND_MOVABLE(multi_index_container)
123
124#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
125 template <typename,typename,typename> friend class detail::index_base;
126 template <typename,typename> friend struct detail::header_holder;
127 template <typename,typename> friend struct detail::converter;
128#endif
129
130 typedef typename detail::multi_index_base_type<
131 Value,IndexSpecifierList,Allocator>::type super;
132 typedef typename
133 boost::detail::allocator::rebind_to<
134 Allocator,
135 typename super::node_type
136 >::type node_allocator;
11fdf7f2
TL
137#ifdef BOOST_NO_CXX11_ALLOCATOR
138 typedef typename node_allocator::pointer node_pointer;
139#else
140 typedef std::allocator_traits<node_allocator> node_allocator_traits;
141 typedef typename node_allocator_traits::pointer node_pointer;
142#endif
7c673cae
FG
143 typedef ::boost::base_from_member<
144 node_allocator> bfm_allocator;
145 typedef detail::header_holder<
11fdf7f2 146 node_pointer,
7c673cae
FG
147 multi_index_container> bfm_header;
148
7c673cae
FG
149public:
150 /* All types are inherited from super, a few are explicitly
151 * brought forward here to save us some typename's.
152 */
153
154 typedef typename super::ctor_args_list ctor_args_list;
155 typedef IndexSpecifierList index_specifier_type_list;
156
157 typedef typename super::index_type_list index_type_list;
158
159 typedef typename super::iterator_type_list iterator_type_list;
160 typedef typename super::const_iterator_type_list const_iterator_type_list;
161 typedef typename super::value_type value_type;
162 typedef typename super::final_allocator_type allocator_type;
163 typedef typename super::iterator iterator;
164 typedef typename super::const_iterator const_iterator;
165
166 BOOST_STATIC_ASSERT(
167 detail::no_duplicate_tags_in_index_list<index_type_list>::value);
168
169 /* global project() needs to see this publicly */
170
171 typedef typename super::node_type node_type;
172
173 /* construct/copy/destroy */
174
175 explicit multi_index_container(
176
177#if BOOST_WORKAROUND(__IBMCPP__,<=600)
178 /* VisualAge seems to have an ETI issue with the default values
179 * for arguments args_list and al.
180 */
181
182 const ctor_args_list& args_list=
183 typename mpl::identity<multi_index_container>::type::
184 ctor_args_list(),
185 const allocator_type& al=
186 typename mpl::identity<multi_index_container>::type::
187 allocator_type()):
188#else
189 const ctor_args_list& args_list=ctor_args_list(),
190 const allocator_type& al=allocator_type()):
191#endif
192
193 bfm_allocator(al),
194 super(args_list,bfm_allocator::member),
195 node_count(0)
196 {
197 BOOST_MULTI_INDEX_CHECK_INVARIANT;
198 }
199
200 explicit multi_index_container(const allocator_type& al):
201 bfm_allocator(al),
202 super(ctor_args_list(),bfm_allocator::member),
203 node_count(0)
204 {
205 BOOST_MULTI_INDEX_CHECK_INVARIANT;
206 }
207
208 template<typename InputIterator>
209 multi_index_container(
210 InputIterator first,InputIterator last,
211
212#if BOOST_WORKAROUND(__IBMCPP__,<=600)
213 /* VisualAge seems to have an ETI issue with the default values
214 * for arguments args_list and al.
215 */
216
217 const ctor_args_list& args_list=
218 typename mpl::identity<multi_index_container>::type::
219 ctor_args_list(),
220 const allocator_type& al=
221 typename mpl::identity<multi_index_container>::type::
222 allocator_type()):
223#else
224 const ctor_args_list& args_list=ctor_args_list(),
225 const allocator_type& al=allocator_type()):
226#endif
227
228 bfm_allocator(al),
229 super(args_list,bfm_allocator::member),
230 node_count(0)
231 {
232 BOOST_MULTI_INDEX_CHECK_INVARIANT;
233 BOOST_TRY{
234 iterator hint=super::end();
235 for(;first!=last;++first){
236 hint=super::make_iterator(
237 insert_ref_(*first,hint.get_node()).first);
238 ++hint;
239 }
240 }
241 BOOST_CATCH(...){
242 clear_();
243 BOOST_RETHROW;
244 }
245 BOOST_CATCH_END
246 }
247
248#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
249 multi_index_container(
250 std::initializer_list<Value> list,
251 const ctor_args_list& args_list=ctor_args_list(),
252 const allocator_type& al=allocator_type()):
253 bfm_allocator(al),
254 super(args_list,bfm_allocator::member),
255 node_count(0)
256 {
257 BOOST_MULTI_INDEX_CHECK_INVARIANT;
258 BOOST_TRY{
259 typedef const Value* init_iterator;
260
261 iterator hint=super::end();
262 for(init_iterator first=list.begin(),last=list.end();
263 first!=last;++first){
264 hint=super::make_iterator(insert_(*first,hint.get_node()).first);
265 ++hint;
266 }
267 }
268 BOOST_CATCH(...){
269 clear_();
270 BOOST_RETHROW;
271 }
272 BOOST_CATCH_END
273 }
274#endif
275
276 multi_index_container(
277 const multi_index_container<Value,IndexSpecifierList,Allocator>& x):
278 bfm_allocator(x.bfm_allocator::member),
279 bfm_header(),
280 super(x),
281 node_count(0)
282 {
283 copy_map_type map(bfm_allocator::member,x.size(),x.header(),header());
284 for(const_iterator it=x.begin(),it_end=x.end();it!=it_end;++it){
285 map.clone(it.get_node());
286 }
287 super::copy_(x,map);
288 map.release();
289 node_count=x.size();
290
291 /* Not until this point are the indices required to be consistent,
292 * hence the position of the invariant checker.
293 */
294
295 BOOST_MULTI_INDEX_CHECK_INVARIANT;
296 }
297
298 multi_index_container(BOOST_RV_REF(multi_index_container) x):
299 bfm_allocator(x.bfm_allocator::member),
300 bfm_header(),
301 super(x,detail::do_not_copy_elements_tag()),
302 node_count(0)
303 {
304 BOOST_MULTI_INDEX_CHECK_INVARIANT;
305 BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(x);
306 swap_elements_(x);
307 }
308
309 ~multi_index_container()
310 {
311 delete_all_nodes_();
312 }
313
314#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
315 /* As per http://www.boost.org/doc/html/move/emulation_limitations.html
316 * #move.emulation_limitations.assignment_operator
317 */
318
319 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
320 const multi_index_container<Value,IndexSpecifierList,Allocator>& x)
321 {
322 multi_index_container y(x);
323 this->swap(y);
324 return *this;
325 }
326#endif
327
328 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
329 BOOST_COPY_ASSIGN_REF(multi_index_container) x)
330 {
331 multi_index_container y(x);
332 this->swap(y);
333 return *this;
334 }
335
336 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
337 BOOST_RV_REF(multi_index_container) x)
338 {
339 this->swap(x);
340 return *this;
341 }
342
343#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
344 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
345 std::initializer_list<Value> list)
346 {
347 BOOST_MULTI_INDEX_CHECK_INVARIANT;
348 typedef const Value* init_iterator;
349
350 multi_index_container x(*this,detail::do_not_copy_elements_tag());
351 iterator hint=x.end();
352 for(init_iterator first=list.begin(),last=list.end();
353 first!=last;++first){
354 hint=x.make_iterator(x.insert_(*first,hint.get_node()).first);
355 ++hint;
356 }
357 x.swap_elements_(*this);
358 return*this;
359 }
360#endif
361
362 allocator_type get_allocator()const BOOST_NOEXCEPT
363 {
364 return allocator_type(bfm_allocator::member);
365 }
366
367 /* retrieval of indices by number */
368
369#if !defined(BOOST_NO_MEMBER_TEMPLATES)
370 template<int N>
371 struct nth_index
372 {
373 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
374 typedef typename mpl::at_c<index_type_list,N>::type type;
375 };
376
377 template<int N>
378 typename nth_index<N>::type& get()BOOST_NOEXCEPT
379 {
380 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
381 return *this;
382 }
383
384 template<int N>
385 const typename nth_index<N>::type& get()const BOOST_NOEXCEPT
386 {
387 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
388 return *this;
389 }
390#endif
391
392 /* retrieval of indices by tag */
393
394#if !defined(BOOST_NO_MEMBER_TEMPLATES)
395 template<typename Tag>
396 struct index
397 {
398 typedef typename mpl::find_if<
399 index_type_list,
400 detail::has_tag<Tag>
401 >::type iter;
402
403 BOOST_STATIC_CONSTANT(
404 bool,index_found=!(is_same<iter,typename mpl::end<index_type_list>::type >::value));
405 BOOST_STATIC_ASSERT(index_found);
406
407 typedef typename mpl::deref<iter>::type type;
408 };
409
410 template<typename Tag>
411 typename index<Tag>::type& get()BOOST_NOEXCEPT
412 {
413 return *this;
414 }
415
416 template<typename Tag>
417 const typename index<Tag>::type& get()const BOOST_NOEXCEPT
418 {
419 return *this;
420 }
421#endif
422
423 /* projection of iterators by number */
424
425#if !defined(BOOST_NO_MEMBER_TEMPLATES)
426 template<int N>
427 struct nth_index_iterator
428 {
429 typedef typename nth_index<N>::type::iterator type;
430 };
431
432 template<int N>
433 struct nth_index_const_iterator
434 {
435 typedef typename nth_index<N>::type::const_iterator type;
436 };
437
438 template<int N,typename IteratorType>
439 typename nth_index_iterator<N>::type project(IteratorType it)
440 {
441 typedef typename nth_index<N>::type index_type;
442
443#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
444 BOOST_STATIC_ASSERT(
445 (mpl::contains<iterator_type_list,IteratorType>::value));
446#endif
447
448 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
449 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
450 it,static_cast<typename IteratorType::container_type&>(*this));
451
452 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
453 }
454
455 template<int N,typename IteratorType>
456 typename nth_index_const_iterator<N>::type project(IteratorType it)const
457 {
458 typedef typename nth_index<N>::type index_type;
459
460#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
461 BOOST_STATIC_ASSERT((
462 mpl::contains<iterator_type_list,IteratorType>::value||
463 mpl::contains<const_iterator_type_list,IteratorType>::value));
464#endif
465
466 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
467 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
468 it,static_cast<const typename IteratorType::container_type&>(*this));
469 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
470 }
471#endif
472
473 /* projection of iterators by tag */
474
475#if !defined(BOOST_NO_MEMBER_TEMPLATES)
476 template<typename Tag>
477 struct index_iterator
478 {
479 typedef typename index<Tag>::type::iterator type;
480 };
481
482 template<typename Tag>
483 struct index_const_iterator
484 {
485 typedef typename index<Tag>::type::const_iterator type;
486 };
487
488 template<typename Tag,typename IteratorType>
489 typename index_iterator<Tag>::type project(IteratorType it)
490 {
491 typedef typename index<Tag>::type index_type;
492
493#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
494 BOOST_STATIC_ASSERT(
495 (mpl::contains<iterator_type_list,IteratorType>::value));
496#endif
497
498 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
499 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
500 it,static_cast<typename IteratorType::container_type&>(*this));
501 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
502 }
503
504 template<typename Tag,typename IteratorType>
505 typename index_const_iterator<Tag>::type project(IteratorType it)const
506 {
507 typedef typename index<Tag>::type index_type;
508
509#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* fails in Sun C++ 5.7 */
510 BOOST_STATIC_ASSERT((
511 mpl::contains<iterator_type_list,IteratorType>::value||
512 mpl::contains<const_iterator_type_list,IteratorType>::value));
513#endif
514
515 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
516 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
517 it,static_cast<const typename IteratorType::container_type&>(*this));
518 return index_type::make_iterator(static_cast<node_type*>(it.get_node()));
519 }
520#endif
521
522BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
523 typedef typename super::copy_map_type copy_map_type;
524
525#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
526 multi_index_container(
527 const multi_index_container<Value,IndexSpecifierList,Allocator>& x,
528 detail::do_not_copy_elements_tag):
529 bfm_allocator(x.bfm_allocator::member),
530 bfm_header(),
531 super(x,detail::do_not_copy_elements_tag()),
532 node_count(0)
533 {
534 BOOST_MULTI_INDEX_CHECK_INVARIANT;
535 }
536#endif
537
538 node_type* header()const
539 {
540 return &*bfm_header::member;
541 }
542
543 node_type* allocate_node()
544 {
11fdf7f2 545#ifdef BOOST_NO_CXX11_ALLOCATOR
7c673cae 546 return &*bfm_allocator::member.allocate(1);
11fdf7f2
TL
547#else
548 return &*node_allocator_traits::allocate(bfm_allocator::member,1);
549#endif
7c673cae
FG
550 }
551
552 void deallocate_node(node_type* x)
553 {
11fdf7f2 554#ifdef BOOST_NO_CXX11_ALLOCATOR
7c673cae 555 bfm_allocator::member.deallocate(static_cast<node_pointer>(x),1);
11fdf7f2
TL
556#else
557 node_allocator_traits::deallocate(bfm_allocator::member,static_cast<node_pointer>(x),1);
558#endif
7c673cae
FG
559 }
560
561 bool empty_()const
562 {
563 return node_count==0;
564 }
565
566 std::size_t size_()const
567 {
568 return node_count;
569 }
570
571 std::size_t max_size_()const
572 {
573 return static_cast<std::size_t >(-1);
574 }
575
576 template<typename Variant>
577 std::pair<node_type*,bool> insert_(const Value& v,Variant variant)
578 {
579 node_type* x=0;
580 node_type* res=super::insert_(v,x,variant);
581 if(res==x){
582 ++node_count;
583 return std::pair<node_type*,bool>(res,true);
584 }
585 else{
586 return std::pair<node_type*,bool>(res,false);
587 }
588 }
589
590 std::pair<node_type*,bool> insert_(const Value& v)
591 {
592 return insert_(v,detail::lvalue_tag());
593 }
594
595 std::pair<node_type*,bool> insert_rv_(const Value& v)
596 {
597 return insert_(v,detail::rvalue_tag());
598 }
599
600 template<typename T>
601 std::pair<node_type*,bool> insert_ref_(T& t)
602 {
603 node_type* x=allocate_node();
604 BOOST_TRY{
11fdf7f2 605 new(boost::addressof(x->value())) value_type(t);
7c673cae
FG
606 BOOST_TRY{
607 node_type* res=super::insert_(x->value(),x,detail::emplaced_tag());
608 if(res==x){
609 ++node_count;
610 return std::pair<node_type*,bool>(res,true);
611 }
612 else{
11fdf7f2 613 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
614 deallocate_node(x);
615 return std::pair<node_type*,bool>(res,false);
616 }
617 }
618 BOOST_CATCH(...){
11fdf7f2 619 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
620 BOOST_RETHROW;
621 }
622 BOOST_CATCH_END
623 }
624 BOOST_CATCH(...){
625 deallocate_node(x);
626 BOOST_RETHROW;
627 }
628 BOOST_CATCH_END
629 }
630
631 std::pair<node_type*,bool> insert_ref_(const value_type& x)
632 {
633 return insert_(x);
634 }
635
636 std::pair<node_type*,bool> insert_ref_(value_type& x)
637 {
638 return insert_(x);
639 }
640
641 template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
642 std::pair<node_type*,bool> emplace_(
643 BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
644 {
645 node_type* x=allocate_node();
646 BOOST_TRY{
647 detail::vartempl_placement_new(
11fdf7f2 648 boost::addressof(x->value()),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
7c673cae
FG
649 BOOST_TRY{
650 node_type* res=super::insert_(x->value(),x,detail::emplaced_tag());
651 if(res==x){
652 ++node_count;
653 return std::pair<node_type*,bool>(res,true);
654 }
655 else{
11fdf7f2 656 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
657 deallocate_node(x);
658 return std::pair<node_type*,bool>(res,false);
659 }
660 }
661 BOOST_CATCH(...){
11fdf7f2 662 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
663 BOOST_RETHROW;
664 }
665 BOOST_CATCH_END
666 }
667 BOOST_CATCH(...){
668 deallocate_node(x);
669 BOOST_RETHROW;
670 }
671 BOOST_CATCH_END
672 }
673
674 template<typename Variant>
675 std::pair<node_type*,bool> insert_(
676 const Value& v,node_type* position,Variant variant)
677 {
678 node_type* x=0;
679 node_type* res=super::insert_(v,position,x,variant);
680 if(res==x){
681 ++node_count;
682 return std::pair<node_type*,bool>(res,true);
683 }
684 else{
685 return std::pair<node_type*,bool>(res,false);
686 }
687 }
688
689 std::pair<node_type*,bool> insert_(const Value& v,node_type* position)
690 {
691 return insert_(v,position,detail::lvalue_tag());
692 }
693
694 std::pair<node_type*,bool> insert_rv_(const Value& v,node_type* position)
695 {
696 return insert_(v,position,detail::rvalue_tag());
697 }
698
699 template<typename T>
700 std::pair<node_type*,bool> insert_ref_(
701 T& t,node_type* position)
702 {
703 node_type* x=allocate_node();
704 BOOST_TRY{
11fdf7f2 705 new(boost::addressof(x->value())) value_type(t);
7c673cae
FG
706 BOOST_TRY{
707 node_type* res=super::insert_(
708 x->value(),position,x,detail::emplaced_tag());
709 if(res==x){
710 ++node_count;
711 return std::pair<node_type*,bool>(res,true);
712 }
713 else{
11fdf7f2 714 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
715 deallocate_node(x);
716 return std::pair<node_type*,bool>(res,false);
717 }
718 }
719 BOOST_CATCH(...){
11fdf7f2 720 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
721 BOOST_RETHROW;
722 }
723 BOOST_CATCH_END
724 }
725 BOOST_CATCH(...){
726 deallocate_node(x);
727 BOOST_RETHROW;
728 }
729 BOOST_CATCH_END
730 }
731
732 std::pair<node_type*,bool> insert_ref_(
733 const value_type& x,node_type* position)
734 {
735 return insert_(x,position);
736 }
737
738 std::pair<node_type*,bool> insert_ref_(
739 value_type& x,node_type* position)
740 {
741 return insert_(x,position);
742 }
743
744 template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
745 std::pair<node_type*,bool> emplace_hint_(
746 node_type* position,
747 BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
748 {
749 node_type* x=allocate_node();
750 BOOST_TRY{
751 detail::vartempl_placement_new(
11fdf7f2 752 boost::addressof(x->value()),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
7c673cae
FG
753 BOOST_TRY{
754 node_type* res=super::insert_(
755 x->value(),position,x,detail::emplaced_tag());
756 if(res==x){
757 ++node_count;
758 return std::pair<node_type*,bool>(res,true);
759 }
760 else{
11fdf7f2 761 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
762 deallocate_node(x);
763 return std::pair<node_type*,bool>(res,false);
764 }
765 }
766 BOOST_CATCH(...){
11fdf7f2 767 boost::detail::allocator::destroy(boost::addressof(x->value()));
7c673cae
FG
768 BOOST_RETHROW;
769 }
770 BOOST_CATCH_END
771 }
772 BOOST_CATCH(...){
773 deallocate_node(x);
774 BOOST_RETHROW;
775 }
776 BOOST_CATCH_END
777 }
778
779 void erase_(node_type* x)
780 {
781 --node_count;
782 super::erase_(x);
783 deallocate_node(x);
784 }
785
786 void delete_node_(node_type* x)
787 {
788 super::delete_node_(x);
789 deallocate_node(x);
790 }
791
792 void delete_all_nodes_()
793 {
794 super::delete_all_nodes_();
795 }
796
797 void clear_()
798 {
799 delete_all_nodes_();
800 super::clear_();
801 node_count=0;
802 }
803
804 void swap_(multi_index_container<Value,IndexSpecifierList,Allocator>& x)
805 {
806 if(bfm_allocator::member!=x.bfm_allocator::member){
807 detail::adl_swap(bfm_allocator::member,x.bfm_allocator::member);
808 }
809 std::swap(bfm_header::member,x.bfm_header::member);
810 super::swap_(x);
811 std::swap(node_count,x.node_count);
812 }
813
814 void swap_elements_(
815 multi_index_container<Value,IndexSpecifierList,Allocator>& x)
816 {
817 std::swap(bfm_header::member,x.bfm_header::member);
818 super::swap_elements_(x);
819 std::swap(node_count,x.node_count);
820 }
821
822 bool replace_(const Value& k,node_type* x)
823 {
824 return super::replace_(k,x,detail::lvalue_tag());
825 }
826
827 bool replace_rv_(const Value& k,node_type* x)
828 {
829 return super::replace_(k,x,detail::rvalue_tag());
830 }
831
832 template<typename Modifier>
833 bool modify_(Modifier& mod,node_type* x)
834 {
b32b8144
FG
835 BOOST_TRY{
836 mod(const_cast<value_type&>(x->value()));
837 }
838 BOOST_CATCH(...){
839 this->erase_(x);
840 BOOST_RETHROW;
841 }
842 BOOST_CATCH_END
7c673cae
FG
843
844 BOOST_TRY{
845 if(!super::modify_(x)){
846 deallocate_node(x);
847 --node_count;
848 return false;
849 }
850 else return true;
851 }
852 BOOST_CATCH(...){
853 deallocate_node(x);
854 --node_count;
855 BOOST_RETHROW;
856 }
857 BOOST_CATCH_END
858 }
859
860 template<typename Modifier,typename Rollback>
861 bool modify_(Modifier& mod,Rollback& back_,node_type* x)
862 {
b32b8144
FG
863 BOOST_TRY{
864 mod(const_cast<value_type&>(x->value()));
865 }
866 BOOST_CATCH(...){
867 this->erase_(x);
868 BOOST_RETHROW;
869 }
870 BOOST_CATCH_END
7c673cae
FG
871
872 bool b;
873 BOOST_TRY{
874 b=super::modify_rollback_(x);
875 }
876 BOOST_CATCH(...){
877 BOOST_TRY{
878 back_(const_cast<value_type&>(x->value()));
b32b8144 879 if(!super::check_rollback_(x))this->erase_(x);
7c673cae
FG
880 BOOST_RETHROW;
881 }
882 BOOST_CATCH(...){
883 this->erase_(x);
884 BOOST_RETHROW;
885 }
886 BOOST_CATCH_END
887 }
888 BOOST_CATCH_END
889
890 BOOST_TRY{
891 if(!b){
892 back_(const_cast<value_type&>(x->value()));
b32b8144 893 if(!super::check_rollback_(x))this->erase_(x);
7c673cae
FG
894 return false;
895 }
896 else return true;
897 }
898 BOOST_CATCH(...){
899 this->erase_(x);
900 BOOST_RETHROW;
901 }
902 BOOST_CATCH_END
903 }
904
905#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
906 /* serialization */
907
908 friend class boost::serialization::access;
909
910 BOOST_SERIALIZATION_SPLIT_MEMBER()
911
912 typedef typename super::index_saver_type index_saver_type;
913 typedef typename super::index_loader_type index_loader_type;
914
915 template<class Archive>
916 void save(Archive& ar,const unsigned int version)const
917 {
918 const serialization::collection_size_type s(size_());
919 const detail::serialization_version<value_type> value_version;
920 ar<<serialization::make_nvp("count",s);
921 ar<<serialization::make_nvp("value_version",value_version);
922
923 index_saver_type sm(bfm_allocator::member,s);
924
925 for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){
11fdf7f2
TL
926 serialization::save_construct_data_adl(
927 ar,boost::addressof(*it),value_version);
7c673cae
FG
928 ar<<serialization::make_nvp("item",*it);
929 sm.add(it.get_node(),ar,version);
930 }
931 sm.add_track(header(),ar,version);
932
933 super::save_(ar,version,sm);
934 }
935
936 template<class Archive>
937 void load(Archive& ar,const unsigned int version)
938 {
939 BOOST_MULTI_INDEX_CHECK_INVARIANT;
940
941 clear_();
942 serialization::collection_size_type s;
943 detail::serialization_version<value_type> value_version;
944 if(version<1){
945 std::size_t sz;
946 ar>>serialization::make_nvp("count",sz);
947 s=static_cast<serialization::collection_size_type>(sz);
948 }
949 else{
950 ar>>serialization::make_nvp("count",s);
951 }
952 if(version<2){
953 value_version=0;
954 }
955 else{
956 ar>>serialization::make_nvp("value_version",value_version);
957 }
958
959 index_loader_type lm(bfm_allocator::member,s);
960
961 for(std::size_t n=0;n<s;++n){
962 detail::archive_constructed<Value> value("item",ar,value_version);
963 std::pair<node_type*,bool> p=insert_(
964 value.get(),super::end().get_node());
965 if(!p.second)throw_exception(
966 archive::archive_exception(
967 archive::archive_exception::other_exception));
11fdf7f2
TL
968 ar.reset_object_address(
969 boost::addressof(p.first->value()),boost::addressof(value.get()));
7c673cae
FG
970 lm.add(p.first,ar,version);
971 }
972 lm.add_track(header(),ar,version);
973
974 super::load_(ar,version,lm);
975 }
976#endif
977
978#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
979 /* invariant stuff */
980
981 bool invariant_()const
982 {
983 return super::invariant_();
984 }
985
986 void check_invariant_()const
987 {
988 BOOST_MULTI_INDEX_INVARIANT_ASSERT(invariant_());
989 }
990#endif
991
992private:
993 std::size_t node_count;
994
995#if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\
996 BOOST_WORKAROUND(__MWERKS__,<=0x3003)
997#pragma parse_mfunc_templ reset
998#endif
999};
1000
1001#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
1002#pragma warning(pop) /* C4522 */
1003#endif
1004
1005/* retrieval of indices by number */
1006
1007template<typename MultiIndexContainer,int N>
1008struct nth_index
1009{
1010 BOOST_STATIC_CONSTANT(
1011 int,
1012 M=mpl::size<typename MultiIndexContainer::index_type_list>::type::value);
1013 BOOST_STATIC_ASSERT(N>=0&&N<M);
1014 typedef typename mpl::at_c<
1015 typename MultiIndexContainer::index_type_list,N>::type type;
1016};
1017
1018template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
1019typename nth_index<
1020 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type&
1021get(
1022 multi_index_container<Value,IndexSpecifierList,Allocator>& m)BOOST_NOEXCEPT
1023{
1024 typedef multi_index_container<
1025 Value,IndexSpecifierList,Allocator> multi_index_type;
1026 typedef typename nth_index<
1027 multi_index_container<
1028 Value,IndexSpecifierList,Allocator>,
1029 N
1030 >::type index_type;
1031
1032 BOOST_STATIC_ASSERT(N>=0&&
1033 N<
1034 mpl::size<
1035 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list
1036 >::type::value);
1037
1038 return detail::converter<multi_index_type,index_type>::index(m);
1039}
1040
1041template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
1042const typename nth_index<
1043 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type&
1044get(
1045 const multi_index_container<Value,IndexSpecifierList,Allocator>& m
1046)BOOST_NOEXCEPT
1047{
1048 typedef multi_index_container<
1049 Value,IndexSpecifierList,Allocator> multi_index_type;
1050 typedef typename nth_index<
1051 multi_index_container<
1052 Value,IndexSpecifierList,Allocator>,
1053 N
1054 >::type index_type;
1055
1056 BOOST_STATIC_ASSERT(N>=0&&
1057 N<
1058 mpl::size<
1059 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list
1060 >::type::value);
1061
1062 return detail::converter<multi_index_type,index_type>::index(m);
1063}
1064
1065/* retrieval of indices by tag */
1066
1067template<typename MultiIndexContainer,typename Tag>
1068struct index
1069{
1070 typedef typename MultiIndexContainer::index_type_list index_type_list;
1071
1072 typedef typename mpl::find_if<
1073 index_type_list,
1074 detail::has_tag<Tag>
1075 >::type iter;
1076
1077 BOOST_STATIC_CONSTANT(
1078 bool,index_found=!(is_same<iter,typename mpl::end<index_type_list>::type >::value));
1079 BOOST_STATIC_ASSERT(index_found);
1080
1081 typedef typename mpl::deref<iter>::type type;
1082};
1083
1084template<
1085 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator
1086>
1087typename ::boost::multi_index::index<
1088 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type&
1089get(
1090 multi_index_container<Value,IndexSpecifierList,Allocator>& m)BOOST_NOEXCEPT
1091{
1092 typedef multi_index_container<
1093 Value,IndexSpecifierList,Allocator> multi_index_type;
1094 typedef typename ::boost::multi_index::index<
1095 multi_index_container<
1096 Value,IndexSpecifierList,Allocator>,
1097 Tag
1098 >::type index_type;
1099
1100 return detail::converter<multi_index_type,index_type>::index(m);
1101}
1102
1103template<
1104 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator
1105>
1106const typename ::boost::multi_index::index<
1107 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type&
1108get(
1109 const multi_index_container<Value,IndexSpecifierList,Allocator>& m
1110)BOOST_NOEXCEPT
1111{
1112 typedef multi_index_container<
1113 Value,IndexSpecifierList,Allocator> multi_index_type;
1114 typedef typename ::boost::multi_index::index<
1115 multi_index_container<
1116 Value,IndexSpecifierList,Allocator>,
1117 Tag
1118 >::type index_type;
1119
1120 return detail::converter<multi_index_type,index_type>::index(m);
1121}
1122
1123/* projection of iterators by number */
1124
1125template<typename MultiIndexContainer,int N>
1126struct nth_index_iterator
1127{
1128 typedef typename nth_index<MultiIndexContainer,N>::type::iterator type;
1129};
1130
1131template<typename MultiIndexContainer,int N>
1132struct nth_index_const_iterator
1133{
1134 typedef typename nth_index<MultiIndexContainer,N>::type::const_iterator type;
1135};
1136
1137template<
1138 int N,typename IteratorType,
1139 typename Value,typename IndexSpecifierList,typename Allocator>
1140typename nth_index_iterator<
1141 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type
1142project(
1143 multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1144 IteratorType it)
1145{
1146 typedef multi_index_container<
1147 Value,IndexSpecifierList,Allocator> multi_index_type;
1148 typedef typename nth_index<multi_index_type,N>::type index_type;
1149
1150#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1151 BOOST_STATIC_ASSERT((
1152 mpl::contains<
1153 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1154 IteratorType>::value));
1155#endif
1156
1157 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
1158
1159#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1160 typedef detail::converter<
1161 multi_index_type,
1162 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1163 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1164#endif
1165
1166 return detail::converter<multi_index_type,index_type>::iterator(
1167 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1168}
1169
1170template<
1171 int N,typename IteratorType,
1172 typename Value,typename IndexSpecifierList,typename Allocator>
1173typename nth_index_const_iterator<
1174 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type
1175project(
1176 const multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1177 IteratorType it)
1178{
1179 typedef multi_index_container<
1180 Value,IndexSpecifierList,Allocator> multi_index_type;
1181 typedef typename nth_index<multi_index_type,N>::type index_type;
1182
1183#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1184 BOOST_STATIC_ASSERT((
1185 mpl::contains<
1186 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1187 IteratorType>::value||
1188 mpl::contains<
1189 BOOST_DEDUCED_TYPENAME multi_index_type::const_iterator_type_list,
1190 IteratorType>::value));
1191#endif
1192
1193 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
1194
1195#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1196 typedef detail::converter<
1197 multi_index_type,
1198 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1199 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1200#endif
1201
1202 return detail::converter<multi_index_type,index_type>::const_iterator(
1203 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1204}
1205
1206/* projection of iterators by tag */
1207
1208template<typename MultiIndexContainer,typename Tag>
1209struct index_iterator
1210{
1211 typedef typename ::boost::multi_index::index<
1212 MultiIndexContainer,Tag>::type::iterator type;
1213};
1214
1215template<typename MultiIndexContainer,typename Tag>
1216struct index_const_iterator
1217{
1218 typedef typename ::boost::multi_index::index<
1219 MultiIndexContainer,Tag>::type::const_iterator type;
1220};
1221
1222template<
1223 typename Tag,typename IteratorType,
1224 typename Value,typename IndexSpecifierList,typename Allocator>
1225typename index_iterator<
1226 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type
1227project(
1228 multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1229 IteratorType it)
1230{
1231 typedef multi_index_container<
1232 Value,IndexSpecifierList,Allocator> multi_index_type;
1233 typedef typename ::boost::multi_index::index<
1234 multi_index_type,Tag>::type index_type;
1235
1236#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1237 BOOST_STATIC_ASSERT((
1238 mpl::contains<
1239 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1240 IteratorType>::value));
1241#endif
1242
1243 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
1244
1245#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1246 typedef detail::converter<
1247 multi_index_type,
1248 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1249 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1250#endif
1251
1252 return detail::converter<multi_index_type,index_type>::iterator(
1253 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1254}
1255
1256template<
1257 typename Tag,typename IteratorType,
1258 typename Value,typename IndexSpecifierList,typename Allocator>
1259typename index_const_iterator<
1260 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type
1261project(
1262 const multi_index_container<Value,IndexSpecifierList,Allocator>& m,
1263 IteratorType it)
1264{
1265 typedef multi_index_container<
1266 Value,IndexSpecifierList,Allocator> multi_index_type;
1267 typedef typename ::boost::multi_index::index<
1268 multi_index_type,Tag>::type index_type;
1269
1270#if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580) /* Sun C++ 5.7 fails */
1271 BOOST_STATIC_ASSERT((
1272 mpl::contains<
1273 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
1274 IteratorType>::value||
1275 mpl::contains<
1276 BOOST_DEDUCED_TYPENAME multi_index_type::const_iterator_type_list,
1277 IteratorType>::value));
1278#endif
1279
1280 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
1281
1282#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1283 typedef detail::converter<
1284 multi_index_type,
1285 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
1286 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
1287#endif
1288
1289 return detail::converter<multi_index_type,index_type>::const_iterator(
1290 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
1291}
1292
1293/* Comparison. Simple forward to first index. */
1294
1295template<
1296 typename Value1,typename IndexSpecifierList1,typename Allocator1,
1297 typename Value2,typename IndexSpecifierList2,typename Allocator2
1298>
1299bool operator==(
1300 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
1301 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1302{
1303 return get<0>(x)==get<0>(y);
1304}
1305
1306template<
1307 typename Value1,typename IndexSpecifierList1,typename Allocator1,
1308 typename Value2,typename IndexSpecifierList2,typename Allocator2
1309>
1310bool operator<(
1311 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
1312 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1313{
1314 return get<0>(x)<get<0>(y);
1315}
1316
1317template<
1318 typename Value1,typename IndexSpecifierList1,typename Allocator1,
1319 typename Value2,typename IndexSpecifierList2,typename Allocator2
1320>
1321bool operator!=(
1322 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
1323 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1324{
1325 return get<0>(x)!=get<0>(y);
1326}
1327
1328template<
1329 typename Value1,typename IndexSpecifierList1,typename Allocator1,
1330 typename Value2,typename IndexSpecifierList2,typename Allocator2
1331>
1332bool operator>(
1333 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
1334 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1335{
1336 return get<0>(x)>get<0>(y);
1337}
1338
1339template<
1340 typename Value1,typename IndexSpecifierList1,typename Allocator1,
1341 typename Value2,typename IndexSpecifierList2,typename Allocator2
1342>
1343bool operator>=(
1344 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
1345 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1346{
1347 return get<0>(x)>=get<0>(y);
1348}
1349
1350template<
1351 typename Value1,typename IndexSpecifierList1,typename Allocator1,
1352 typename Value2,typename IndexSpecifierList2,typename Allocator2
1353>
1354bool operator<=(
1355 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
1356 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1357{
1358 return get<0>(x)<=get<0>(y);
1359}
1360
1361/* specialized algorithms */
1362
1363template<typename Value,typename IndexSpecifierList,typename Allocator>
1364void swap(
1365 multi_index_container<Value,IndexSpecifierList,Allocator>& x,
1366 multi_index_container<Value,IndexSpecifierList,Allocator>& y)
1367{
1368 x.swap(y);
1369}
1370
1371} /* namespace multi_index */
1372
1373#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
1374/* class version = 1 : we now serialize the size through
1375 * boost::serialization::collection_size_type.
1376 * class version = 2 : proper use of {save|load}_construct_data.
1377 */
1378
1379namespace serialization {
1380template<typename Value,typename IndexSpecifierList,typename Allocator>
1381struct version<
1382 boost::multi_index_container<Value,IndexSpecifierList,Allocator>
1383>
1384{
1385 BOOST_STATIC_CONSTANT(int,value=2);
1386};
1387} /* namespace serialization */
1388#endif
1389
1390/* Associated global functions are promoted to namespace boost, except
1391 * comparison operators and swap, which are meant to be Koenig looked-up.
1392 */
1393
1394using multi_index::get;
1395using multi_index::project;
1396
1397} /* namespace boost */
1398
1399#undef BOOST_MULTI_INDEX_CHECK_INVARIANT
1400#undef BOOST_MULTI_INDEX_CHECK_INVARIANT_OF
1401
1402#endif