diff --git a/include/boost/intrusive/slist.hpp b/include/boost/intrusive/slist.hpp index 8ef2e23..ac64e41 100644 --- a/include/boost/intrusive/slist.hpp +++ b/include/boost/intrusive/slist.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -171,49 +172,47 @@ class slist_impl //A list with cached last node is incompatible with auto-unlink hooks! BOOST_STATIC_ASSERT(!(cache_last && ((int)value_traits::link_mode == (int)auto_unlink))); - node_ptr get_end_node() - { return node_ptr(linear ? node_ptr() : this->get_root_node()); } + BOOST_INTRUSIVE_FORCEINLINE node_ptr get_end_node() + { return node_algorithms::end_node(this->get_root_node()); } - const_node_ptr get_end_node() const - { - return const_node_ptr - (linear ? const_node_ptr() : this->get_root_node()); } + BOOST_INTRUSIVE_FORCEINLINE const_node_ptr get_end_node() const + { return node_algorithms::end_node(this->get_root_node()); } - node_ptr get_root_node() + BOOST_INTRUSIVE_FORCEINLINE node_ptr get_root_node() { return data_.root_plus_size_.header_holder_.get_node(); } - const_node_ptr get_root_node() const + BOOST_INTRUSIVE_FORCEINLINE const_node_ptr get_root_node() const { return data_.root_plus_size_.header_holder_.get_node(); } - node_ptr get_last_node() + BOOST_INTRUSIVE_FORCEINLINE node_ptr get_last_node() { return this->get_last_node(detail::bool_()); } - const_node_ptr get_last_node() const + BOOST_INTRUSIVE_FORCEINLINE const_node_ptr get_last_node() const { return this->get_last_node(detail::bool_()); } - void set_last_node(node_ptr n) + BOOST_INTRUSIVE_FORCEINLINE void set_last_node(node_ptr n) { return this->set_last_node(n, detail::bool_()); } - static node_ptr get_last_node(detail::bool_) + BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_last_node(detail::bool_) { //This function shall not be used if cache_last is not true BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last); return node_ptr(); } - static void set_last_node(node_ptr , detail::bool_) + BOOST_INTRUSIVE_FORCEINLINE static void set_last_node(node_ptr , detail::bool_) { //This function shall not be used if cache_last is not true BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last); } - node_ptr get_last_node(detail::bool_) + BOOST_INTRUSIVE_FORCEINLINE node_ptr get_last_node(detail::bool_) { return node_ptr(data_.root_plus_size_.last_); } - const_node_ptr get_last_node(detail::bool_) const + BOOST_INTRUSIVE_FORCEINLINE const_node_ptr get_last_node(detail::bool_) const { return const_node_ptr(data_.root_plus_size_.last_); } - void set_last_node(node_ptr n, detail::bool_) + BOOST_INTRUSIVE_FORCEINLINE void set_last_node(node_ptr n, detail::bool_) { data_.root_plus_size_.last_ = n; } void set_default_constructed_state() @@ -242,22 +241,22 @@ class slist_impl root_plus_size root_plus_size_; } data_; - size_traits &priv_size_traits() + BOOST_INTRUSIVE_FORCEINLINE size_traits &priv_size_traits() { return data_.root_plus_size_; } - const size_traits &priv_size_traits() const + BOOST_INTRUSIVE_FORCEINLINE const size_traits &priv_size_traits() const { return data_.root_plus_size_; } - const value_traits &priv_value_traits() const + BOOST_INTRUSIVE_FORCEINLINE const value_traits &priv_value_traits() const { return data_; } - value_traits &priv_value_traits() + BOOST_INTRUSIVE_FORCEINLINE value_traits &priv_value_traits() { return data_; } typedef typename boost::intrusive::value_traits_pointers ::const_value_traits_ptr const_value_traits_ptr; - const_value_traits_ptr priv_value_traits_ptr() const + BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr priv_value_traits_ptr() const { return pointer_traits::pointer_to(this->priv_value_traits()); } /// @endcond @@ -407,14 +406,10 @@ class slist_impl template void clear_and_dispose(Disposer disposer) BOOST_NOEXCEPT { - const_iterator it(this->begin()), itend(this->end()); - while(it != itend){ - node_ptr to_erase(it.pointed_node()); - ++it; - BOOST_IF_CONSTEXPR(safemode_or_autounlink) - node_algorithms::init(to_erase); - disposer(priv_value_traits().to_value_ptr(to_erase)); - } + node_algorithms::detach_and_dispose + ( this->get_root_node() + , detail::node_disposer + (disposer, &this->priv_value_traits()) ); this->set_default_constructed_state(); } @@ -704,7 +699,7 @@ class slist_impl //! //! Note: Does not affect the validity of iterators and references. BOOST_INTRUSIVE_FORCEINLINE bool empty() const BOOST_NOEXCEPT - { return node_algorithms::unique(this->get_root_node()); } + { return node_algorithms::is_empty(this->get_root_node()); } //! Effects: Swaps the elements of x and *this. //! @@ -1946,7 +1941,7 @@ class slist_impl while (true) { const_node_ptr next_p = node_traits::get_next(p); - if (!linear) + BOOST_IF_CONSTEXPR(!linear) { BOOST_INTRUSIVE_INVARIANT_ASSERT(next_p); }