1 /////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Olaf Krzikalla 2004-2006.
4 // (C) Copyright Ion Gaztanaga 2006-2008
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 // See http://www.boost.org/libs/intrusive for documentation.
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef BOOST_INTRUSIVE_LIST_HPP
15 #define BOOST_INTRUSIVE_LIST_HPP
17 #include <boost/intrusive/detail/config_begin.hpp>
18 #include <boost/intrusive/detail/assert.hpp>
19 #include <boost/intrusive/intrusive_fwd.hpp>
20 #include <boost/intrusive/list_hook.hpp>
21 #include <boost/intrusive/circular_list_algorithms.hpp>
22 #include <boost/intrusive/detail/pointer_to_other.hpp>
23 #include <boost/intrusive/detail/clear_on_destructor_base.hpp>
24 #include <boost/intrusive/detail/mpl.hpp>
25 #include <boost/intrusive/link_mode.hpp>
26 #include <boost/static_assert.hpp>
27 #include <boost/intrusive/options.hpp>
28 #include <boost/intrusive/detail/utilities.hpp>
39 template <class ValueTraits
, class SizeType
, bool ConstantTimeSize
>
42 typedef ValueTraits value_traits
;
43 typedef SizeType size_type
;
44 static const bool constant_time_size
= ConstantTimeSize
;
52 , base_hook
<detail::default_list_hook
>
53 , constant_time_size
<true>
54 , size_type
<std::size_t>
60 //! The class template list is an intrusive container that mimics most of the
61 //! interface of std::list as described in the C++ standard.
63 //! The template parameter \c T is the type to be managed by the container.
64 //! The user can specify additional options and if no options are provided
65 //! default options are used.
67 //! The container supports the following options:
68 //! \c base_hook<>/member_hook<>/value_traits<>,
69 //! \c constant_time_size<> and \c size_type<>.
70 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
71 template<class T
, class ...Options
>
73 template<class Config
>
76 : private detail::clear_on_destructor_base
< list_impl
<Config
> >
78 template<class C
> friend class detail::clear_on_destructor_base
;
81 typedef typename
Config::value_traits value_traits
;
83 static const bool external_value_traits
=
84 detail::external_value_traits_is_true
<value_traits
>::value
;
85 typedef typename
detail::eval_if_c
86 < external_value_traits
87 , detail::eval_value_traits
<value_traits
>
88 , detail::identity
<value_traits
>
89 >::type real_value_traits
;
91 typedef typename
real_value_traits::pointer pointer
;
92 typedef typename
real_value_traits::const_pointer const_pointer
;
93 typedef typename
std::iterator_traits
<pointer
>::value_type value_type
;
94 typedef typename
std::iterator_traits
<pointer
>::reference reference
;
95 typedef typename
std::iterator_traits
<const_pointer
>::reference const_reference
;
96 typedef typename
std::iterator_traits
<pointer
>::difference_type difference_type
;
97 typedef typename
Config::size_type size_type
;
98 typedef list_iterator
<list_impl
, false> iterator
;
99 typedef list_iterator
<list_impl
, true> const_iterator
;
100 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
101 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
102 typedef typename
real_value_traits::node_traits node_traits
;
103 typedef typename
node_traits::node node
;
104 typedef typename
node_traits::node_ptr node_ptr
;
105 typedef typename
node_traits::const_node_ptr const_node_ptr
;
106 typedef circular_list_algorithms
<node_traits
> node_algorithms
;
108 static const bool constant_time_size
= Config::constant_time_size
;
109 static const bool stateful_value_traits
= detail::store_cont_ptr_on_it
<list_impl
>::value
;
114 typedef detail::size_holder
<constant_time_size
, size_type
> size_traits
;
116 //Non-copyable and non-moveable
117 list_impl (const list_impl
&);
118 list_impl
&operator =(const list_impl
&);
120 enum { safemode_or_autounlink
=
121 (int)real_value_traits::link_mode
== (int)auto_unlink
||
122 (int)real_value_traits::link_mode
== (int)safe_link
};
124 //Constant-time size is incompatible with auto-unlink hooks!
125 BOOST_STATIC_ASSERT(!(constant_time_size
&&
126 ((int)real_value_traits::link_mode
== (int)auto_unlink
)
129 //Const cast emulation for smart pointers
130 static node_ptr
uncast(const_node_ptr ptr
)
132 //return node_ptr(detail::get_pointer(ptr)));
133 return const_cast<node
*>(detail::get_pointer(ptr
));
136 node_ptr
get_root_node()
137 { return node_ptr(&data_
.root_plus_size_
.root_
); }
139 const_node_ptr
get_root_node() const
140 { return const_node_ptr(&data_
.root_plus_size_
.root_
); }
142 struct root_plus_size
: public size_traits
147 struct data_t
: public value_traits
149 typedef typename
list_impl::value_traits value_traits
;
150 data_t(const value_traits
&val_traits
)
151 : value_traits(val_traits
)
154 root_plus_size root_plus_size_
;
157 size_traits
&priv_size_traits()
158 { return data_
.root_plus_size_
; }
160 const size_traits
&priv_size_traits() const
161 { return data_
.root_plus_size_
; }
163 const real_value_traits
&get_real_value_traits(detail::bool_
<false>) const
166 const real_value_traits
&get_real_value_traits(detail::bool_
<true>) const
167 { return data_
.get_value_traits(*this); }
169 real_value_traits
&get_real_value_traits(detail::bool_
<false>)
172 real_value_traits
&get_real_value_traits(detail::bool_
<true>)
173 { return data_
.get_value_traits(*this); }
179 const real_value_traits
&get_real_value_traits() const
180 { return this->get_real_value_traits(detail::bool_
<external_value_traits
>()); }
182 real_value_traits
&get_real_value_traits()
183 { return this->get_real_value_traits(detail::bool_
<external_value_traits
>()); }
185 //! <b>Effects</b>: constructs an empty list.
187 //! <b>Complexity</b>: Constant
189 //! <b>Throws</b>: If real_value_traits::node_traits::node
190 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks).
191 list_impl(const value_traits
&v_traits
= value_traits())
194 this->priv_size_traits().set_size(size_type(0));
195 node_algorithms::init_header(this->get_root_node());
198 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
200 //! <b>Effects</b>: Constructs a list equal to the range [first,last).
202 //! <b>Complexity</b>: Linear in std::distance(b, e). No copy constructors are called.
204 //! <b>Throws</b>: If real_value_traits::node_traits::node
205 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks).
206 template<class Iterator
>
207 list_impl(Iterator b
, Iterator e
, const value_traits
&v_traits
= value_traits())
210 this->priv_size_traits().set_size(size_type(0));
211 node_algorithms::init_header(this->get_root_node());
212 this->insert(this->cend(), b
, e
);
215 //! <b>Effects</b>: If it's not a safe-mode or an auto-unlink value_type
216 //! the destructor does nothing
217 //! (ie. no code is generated). Otherwise it detaches all elements from this.
218 //! In this case the objects in the list are not deleted (i.e. no destructors
219 //! are called), but the hooks according to the ValueTraits template parameter
220 //! are set to their default value.
222 //! <b>Complexity</b>: Linear to the number of elements in the list, if
223 //! it's a safe-mode or auto-unlink value . Otherwise constant.
227 //! <b>Requires</b>: value must be an lvalue.
229 //! <b>Effects</b>: Inserts the value in the back of the list.
230 //! No copy constructors are called.
232 //! <b>Throws</b>: Nothing.
234 //! <b>Complexity</b>: Constant.
236 //! <b>Note</b>: Does not affect the validity of iterators and references.
237 void push_back(reference value
)
239 node_ptr to_insert
= get_real_value_traits().to_node_ptr(value
);
240 if(safemode_or_autounlink
)
241 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert
));
242 node_algorithms::link_before(this->get_root_node(), to_insert
);
243 this->priv_size_traits().increment();
246 //! <b>Requires</b>: value must be an lvalue.
248 //! <b>Effects</b>: Inserts the value in the front of the list.
249 //! No copy constructors are called.
251 //! <b>Throws</b>: Nothing.
253 //! <b>Complexity</b>: Constant.
255 //! <b>Note</b>: Does not affect the validity of iterators and references.
256 void push_front(reference value
)
258 node_ptr to_insert
= get_real_value_traits().to_node_ptr(value
);
259 if(safemode_or_autounlink
)
260 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert
));
261 node_algorithms::link_before(node_traits::get_next(this->get_root_node()), to_insert
);
262 this->priv_size_traits().increment();
265 //! <b>Effects</b>: Erases the last element of the list.
266 //! No destructors are called.
268 //! <b>Throws</b>: Nothing.
270 //! <b>Complexity</b>: Constant.
272 //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
274 { return this->pop_back_and_dispose(detail::null_disposer()); }
276 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
278 //! <b>Effects</b>: Erases the last element of the list.
279 //! No destructors are called.
280 //! Disposer::operator()(pointer) is called for the removed element.
282 //! <b>Throws</b>: Nothing.
284 //! <b>Complexity</b>: Constant.
286 //! <b>Note</b>: Invalidates the iterators to the erased element.
287 template<class Disposer
>
288 void pop_back_and_dispose(Disposer disposer
)
290 node_ptr to_erase
= node_traits::get_previous(this->get_root_node());
291 node_algorithms::unlink(to_erase
);
292 this->priv_size_traits().decrement();
293 if(safemode_or_autounlink
)
294 node_algorithms::init(to_erase
);
295 disposer(get_real_value_traits().to_value_ptr(to_erase
));
298 //! <b>Effects</b>: Erases the first element of the list.
299 //! No destructors are called.
301 //! <b>Throws</b>: Nothing.
303 //! <b>Complexity</b>: Constant.
305 //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased element.
307 { return this->pop_front_and_dispose(detail::null_disposer()); }
309 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
311 //! <b>Effects</b>: Erases the first element of the list.
312 //! No destructors are called.
313 //! Disposer::operator()(pointer) is called for the removed element.
315 //! <b>Throws</b>: Nothing.
317 //! <b>Complexity</b>: Constant.
319 //! <b>Note</b>: Invalidates the iterators to the erased element.
320 template<class Disposer
>
321 void pop_front_and_dispose(Disposer disposer
)
323 node_ptr to_erase
= node_traits::get_next(this->get_root_node());
324 node_algorithms::unlink(to_erase
);
325 this->priv_size_traits().decrement();
326 if(safemode_or_autounlink
)
327 node_algorithms::init(to_erase
);
328 disposer(get_real_value_traits().to_value_ptr(to_erase
));
331 //! <b>Effects</b>: Returns a reference to the first element of the list.
333 //! <b>Throws</b>: Nothing.
335 //! <b>Complexity</b>: Constant.
337 { return *get_real_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); }
339 //! <b>Effects</b>: Returns a const_reference to the first element of the list.
341 //! <b>Throws</b>: Nothing.
343 //! <b>Complexity</b>: Constant.
344 const_reference
front() const
345 { return *get_real_value_traits().to_value_ptr(uncast(node_traits::get_next(this->get_root_node()))); }
347 //! <b>Effects</b>: Returns a reference to the last element of the list.
349 //! <b>Throws</b>: Nothing.
351 //! <b>Complexity</b>: Constant.
353 { return *get_real_value_traits().to_value_ptr(node_traits::get_previous(this->get_root_node())); }
355 //! <b>Effects</b>: Returns a const_reference to the last element of the list.
357 //! <b>Throws</b>: Nothing.
359 //! <b>Complexity</b>: Constant.
360 const_reference
back() const
361 { return *get_real_value_traits().to_value_ptr(uncast(node_traits::get_previous(this->get_root_node()))); }
363 //! <b>Effects</b>: Returns an iterator to the first element contained in the list.
365 //! <b>Throws</b>: Nothing.
367 //! <b>Complexity</b>: Constant.
369 { return iterator(node_traits::get_next(this->get_root_node()), this); }
371 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
373 //! <b>Throws</b>: Nothing.
375 //! <b>Complexity</b>: Constant.
376 const_iterator
begin() const
377 { return this->cbegin(); }
379 //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
381 //! <b>Throws</b>: Nothing.
383 //! <b>Complexity</b>: Constant.
384 const_iterator
cbegin() const
385 { return const_iterator(node_traits::get_next(this->get_root_node()), this); }
387 //! <b>Effects</b>: Returns an iterator to the end of the list.
389 //! <b>Throws</b>: Nothing.
391 //! <b>Complexity</b>: Constant.
393 { return iterator(this->get_root_node(), this); }
395 //! <b>Effects</b>: Returns a const_iterator to the end of the list.
397 //! <b>Throws</b>: Nothing.
399 //! <b>Complexity</b>: Constant.
400 const_iterator
end() const
401 { return this->cend(); }
403 //! <b>Effects</b>: Returns a constant iterator to the end of the list.
405 //! <b>Throws</b>: Nothing.
407 //! <b>Complexity</b>: Constant.
408 const_iterator
cend() const
409 { return const_iterator(uncast(this->get_root_node()), this); }
411 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
412 //! of the reversed list.
414 //! <b>Throws</b>: Nothing.
416 //! <b>Complexity</b>: Constant.
417 reverse_iterator
rbegin()
418 { return reverse_iterator(this->end()); }
420 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
421 //! of the reversed list.
423 //! <b>Throws</b>: Nothing.
425 //! <b>Complexity</b>: Constant.
426 const_reverse_iterator
rbegin() const
427 { return this->crbegin(); }
429 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
430 //! of the reversed list.
432 //! <b>Throws</b>: Nothing.
434 //! <b>Complexity</b>: Constant.
435 const_reverse_iterator
crbegin() const
436 { return const_reverse_iterator(end()); }
438 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
439 //! of the reversed list.
441 //! <b>Throws</b>: Nothing.
443 //! <b>Complexity</b>: Constant.
444 reverse_iterator
rend()
445 { return reverse_iterator(begin()); }
447 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
448 //! of the reversed list.
450 //! <b>Throws</b>: Nothing.
452 //! <b>Complexity</b>: Constant.
453 const_reverse_iterator
rend() const
454 { return this->crend(); }
456 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
457 //! of the reversed list.
459 //! <b>Throws</b>: Nothing.
461 //! <b>Complexity</b>: Constant.
462 const_reverse_iterator
crend() const
463 { return const_reverse_iterator(this->begin()); }
465 //! <b>Precondition</b>: end_iterator must be a valid end iterator
468 //! <b>Effects</b>: Returns a const reference to the list associated to the end iterator
470 //! <b>Throws</b>: Nothing.
472 //! <b>Complexity</b>: Constant.
473 static list_impl
&container_from_end_iterator(iterator end_iterator
)
474 { return list_impl::priv_container_from_end_iterator(end_iterator
); }
476 //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
479 //! <b>Effects</b>: Returns a const reference to the list associated to the end iterator
481 //! <b>Throws</b>: Nothing.
483 //! <b>Complexity</b>: Constant.
484 static const list_impl
&container_from_end_iterator(const_iterator end_iterator
)
485 { return list_impl::priv_container_from_end_iterator(end_iterator
); }
487 //! <b>Effects</b>: Returns the number of the elements contained in the list.
489 //! <b>Throws</b>: Nothing.
491 //! <b>Complexity</b>: Linear to the number of elements contained in the list.
492 //! if constant-time size option is disabled. Constant time otherwise.
494 //! <b>Note</b>: Does not affect the validity of iterators and references.
495 size_type
size() const
497 if(constant_time_size
)
498 return this->priv_size_traits().get_size();
500 return node_algorithms::count(this->get_root_node()) - 1;
503 //! <b>Effects</b>: Returns true if the list contains no elements.
505 //! <b>Throws</b>: Nothing.
507 //! <b>Complexity</b>: Constant.
509 //! <b>Note</b>: Does not affect the validity of iterators and references.
511 { return node_algorithms::unique(this->get_root_node()); }
513 //! <b>Effects</b>: Swaps the elements of x and *this.
515 //! <b>Throws</b>: Nothing.
517 //! <b>Complexity</b>: Constant.
519 //! <b>Note</b>: Does not affect the validity of iterators and references.
520 void swap(list_impl
& other
)
522 node_algorithms::swap_nodes(this->get_root_node(), other
.get_root_node());
523 if(constant_time_size
){
524 size_type backup
= this->priv_size_traits().get_size();
525 this->priv_size_traits().set_size(other
.priv_size_traits().get_size());
526 other
.priv_size_traits().set_size(backup
);
530 //! <b>Effects</b>: Moves backwards all the elements, so that the first
531 //! element becomes the second, the second becomes the third...
532 //! the last element becomes the first one.
534 //! <b>Throws</b>: Nothing.
536 //! <b>Complexity</b>: Linear to the number of shifts.
538 //! <b>Note</b>: Does not affect the validity of iterators and references.
539 void shift_backwards(size_type n
= 1)
540 { node_algorithms::move_forward(this->get_root_node(), n
); }
542 //! <b>Effects</b>: Moves forward all the elements, so that the second
543 //! element becomes the first, the third becomes the second...
544 //! the first element becomes the last one.
546 //! <b>Throws</b>: Nothing.
548 //! <b>Complexity</b>: Linear to the number of shifts.
550 //! <b>Note</b>: Does not affect the validity of iterators and references.
551 void shift_forward(size_type n
= 1)
552 { node_algorithms::move_backwards(this->get_root_node(), n
); }
554 //! <b>Effects</b>: Erases the element pointed by i of the list.
555 //! No destructors are called.
557 //! <b>Returns</b>: the first element remaining beyond the removed element,
558 //! or end() if no such element exists.
560 //! <b>Throws</b>: Nothing.
562 //! <b>Complexity</b>: Constant.
564 //! <b>Note</b>: Invalidates the iterators (but not the references) to the
566 iterator
erase(const_iterator i
)
567 { return this->erase_and_dispose(i
, detail::null_disposer()); }
569 //! <b>Requires</b>: b and e must be valid iterators to elements in *this.
571 //! <b>Effects</b>: Erases the element range pointed by b and e
572 //! No destructors are called.
574 //! <b>Returns</b>: the first element remaining beyond the removed elements,
575 //! or end() if no such element exists.
577 //! <b>Throws</b>: Nothing.
579 //! <b>Complexity</b>: Linear to the number of erased elements if it's a safe-mode
580 //! or auto-unlink value, or constant-time size is enabled. Constant-time otherwise.
582 //! <b>Note</b>: Invalidates the iterators (but not the references) to the
584 iterator
erase(const_iterator b
, const_iterator e
)
586 if(safemode_or_autounlink
|| constant_time_size
){
587 return this->erase_and_dispose(b
, e
, detail::null_disposer());
590 node_algorithms::unlink(b
.pointed_node(), e
.pointed_node());
595 //! <b>Requires</b>: b and e must be valid iterators to elements in *this.
596 //! n must be std::distance(b, e).
598 //! <b>Effects</b>: Erases the element range pointed by b and e
599 //! No destructors are called.
601 //! <b>Returns</b>: the first element remaining beyond the removed elements,
602 //! or end() if no such element exists.
604 //! <b>Throws</b>: Nothing.
606 //! <b>Complexity</b>: Linear to the number of erased elements if it's a safe-mode
607 //! or auto-unlink value is enabled. Constant-time otherwise.
609 //! <b>Note</b>: Invalidates the iterators (but not the references) to the
611 iterator
erase(const_iterator b
, const_iterator e
, difference_type n
)
613 BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(b
, e
) == difference_type(n
));
614 if(safemode_or_autounlink
|| constant_time_size
){
615 return this->erase_and_dispose(b
, e
, detail::null_disposer());
618 if(constant_time_size
){
619 this->priv_size_traits().set_size(this->priv_size_traits().get_size() - n
);
621 node_algorithms::unlink(b
.pointed_node(), e
.pointed_node());
626 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
628 //! <b>Effects</b>: Erases the element pointed by i of the list.
629 //! No destructors are called.
630 //! Disposer::operator()(pointer) is called for the removed element.
632 //! <b>Returns</b>: the first element remaining beyond the removed element,
633 //! or end() if no such element exists.
635 //! <b>Throws</b>: Nothing.
637 //! <b>Complexity</b>: Constant.
639 //! <b>Note</b>: Invalidates the iterators to the erased element.
640 template <class Disposer
>
641 iterator
erase_and_dispose(const_iterator i
, Disposer disposer
)
643 node_ptr
to_erase(i
.pointed_node());
645 node_algorithms::unlink(to_erase
);
646 this->priv_size_traits().decrement();
647 if(safemode_or_autounlink
)
648 node_algorithms::init(to_erase
);
649 disposer(this->get_real_value_traits().to_value_ptr(to_erase
));
653 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
654 template<class Disposer
>
655 iterator
erase_and_dispose(iterator i
, Disposer disposer
)
656 { return this->erase_and_dispose(const_iterator(i
), disposer
); }
659 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
661 //! <b>Effects</b>: Erases the element range pointed by b and e
662 //! No destructors are called.
663 //! Disposer::operator()(pointer) is called for the removed elements.
665 //! <b>Returns</b>: the first element remaining beyond the removed elements,
666 //! or end() if no such element exists.
668 //! <b>Throws</b>: Nothing.
670 //! <b>Complexity</b>: Linear to the number of elements erased.
672 //! <b>Note</b>: Invalidates the iterators to the erased elements.
673 template <class Disposer
>
674 iterator
erase_and_dispose(const_iterator b
, const_iterator e
, Disposer disposer
)
676 node_ptr
bp(b
.pointed_node()), ep(e
.pointed_node());
677 node_algorithms::unlink(bp
, ep
);
679 node_ptr
to_erase(bp
);
680 bp
= node_traits::get_next(bp
);
681 if(safemode_or_autounlink
)
682 node_algorithms::init(to_erase
);
683 disposer(get_real_value_traits().to_value_ptr(to_erase
));
684 this->priv_size_traits().decrement();
689 //! <b>Effects</b>: Erases all the elements of the container.
690 //! No destructors are called.
692 //! <b>Throws</b>: Nothing.
694 //! <b>Complexity</b>: Linear to the number of elements of the list.
695 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
697 //! <b>Note</b>: Invalidates the iterators (but not the references) to the erased elements.
700 if(safemode_or_autounlink
){
701 this->clear_and_dispose(detail::null_disposer());
704 node_algorithms::init_header(this->get_root_node());
705 this->priv_size_traits().set_size(size_type(0));
709 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
711 //! <b>Effects</b>: Erases all the elements of the container.
712 //! No destructors are called.
713 //! Disposer::operator()(pointer) is called for the removed elements.
715 //! <b>Throws</b>: Nothing.
717 //! <b>Complexity</b>: Linear to the number of elements of the list.
719 //! <b>Note</b>: Invalidates the iterators to the erased elements.
720 template <class Disposer
>
721 void clear_and_dispose(Disposer disposer
)
723 const_iterator
it(this->begin()), itend(this->end());
725 node_ptr
to_erase(it
.pointed_node());
727 if(safemode_or_autounlink
)
728 node_algorithms::init(to_erase
);
729 disposer(get_real_value_traits().to_value_ptr(to_erase
));
731 node_algorithms::init_header(this->get_root_node());
732 this->priv_size_traits().set_size(0);
735 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
736 //! Cloner should yield to nodes equivalent to the original nodes.
738 //! <b>Effects</b>: Erases all the elements from *this
739 //! calling Disposer::operator()(pointer), clones all the
740 //! elements from src calling Cloner::operator()(const_reference )
741 //! and inserts them on *this.
743 //! If cloner throws, all cloned elements are unlinked and disposed
744 //! calling Disposer::operator()(pointer).
746 //! <b>Complexity</b>: Linear to erased plus inserted elements.
748 //! <b>Throws</b>: If cloner throws. Basic guarantee.
749 template <class Cloner
, class Disposer
>
750 void clone_from(const list_impl
&src
, Cloner cloner
, Disposer disposer
)
752 this->clear_and_dispose(disposer
);
753 detail::exception_disposer
<list_impl
, Disposer
>
754 rollback(*this, disposer
);
755 const_iterator
b(src
.begin()), e(src
.end());
757 this->push_back(*cloner(*b
));
762 //! <b>Requires</b>: value must be an lvalue and p must be a valid iterator of *this.
764 //! <b>Effects</b>: Inserts the value before the position pointed by p.
766 //! <b>Returns</b>: An iterator to the inserted element.
768 //! <b>Throws</b>: Nothing.
770 //! <b>Complexity</b>: Constant time. No copy constructors are called.
772 //! <b>Note</b>: Does not affect the validity of iterators and references.
773 iterator
insert(const_iterator p
, reference value
)
775 node_ptr to_insert
= this->get_real_value_traits().to_node_ptr(value
);
776 if(safemode_or_autounlink
)
777 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert
));
778 node_algorithms::link_before(p
.pointed_node(), to_insert
);
779 this->priv_size_traits().increment();
780 return iterator(to_insert
, this);
783 //! <b>Requires</b>: Dereferencing iterator must yield
784 //! an lvalue of type value_type and p must be a valid iterator of *this.
786 //! <b>Effects</b>: Inserts the range pointed by b and e before the position p.
787 //! No copy constructors are called.
789 //! <b>Throws</b>: Nothing.
791 //! <b>Complexity</b>: Linear to the number of elements inserted.
793 //! <b>Note</b>: Does not affect the validity of iterators and references.
794 template<class Iterator
>
795 void insert(const_iterator p
, Iterator b
, Iterator e
)
801 //! <b>Requires</b>: Dereferencing iterator must yield
802 //! an lvalue of type value_type.
804 //! <b>Effects</b>: Clears the list and inserts the range pointed by b and e.
805 //! No destructors or copy constructors are called.
807 //! <b>Throws</b>: Nothing.
809 //! <b>Complexity</b>: Linear to the number of elements inserted plus
810 //! linear to the elements contained in the list if it's a safe-mode
811 //! or auto-unlink value.
812 //! Linear to the number of elements inserted in the list otherwise.
814 //! <b>Note</b>: Invalidates the iterators (but not the references)
815 //! to the erased elements.
816 template<class Iterator
>
817 void assign(Iterator b
, Iterator e
)
820 this->insert(this->cend(), b
, e
);
823 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
825 //! <b>Requires</b>: Dereferencing iterator must yield
826 //! an lvalue of type value_type.
828 //! <b>Effects</b>: Clears the list and inserts the range pointed by b and e.
829 //! No destructors or copy constructors are called.
830 //! Disposer::operator()(pointer) is called for the removed elements.
832 //! <b>Throws</b>: Nothing.
834 //! <b>Complexity</b>: Linear to the number of elements inserted plus
835 //! linear to the elements contained in the list.
837 //! <b>Note</b>: Invalidates the iterators (but not the references)
838 //! to the erased elements.
839 template<class Iterator
, class Disposer
>
840 void dispose_and_assign(Disposer disposer
, Iterator b
, Iterator e
)
842 this->clear_and_dispose(disposer
);
843 this->insert(this->cend(), b
, e
);
846 //! <b>Requires</b>: p must be a valid iterator of *this.
848 //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
849 //! the element pointed by p. No destructors or copy constructors are called.
851 //! <b>Throws</b>: Nothing.
853 //! <b>Complexity</b>: Constant.
855 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
856 //! this list. Iterators of this list and all the references are not invalidated.
857 void splice(const_iterator p
, list_impl
& x
)
860 size_traits
&thist
= this->priv_size_traits();
861 size_traits
&xt
= x
.priv_size_traits();
862 node_algorithms::transfer
863 (p
.pointed_node(), x
.begin().pointed_node(), x
.end().pointed_node());
864 thist
.set_size(thist
.get_size() + xt
.get_size());
865 xt
.set_size(size_type(0));
869 //! <b>Requires</b>: p must be a valid iterator of *this.
870 //! new_ele must point to an element contained in list x.
872 //! <b>Effects</b>: Transfers the value pointed by new_ele, from list x to this list,
873 //! before the the element pointed by p. No destructors or copy constructors are called.
874 //! If p == new_ele or p == ++new_ele, this function is a null operation.
876 //! <b>Throws</b>: Nothing.
878 //! <b>Complexity</b>: Constant.
880 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
881 //! list. Iterators of this list and all the references are not invalidated.
882 void splice(const_iterator p
, list_impl
&x
, const_iterator new_ele
)
884 node_algorithms::transfer(p
.pointed_node(), new_ele
.pointed_node());
885 x
.priv_size_traits().decrement();
886 this->priv_size_traits().increment();
889 //! <b>Requires</b>: p must be a valid iterator of *this.
890 //! start and end must point to elements contained in list x.
892 //! <b>Effects</b>: Transfers the range pointed by start and end from list x to this list,
893 //! before the the element pointed by p. No destructors or copy constructors are called.
895 //! <b>Throws</b>: Nothing.
897 //! <b>Complexity</b>: Linear to the number of elements transferred
898 //! if constant-time size option is enabled. Constant-time otherwise.
900 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
901 //! list. Iterators of this list and all the references are not invalidated.
902 void splice(const_iterator p
, list_impl
&x
, const_iterator start
, const_iterator end
)
904 if(constant_time_size
)
905 this->splice(p
, x
, start
, end
, std::distance(start
, end
));
907 this->splice(p
, x
, start
, end
, 1);//distance is a dummy value
910 //! <b>Requires</b>: p must be a valid iterator of *this.
911 //! start and end must point to elements contained in list x.
912 //! n == std::distance(start, end)
914 //! <b>Effects</b>: Transfers the range pointed by start and end from list x to this list,
915 //! before the the element pointed by p. No destructors or copy constructors are called.
917 //! <b>Throws</b>: Nothing.
919 //! <b>Complexity</b>: Constant.
921 //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
922 //! list. Iterators of this list and all the references are not invalidated.
923 void splice(const_iterator p
, list_impl
&x
, const_iterator start
, const_iterator end
, difference_type n
)
926 if(constant_time_size
){
927 size_traits
&thist
= this->priv_size_traits();
928 size_traits
&xt
= x
.priv_size_traits();
929 BOOST_INTRUSIVE_INVARIANT_ASSERT(n
== std::distance(start
, end
));
930 node_algorithms::transfer(p
.pointed_node(), start
.pointed_node(), end
.pointed_node());
931 thist
.set_size(thist
.get_size() + n
);
932 xt
.set_size(xt
.get_size() - n
);
935 node_algorithms::transfer(p
.pointed_node(), start
.pointed_node(), end
.pointed_node());
940 //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
941 //! The sort is stable, that is, the relative order of equivalent elements is preserved.
943 //! <b>Throws</b>: If real_value_traits::node_traits::node
944 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
945 //! or std::less<value_type> throws. Basic guarantee.
947 //! <b>Notes</b>: Iterators and references are not invalidated.
949 //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
950 //! is the list's size.
952 { this->sort(std::less
<value_type
>()); }
954 //! <b>Requires</b>: p must be a comparison function that induces a strict weak ordering
956 //! <b>Effects</b>: This function sorts the list *this according to p. The sort is
957 //! stable, that is, the relative order of equivalent elements is preserved.
959 //! <b>Throws</b>: If real_value_traits::node_traits::node
960 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
961 //! or the predicate throws. Basic guarantee.
963 //! <b>Notes</b>: This won't throw if list_base_hook<> or
964 //! list_member_hook are used.
965 //! Iterators and references are not invalidated.
967 //! <b>Complexity</b>: The number of comparisons is approximately N log N, where N
968 //! is the list's size.
969 template<class Predicate
>
970 void sort(Predicate p
)
972 if(node_traits::get_next(this->get_root_node())
973 != node_traits::get_previous(this->get_root_node())){
975 list_impl counter
[64];
977 while(!this->empty()){
978 carry
.splice(carry
.cbegin(), *this, this->cbegin());
980 while(i
< fill
&& !counter
[i
].empty()) {
981 counter
[i
].merge(carry
, p
);
982 carry
.swap(counter
[i
++]);
984 carry
.swap(counter
[i
]);
988 for (int i
= 1; i
< fill
; ++i
)
989 counter
[i
].merge(counter
[i
-1], p
);
990 this->swap(counter
[fill
-1]);
994 //! <b>Effects</b>: This function removes all of x's elements and inserts them
995 //! in order into *this according to std::less<value_type>. The merge is stable;
996 //! that is, if an element from *this is equivalent to one from x, then the element
997 //! from *this will precede the one from x.
999 //! <b>Throws</b>: If std::less<value_type> throws. Basic guarantee.
1001 //! <b>Complexity</b>: This function is linear time: it performs at most
1002 //! size() + x.size() - 1 comparisons.
1004 //! <b>Note</b>: Iterators and references are not invalidated
1005 void merge(list_impl
& x
)
1006 { this->merge(x
, std::less
<value_type
>()); }
1008 //! <b>Requires</b>: p must be a comparison function that induces a strict weak
1009 //! ordering and both *this and x must be sorted according to that ordering
1010 //! The lists x and *this must be distinct.
1012 //! <b>Effects</b>: This function removes all of x's elements and inserts them
1013 //! in order into *this. The merge is stable; that is, if an element from *this is
1014 //! equivalent to one from x, then the element from *this will precede the one from x.
1016 //! <b>Throws</b>: If the predicate throws. Basic guarantee.
1018 //! <b>Complexity</b>: This function is linear time: it performs at most
1019 //! size() + x.size() - 1 comparisons.
1021 //! <b>Note</b>: Iterators and references are not invalidated.
1022 template<class Predicate
>
1023 void merge(list_impl
& x
, Predicate p
)
1025 const_iterator
e(this->cend()), ex(x
.cend());
1026 const_iterator
b(this->cbegin());
1028 const_iterator
ix(x
.cbegin());
1029 while (b
!= e
&& !p(*ix
, *b
)){
1033 //Now transfer the rest to the end of the container
1041 } while(ix
!= ex
&& p(*ix
, *b
));
1042 this->splice(b
, x
, x
.begin(), ix
, n
);
1047 //! <b>Effects</b>: Reverses the order of elements in the list.
1049 //! <b>Throws</b>: Nothing.
1051 //! <b>Complexity</b>: This function is linear time.
1053 //! <b>Note</b>: Iterators and references are not invalidated
1055 { node_algorithms::reverse(this->get_root_node()); }
1057 //! <b>Effects</b>: Removes all the elements that compare equal to value.
1058 //! No destructors are called.
1060 //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee.
1062 //! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
1064 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1065 //! and iterators to elements that are not removed remain valid.
1066 void remove(const_reference value
)
1067 { this->remove_if(detail::equal_to_value
<const_reference
>(value
)); }
1069 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1071 //! <b>Effects</b>: Removes all the elements that compare equal to value.
1072 //! Disposer::operator()(pointer) is called for every removed element.
1074 //! <b>Throws</b>: If std::equal_to<value_type> throws. Basic guarantee.
1076 //! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
1078 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1079 //! and iterators to elements that are not removed remain valid.
1080 template<class Disposer
>
1081 void remove_and_dispose(const_reference value
, Disposer disposer
)
1082 { this->remove_and_dispose_if(detail::equal_to_value
<const_reference
>(value
), disposer
); }
1084 //! <b>Effects</b>: Removes all the elements for which a specified
1085 //! predicate is satisfied. No destructors are called.
1087 //! <b>Throws</b>: If pred throws. Basic guarantee.
1089 //! <b>Complexity</b>: Linear time. It performs exactly size() calls to the predicate.
1091 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1092 //! and iterators to elements that are not removed remain valid.
1093 template<class Pred
>
1094 void remove_if(Pred pred
)
1095 { this->remove_and_dispose_if(pred
, detail::null_disposer()); }
1097 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1099 //! <b>Effects</b>: Removes all the elements for which a specified
1100 //! predicate is satisfied.
1101 //! Disposer::operator()(pointer) is called for every removed element.
1103 //! <b>Throws</b>: If pred throws. Basic guarantee.
1105 //! <b>Complexity</b>: Linear time. It performs exactly size() comparisons for equality.
1107 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1108 //! and iterators to elements that are not removed remain valid.
1109 template<class Pred
, class Disposer
>
1110 void remove_and_dispose_if(Pred pred
, Disposer disposer
)
1112 const_iterator
cur(this->cbegin());
1113 const_iterator
last(this->cend());
1114 while(cur
!= last
) {
1116 cur
= this->erase_and_dispose(cur
, disposer
);
1124 //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
1125 //! elements that are equal from the list. No destructors are called.
1127 //! <b>Throws</b>: If std::equal_to<value_type throws. Basic guarantee.
1129 //! <b>Complexity</b>: Linear time (size()-1 comparisons calls to pred()).
1131 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1132 //! and iterators to elements that are not removed remain valid.
1134 { this->unique_and_dispose(std::equal_to
<value_type
>(), detail::null_disposer()); }
1136 //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
1137 //! elements that satisfy some binary predicate from the list.
1138 //! No destructors are called.
1140 //! <b>Throws</b>: If pred throws. Basic guarantee.
1142 //! <b>Complexity</b>: Linear time (size()-1 comparisons equality comparisons).
1144 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1145 //! and iterators to elements that are not removed remain valid.
1146 template<class BinaryPredicate
>
1147 void unique(BinaryPredicate pred
)
1148 { this->unique_and_dispose(pred
, detail::null_disposer()); }
1150 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1152 //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
1153 //! elements that are equal from the list.
1154 //! Disposer::operator()(pointer) is called for every removed element.
1156 //! <b>Throws</b>: If std::equal_to<value_type throws. Basic guarantee.
1158 //! <b>Complexity</b>: Linear time (size()-1) comparisons equality comparisons.
1160 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1161 //! and iterators to elements that are not removed remain valid.
1162 template<class Disposer
>
1163 void unique_and_dispose(Disposer disposer
)
1164 { this->unique_and_dispose(std::equal_to
<value_type
>(), disposer
); }
1166 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1168 //! <b>Effects</b>: Removes adjacent duplicate elements or adjacent
1169 //! elements that satisfy some binary predicate from the list.
1170 //! Disposer::operator()(pointer) is called for every removed element.
1172 //! <b>Throws</b>: If pred throws. Basic guarantee.
1174 //! <b>Complexity</b>: Linear time (size()-1) comparisons equality comparisons.
1176 //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
1177 //! and iterators to elements that are not removed remain valid.
1178 template<class BinaryPredicate
, class Disposer
>
1179 void unique_and_dispose(BinaryPredicate pred
, Disposer disposer
)
1181 const_iterator
itend(this->cend());
1182 const_iterator
cur(this->cbegin());
1185 const_iterator
after(cur
);
1187 while(after
!= itend
){
1188 if(pred(*cur
, *after
)){
1189 after
= this->erase_and_dispose(after
, disposer
);
1199 //! <b>Requires</b>: value must be a reference to a value inserted in a list.
1201 //! <b>Effects</b>: This function returns a const_iterator pointing to the element
1203 //! <b>Throws</b>: Nothing.
1205 //! <b>Complexity</b>: Constant time.
1207 //! <b>Note</b>: Iterators and references are not invalidated.
1208 //! This static function is available only if the <i>value traits</i>
1210 static iterator
s_iterator_to(reference value
)
1212 BOOST_STATIC_ASSERT((!stateful_value_traits
));
1213 BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(value
)));
1214 return iterator(real_value_traits::to_node_ptr(value
), 0);
1217 //! <b>Requires</b>: value must be a const reference to a value inserted in a list.
1219 //! <b>Effects</b>: This function returns an iterator pointing to the element.
1221 //! <b>Throws</b>: Nothing.
1223 //! <b>Complexity</b>: Constant time.
1225 //! <b>Note</b>: Iterators and references are not invalidated.
1226 //! This static function is available only if the <i>value traits</i>
1228 static const_iterator
s_iterator_to(const_reference value
)
1230 BOOST_STATIC_ASSERT((!stateful_value_traits
));
1231 BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(const_cast<reference
> (value
))));
1232 return const_iterator(real_value_traits::to_node_ptr(const_cast<reference
> (value
)), 0);
1235 //! <b>Requires</b>: value must be a reference to a value inserted in a list.
1237 //! <b>Effects</b>: This function returns a const_iterator pointing to the element
1239 //! <b>Throws</b>: Nothing.
1241 //! <b>Complexity</b>: Constant time.
1243 //! <b>Note</b>: Iterators and references are not invalidated.
1244 iterator
iterator_to(reference value
)
1246 BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(value
)));
1247 return iterator(real_value_traits::to_node_ptr(value
), this);
1250 //! <b>Requires</b>: value must be a const reference to a value inserted in a list.
1252 //! <b>Effects</b>: This function returns an iterator pointing to the element.
1254 //! <b>Throws</b>: Nothing.
1256 //! <b>Complexity</b>: Constant time.
1258 //! <b>Note</b>: Iterators and references are not invalidated.
1259 const_iterator
iterator_to(const_reference value
) const
1261 BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(const_cast<reference
> (value
))));
1262 return const_iterator(real_value_traits::to_node_ptr(const_cast<reference
> (value
)), this);
1268 static list_impl
&priv_container_from_end_iterator(const const_iterator
&end_iterator
)
1270 root_plus_size
*r
= detail::parent_from_member
<root_plus_size
, node
>
1271 ( detail::get_pointer(end_iterator
.pointed_node()), &root_plus_size::root_
);
1272 data_t
*d
= detail::parent_from_member
<data_t
, root_plus_size
>
1273 ( r
, &data_t::root_plus_size_
);
1274 list_impl
*s
= detail::parent_from_member
<list_impl
, data_t
>(d
, &list_impl::data_
);
1280 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1281 template<class T
, class ...Options
>
1283 template<class Config
>
1285 inline bool operator<
1286 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1287 (const list_impl
<T
, Options
...> &x
, const list_impl
<T
, Options
...> &y
)
1289 (const list_impl
<Config
> &x
, const list_impl
<Config
> &y
)
1291 { return std::lexicographical_compare(x
.begin(), x
.end(), y
.begin(), y
.end()); }
1293 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1294 template<class T
, class ...Options
>
1296 template<class Config
>
1299 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1300 (const list_impl
<T
, Options
...> &x
, const list_impl
<T
, Options
...> &y
)
1302 (const list_impl
<Config
> &x
, const list_impl
<Config
> &y
)
1305 typedef list_impl
<Config
> list_type
;
1306 typedef typename
list_type::const_iterator const_iterator
;
1307 const bool C
= list_type::constant_time_size
;
1308 if(C
&& x
.size() != y
.size()){
1311 const_iterator end1
= x
.end();
1313 const_iterator i1
= x
.begin();
1314 const_iterator i2
= y
.begin();
1316 while (i1
!= end1
&& *i1
== *i2
) {
1323 const_iterator end2
= y
.end();
1324 while (i1
!= end1
&& i2
!= end2
&& *i1
== *i2
) {
1328 return i1
== end1
&& i2
== end2
;
1332 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1333 template<class T
, class ...Options
>
1335 template<class Config
>
1337 inline bool operator!=
1338 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1339 (const list_impl
<T
, Options
...> &x
, const list_impl
<T
, Options
...> &y
)
1341 (const list_impl
<Config
> &x
, const list_impl
<Config
> &y
)
1343 { return !(x
== y
); }
1345 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1346 template<class T
, class ...Options
>
1348 template<class Config
>
1350 inline bool operator>
1351 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1352 (const list_impl
<T
, Options
...> &x
, const list_impl
<T
, Options
...> &y
)
1354 (const list_impl
<Config
> &x
, const list_impl
<Config
> &y
)
1358 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1359 template<class T
, class ...Options
>
1361 template<class Config
>
1363 inline bool operator<=
1364 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1365 (const list_impl
<T
, Options
...> &x
, const list_impl
<T
, Options
...> &y
)
1367 (const list_impl
<Config
> &x
, const list_impl
<Config
> &y
)
1369 { return !(y
< x
); }
1371 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1372 template<class T
, class ...Options
>
1374 template<class Config
>
1376 inline bool operator>=
1377 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1378 (const list_impl
<T
, Options
...> &x
, const list_impl
<T
, Options
...> &y
)
1380 (const list_impl
<Config
> &x
, const list_impl
<Config
> &y
)
1382 { return !(x
< y
); }
1384 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1385 template<class T
, class ...Options
>
1387 template<class Config
>
1390 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1391 (list_impl
<T
, Options
...> &x
, list_impl
<T
, Options
...> &y
)
1393 (list_impl
<Config
> &x
, list_impl
<Config
> &y
)
1397 //! Helper metafunction to define a \c list that yields to the same type when the
1398 //! same options (either explicitly or implicitly) are used.
1399 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1400 template<class T
, class ...Options
>
1402 template<class T
, class O1
= none
, class O2
= none
, class O3
= none
>
1407 typedef typename pack_options
1409 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1414 >::type packed_options
;
1416 typedef typename
detail::get_value_traits
1417 <T
, typename
packed_options::value_traits
>::type value_traits
;
1423 , typename
packed_options::size_type
1424 , packed_options::constant_time_size
1426 > implementation_defined
;
1428 typedef implementation_defined type
;
1432 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
1434 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1435 template<class T
, class O1
, class O2
, class O3
>
1437 template<class T
, class ...Options
>
1440 : public make_list
<T
,
1441 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1448 typedef typename make_list
1450 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1456 typedef typename
Base::real_value_traits real_value_traits
;
1457 //Assert if passed value traits are compatible with the type
1458 BOOST_STATIC_ASSERT((detail::is_same
<typename
real_value_traits::value_type
, T
>::value
));
1460 typedef typename
Base::value_traits value_traits
;
1461 typedef typename
Base::iterator iterator
;
1462 typedef typename
Base::const_iterator const_iterator
;
1464 list(const value_traits
&v_traits
= value_traits())
1468 template<class Iterator
>
1469 list(Iterator b
, Iterator e
, const value_traits
&v_traits
= value_traits())
1470 : Base(b
, e
, v_traits
)
1473 static list
&container_from_end_iterator(iterator end_iterator
)
1474 { return static_cast<list
&>(Base::container_from_end_iterator(end_iterator
)); }
1476 static const list
&container_from_end_iterator(const_iterator end_iterator
)
1477 { return static_cast<const list
&>(Base::container_from_end_iterator(end_iterator
)); }
1482 } //namespace intrusive
1485 #include <boost/intrusive/detail/config_end.hpp>
1487 #endif //BOOST_INTRUSIVE_LIST_HPP