From b85b40e851a78095526a01624b812cca803cc4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 11 Aug 2013 21:33:51 +0000 Subject: [PATCH] Marked some constructor as explicit and fixed trivial documentation issues [SVN r85307] --- doc/intrusive.qbk | 6 ++--- include/boost/intrusive/avl_set.hpp | 8 +++---- include/boost/intrusive/avltree.hpp | 5 ++--- include/boost/intrusive/bs_set.hpp | 10 ++++----- include/boost/intrusive/bstree.hpp | 10 +++++---- .../detail/clear_on_destructor_base.hpp | 6 ++++- include/boost/intrusive/hashtable.hpp | 11 +++++++--- include/boost/intrusive/list.hpp | 13 +++++++---- include/boost/intrusive/rbtree.hpp | 5 ++--- include/boost/intrusive/set.hpp | 4 ++-- include/boost/intrusive/sg_set.hpp | 4 ++-- include/boost/intrusive/sgtree.hpp | 5 ++--- include/boost/intrusive/slist.hpp | 11 +++++++--- include/boost/intrusive/splay_set.hpp | 8 +++---- include/boost/intrusive/splaytree.hpp | 7 +++--- include/boost/intrusive/treap.hpp | 7 +++--- include/boost/intrusive/treap_set.hpp | 12 +++++----- include/boost/intrusive/unordered_set.hpp | 22 +++++++++---------- 18 files changed, 85 insertions(+), 69 deletions(-) diff --git a/doc/intrusive.qbk b/doc/intrusive.qbk index 6910de1..c84700c 100644 --- a/doc/intrusive.qbk +++ b/doc/intrusive.qbk @@ -3368,10 +3368,10 @@ To analyze the thread safety, consider the following points: [section:scary_iterators Scary Iterators] The paper N2913, titled [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2913.pdf, -SCARY Iterator Assignment and Initialization], proposed a requirement that a standard container’s -iterator types have no dependency on any type argument apart from the container’s `value_type`, +SCARY Iterator Assignment and Initialization], proposed a requirement that a standard container's +iterator types have no dependency on any type argument apart from the container's `value_type`, `difference_type`, `pointer type`, and `const_pointer` type. In particular, according to the proposal, -the types of a standard container’s iterators should not depend on the container’s `key_compare`, +the types of a standard container's iterators should not depend on the container's `key_compare`, `hasher`, `key_equal`, or `allocator` types. That paper demonstrated that SCARY operations were crucial to the performant implementation of common diff --git a/include/boost/intrusive/avl_set.hpp b/include/boost/intrusive/avl_set.hpp index a4b8044..061a086 100644 --- a/include/boost/intrusive/avl_set.hpp +++ b/include/boost/intrusive/avl_set.hpp @@ -444,8 +444,8 @@ class avl_set //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - avl_set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit avl_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} @@ -882,8 +882,8 @@ class avl_multiset //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - avl_multiset( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit avl_multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/avltree.hpp b/include/boost/intrusive/avltree.hpp index a9362b9..f0cb9fe 100644 --- a/include/boost/intrusive/avltree.hpp +++ b/include/boost/intrusive/avltree.hpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -497,8 +496,8 @@ class avltree //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - avltree( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit avltree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/bs_set.hpp b/include/boost/intrusive/bs_set.hpp index 4b2cdc6..2062d49 100644 --- a/include/boost/intrusive/bs_set.hpp +++ b/include/boost/intrusive/bs_set.hpp @@ -442,8 +442,8 @@ class bs_set //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - bs_set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit bs_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} @@ -531,7 +531,7 @@ class bs_multiset_impl public: //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) explicit bs_multiset_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + , const value_traits &v_traits = value_traits()) : tree_type(cmp, v_traits) {} @@ -880,8 +880,8 @@ class bs_multiset //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - bs_multiset( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit bs_multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/bstree.hpp b/include/boost/intrusive/bstree.hpp index 2f57c62..32554fb 100644 --- a/include/boost/intrusive/bstree.hpp +++ b/include/boost/intrusive/bstree.hpp @@ -476,9 +476,12 @@ template - , private detail::clear_on_destructor_base > + , private detail::clear_on_destructor_base + < bstree_impl + , is_safe_autounlink::type::link_mode>::value + > { - template friend class detail::clear_on_destructor_base; + template friend class detail::clear_on_destructor_base; public: typedef ValueTraits value_traits; /// @cond @@ -592,6 +595,7 @@ class bstree_impl bstree_impl& operator=(BOOST_RV_REF(bstree_impl) x) { this->swap(x); return *this; } + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED //! Effects: Detaches all elements from this. The objects in the set //! are not deleted (i.e. no destructors are called), but the nodes according to //! the value_traits template parameter are reinitialized and thus can be reused. @@ -602,8 +606,6 @@ class bstree_impl ~bstree_impl() {} - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! Effects: Returns an iterator pointing to the beginning of the container. //! //! Complexity: Constant. diff --git a/include/boost/intrusive/detail/clear_on_destructor_base.hpp b/include/boost/intrusive/detail/clear_on_destructor_base.hpp index c81015d..164fe40 100644 --- a/include/boost/intrusive/detail/clear_on_destructor_base.hpp +++ b/include/boost/intrusive/detail/clear_on_destructor_base.hpp @@ -17,7 +17,7 @@ namespace boost { namespace intrusive { namespace detail { -template +template class clear_on_destructor_base { protected: @@ -27,6 +27,10 @@ class clear_on_destructor_base } }; +template +class clear_on_destructor_base +{}; + } // namespace detail { } // namespace intrusive { } // namespace boost { diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index bf1f18f..750ebab 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -1092,9 +1092,12 @@ class hashtable_impl < SizeType , BoolFlags & hashtable_data_bool_flags_mask , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits> - , private detail::clear_on_destructor_base > + , private detail::clear_on_destructor_base + < hashtable_impl + , is_safe_autounlink::type::link_mode>::value + > { - template friend class detail::clear_on_destructor_base; + template friend class detail::clear_on_destructor_base; public: typedef ValueTraits value_traits; @@ -1284,6 +1287,7 @@ class hashtable_impl hashtable_impl& operator=(BOOST_RV_REF(hashtable_impl) x) { this->swap(x); return *this; } + #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) //! Effects: Detaches all elements from this. The objects in the unordered_set //! are not deleted (i.e. no destructors are called). //! @@ -1293,6 +1297,7 @@ class hashtable_impl //! Throws: Nothing. ~hashtable_impl() {} + #endif //! Effects: Returns an iterator pointing to the beginning of the unordered_set. //! @@ -3114,7 +3119,7 @@ class hashtable //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - hashtable ( const bucket_traits &b_traits + explicit hashtable ( const bucket_traits &b_traits , const hasher & hash_func = hasher() , const key_equal &equal_func = key_equal() , const value_traits &v_traits = value_traits()) diff --git a/include/boost/intrusive/list.hpp b/include/boost/intrusive/list.hpp index e9d2ea2..01eae13 100644 --- a/include/boost/intrusive/list.hpp +++ b/include/boost/intrusive/list.hpp @@ -63,9 +63,12 @@ template template #endif class list_impl - : private detail::clear_on_destructor_base< list_impl > + : private detail::clear_on_destructor_base + < list_impl + , is_safe_autounlink::type::link_mode>::value + > { - template friend class detail::clear_on_destructor_base; + template friend class detail::clear_on_destructor_base; //Public typedefs public: typedef ValueTraits value_traits; @@ -123,7 +126,7 @@ class list_impl struct data_t : public value_traits { typedef typename list_impl::value_traits value_traits; - data_t(const value_traits &val_traits) + explicit data_t(const value_traits &val_traits) : value_traits(val_traits) {} @@ -224,6 +227,7 @@ class list_impl list_impl& operator=(BOOST_RV_REF(list_impl) x) { this->swap(x); return *this; } + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED //! Effects: If it's not a safe-mode or an auto-unlink value_type //! the destructor does nothing //! (ie. no code is generated). Otherwise it detaches all elements from this. @@ -235,6 +239,7 @@ class list_impl //! it's a safe-mode or auto-unlink value . Otherwise constant. ~list_impl() {} + #endif //! Requires: value must be an lvalue. //! @@ -1473,7 +1478,7 @@ class list typedef typename Base::iterator iterator; typedef typename Base::const_iterator const_iterator; - list(const value_traits &v_traits = value_traits()) + explicit list(const value_traits &v_traits = value_traits()) : Base(v_traits) {} diff --git a/include/boost/intrusive/rbtree.hpp b/include/boost/intrusive/rbtree.hpp index 04a067a..8acfe45 100644 --- a/include/boost/intrusive/rbtree.hpp +++ b/include/boost/intrusive/rbtree.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -493,8 +492,8 @@ class rbtree //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - rbtree( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit rbtree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/set.hpp b/include/boost/intrusive/set.hpp index 72742e5..c8c197c 100644 --- a/include/boost/intrusive/set.hpp +++ b/include/boost/intrusive/set.hpp @@ -443,8 +443,8 @@ class set //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/sg_set.hpp b/include/boost/intrusive/sg_set.hpp index f42fab8..7e5d072 100644 --- a/include/boost/intrusive/sg_set.hpp +++ b/include/boost/intrusive/sg_set.hpp @@ -455,8 +455,8 @@ class sg_set //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - sg_set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit sg_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/sgtree.hpp b/include/boost/intrusive/sgtree.hpp index aa92da5..0be42dc 100644 --- a/include/boost/intrusive/sgtree.hpp +++ b/include/boost/intrusive/sgtree.hpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -925,8 +924,8 @@ class sgtree //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - sgtree( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit sgtree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/slist.hpp b/include/boost/intrusive/slist.hpp index ac7301a..c471826 100644 --- a/include/boost/intrusive/slist.hpp +++ b/include/boost/intrusive/slist.hpp @@ -99,9 +99,12 @@ template template #endif class slist_impl - : private detail::clear_on_destructor_base > + : private detail::clear_on_destructor_base + < slist_impl + , is_safe_autounlink::type::link_mode>::value + > { - template friend class detail::clear_on_destructor_base; + template friend class detail::clear_on_destructor_base; //Public typedefs public: typedef ValueTraits value_traits; @@ -214,7 +217,7 @@ class slist_impl : public slist_impl::value_traits { typedef typename slist_impl::value_traits value_traits; - data_t(const value_traits &val_traits) + explicit data_t(const value_traits &val_traits) : value_traits(val_traits) {} @@ -349,6 +352,7 @@ class slist_impl slist_impl& operator=(BOOST_RV_REF(slist_impl) x) { this->swap(x); return *this; } + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED //! Effects: If it's a safe-mode //! or auto-unlink value, the destructor does nothing //! (ie. no code is generated). Otherwise it detaches all elements from this. @@ -360,6 +364,7 @@ class slist_impl //! it's a safe-mode or auto-unlink value. Otherwise constant. ~slist_impl() {} + #endif //! Effects: Erases all the elements of the container. //! diff --git a/include/boost/intrusive/splay_set.hpp b/include/boost/intrusive/splay_set.hpp index 67aa56b..0a80ce6 100644 --- a/include/boost/intrusive/splay_set.hpp +++ b/include/boost/intrusive/splay_set.hpp @@ -511,8 +511,8 @@ class splay_set //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - splay_set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit splay_set( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} @@ -1018,8 +1018,8 @@ class splay_multiset //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - splay_multiset( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit splay_multiset( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/splaytree.hpp b/include/boost/intrusive/splaytree.hpp index 6fa1d47..f02de06 100644 --- a/include/boost/intrusive/splaytree.hpp +++ b/include/boost/intrusive/splaytree.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -117,7 +116,7 @@ class splaytree_impl //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) explicit splaytree_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + , const value_traits &v_traits = value_traits()) : tree_type(cmp, v_traits) {} @@ -654,8 +653,8 @@ class splaytree //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - splaytree( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) + explicit splaytree( const value_compare &cmp = value_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, v_traits) {} diff --git a/include/boost/intrusive/treap.hpp b/include/boost/intrusive/treap.hpp index 2979fc9..38b02d5 100644 --- a/include/boost/intrusive/treap.hpp +++ b/include/boost/intrusive/treap.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -1130,9 +1129,9 @@ class treap //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - treap( const value_compare &cmp = value_compare() - , const priority_compare &pcmp = priority_compare() - , const value_traits &v_traits = value_traits()) + explicit treap( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, pcmp, v_traits) {} diff --git a/include/boost/intrusive/treap_set.hpp b/include/boost/intrusive/treap_set.hpp index 48e332f..739e56b 100644 --- a/include/boost/intrusive/treap_set.hpp +++ b/include/boost/intrusive/treap_set.hpp @@ -471,9 +471,9 @@ class treap_set //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - treap_set( const value_compare &cmp = value_compare() - , const priority_compare &pcmp = priority_compare() - , const value_traits &v_traits = value_traits()) + explicit treap_set( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, pcmp, v_traits) {} @@ -937,9 +937,9 @@ class treap_multiset //Assert if passed value traits are compatible with the type BOOST_STATIC_ASSERT((detail::is_same::value)); - treap_multiset( const value_compare &cmp = value_compare() - , const priority_compare &pcmp = priority_compare() - , const value_traits &v_traits = value_traits()) + explicit treap_multiset( const value_compare &cmp = value_compare() + , const priority_compare &pcmp = priority_compare() + , const value_traits &v_traits = value_traits()) : Base(cmp, pcmp, v_traits) {} diff --git a/include/boost/intrusive/unordered_set.hpp b/include/boost/intrusive/unordered_set.hpp index 4ba9d4e..5ba36fe 100644 --- a/include/boost/intrusive/unordered_set.hpp +++ b/include/boost/intrusive/unordered_set.hpp @@ -161,6 +161,7 @@ class unordered_set_impl unordered_set_impl& operator=(BOOST_RV_REF(unordered_set_impl) x) { return static_cast(table_type::operator=(::boost::move(static_cast(x)))); } + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED //! Effects: Detaches all elements from this. The objects in the unordered_set //! are not deleted (i.e. no destructors are called). //! @@ -171,7 +172,6 @@ class unordered_set_impl ~unordered_set_impl() {} - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED //! Effects: Returns an iterator pointing to the beginning of the unordered_set. //! //! Complexity: Constant time if `cache_begin<>` is true. Amortized @@ -1089,10 +1089,10 @@ class unordered_set typedef typename Base::hasher hasher; typedef typename Base::key_equal key_equal; - unordered_set ( const bucket_traits &b_traits - , const hasher & hash_func = hasher() - , const key_equal &equal_func = key_equal() - , const value_traits &v_traits = value_traits()) + explicit unordered_set ( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) : Base(b_traits, hash_func, equal_func, v_traits) {} @@ -1254,6 +1254,8 @@ class unordered_multiset_impl unordered_multiset_impl& operator=(BOOST_RV_REF(unordered_multiset_impl) x) { return static_cast(table_type::operator=(::boost::move(static_cast(x)))); } + #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED + //! Effects: Detaches all elements from this. The objects in the unordered_multiset //! are not deleted (i.e. no destructors are called). //! @@ -1264,8 +1266,6 @@ class unordered_multiset_impl ~unordered_multiset_impl() {} - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! Effects: Returns an iterator pointing to the beginning of the unordered_multiset. //! //! Complexity: Constant time if `cache_begin<>` is true. Amortized @@ -2125,10 +2125,10 @@ class unordered_multiset typedef typename Base::hasher hasher; typedef typename Base::key_equal key_equal; - unordered_multiset( const bucket_traits &b_traits - , const hasher & hash_func = hasher() - , const key_equal &equal_func = key_equal() - , const value_traits &v_traits = value_traits()) + explicit unordered_multiset( const bucket_traits &b_traits + , const hasher & hash_func = hasher() + , const key_equal &equal_func = key_equal() + , const value_traits &v_traits = value_traits()) : Base(b_traits, hash_func, equal_func, v_traits) {}