11 #ifndef BOOST_MULTI_INDEX_HPP
12 #define BOOST_MULTI_INDEX_HPP
47 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
48 #include <initializer_list>
51 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
61 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
63 #define BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(x) \
64 detail::scope_guard BOOST_JOIN(check_invariant_,__LINE__)= \
65 detail::make_obj_guard(x,&multi_index_container::check_invariant_); \
66 BOOST_JOIN(check_invariant_,__LINE__).touch();
67 #define BOOST_MULTI_INDEX_CHECK_INVARIANT \
68 BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(*this)
70 #define BOOST_MULTI_INDEX_CHECK_INVARIANT_OF(x)
71 #define BOOST_MULTI_INDEX_CHECK_INVARIANT
76 namespace multi_index{
78 #if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
80 #pragma warning(disable:4522)
83 template<
typename Value,
typename IndexSpecifierList,
typename Allocator>
86 typename boost::detail::allocator::rebind_to<
88 typename detail::multi_index_node_type<
89 Value,IndexSpecifierList,Allocator>::type
92 typename boost::detail::allocator::rebind_to<
94 typename detail::multi_index_node_type<
95 Value,IndexSpecifierList,Allocator>::type
97 multi_index_container<Value,IndexSpecifierList,Allocator> >,
99 Value,IndexSpecifierList,Allocator>
::type
101 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\
102 BOOST_WORKAROUND(__MWERKS__,<=0x3003)
108 #pragma parse_mfunc_templ off
114 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
127 typedef ::boost::base_from_member<
130 typename node_allocator::pointer,
193 template<
typename InputIterator>
195 InputIterator first,InputIterator last,
220 for(;first!=last;++first){
221 hint=super::make_iterator(
233 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
235 std::initializer_list<Value> list,
244 typedef const Value* init_iterator;
247 for(init_iterator first=list.begin(),last=list.end();
248 first!=last;++first){
249 hint=super::make_iterator(
insert_(*first,hint.get_node()).first);
270 map.clone(it.get_node());
286 super(x,detail::do_not_copy_elements_tag()),
299 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
328 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
330 std::initializer_list<Value> list)
333 typedef const Value* init_iterator;
337 for(init_iterator first=list.begin(),last=list.end();
338 first!=last;++first){
339 hint=x.make_iterator(x.
insert_(*first,hint.get_node()).first);
354 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
379 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
380 template<
typename Tag>
395 template<
typename Tag>
401 template<
typename Tag>
410 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
423 template<
int N,
typename IteratorType>
428 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
435 it,
static_cast<typename IteratorType::container_type&
>(*
this));
437 return index_type::make_iterator(
static_cast<node_type*
>(it.get_node()));
440 template<
int N,
typename IteratorType>
445 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
453 it,
static_cast<const typename IteratorType::container_type&
>(*
this));
454 return index_type::make_iterator(
static_cast<node_type*
>(it.get_node()));
460 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
461 template<
typename Tag>
467 template<
typename Tag>
473 template<
typename Tag,
typename IteratorType>
478 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
485 it,
static_cast<typename IteratorType::container_type&
>(*
this));
486 return index_type::make_iterator(
static_cast<node_type*
>(it.get_node()));
489 template<
typename Tag,
typename IteratorType>
494 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
502 it,
static_cast<const typename IteratorType::container_type&
>(*
this));
503 return index_type::make_iterator(
static_cast<node_type*
>(it.get_node()));
508 typedef typename super::copy_map_type copy_map_type;
510 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
516 super(x,detail::do_not_copy_elements_tag()),
535 typedef typename node_allocator::pointer node_pointer;
551 return static_cast<std::size_t
>(-1);
554 template<
typename Variant>
555 std::pair<node_type*,bool>
insert_(
const Value& v,Variant variant)
558 node_type* res=super::insert_(v,x,variant);
561 return std::pair<node_type*,bool>(res,
true);
564 return std::pair<node_type*,bool>(res,
false);
568 std::pair<node_type*,bool>
insert_(
const Value& v)
588 return std::pair<node_type*,bool>(res,
true);
593 return std::pair<node_type*,bool>(res,
false);
619 template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
631 return std::pair<node_type*,bool>(res,
true);
636 return std::pair<node_type*,bool>(res,
false);
652 template<
typename Variant>
654 const Value& v,
node_type* position,Variant variant)
657 node_type* res=super::insert_(v,position,x,variant);
660 return std::pair<node_type*,bool>(res,
true);
663 return std::pair<node_type*,bool>(res,
false);
689 return std::pair<node_type*,bool>(res,
true);
694 return std::pair<node_type*,bool>(res,
false);
722 template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
736 return std::pair<node_type*,bool>(res,
true);
741 return std::pair<node_type*,bool>(res,
false);
766 super::delete_node_(x);
772 super::delete_all_nodes_();
796 super::swap_elements_(x);
810 template<
typename Modifier>
816 if(!super::modify_(x)){
831 template<
typename Modifier,
typename Rollback>
838 b=super::modify_rollback_(x);
867 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
877 template<class Archive>
878 void save(Archive& ar,const
unsigned int version)
const
890 sm.add(it.get_node(),ar,version);
892 sm.add_track(
header(),ar,version);
894 super::save_(ar,version,sm);
897 template<
class Archive>
898 void load(Archive& ar,
const unsigned int version)
922 for(std::size_t n=0;n<
s;++n){
924 std::pair<node_type*,bool> p=
insert_(
929 ar.reset_object_address(&p.first->value(),&value.
get());
930 lm.add(p.first,ar,version);
932 lm.add_track(
header(),ar,version);
934 super::load_(ar,version,lm);
938 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
941 bool invariant_()
const
943 return super::invariant_();
946 void check_invariant_()
const
955 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\
956 BOOST_WORKAROUND(__MWERKS__,<=0x3003)
957 #pragma parse_mfunc_templ reset
961 #if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
967 template<
typename MultiIndexContainer,
int N>
978 template<
int N,
typename Value,
typename IndexSpecifierList,
typename Allocator>
985 Value,IndexSpecifierList,Allocator> multi_index_type;
988 Value,IndexSpecifierList,Allocator>,
1001 template<
int N,
typename Value,
typename IndexSpecifierList,
typename Allocator>
1002 const typename nth_index<
1009 Value,IndexSpecifierList,Allocator> multi_index_type;
1012 Value,IndexSpecifierList,Allocator>,
1027 template<
typename MultiIndexContainer,
typename Tag>
1045 typename Tag,
typename Value,
typename IndexSpecifierList,
typename Allocator
1047 typename ::boost::multi_index::index<
1053 Value,IndexSpecifierList,Allocator> multi_index_type;
1054 typedef typename ::boost::multi_index::index<
1056 Value,IndexSpecifierList,Allocator>,
1064 typename Tag,
typename Value,
typename IndexSpecifierList,
typename Allocator
1066 const typename ::boost::multi_index::index<
1073 Value,IndexSpecifierList,Allocator> multi_index_type;
1074 typedef typename ::boost::multi_index::index<
1076 Value,IndexSpecifierList,Allocator>,
1085 template<
typename MultiIndexContainer,
int N>
1091 template<
typename MultiIndexContainer,
int N>
1098 int N,
typename IteratorType,
1099 typename Value,
typename IndexSpecifierList,
typename Allocator>
1107 Value,IndexSpecifierList,Allocator> multi_index_type;
1110 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
1114 IteratorType>::value));
1119 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1131 int N,
typename IteratorType,
1132 typename Value,
typename IndexSpecifierList,
typename Allocator>
1133 typename nth_index_const_iterator<
1140 Value,IndexSpecifierList,Allocator> multi_index_type;
1143 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
1147 IteratorType>::value||
1150 IteratorType>::value));
1155 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1168 template<
typename MultiIndexContainer,
typename Tag>
1171 typedef typename ::boost::multi_index::index<
1172 MultiIndexContainer,Tag>::type::iterator
type;
1175 template<
typename MultiIndexContainer,
typename Tag>
1178 typedef typename ::boost::multi_index::index<
1179 MultiIndexContainer,Tag>::type::const_iterator
type;
1183 typename Tag,
typename IteratorType,
1184 typename Value,
typename IndexSpecifierList,
typename Allocator>
1192 Value,IndexSpecifierList,Allocator> multi_index_type;
1193 typedef typename ::boost::multi_index::index<
1194 multi_index_type,Tag>
::type index_type;
1196 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
1200 IteratorType>::value));
1205 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1217 typename Tag,
typename IteratorType,
1218 typename Value,
typename IndexSpecifierList,
typename Allocator>
1219 typename index_const_iterator<
1226 Value,IndexSpecifierList,Allocator> multi_index_type;
1227 typedef typename ::boost::multi_index::index<
1228 multi_index_type,Tag>
::type index_type;
1230 #if !defined(__SUNPRO_CC)||!(__SUNPRO_CC<0x580)
1234 IteratorType>::value||
1237 IteratorType>::value));
1242 #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
1256 typename Value1,
typename IndexSpecifierList1,
typename Allocator1,
1257 typename Value2,
typename IndexSpecifierList2,
typename Allocator2
1263 return get<0>(x)==get<0>(y);
1267 typename Value1,
typename IndexSpecifierList1,
typename Allocator1,
1268 typename Value2,
typename IndexSpecifierList2,
typename Allocator2
1274 return get<0>(x)<get<0>(y);
1278 typename Value1,
typename IndexSpecifierList1,
typename Allocator1,
1279 typename Value2,
typename IndexSpecifierList2,
typename Allocator2
1285 return get<0>(x)!=get<0>(y);
1289 typename Value1,
typename IndexSpecifierList1,
typename Allocator1,
1290 typename Value2,
typename IndexSpecifierList2,
typename Allocator2
1296 return get<0>(x)>get<0>(y);
1300 typename Value1,
typename IndexSpecifierList1,
typename Allocator1,
1301 typename Value2,
typename IndexSpecifierList2,
typename Allocator2
1307 return get<0>(x)>=get<0>(y);
1311 typename Value1,
typename IndexSpecifierList1,
typename Allocator1,
1312 typename Value2,
typename IndexSpecifierList2,
typename Allocator2
1318 return get<0>(x)<=get<0>(y);
1323 template<
typename Value,
typename IndexSpecifierList,
typename Allocator>
1333 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
1339 namespace serialization {
1340 template<
typename Value,
typename IndexSpecifierList,
typename Allocator>
1359 #undef BOOST_MULTI_INDEX_CHECK_INVARIANT
1360 #undef BOOST_MULTI_INDEX_CHECK_INVARIANT_OF