Brian Silverman | 3cbbaca | 2018-08-04 23:38:07 -0700 | [diff] [blame^] | 1 | /* Copyright 2003-2018 Joaquin M Lopez Munoz. |
| 2 | * Distributed under the Boost Software License, Version 1.0. |
| 3 | * (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | * http://www.boost.org/LICENSE_1_0.txt) |
| 5 | * |
| 6 | * See http://www.boost.org/libs/multi_index for library home page. |
| 7 | */ |
| 8 | |
| 9 | #ifndef BOOST_MULTI_INDEX_SEQUENCED_INDEX_HPP |
| 10 | #define BOOST_MULTI_INDEX_SEQUENCED_INDEX_HPP |
| 11 | |
| 12 | #if defined(_MSC_VER) |
| 13 | #pragma once |
| 14 | #endif |
| 15 | |
| 16 | #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ |
| 17 | #include <boost/bind.hpp> |
| 18 | #include <boost/call_traits.hpp> |
| 19 | #include <boost/core/addressof.hpp> |
| 20 | #include <boost/detail/allocator_utilities.hpp> |
| 21 | #include <boost/detail/no_exceptions_support.hpp> |
| 22 | #include <boost/detail/workaround.hpp> |
| 23 | #include <boost/foreach_fwd.hpp> |
| 24 | #include <boost/iterator/reverse_iterator.hpp> |
| 25 | #include <boost/move/core.hpp> |
| 26 | #include <boost/move/utility.hpp> |
| 27 | #include <boost/mpl/bool.hpp> |
| 28 | #include <boost/mpl/not.hpp> |
| 29 | #include <boost/mpl/push_front.hpp> |
| 30 | #include <boost/multi_index/detail/access_specifier.hpp> |
| 31 | #include <boost/multi_index/detail/bidir_node_iterator.hpp> |
| 32 | #include <boost/multi_index/detail/do_not_copy_elements_tag.hpp> |
| 33 | #include <boost/multi_index/detail/index_node_base.hpp> |
| 34 | #include <boost/multi_index/detail/safe_mode.hpp> |
| 35 | #include <boost/multi_index/detail/scope_guard.hpp> |
| 36 | #include <boost/multi_index/detail/seq_index_node.hpp> |
| 37 | #include <boost/multi_index/detail/seq_index_ops.hpp> |
| 38 | #include <boost/multi_index/detail/vartempl_support.hpp> |
| 39 | #include <boost/multi_index/sequenced_index_fwd.hpp> |
| 40 | #include <boost/tuple/tuple.hpp> |
| 41 | #include <boost/type_traits/is_integral.hpp> |
| 42 | #include <cstddef> |
| 43 | #include <functional> |
| 44 | #include <utility> |
| 45 | #include <memory> |
| 46 | |
| 47 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 48 | #include<initializer_list> |
| 49 | #endif |
| 50 | |
| 51 | #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) |
| 52 | #include <boost/bind.hpp> |
| 53 | #endif |
| 54 | |
| 55 | #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING) |
| 56 | #define BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT_OF(x) \ |
| 57 | detail::scope_guard BOOST_JOIN(check_invariant_,__LINE__)= \ |
| 58 | detail::make_obj_guard(x,&sequenced_index::check_invariant_); \ |
| 59 | BOOST_JOIN(check_invariant_,__LINE__).touch(); |
| 60 | #define BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT \ |
| 61 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT_OF(*this) |
| 62 | #else |
| 63 | #define BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT_OF(x) |
| 64 | #define BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT |
| 65 | #endif |
| 66 | |
| 67 | namespace boost{ |
| 68 | |
| 69 | namespace multi_index{ |
| 70 | |
| 71 | namespace detail{ |
| 72 | |
| 73 | /* sequenced_index adds a layer of sequenced indexing to a given Super */ |
| 74 | |
| 75 | template<typename SuperMeta,typename TagList> |
| 76 | class sequenced_index: |
| 77 | BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS SuperMeta::type |
| 78 | |
| 79 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 80 | ,public safe_mode::safe_container< |
| 81 | sequenced_index<SuperMeta,TagList> > |
| 82 | #endif |
| 83 | |
| 84 | { |
| 85 | #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\ |
| 86 | BOOST_WORKAROUND(__MWERKS__,<=0x3003) |
| 87 | /* The "ISO C++ Template Parser" option in CW8.3 has a problem with the |
| 88 | * lifetime of const references bound to temporaries --precisely what |
| 89 | * scopeguards are. |
| 90 | */ |
| 91 | |
| 92 | #pragma parse_mfunc_templ off |
| 93 | #endif |
| 94 | |
| 95 | typedef typename SuperMeta::type super; |
| 96 | |
| 97 | protected: |
| 98 | typedef sequenced_index_node< |
| 99 | typename super::node_type> node_type; |
| 100 | |
| 101 | private: |
| 102 | typedef typename node_type::impl_type node_impl_type; |
| 103 | |
| 104 | public: |
| 105 | /* types */ |
| 106 | |
| 107 | typedef typename node_type::value_type value_type; |
| 108 | typedef tuples::null_type ctor_args; |
| 109 | typedef typename super::final_allocator_type allocator_type; |
| 110 | #ifdef BOOST_NO_CXX11_ALLOCATOR |
| 111 | typedef typename allocator_type::reference reference; |
| 112 | typedef typename allocator_type::const_reference const_reference; |
| 113 | #else |
| 114 | typedef value_type& reference; |
| 115 | typedef const value_type& const_reference; |
| 116 | #endif |
| 117 | |
| 118 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 119 | typedef safe_mode::safe_iterator< |
| 120 | bidir_node_iterator<node_type>, |
| 121 | sequenced_index> iterator; |
| 122 | #else |
| 123 | typedef bidir_node_iterator<node_type> iterator; |
| 124 | #endif |
| 125 | |
| 126 | typedef iterator const_iterator; |
| 127 | |
| 128 | typedef std::size_t size_type; |
| 129 | typedef std::ptrdiff_t difference_type; |
| 130 | #ifdef BOOST_NO_CXX11_ALLOCATOR |
| 131 | typedef typename allocator_type::pointer pointer; |
| 132 | typedef typename allocator_type::const_pointer const_pointer; |
| 133 | #else |
| 134 | typedef std::allocator_traits<allocator_type> allocator_traits; |
| 135 | typedef typename allocator_traits::pointer pointer; |
| 136 | typedef typename allocator_traits::const_pointer const_pointer; |
| 137 | #endif |
| 138 | typedef typename |
| 139 | boost::reverse_iterator<iterator> reverse_iterator; |
| 140 | typedef typename |
| 141 | boost::reverse_iterator<const_iterator> const_reverse_iterator; |
| 142 | typedef TagList tag_list; |
| 143 | |
| 144 | protected: |
| 145 | typedef typename super::final_node_type final_node_type; |
| 146 | typedef tuples::cons< |
| 147 | ctor_args, |
| 148 | typename super::ctor_args_list> ctor_args_list; |
| 149 | typedef typename mpl::push_front< |
| 150 | typename super::index_type_list, |
| 151 | sequenced_index>::type index_type_list; |
| 152 | typedef typename mpl::push_front< |
| 153 | typename super::iterator_type_list, |
| 154 | iterator>::type iterator_type_list; |
| 155 | typedef typename mpl::push_front< |
| 156 | typename super::const_iterator_type_list, |
| 157 | const_iterator>::type const_iterator_type_list; |
| 158 | typedef typename super::copy_map_type copy_map_type; |
| 159 | |
| 160 | #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) |
| 161 | typedef typename super::index_saver_type index_saver_type; |
| 162 | typedef typename super::index_loader_type index_loader_type; |
| 163 | #endif |
| 164 | |
| 165 | private: |
| 166 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 167 | typedef safe_mode::safe_container< |
| 168 | sequenced_index> safe_super; |
| 169 | #endif |
| 170 | |
| 171 | typedef typename call_traits<value_type>::param_type value_param_type; |
| 172 | |
| 173 | /* Needed to avoid commas in BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL |
| 174 | * expansion. |
| 175 | */ |
| 176 | |
| 177 | typedef std::pair<iterator,bool> emplace_return_type; |
| 178 | |
| 179 | public: |
| 180 | |
| 181 | /* construct/copy/destroy |
| 182 | * Default and copy ctors are in the protected section as indices are |
| 183 | * not supposed to be created on their own. No range ctor either. |
| 184 | */ |
| 185 | |
| 186 | sequenced_index<SuperMeta,TagList>& operator=( |
| 187 | const sequenced_index<SuperMeta,TagList>& x) |
| 188 | { |
| 189 | this->final()=x.final(); |
| 190 | return *this; |
| 191 | } |
| 192 | |
| 193 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 194 | sequenced_index<SuperMeta,TagList>& operator=( |
| 195 | std::initializer_list<value_type> list) |
| 196 | { |
| 197 | this->final()=list; |
| 198 | return *this; |
| 199 | } |
| 200 | #endif |
| 201 | |
| 202 | template <class InputIterator> |
| 203 | void assign(InputIterator first,InputIterator last) |
| 204 | { |
| 205 | assign_iter(first,last,mpl::not_<is_integral<InputIterator> >()); |
| 206 | } |
| 207 | |
| 208 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 209 | void assign(std::initializer_list<value_type> list) |
| 210 | { |
| 211 | assign(list.begin(),list.end()); |
| 212 | } |
| 213 | #endif |
| 214 | |
| 215 | void assign(size_type n,value_param_type value) |
| 216 | { |
| 217 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 218 | clear(); |
| 219 | for(size_type i=0;i<n;++i)push_back(value); |
| 220 | } |
| 221 | |
| 222 | allocator_type get_allocator()const BOOST_NOEXCEPT |
| 223 | { |
| 224 | return this->final().get_allocator(); |
| 225 | } |
| 226 | |
| 227 | /* iterators */ |
| 228 | |
| 229 | iterator begin()BOOST_NOEXCEPT |
| 230 | {return make_iterator(node_type::from_impl(header()->next()));} |
| 231 | const_iterator begin()const BOOST_NOEXCEPT |
| 232 | {return make_iterator(node_type::from_impl(header()->next()));} |
| 233 | iterator |
| 234 | end()BOOST_NOEXCEPT{return make_iterator(header());} |
| 235 | const_iterator |
| 236 | end()const BOOST_NOEXCEPT{return make_iterator(header());} |
| 237 | reverse_iterator |
| 238 | rbegin()BOOST_NOEXCEPT{return boost::make_reverse_iterator(end());} |
| 239 | const_reverse_iterator |
| 240 | rbegin()const BOOST_NOEXCEPT{return boost::make_reverse_iterator(end());} |
| 241 | reverse_iterator |
| 242 | rend()BOOST_NOEXCEPT{return boost::make_reverse_iterator(begin());} |
| 243 | const_reverse_iterator |
| 244 | rend()const BOOST_NOEXCEPT{return boost::make_reverse_iterator(begin());} |
| 245 | const_iterator |
| 246 | cbegin()const BOOST_NOEXCEPT{return begin();} |
| 247 | const_iterator |
| 248 | cend()const BOOST_NOEXCEPT{return end();} |
| 249 | const_reverse_iterator |
| 250 | crbegin()const BOOST_NOEXCEPT{return rbegin();} |
| 251 | const_reverse_iterator |
| 252 | crend()const BOOST_NOEXCEPT{return rend();} |
| 253 | |
| 254 | iterator iterator_to(const value_type& x) |
| 255 | { |
| 256 | return make_iterator(node_from_value<node_type>(boost::addressof(x))); |
| 257 | } |
| 258 | |
| 259 | const_iterator iterator_to(const value_type& x)const |
| 260 | { |
| 261 | return make_iterator(node_from_value<node_type>(boost::addressof(x))); |
| 262 | } |
| 263 | |
| 264 | /* capacity */ |
| 265 | |
| 266 | bool empty()const BOOST_NOEXCEPT{return this->final_empty_();} |
| 267 | size_type size()const BOOST_NOEXCEPT{return this->final_size_();} |
| 268 | size_type max_size()const BOOST_NOEXCEPT{return this->final_max_size_();} |
| 269 | |
| 270 | void resize(size_type n) |
| 271 | { |
| 272 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 273 | if(n>size()){ |
| 274 | for(size_type m=n-size();m--;) |
| 275 | this->final_emplace_(BOOST_MULTI_INDEX_NULL_PARAM_PACK); |
| 276 | } |
| 277 | else if(n<size()){for(size_type m=size()-n;m--;)pop_back();} |
| 278 | } |
| 279 | |
| 280 | void resize(size_type n,value_param_type x) |
| 281 | { |
| 282 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 283 | if(n>size())insert(end(),n-size(),x); |
| 284 | else if(n<size())for(size_type m=size()-n;m--;)pop_back(); |
| 285 | } |
| 286 | |
| 287 | /* access: no non-const versions provided as sequenced_index |
| 288 | * handles const elements. |
| 289 | */ |
| 290 | |
| 291 | const_reference front()const{return *begin();} |
| 292 | const_reference back()const{return *--end();} |
| 293 | |
| 294 | /* modifiers */ |
| 295 | |
| 296 | BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL( |
| 297 | emplace_return_type,emplace_front,emplace_front_impl) |
| 298 | |
| 299 | std::pair<iterator,bool> push_front(const value_type& x) |
| 300 | {return insert(begin(),x);} |
| 301 | std::pair<iterator,bool> push_front(BOOST_RV_REF(value_type) x) |
| 302 | {return insert(begin(),boost::move(x));} |
| 303 | void pop_front(){erase(begin());} |
| 304 | |
| 305 | BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL( |
| 306 | emplace_return_type,emplace_back,emplace_back_impl) |
| 307 | |
| 308 | std::pair<iterator,bool> push_back(const value_type& x) |
| 309 | {return insert(end(),x);} |
| 310 | std::pair<iterator,bool> push_back(BOOST_RV_REF(value_type) x) |
| 311 | {return insert(end(),boost::move(x));} |
| 312 | void pop_back(){erase(--end());} |
| 313 | |
| 314 | BOOST_MULTI_INDEX_OVERLOADS_TO_VARTEMPL_EXTRA_ARG( |
| 315 | emplace_return_type,emplace,emplace_impl,iterator,position) |
| 316 | |
| 317 | std::pair<iterator,bool> insert(iterator position,const value_type& x) |
| 318 | { |
| 319 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 320 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 321 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 322 | std::pair<final_node_type*,bool> p=this->final_insert_(x); |
| 323 | if(p.second&&position.get_node()!=header()){ |
| 324 | relink(position.get_node(),p.first); |
| 325 | } |
| 326 | return std::pair<iterator,bool>(make_iterator(p.first),p.second); |
| 327 | } |
| 328 | |
| 329 | std::pair<iterator,bool> insert(iterator position,BOOST_RV_REF(value_type) x) |
| 330 | { |
| 331 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 332 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 333 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 334 | std::pair<final_node_type*,bool> p=this->final_insert_rv_(x); |
| 335 | if(p.second&&position.get_node()!=header()){ |
| 336 | relink(position.get_node(),p.first); |
| 337 | } |
| 338 | return std::pair<iterator,bool>(make_iterator(p.first),p.second); |
| 339 | } |
| 340 | |
| 341 | void insert(iterator position,size_type n,value_param_type x) |
| 342 | { |
| 343 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 344 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 345 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 346 | for(size_type i=0;i<n;++i)insert(position,x); |
| 347 | } |
| 348 | |
| 349 | template<typename InputIterator> |
| 350 | void insert(iterator position,InputIterator first,InputIterator last) |
| 351 | { |
| 352 | insert_iter(position,first,last,mpl::not_<is_integral<InputIterator> >()); |
| 353 | } |
| 354 | |
| 355 | #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) |
| 356 | void insert(iterator position,std::initializer_list<value_type> list) |
| 357 | { |
| 358 | insert(position,list.begin(),list.end()); |
| 359 | } |
| 360 | #endif |
| 361 | |
| 362 | iterator erase(iterator position) |
| 363 | { |
| 364 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 365 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); |
| 366 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 367 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 368 | this->final_erase_(static_cast<final_node_type*>(position++.get_node())); |
| 369 | return position; |
| 370 | } |
| 371 | |
| 372 | iterator erase(iterator first,iterator last) |
| 373 | { |
| 374 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(first); |
| 375 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(last); |
| 376 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(first,*this); |
| 377 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,*this); |
| 378 | BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last); |
| 379 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 380 | while(first!=last){ |
| 381 | first=erase(first); |
| 382 | } |
| 383 | return first; |
| 384 | } |
| 385 | |
| 386 | bool replace(iterator position,const value_type& x) |
| 387 | { |
| 388 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 389 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); |
| 390 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 391 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 392 | return this->final_replace_( |
| 393 | x,static_cast<final_node_type*>(position.get_node())); |
| 394 | } |
| 395 | |
| 396 | bool replace(iterator position,BOOST_RV_REF(value_type) x) |
| 397 | { |
| 398 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 399 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); |
| 400 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 401 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 402 | return this->final_replace_rv_( |
| 403 | x,static_cast<final_node_type*>(position.get_node())); |
| 404 | } |
| 405 | |
| 406 | template<typename Modifier> |
| 407 | bool modify(iterator position,Modifier mod) |
| 408 | { |
| 409 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 410 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); |
| 411 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 412 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 413 | |
| 414 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 415 | /* MSVC++ 6.0 optimizer on safe mode code chokes if this |
| 416 | * this is not added. Left it for all compilers as it does no |
| 417 | * harm. |
| 418 | */ |
| 419 | |
| 420 | position.detach(); |
| 421 | #endif |
| 422 | |
| 423 | return this->final_modify_( |
| 424 | mod,static_cast<final_node_type*>(position.get_node())); |
| 425 | } |
| 426 | |
| 427 | template<typename Modifier,typename Rollback> |
| 428 | bool modify(iterator position,Modifier mod,Rollback back_) |
| 429 | { |
| 430 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 431 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(position); |
| 432 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 433 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 434 | |
| 435 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 436 | /* MSVC++ 6.0 optimizer on safe mode code chokes if this |
| 437 | * this is not added. Left it for all compilers as it does no |
| 438 | * harm. |
| 439 | */ |
| 440 | |
| 441 | position.detach(); |
| 442 | #endif |
| 443 | |
| 444 | return this->final_modify_( |
| 445 | mod,back_,static_cast<final_node_type*>(position.get_node())); |
| 446 | } |
| 447 | |
| 448 | void swap(sequenced_index<SuperMeta,TagList>& x) |
| 449 | { |
| 450 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 451 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT_OF(x); |
| 452 | this->final_swap_(x.final()); |
| 453 | } |
| 454 | |
| 455 | void clear()BOOST_NOEXCEPT |
| 456 | { |
| 457 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 458 | this->final_clear_(); |
| 459 | } |
| 460 | |
| 461 | /* list operations */ |
| 462 | |
| 463 | void splice(iterator position,sequenced_index<SuperMeta,TagList>& x) |
| 464 | { |
| 465 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 466 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 467 | BOOST_MULTI_INDEX_CHECK_DIFFERENT_CONTAINER(*this,x); |
| 468 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 469 | iterator first=x.begin(),last=x.end(); |
| 470 | while(first!=last){ |
| 471 | if(insert(position,*first).second)first=x.erase(first); |
| 472 | else ++first; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | void splice(iterator position,sequenced_index<SuperMeta,TagList>& x,iterator i) |
| 477 | { |
| 478 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 479 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 480 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(i); |
| 481 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(i); |
| 482 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(i,x); |
| 483 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 484 | if(&x==this){ |
| 485 | if(position!=i)relink(position.get_node(),i.get_node()); |
| 486 | } |
| 487 | else{ |
| 488 | if(insert(position,*i).second){ |
| 489 | |
| 490 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 491 | /* MSVC++ 6.0 optimizer has a hard time with safe mode, and the following |
| 492 | * workaround is needed. Left it for all compilers as it does no |
| 493 | * harm. |
| 494 | */ |
| 495 | i.detach(); |
| 496 | x.erase(x.make_iterator(i.get_node())); |
| 497 | #else |
| 498 | x.erase(i); |
| 499 | #endif |
| 500 | |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | void splice( |
| 506 | iterator position,sequenced_index<SuperMeta,TagList>& x, |
| 507 | iterator first,iterator last) |
| 508 | { |
| 509 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 510 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 511 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(first); |
| 512 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(last); |
| 513 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(first,x); |
| 514 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,x); |
| 515 | BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last); |
| 516 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 517 | if(&x==this){ |
| 518 | BOOST_MULTI_INDEX_CHECK_OUTSIDE_RANGE(position,first,last); |
| 519 | if(position!=last)relink( |
| 520 | position.get_node(),first.get_node(),last.get_node()); |
| 521 | } |
| 522 | else{ |
| 523 | while(first!=last){ |
| 524 | if(insert(position,*first).second)first=x.erase(first); |
| 525 | else ++first; |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | void remove(value_param_type value) |
| 531 | { |
| 532 | sequenced_index_remove( |
| 533 | *this, |
| 534 | ::boost::bind(std::equal_to<value_type>(),::boost::arg<1>(),value)); |
| 535 | } |
| 536 | |
| 537 | template<typename Predicate> |
| 538 | void remove_if(Predicate pred) |
| 539 | { |
| 540 | sequenced_index_remove(*this,pred); |
| 541 | } |
| 542 | |
| 543 | void unique() |
| 544 | { |
| 545 | sequenced_index_unique(*this,std::equal_to<value_type>()); |
| 546 | } |
| 547 | |
| 548 | template <class BinaryPredicate> |
| 549 | void unique(BinaryPredicate binary_pred) |
| 550 | { |
| 551 | sequenced_index_unique(*this,binary_pred); |
| 552 | } |
| 553 | |
| 554 | void merge(sequenced_index<SuperMeta,TagList>& x) |
| 555 | { |
| 556 | sequenced_index_merge(*this,x,std::less<value_type>()); |
| 557 | } |
| 558 | |
| 559 | template <typename Compare> |
| 560 | void merge(sequenced_index<SuperMeta,TagList>& x,Compare comp) |
| 561 | { |
| 562 | sequenced_index_merge(*this,x,comp); |
| 563 | } |
| 564 | |
| 565 | void sort() |
| 566 | { |
| 567 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 568 | sequenced_index_sort(header(),std::less<value_type>()); |
| 569 | } |
| 570 | |
| 571 | template <typename Compare> |
| 572 | void sort(Compare comp) |
| 573 | { |
| 574 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 575 | sequenced_index_sort(header(),comp); |
| 576 | } |
| 577 | |
| 578 | void reverse()BOOST_NOEXCEPT |
| 579 | { |
| 580 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 581 | node_impl_type::reverse(header()->impl()); |
| 582 | } |
| 583 | |
| 584 | /* rearrange operations */ |
| 585 | |
| 586 | void relocate(iterator position,iterator i) |
| 587 | { |
| 588 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 589 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 590 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(i); |
| 591 | BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(i); |
| 592 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(i,*this); |
| 593 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 594 | if(position!=i)relink(position.get_node(),i.get_node()); |
| 595 | } |
| 596 | |
| 597 | void relocate(iterator position,iterator first,iterator last) |
| 598 | { |
| 599 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 600 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 601 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(first); |
| 602 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(last); |
| 603 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(first,*this); |
| 604 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,*this); |
| 605 | BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last); |
| 606 | BOOST_MULTI_INDEX_CHECK_OUTSIDE_RANGE(position,first,last); |
| 607 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 608 | if(position!=last)relink( |
| 609 | position.get_node(),first.get_node(),last.get_node()); |
| 610 | } |
| 611 | |
| 612 | template<typename InputIterator> |
| 613 | void rearrange(InputIterator first) |
| 614 | { |
| 615 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 616 | node_type* pos=header(); |
| 617 | for(size_type s=size();s--;){ |
| 618 | const value_type& v=*first++; |
| 619 | relink(pos,node_from_value<node_type>(&v)); |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS: |
| 624 | sequenced_index(const ctor_args_list& args_list,const allocator_type& al): |
| 625 | super(args_list.get_tail(),al) |
| 626 | { |
| 627 | empty_initialize(); |
| 628 | } |
| 629 | |
| 630 | sequenced_index(const sequenced_index<SuperMeta,TagList>& x): |
| 631 | super(x) |
| 632 | |
| 633 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 634 | ,safe_super() |
| 635 | #endif |
| 636 | |
| 637 | { |
| 638 | /* the actual copying takes place in subsequent call to copy_() */ |
| 639 | } |
| 640 | |
| 641 | sequenced_index( |
| 642 | const sequenced_index<SuperMeta,TagList>& x,do_not_copy_elements_tag): |
| 643 | super(x,do_not_copy_elements_tag()) |
| 644 | |
| 645 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 646 | ,safe_super() |
| 647 | #endif |
| 648 | |
| 649 | { |
| 650 | empty_initialize(); |
| 651 | } |
| 652 | |
| 653 | ~sequenced_index() |
| 654 | { |
| 655 | /* the container is guaranteed to be empty by now */ |
| 656 | } |
| 657 | |
| 658 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 659 | iterator make_iterator(node_type* node){return iterator(node,this);} |
| 660 | const_iterator make_iterator(node_type* node)const |
| 661 | {return const_iterator(node,const_cast<sequenced_index*>(this));} |
| 662 | #else |
| 663 | iterator make_iterator(node_type* node){return iterator(node);} |
| 664 | const_iterator make_iterator(node_type* node)const |
| 665 | {return const_iterator(node);} |
| 666 | #endif |
| 667 | |
| 668 | void copy_( |
| 669 | const sequenced_index<SuperMeta,TagList>& x,const copy_map_type& map) |
| 670 | { |
| 671 | node_type* org=x.header(); |
| 672 | node_type* cpy=header(); |
| 673 | do{ |
| 674 | node_type* next_org=node_type::from_impl(org->next()); |
| 675 | node_type* next_cpy=map.find(static_cast<final_node_type*>(next_org)); |
| 676 | cpy->next()=next_cpy->impl(); |
| 677 | next_cpy->prior()=cpy->impl(); |
| 678 | org=next_org; |
| 679 | cpy=next_cpy; |
| 680 | }while(org!=x.header()); |
| 681 | |
| 682 | super::copy_(x,map); |
| 683 | } |
| 684 | |
| 685 | template<typename Variant> |
| 686 | final_node_type* insert_( |
| 687 | value_param_type v,final_node_type*& x,Variant variant) |
| 688 | { |
| 689 | final_node_type* res=super::insert_(v,x,variant); |
| 690 | if(res==x)link(static_cast<node_type*>(x)); |
| 691 | return res; |
| 692 | } |
| 693 | |
| 694 | template<typename Variant> |
| 695 | final_node_type* insert_( |
| 696 | value_param_type v,node_type* position,final_node_type*& x,Variant variant) |
| 697 | { |
| 698 | final_node_type* res=super::insert_(v,position,x,variant); |
| 699 | if(res==x)link(static_cast<node_type*>(x)); |
| 700 | return res; |
| 701 | } |
| 702 | |
| 703 | void erase_(node_type* x) |
| 704 | { |
| 705 | unlink(x); |
| 706 | super::erase_(x); |
| 707 | |
| 708 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 709 | detach_iterators(x); |
| 710 | #endif |
| 711 | } |
| 712 | |
| 713 | void delete_all_nodes_() |
| 714 | { |
| 715 | for(node_type* x=node_type::from_impl(header()->next());x!=header();){ |
| 716 | node_type* y=node_type::from_impl(x->next()); |
| 717 | this->final_delete_node_(static_cast<final_node_type*>(x)); |
| 718 | x=y; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | void clear_() |
| 723 | { |
| 724 | super::clear_(); |
| 725 | empty_initialize(); |
| 726 | |
| 727 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 728 | safe_super::detach_dereferenceable_iterators(); |
| 729 | #endif |
| 730 | } |
| 731 | |
| 732 | void swap_(sequenced_index<SuperMeta,TagList>& x) |
| 733 | { |
| 734 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 735 | safe_super::swap(x); |
| 736 | #endif |
| 737 | |
| 738 | super::swap_(x); |
| 739 | } |
| 740 | |
| 741 | void swap_elements_(sequenced_index<SuperMeta,TagList>& x) |
| 742 | { |
| 743 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 744 | safe_super::swap(x); |
| 745 | #endif |
| 746 | |
| 747 | super::swap_elements_(x); |
| 748 | } |
| 749 | |
| 750 | template<typename Variant> |
| 751 | bool replace_(value_param_type v,node_type* x,Variant variant) |
| 752 | { |
| 753 | return super::replace_(v,x,variant); |
| 754 | } |
| 755 | |
| 756 | bool modify_(node_type* x) |
| 757 | { |
| 758 | BOOST_TRY{ |
| 759 | if(!super::modify_(x)){ |
| 760 | unlink(x); |
| 761 | |
| 762 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 763 | detach_iterators(x); |
| 764 | #endif |
| 765 | |
| 766 | return false; |
| 767 | } |
| 768 | else return true; |
| 769 | } |
| 770 | BOOST_CATCH(...){ |
| 771 | unlink(x); |
| 772 | |
| 773 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 774 | detach_iterators(x); |
| 775 | #endif |
| 776 | |
| 777 | BOOST_RETHROW; |
| 778 | } |
| 779 | BOOST_CATCH_END |
| 780 | } |
| 781 | |
| 782 | bool modify_rollback_(node_type* x) |
| 783 | { |
| 784 | return super::modify_rollback_(x); |
| 785 | } |
| 786 | |
| 787 | bool check_rollback_(node_type* x)const |
| 788 | { |
| 789 | return super::check_rollback_(x); |
| 790 | } |
| 791 | |
| 792 | #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) |
| 793 | /* serialization */ |
| 794 | |
| 795 | template<typename Archive> |
| 796 | void save_( |
| 797 | Archive& ar,const unsigned int version,const index_saver_type& sm)const |
| 798 | { |
| 799 | sm.save(begin(),end(),ar,version); |
| 800 | super::save_(ar,version,sm); |
| 801 | } |
| 802 | |
| 803 | template<typename Archive> |
| 804 | void load_( |
| 805 | Archive& ar,const unsigned int version,const index_loader_type& lm) |
| 806 | { |
| 807 | lm.load( |
| 808 | ::boost::bind( |
| 809 | &sequenced_index::rearranger,this,::boost::arg<1>(),::boost::arg<2>()), |
| 810 | ar,version); |
| 811 | super::load_(ar,version,lm); |
| 812 | } |
| 813 | #endif |
| 814 | |
| 815 | #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING) |
| 816 | /* invariant stuff */ |
| 817 | |
| 818 | bool invariant_()const |
| 819 | { |
| 820 | if(size()==0||begin()==end()){ |
| 821 | if(size()!=0||begin()!=end()|| |
| 822 | header()->next()!=header()->impl()|| |
| 823 | header()->prior()!=header()->impl())return false; |
| 824 | } |
| 825 | else{ |
| 826 | size_type s=0; |
| 827 | for(const_iterator it=begin(),it_end=end();it!=it_end;++it,++s){ |
| 828 | if(it.get_node()->next()->prior()!=it.get_node()->impl())return false; |
| 829 | if(it.get_node()->prior()->next()!=it.get_node()->impl())return false; |
| 830 | } |
| 831 | if(s!=size())return false; |
| 832 | } |
| 833 | |
| 834 | return super::invariant_(); |
| 835 | } |
| 836 | |
| 837 | /* This forwarding function eases things for the boost::mem_fn construct |
| 838 | * in BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT. Actually, |
| 839 | * final_check_invariant is already an inherited member function of index. |
| 840 | */ |
| 841 | void check_invariant_()const{this->final_check_invariant_();} |
| 842 | #endif |
| 843 | |
| 844 | private: |
| 845 | node_type* header()const{return this->final_header();} |
| 846 | |
| 847 | void empty_initialize() |
| 848 | { |
| 849 | header()->prior()=header()->next()=header()->impl(); |
| 850 | } |
| 851 | |
| 852 | void link(node_type* x) |
| 853 | { |
| 854 | node_impl_type::link(x->impl(),header()->impl()); |
| 855 | }; |
| 856 | |
| 857 | static void unlink(node_type* x) |
| 858 | { |
| 859 | node_impl_type::unlink(x->impl()); |
| 860 | } |
| 861 | |
| 862 | static void relink(node_type* position,node_type* x) |
| 863 | { |
| 864 | node_impl_type::relink(position->impl(),x->impl()); |
| 865 | } |
| 866 | |
| 867 | static void relink(node_type* position,node_type* first,node_type* last) |
| 868 | { |
| 869 | node_impl_type::relink( |
| 870 | position->impl(),first->impl(),last->impl()); |
| 871 | } |
| 872 | |
| 873 | #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) |
| 874 | void rearranger(node_type* position,node_type *x) |
| 875 | { |
| 876 | if(!position)position=header(); |
| 877 | node_type::increment(position); |
| 878 | if(position!=x)relink(position,x); |
| 879 | } |
| 880 | #endif |
| 881 | |
| 882 | #if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE) |
| 883 | void detach_iterators(node_type* x) |
| 884 | { |
| 885 | iterator it=make_iterator(x); |
| 886 | safe_mode::detach_equivalent_iterators(it); |
| 887 | } |
| 888 | #endif |
| 889 | |
| 890 | template <class InputIterator> |
| 891 | void assign_iter(InputIterator first,InputIterator last,mpl::true_) |
| 892 | { |
| 893 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 894 | clear(); |
| 895 | for(;first!=last;++first)this->final_insert_ref_(*first); |
| 896 | } |
| 897 | |
| 898 | void assign_iter(size_type n,value_param_type value,mpl::false_) |
| 899 | { |
| 900 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 901 | clear(); |
| 902 | for(size_type i=0;i<n;++i)push_back(value); |
| 903 | } |
| 904 | |
| 905 | template<typename InputIterator> |
| 906 | void insert_iter( |
| 907 | iterator position,InputIterator first,InputIterator last,mpl::true_) |
| 908 | { |
| 909 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 910 | for(;first!=last;++first){ |
| 911 | std::pair<final_node_type*,bool> p= |
| 912 | this->final_insert_ref_(*first); |
| 913 | if(p.second&&position.get_node()!=header()){ |
| 914 | relink(position.get_node(),p.first); |
| 915 | } |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | void insert_iter( |
| 920 | iterator position,size_type n,value_param_type x,mpl::false_) |
| 921 | { |
| 922 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 923 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 924 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 925 | for(size_type i=0;i<n;++i)insert(position,x); |
| 926 | } |
| 927 | |
| 928 | template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK> |
| 929 | std::pair<iterator,bool> emplace_front_impl( |
| 930 | BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK) |
| 931 | { |
| 932 | return emplace_impl(begin(),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK); |
| 933 | } |
| 934 | |
| 935 | template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK> |
| 936 | std::pair<iterator,bool> emplace_back_impl( |
| 937 | BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK) |
| 938 | { |
| 939 | return emplace_impl(end(),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK); |
| 940 | } |
| 941 | |
| 942 | template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK> |
| 943 | std::pair<iterator,bool> emplace_impl( |
| 944 | iterator position,BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK) |
| 945 | { |
| 946 | BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position); |
| 947 | BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this); |
| 948 | BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT; |
| 949 | std::pair<final_node_type*,bool> p= |
| 950 | this->final_emplace_(BOOST_MULTI_INDEX_FORWARD_PARAM_PACK); |
| 951 | if(p.second&&position.get_node()!=header()){ |
| 952 | relink(position.get_node(),p.first); |
| 953 | } |
| 954 | return std::pair<iterator,bool>(make_iterator(p.first),p.second); |
| 955 | } |
| 956 | |
| 957 | #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)&&\ |
| 958 | BOOST_WORKAROUND(__MWERKS__,<=0x3003) |
| 959 | #pragma parse_mfunc_templ reset |
| 960 | #endif |
| 961 | }; |
| 962 | |
| 963 | /* comparison */ |
| 964 | |
| 965 | template< |
| 966 | typename SuperMeta1,typename TagList1, |
| 967 | typename SuperMeta2,typename TagList2 |
| 968 | > |
| 969 | bool operator==( |
| 970 | const sequenced_index<SuperMeta1,TagList1>& x, |
| 971 | const sequenced_index<SuperMeta2,TagList2>& y) |
| 972 | { |
| 973 | return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin()); |
| 974 | } |
| 975 | |
| 976 | template< |
| 977 | typename SuperMeta1,typename TagList1, |
| 978 | typename SuperMeta2,typename TagList2 |
| 979 | > |
| 980 | bool operator<( |
| 981 | const sequenced_index<SuperMeta1,TagList1>& x, |
| 982 | const sequenced_index<SuperMeta2,TagList2>& y) |
| 983 | { |
| 984 | return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); |
| 985 | } |
| 986 | |
| 987 | template< |
| 988 | typename SuperMeta1,typename TagList1, |
| 989 | typename SuperMeta2,typename TagList2 |
| 990 | > |
| 991 | bool operator!=( |
| 992 | const sequenced_index<SuperMeta1,TagList1>& x, |
| 993 | const sequenced_index<SuperMeta2,TagList2>& y) |
| 994 | { |
| 995 | return !(x==y); |
| 996 | } |
| 997 | |
| 998 | template< |
| 999 | typename SuperMeta1,typename TagList1, |
| 1000 | typename SuperMeta2,typename TagList2 |
| 1001 | > |
| 1002 | bool operator>( |
| 1003 | const sequenced_index<SuperMeta1,TagList1>& x, |
| 1004 | const sequenced_index<SuperMeta2,TagList2>& y) |
| 1005 | { |
| 1006 | return y<x; |
| 1007 | } |
| 1008 | |
| 1009 | template< |
| 1010 | typename SuperMeta1,typename TagList1, |
| 1011 | typename SuperMeta2,typename TagList2 |
| 1012 | > |
| 1013 | bool operator>=( |
| 1014 | const sequenced_index<SuperMeta1,TagList1>& x, |
| 1015 | const sequenced_index<SuperMeta2,TagList2>& y) |
| 1016 | { |
| 1017 | return !(x<y); |
| 1018 | } |
| 1019 | |
| 1020 | template< |
| 1021 | typename SuperMeta1,typename TagList1, |
| 1022 | typename SuperMeta2,typename TagList2 |
| 1023 | > |
| 1024 | bool operator<=( |
| 1025 | const sequenced_index<SuperMeta1,TagList1>& x, |
| 1026 | const sequenced_index<SuperMeta2,TagList2>& y) |
| 1027 | { |
| 1028 | return !(x>y); |
| 1029 | } |
| 1030 | |
| 1031 | /* specialized algorithms */ |
| 1032 | |
| 1033 | template<typename SuperMeta,typename TagList> |
| 1034 | void swap( |
| 1035 | sequenced_index<SuperMeta,TagList>& x, |
| 1036 | sequenced_index<SuperMeta,TagList>& y) |
| 1037 | { |
| 1038 | x.swap(y); |
| 1039 | } |
| 1040 | |
| 1041 | } /* namespace multi_index::detail */ |
| 1042 | |
| 1043 | /* sequenced index specifier */ |
| 1044 | |
| 1045 | template <typename TagList> |
| 1046 | struct sequenced |
| 1047 | { |
| 1048 | BOOST_STATIC_ASSERT(detail::is_tag<TagList>::value); |
| 1049 | |
| 1050 | template<typename Super> |
| 1051 | struct node_class |
| 1052 | { |
| 1053 | typedef detail::sequenced_index_node<Super> type; |
| 1054 | }; |
| 1055 | |
| 1056 | template<typename SuperMeta> |
| 1057 | struct index_class |
| 1058 | { |
| 1059 | typedef detail::sequenced_index<SuperMeta,typename TagList::type> type; |
| 1060 | }; |
| 1061 | }; |
| 1062 | |
| 1063 | } /* namespace multi_index */ |
| 1064 | |
| 1065 | } /* namespace boost */ |
| 1066 | |
| 1067 | /* Boost.Foreach compatibility */ |
| 1068 | |
| 1069 | template<typename SuperMeta,typename TagList> |
| 1070 | inline boost::mpl::true_* boost_foreach_is_noncopyable( |
| 1071 | boost::multi_index::detail::sequenced_index<SuperMeta,TagList>*&, |
| 1072 | boost_foreach_argument_dependent_lookup_hack) |
| 1073 | { |
| 1074 | return 0; |
| 1075 | } |
| 1076 | |
| 1077 | #undef BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT |
| 1078 | #undef BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT_OF |
| 1079 | |
| 1080 | #endif |