1 /* Multiply indexed container.
3 * Copyright 2003-2007 Joaquín M López Muñoz.
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)
8 * See http://www.boost.org/libs/multi_index for library home page.
11 #ifndef BOOST_MULTI_INDEX_HPP
12 #define BOOST_MULTI_INDEX_HPP
14 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
18 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
20 #include <boost/detail/allocator_utilities.hpp>
21 #include <boost/detail/no_exceptions_support.hpp>
22 #include <boost/detail/workaround.hpp>
23 #include <boost/mpl/at.hpp>
24 #include <boost/mpl/contains.hpp>
25 #include <boost/mpl/find_if.hpp>
26 #include <boost/mpl/identity.hpp>
27 #include <boost/mpl/int.hpp>
28 #include <boost/mpl/size.hpp>
29 #include <boost/mpl/deref.hpp>
30 #include <boost/multi_index_container_fwd.hpp>
31 #include <boost/multi_index/detail/access_specifier.hpp>
32 #include <boost/multi_index/detail/base_type.hpp>
33 #include <boost/multi_index/detail/converter.hpp>
34 #include <boost/multi_index/detail/def_ctor_tuple_cons.hpp>
35 #include <boost/multi_index/detail/header_holder.hpp>
36 #include <boost/multi_index/detail/has_tag.hpp>
37 #include <boost/multi_index/detail/no_duplicate_tags.hpp>
38 #include <boost/multi_index/detail/prevent_eti.hpp>
39 #include <boost/multi_index/detail/safe_mode.hpp>
40 #include <boost/multi_index/detail/scope_guard.hpp>
41 #include <boost/static_assert.hpp>
42 #include <boost/type_traits/is_same.hpp>
43 #include <boost/utility/base_from_member.hpp>
45 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
46 #include <boost/multi_index/detail/archive_constructed.hpp>
47 #include <boost/serialization/nvp.hpp>
48 #include <boost/serialization/split_member.hpp>
49 #include <boost/throw_exception.hpp>
52 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
53 #include <boost/multi_index/detail/invariant_assert.hpp>
54 #define BOOST_MULTI_INDEX_CHECK_INVARIANT \
55 detail::scope_guard BOOST_JOIN(check_invariant_,__LINE__)= \
56 detail::make_obj_guard(*this,&multi_index_container::check_invariant_); \
57 BOOST_JOIN(check_invariant_,__LINE__).touch();
59 #define BOOST_MULTI_INDEX_CHECK_INVARIANT
64 namespace multi_index{
66 template<typename Value,typename IndexSpecifierList,typename Allocator>
67 class multi_index_container:
68 private ::boost::base_from_member<
69 typename boost::detail::allocator::rebind_to<
71 typename detail::multi_index_node_type<
72 Value,IndexSpecifierList,Allocator>::type
74 BOOST_MULTI_INDEX_PRIVATE_IF_MEMBER_TEMPLATE_FRIENDS detail::header_holder<
75 typename detail::multi_index_node_type<
76 Value,IndexSpecifierList,Allocator>::type,
77 multi_index_container<Value,IndexSpecifierList,Allocator> >,
78 public detail::multi_index_base_type<
79 Value,IndexSpecifierList,Allocator>::type
81 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\
82 BOOST_WORKAROUND(__MWERKS__,<=0x3003)
83 /* The "ISO C++ Template Parser" option in CW8.3 has a problem with the
84 * lifetime of const references bound to temporaries --precisely what
88 #pragma parse_mfunc_templ off
92 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
93 template <typename,typename,typename> friend class detail::index_base;
94 template <typename,typename> friend class detail::header_holder;
95 template <typename,typename> friend class detail::converter;
98 typedef typename detail::multi_index_base_type<
99 Value,IndexSpecifierList,Allocator>::type super;
100 typedef ::boost::base_from_member<
101 typename boost::detail::allocator::rebind_to<
103 typename super::node_type
104 >::type> bfm_allocator;
105 typedef detail::header_holder<
106 typename super::node_type,
107 multi_index_container> bfm_header;
109 #if BOOST_WORKAROUND(BOOST_MSVC,<1300)
110 /* see definition of index_type_list below */
111 typedef typename super::index_type_list super_index_type_list;
115 /* All types are inherited from super, a few are explicitly
116 * brought forward here to save us some typename's.
119 #if defined(BOOST_MSVC)
121 detail::default_constructible_tuple_cons<
122 typename super::ctor_args_list> ctor_args_list;
124 typedef typename super::ctor_args_list ctor_args_list;
127 typedef IndexSpecifierList index_specifier_type_list;
129 #if BOOST_WORKAROUND(BOOST_MSVC,<1300)
130 /* MSVC++ 6.0 chokes on moderately long index lists (around 6 indices
131 * or more), with errors ranging from corrupt exes to duplicate
132 * comdats. The following type hiding hack alleviates this condition;
133 * best results combined with type hiding of the indexed_by construct
134 * itself, as explained in the "Compiler specifics" section of
138 struct index_type_list:super_index_type_list
140 typedef index_type_list type;
141 typedef typename super_index_type_list::back back;
142 typedef mpl::v_iter<type,0> begin;
145 mpl::size<super_index_type_list>::value> end;
148 typedef typename super::index_type_list index_type_list;
151 typedef typename super::iterator_type_list iterator_type_list;
152 typedef typename super::const_iterator_type_list const_iterator_type_list;
153 typedef typename super::value_type value_type;
154 typedef typename super::final_allocator_type allocator_type;
155 typedef typename super::iterator iterator;
156 typedef typename super::const_iterator const_iterator;
159 detail::no_duplicate_tags_in_index_list<index_type_list>::value);
161 /* global project() needs to see this publicly */
163 typedef typename super::node_type node_type;
165 /* construct/copy/destroy */
167 explicit multi_index_container(
169 #if BOOST_WORKAROUND(__IBMCPP__,<=600)
170 /* VisualAge seems to have an ETI issue with the default values
171 * for arguments args_list and al.
174 const ctor_args_list& args_list=
175 typename mpl::identity<multi_index_container>::type::
177 const allocator_type& al=
178 typename mpl::identity<multi_index_container>::type::
181 const ctor_args_list& args_list=ctor_args_list(),
182 const allocator_type& al=allocator_type()):
186 super(args_list,bfm_allocator::member),
189 BOOST_MULTI_INDEX_CHECK_INVARIANT;
192 template<typename InputIterator>
193 multi_index_container(
194 InputIterator first,InputIterator last,
196 #if BOOST_WORKAROUND(__IBMCPP__,<=600)
197 /* VisualAge seems to have an ETI issue with the default values
198 * for arguments args_list and al.
201 const ctor_args_list& args_list=
202 typename mpl::identity<multi_index_container>::type::
204 const allocator_type& al=
205 typename mpl::identity<multi_index_container>::type::
208 const ctor_args_list& args_list=ctor_args_list(),
209 const allocator_type& al=allocator_type()):
213 super(args_list,bfm_allocator::member),
216 BOOST_MULTI_INDEX_CHECK_INVARIANT;
218 iterator hint=super::end();
219 for(;first!=last;++first){
220 hint=super::make_iterator(insert_(*first,hint.get_node()).first);
230 multi_index_container(
231 const multi_index_container<Value,IndexSpecifierList,Allocator>& x):
232 bfm_allocator(x.bfm_allocator::member),
237 copy_map_type map(bfm_allocator::member,x.size(),x.header(),header());
238 for(const_iterator it=x.begin(),it_end=x.end();it!=it_end;++it){
239 map.clone(it.get_node());
245 /* Not until this point are the indices required to be consistent,
246 * hence the position of the invariant checker.
249 BOOST_MULTI_INDEX_CHECK_INVARIANT;
252 ~multi_index_container()
257 multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
258 const multi_index_container<Value,IndexSpecifierList,Allocator>& x)
260 BOOST_MULTI_INDEX_CHECK_INVARIANT;
261 multi_index_container<Value,IndexSpecifierList,Allocator> tmp(x);
266 allocator_type get_allocator()const
268 return allocator_type(bfm_allocator::member);
271 /* retrieval of indices by number */
273 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
277 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
278 typedef typename mpl::at_c<index_type_list,N>::type type;
282 typename nth_index<N>::type& get(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
284 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
289 const typename nth_index<N>::type& get(
290 BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int,N))const
292 BOOST_STATIC_ASSERT(N>=0&&N<mpl::size<index_type_list>::type::value);
297 /* retrieval of indices by tag */
299 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
300 template<typename Tag>
303 typedef typename mpl::find_if<
308 BOOST_STATIC_CONSTANT(
309 bool,index_found=!(is_same<iter,typename mpl::end<index_type_list>::type >::value));
310 BOOST_STATIC_ASSERT(index_found);
312 typedef typename mpl::deref<iter>::type type;
315 template<typename Tag>
316 typename index<Tag>::type& get(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag))
321 template<typename Tag>
322 const typename index<Tag>::type& get(
323 BOOST_EXPLICIT_TEMPLATE_TYPE(Tag))const
329 /* projection of iterators by number */
331 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
333 struct nth_index_iterator
335 typedef typename nth_index<N>::type::iterator type;
339 struct nth_index_const_iterator
341 typedef typename nth_index<N>::type::const_iterator type;
344 template<int N,typename IteratorType>
345 typename nth_index_iterator<N>::type project(
347 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
349 typedef typename nth_index<N>::type index;
352 (mpl::contains<iterator_type_list,IteratorType>::value));
354 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
355 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
356 it,static_cast<typename IteratorType::container_type&>(*this));
358 return index::make_iterator(static_cast<node_type*>(it.get_node()));
361 template<int N,typename IteratorType>
362 typename nth_index_const_iterator<N>::type project(
364 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))const
366 typedef typename nth_index<N>::type index;
368 BOOST_STATIC_ASSERT((
369 mpl::contains<iterator_type_list,IteratorType>::value||
370 mpl::contains<const_iterator_type_list,IteratorType>::value));
372 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
373 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
374 it,static_cast<const typename IteratorType::container_type&>(*this));
375 return index::make_iterator(static_cast<node_type*>(it.get_node()));
379 /* projection of iterators by tag */
381 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
382 template<typename Tag>
383 struct index_iterator
385 typedef typename index<Tag>::type::iterator type;
388 template<typename Tag>
389 struct index_const_iterator
391 typedef typename index<Tag>::type::const_iterator type;
394 template<typename Tag,typename IteratorType>
395 typename index_iterator<Tag>::type project(
397 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
399 typedef typename index<Tag>::type index;
402 (mpl::contains<iterator_type_list,IteratorType>::value));
404 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
405 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
406 it,static_cast<typename IteratorType::container_type&>(*this));
407 return index::make_iterator(static_cast<node_type*>(it.get_node()));
410 template<typename Tag,typename IteratorType>
411 typename index_const_iterator<Tag>::type project(
413 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))const
415 typedef typename index<Tag>::type index;
417 BOOST_STATIC_ASSERT((
418 mpl::contains<iterator_type_list,IteratorType>::value||
419 mpl::contains<const_iterator_type_list,IteratorType>::value));
421 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
422 BOOST_MULTI_INDEX_CHECK_IS_OWNER(
423 it,static_cast<const typename IteratorType::container_type&>(*this));
424 return index::make_iterator(static_cast<node_type*>(it.get_node()));
428 BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
429 typedef typename super::copy_map_type copy_map_type;
431 node_type* header()const
433 return bfm_header::member;
436 node_type* allocate_node()
438 return bfm_allocator::member.allocate(1);
441 void deallocate_node(node_type* x)
443 bfm_allocator::member.deallocate(x,1);
448 return node_count==0;
451 std::size_t size_()const
456 std::size_t max_size_()const
458 return static_cast<std::size_t >(-1);
461 std::pair<node_type*,bool> insert_(const Value& v)
463 node_type* x=allocate_node();
465 node_type* res=super::insert_(v,x);
468 return std::pair<node_type*,bool>(res,true);
472 return std::pair<node_type*,bool>(res,false);
482 std::pair<node_type*,bool> insert_(const Value& v,node_type* position)
484 node_type* x=allocate_node();
486 node_type* res=super::insert_(v,position,x);
489 return std::pair<node_type*,bool>(res,true);
493 return std::pair<node_type*,bool>(res,false);
503 void erase_(node_type* x)
510 void delete_node_(node_type* x)
512 super::delete_node_(x);
516 void delete_all_nodes_()
518 super::delete_all_nodes_();
528 void swap_(multi_index_container<Value,IndexSpecifierList,Allocator>& x)
530 std::swap(bfm_header::member,x.bfm_header::member);
532 std::swap(node_count,x.node_count);
535 bool replace_(const Value& k,node_type* x)
537 return super::replace_(k,x);
540 template<typename Modifier>
541 bool modify_(Modifier mod,node_type* x)
543 mod(const_cast<value_type&>(x->value()));
546 if(!super::modify_(x)){
561 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
564 friend class boost::serialization::access;
566 BOOST_SERIALIZATION_SPLIT_MEMBER()
568 typedef typename super::index_saver_type index_saver_type;
569 typedef typename super::index_loader_type index_loader_type;
571 template<class Archive>
572 void save(Archive& ar,const unsigned int version)const
574 const std::size_t s=size_();
575 ar<<serialization::make_nvp("count",s);
576 index_saver_type sm(bfm_allocator::member,s);
578 for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){
579 ar<<serialization::make_nvp("item",*it);
580 sm.add(it.get_node(),ar,version);
582 sm.add_track(header(),ar,version);
584 super::save_(ar,version,sm);
587 template<class Archive>
588 void load(Archive& ar,const unsigned int version)
590 BOOST_MULTI_INDEX_CHECK_INVARIANT;
595 ar>>serialization::make_nvp("count",s);
596 index_loader_type lm(bfm_allocator::member,s);
598 for(std::size_t n=0;n<s;++n){
599 detail::archive_constructed<Value> value("item",ar,version);
600 std::pair<node_type*,bool> p=insert_(
601 value.get(),super::end().get_node());
602 if(!p.second)throw_exception(
603 archive::archive_exception(
604 archive::archive_exception::other_exception));
605 ar.reset_object_address(&p.first->value(),&value.get());
606 lm.add(p.first,ar,version);
608 lm.add_track(header(),ar,version);
610 super::load_(ar,version,lm);
614 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
615 /* invariant stuff */
617 bool invariant_()const
619 return super::invariant_();
622 void check_invariant_()const
624 BOOST_MULTI_INDEX_INVARIANT_ASSERT(invariant_());
629 std::size_t node_count;
631 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\
632 BOOST_WORKAROUND(__MWERKS__,<=0x3003)
633 #pragma parse_mfunc_templ reset
637 /* retrieval of indices by number */
639 template<typename MultiIndexContainer,int N>
642 BOOST_STATIC_CONSTANT(
644 M=mpl::size<typename MultiIndexContainer::index_type_list>::type::value);
645 BOOST_STATIC_ASSERT(N>=0&&N<M);
646 typedef typename mpl::at_c<
647 typename MultiIndexContainer::index_type_list,N>::type type;
650 template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
652 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type&
654 multi_index_container<Value,IndexSpecifierList,Allocator>& m
655 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
657 typedef multi_index_container<
658 Value,IndexSpecifierList,Allocator> multi_index_type;
659 typedef typename nth_index<
660 multi_index_container<
661 Value,IndexSpecifierList,Allocator>,
665 BOOST_STATIC_ASSERT(N>=0&&
668 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list
671 return detail::converter<multi_index_type,index>::index(m);
674 template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
675 const typename nth_index<
676 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type&
678 const multi_index_container<Value,IndexSpecifierList,Allocator>& m
679 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
681 typedef multi_index_container<
682 Value,IndexSpecifierList,Allocator> multi_index_type;
683 typedef typename nth_index<
684 multi_index_container<
685 Value,IndexSpecifierList,Allocator>,
689 BOOST_STATIC_ASSERT(N>=0&&
692 BOOST_DEDUCED_TYPENAME multi_index_type::index_type_list
695 return detail::converter<multi_index_type,index>::index(m);
698 /* retrieval of indices by tag */
700 template<typename MultiIndexContainer,typename Tag>
703 typedef typename MultiIndexContainer::index_type_list index_type_list;
705 typedef typename mpl::find_if<
710 BOOST_STATIC_CONSTANT(
711 bool,index_found=!(is_same<iter,typename mpl::end<index_type_list>::type >::value));
712 BOOST_STATIC_ASSERT(index_found);
714 typedef typename mpl::deref<iter>::type type;
718 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator
720 typename ::boost::multi_index::index<
721 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type&
723 multi_index_container<Value,IndexSpecifierList,Allocator>& m
724 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
726 typedef multi_index_container<
727 Value,IndexSpecifierList,Allocator> multi_index_type;
728 typedef typename ::boost::multi_index::index<
729 multi_index_container<
730 Value,IndexSpecifierList,Allocator>,
734 return detail::converter<multi_index_type,index>::index(m);
738 typename Tag,typename Value,typename IndexSpecifierList,typename Allocator
740 const typename ::boost::multi_index::index<
741 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type&
743 const multi_index_container<Value,IndexSpecifierList,Allocator>& m
744 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
746 typedef multi_index_container<
747 Value,IndexSpecifierList,Allocator> multi_index_type;
748 typedef typename ::boost::multi_index::index<
749 multi_index_container<
750 Value,IndexSpecifierList,Allocator>,
754 return detail::converter<multi_index_type,index>::index(m);
757 /* projection of iterators by number */
759 template<typename MultiIndexContainer,int N>
760 struct nth_index_iterator
762 typedef typename detail::prevent_eti<
763 nth_index<MultiIndexContainer,N>,
764 typename nth_index<MultiIndexContainer,N>::type>::type::iterator type;
767 template<typename MultiIndexContainer,int N>
768 struct nth_index_const_iterator
770 typedef typename detail::prevent_eti<
771 nth_index<MultiIndexContainer,N>,
772 typename nth_index<MultiIndexContainer,N>::type
773 >::type::const_iterator type;
777 int N,typename IteratorType,
778 typename Value,typename IndexSpecifierList,typename Allocator>
779 typename nth_index_iterator<
780 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type
782 multi_index_container<Value,IndexSpecifierList,Allocator>& m,
784 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
786 typedef multi_index_container<
787 Value,IndexSpecifierList,Allocator> multi_index_type;
788 typedef typename nth_index<multi_index_type,N>::type index;
790 #if !defined(BOOST_MSVC)||!(BOOST_MSVC<1310) /* ain't work in MSVC++ 6.0/7.0 */
791 BOOST_STATIC_ASSERT((
793 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
794 IteratorType>::value));
797 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
799 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
800 typedef detail::converter<
802 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
803 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
806 return detail::converter<multi_index_type,index>::iterator(
807 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
811 int N,typename IteratorType,
812 typename Value,typename IndexSpecifierList,typename Allocator>
813 typename nth_index_const_iterator<
814 multi_index_container<Value,IndexSpecifierList,Allocator>,N>::type
816 const multi_index_container<Value,IndexSpecifierList,Allocator>& m,
818 BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int,N))
820 typedef multi_index_container<
821 Value,IndexSpecifierList,Allocator> multi_index_type;
822 typedef typename nth_index<multi_index_type,N>::type index;
824 #if !defined(BOOST_MSVC)||!(BOOST_MSVC<1310) /* ain't work in MSVC++ 6.0/7.0 */
825 BOOST_STATIC_ASSERT((
827 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
828 IteratorType>::value||
830 BOOST_DEDUCED_TYPENAME multi_index_type::const_iterator_type_list,
831 IteratorType>::value));
834 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
836 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
837 typedef detail::converter<
839 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
840 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
843 return detail::converter<multi_index_type,index>::const_iterator(
844 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
847 /* projection of iterators by tag */
849 template<typename MultiIndexContainer,typename Tag>
850 struct index_iterator
852 typedef typename ::boost::multi_index::index<
853 MultiIndexContainer,Tag>::type::iterator type;
856 template<typename MultiIndexContainer,typename Tag>
857 struct index_const_iterator
859 typedef typename ::boost::multi_index::index<
860 MultiIndexContainer,Tag>::type::const_iterator type;
864 typename Tag,typename IteratorType,
865 typename Value,typename IndexSpecifierList,typename Allocator>
866 typename index_iterator<
867 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type
869 multi_index_container<Value,IndexSpecifierList,Allocator>& m,
871 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
873 typedef multi_index_container<
874 Value,IndexSpecifierList,Allocator> multi_index_type;
875 typedef typename ::boost::multi_index::index<
876 multi_index_type,Tag>::type index;
878 #if !defined(BOOST_MSVC)||!(BOOST_MSVC<1310) /* ain't work in MSVC++ 6.0/7.0 */
879 BOOST_STATIC_ASSERT((
881 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
882 IteratorType>::value));
885 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
887 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
888 typedef detail::converter<
890 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
891 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
894 return detail::converter<multi_index_type,index>::iterator(
895 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
899 typename Tag,typename IteratorType,
900 typename Value,typename IndexSpecifierList,typename Allocator>
901 typename index_const_iterator<
902 multi_index_container<Value,IndexSpecifierList,Allocator>,Tag>::type
904 const multi_index_container<Value,IndexSpecifierList,Allocator>& m,
906 BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
908 typedef multi_index_container<
909 Value,IndexSpecifierList,Allocator> multi_index_type;
910 typedef typename ::boost::multi_index::index<
911 multi_index_type,Tag>::type index;
913 #if !defined(BOOST_MSVC)||!(BOOST_MSVC<1310) /* ain't work in MSVC++ 6.0/7.0 */
914 BOOST_STATIC_ASSERT((
916 BOOST_DEDUCED_TYPENAME multi_index_type::iterator_type_list,
917 IteratorType>::value||
919 BOOST_DEDUCED_TYPENAME multi_index_type::const_iterator_type_list,
920 IteratorType>::value));
923 BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(it);
925 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
926 typedef detail::converter<
928 BOOST_DEDUCED_TYPENAME IteratorType::container_type> converter;
929 BOOST_MULTI_INDEX_CHECK_IS_OWNER(it,converter::index(m));
932 return detail::converter<multi_index_type,index>::const_iterator(
933 m,static_cast<typename multi_index_type::node_type*>(it.get_node()));
936 /* Comparison. Simple forward to first index. */
939 typename Value1,typename IndexSpecifierList1,typename Allocator1,
940 typename Value2,typename IndexSpecifierList2,typename Allocator2
943 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
944 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
946 return get<0>(x)==get<0>(y);
950 typename Value1,typename IndexSpecifierList1,typename Allocator1,
951 typename Value2,typename IndexSpecifierList2,typename Allocator2
954 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
955 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
957 return get<0>(x)<get<0>(y);
961 typename Value1,typename IndexSpecifierList1,typename Allocator1,
962 typename Value2,typename IndexSpecifierList2,typename Allocator2
965 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
966 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
968 return get<0>(x)!=get<0>(y);
972 typename Value1,typename IndexSpecifierList1,typename Allocator1,
973 typename Value2,typename IndexSpecifierList2,typename Allocator2
976 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
977 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
979 return get<0>(x)>get<0>(y);
983 typename Value1,typename IndexSpecifierList1,typename Allocator1,
984 typename Value2,typename IndexSpecifierList2,typename Allocator2
987 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
988 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
990 return get<0>(x)>=get<0>(y);
994 typename Value1,typename IndexSpecifierList1,typename Allocator1,
995 typename Value2,typename IndexSpecifierList2,typename Allocator2
998 const multi_index_container<Value1,IndexSpecifierList1,Allocator1>& x,
999 const multi_index_container<Value2,IndexSpecifierList2,Allocator2>& y)
1001 return get<0>(x)<=get<0>(y);
1004 /* specialized algorithms */
1006 template<typename Value,typename IndexSpecifierList,typename Allocator>
1008 multi_index_container<Value,IndexSpecifierList,Allocator>& x,
1009 multi_index_container<Value,IndexSpecifierList,Allocator>& y)
1014 } /* namespace multi_index */
1016 /* Associated global functions are promoted to namespace boost, except
1017 * comparison operators and swap, which are meant to be Koenig looked-up.
1020 using multi_index::get;
1021 using multi_index::project;
1023 } /* namespace boost */
1025 #undef BOOST_MULTI_INDEX_CHECK_INVARIANT