From 10618b3c81c1b3db5144b7452d0455c48e203df5 Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Sat, 22 Sep 2018 22:37:34 +0200 Subject: [PATCH 1/2] [CMake] Add minimal cmake support - CMake file only supports add_subdirectory workflow. - Provides Boost::intrusive target, but no installation and no unit tests.. --- CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3ab541f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2019 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt +# +# NOTE: CMake support for Boost.Intrusive is currently experimental at best +# and the interface is likely to change in the future + +cmake_minimum_required( VERSION 3.5 ) + +project( Boost.Intrusive LANGUAGES CXX ) + +add_library (boost_intrusive INTERFACE ) +add_library( Boost::intrusive ALIAS boost_intrusive ) + +target_include_directories( boost_intrusive INTERFACE include ) + +target_link_libraries( boost_intrusive + INTERFACE + Boost::assert + Boost::config + Boost::container_hash + Boost::core + Boost::move + Boost::static_assert +) From 215ef2617ed67ed89ef8e6a16e3372a7573d4789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 5 Mar 2019 11:26:29 +0100 Subject: [PATCH 2/2] Fix #34 ("-Wdeprecated-copy on gcc9) --- doc/intrusive.qbk | 1 + .../boost/intrusive/detail/hashtable_node.hpp | 20 ++++++++--- .../boost/intrusive/detail/list_iterator.hpp | 18 ++++++++-- .../boost/intrusive/detail/slist_iterator.hpp | 14 +++++++- .../boost/intrusive/detail/tree_iterator.hpp | 34 +++++++++++++------ 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/doc/intrusive.qbk b/doc/intrusive.qbk index b23eb6a..abde8f9 100644 --- a/doc/intrusive.qbk +++ b/doc/intrusive.qbk @@ -3885,6 +3885,7 @@ to be inserted in intrusive containers are allocated using `std::vector` or `std * Fixed bugs: * [@https://github.com/boostorg/intrusive/pull/33 GitHub Pull #33: ['Fix compilation in case if key is void*, again]] + * [@https://github.com/boostorg/intrusive/issues/34 GitHub Issue #34: ['-Wdeprecated-copy on gcc9]] * [@https://github.com/boostorg/intrusive/issues/35 GitHub Issue #35: ['key_of_value on treap_set seems to be broken in 1.69]] * [@https://github.com/boostorg/intrusive/issues/38 GitHub Issue #38: ['treap: Same type for priority and key comparison leads to ambiguous base class error]] * [@https://github.com/boostorg/intrusive/pull/39 GitHub Pull #39: ['Fix -Wextra-semi clang warnings]] diff --git a/include/boost/intrusive/detail/hashtable_node.hpp b/include/boost/intrusive/detail/hashtable_node.hpp index 45e17f3..913c38d 100644 --- a/include/boost/intrusive/detail/hashtable_node.hpp +++ b/include/boost/intrusive/detail/hashtable_node.hpp @@ -171,12 +171,17 @@ class hashtable_iterator ::type >::type slist_impl; typedef typename slist_impl::iterator siterator; typedef typename slist_impl::const_iterator const_siterator; - typedef bucket_impl bucket_type; + typedef bucket_impl bucket_type; typedef typename pointer_traits ::template rebind_pointer < const BucketValueTraits >::type const_bucketvaltraits_ptr; typedef typename slist_impl::size_type size_type; + class nat; + typedef typename + detail::if_c< IsConst + , hashtable_iterator + , nat>::type nonconst_iterator; BOOST_INTRUSIVE_FORCEINLINE static node_ptr downcast_bucket(typename bucket_type::node_ptr p) { @@ -190,12 +195,16 @@ class hashtable_iterator : slist_it_() //Value initialization to achieve "null iterators" (N3644) {} - explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) + BOOST_INTRUSIVE_FORCEINLINE explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) : slist_it_ (ptr) , traitsptr_ (cont ? pointer_traits::pointer_to(*cont) : const_bucketvaltraits_ptr() ) {} - BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const hashtable_iterator &other) + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const hashtable_iterator &other) + : slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const nonconst_iterator &other) : slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits()) {} @@ -208,7 +217,10 @@ class hashtable_iterator BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator& operator++() { this->increment(); return *this; } - hashtable_iterator operator++(int) + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator &operator=(const hashtable_iterator &other) + { slist_it_ = other.slist_it(); traitsptr_ = other.get_bucket_value_traits(); return *this; } + + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator operator++(int) { hashtable_iterator result (*this); this->increment(); diff --git a/include/boost/intrusive/detail/list_iterator.hpp b/include/boost/intrusive/detail/list_iterator.hpp index 3aae2d5..880b6a9 100644 --- a/include/boost/intrusive/detail/list_iterator.hpp +++ b/include/boost/intrusive/detail/list_iterator.hpp @@ -47,6 +47,11 @@ class list_iterator typedef typename types_t::node node; typedef typename types_t::node_ptr node_ptr; typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; + class nat; + typedef typename + detail::if_c< IsConst + , list_iterator + , nat>::type nonconst_iterator; public: typedef typename types_t::iterator_type::difference_type difference_type; @@ -62,15 +67,22 @@ class list_iterator : members_(nodeptr, traits_ptr) {} - BOOST_INTRUSIVE_FORCEINLINE list_iterator(list_iterator const& other) + BOOST_INTRUSIVE_FORCEINLINE list_iterator(const list_iterator &other) : members_(other.pointed_node(), other.get_value_traits()) {} + BOOST_INTRUSIVE_FORCEINLINE list_iterator(const nonconst_iterator &other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(const list_iterator &other) + { members_.nodeptr_ = other.members_.nodeptr_; return *this; } + BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const { return members_.nodeptr_; } BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(const node_ptr &node) - { members_.nodeptr_ = node; return static_cast(*this); } + { members_.nodeptr_ = node; return *this; } BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr get_value_traits() const { return members_.get_ptr(); } @@ -115,7 +127,7 @@ class list_iterator BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const { return this->operator_arrow(detail::bool_()); } - list_iterator unconst() const + BOOST_INTRUSIVE_FORCEINLINE list_iterator unconst() const { return list_iterator(this->pointed_node(), this->get_value_traits()); } private: diff --git a/include/boost/intrusive/detail/slist_iterator.hpp b/include/boost/intrusive/detail/slist_iterator.hpp index 96a5ac0..9e72af9 100644 --- a/include/boost/intrusive/detail/slist_iterator.hpp +++ b/include/boost/intrusive/detail/slist_iterator.hpp @@ -49,6 +49,11 @@ class slist_iterator typedef typename types_t::node node; typedef typename types_t::node_ptr node_ptr; typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; + class nat; + typedef typename + detail::if_c< IsConst + , slist_iterator + , nat>::type nonconst_iterator; public: typedef typename types_t::iterator_type::difference_type difference_type; @@ -64,10 +69,17 @@ class slist_iterator : members_(nodeptr, traits_ptr) {} - BOOST_INTRUSIVE_FORCEINLINE slist_iterator(slist_iterator const& other) + BOOST_INTRUSIVE_FORCEINLINE slist_iterator(const slist_iterator &other) : members_(other.pointed_node(), other.get_value_traits()) {} + BOOST_INTRUSIVE_FORCEINLINE slist_iterator(const nonconst_iterator &other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE slist_iterator &operator=(const slist_iterator &other) + { members_.nodeptr_ = other.members_.nodeptr_; return *this; } + BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const { return members_.nodeptr_; } diff --git a/include/boost/intrusive/detail/tree_iterator.hpp b/include/boost/intrusive/detail/tree_iterator.hpp index a4bbc1b..41988cf 100644 --- a/include/boost/intrusive/detail/tree_iterator.hpp +++ b/include/boost/intrusive/detail/tree_iterator.hpp @@ -55,6 +55,11 @@ class tree_iterator void unspecified_bool_type_func() const {} typedef void (tree_iterator::*unspecified_bool_type)() const; + class nat; + typedef typename + detail::if_c< IsConst + , tree_iterator + , nat>::type nonconst_iterator; public: typedef typename types_t::iterator_type::difference_type difference_type; @@ -70,21 +75,28 @@ class tree_iterator : members_(nodeptr, traits_ptr) {} - BOOST_INTRUSIVE_FORCEINLINE tree_iterator(tree_iterator const& other) + BOOST_INTRUSIVE_FORCEINLINE tree_iterator(const tree_iterator &other) : members_(other.pointed_node(), other.get_value_traits()) {} + BOOST_INTRUSIVE_FORCEINLINE tree_iterator(const nonconst_iterator &other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE tree_iterator &operator=(const tree_iterator &other) + { members_.nodeptr_ = other.members_.nodeptr_; return *this; } + + BOOST_INTRUSIVE_FORCEINLINE tree_iterator &operator=(const node_ptr &nodeptr) + { members_.nodeptr_ = nodeptr; return *this; } + BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const { return members_.nodeptr_; } - BOOST_INTRUSIVE_FORCEINLINE tree_iterator &operator=(const node_ptr &nodeptr) - { members_.nodeptr_ = nodeptr; return static_cast(*this); } - public: - tree_iterator& operator++() + BOOST_INTRUSIVE_FORCEINLINE tree_iterator& operator++() { members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_); - return static_cast (*this); + return *this; } tree_iterator operator++(int) @@ -94,10 +106,10 @@ class tree_iterator return result; } - tree_iterator& operator--() + BOOST_INTRUSIVE_FORCEINLINE tree_iterator& operator--() { members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_); - return static_cast (*this); + return *this; } tree_iterator operator--(int) @@ -110,19 +122,19 @@ class tree_iterator BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_left() { members_.nodeptr_ = node_traits::get_left(members_.nodeptr_); - return static_cast (*this); + return *this; } BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_right() { members_.nodeptr_ = node_traits::get_right(members_.nodeptr_); - return static_cast (*this); + return *this; } BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_parent() { members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_); - return static_cast (*this); + return *this; } BOOST_INTRUSIVE_FORCEINLINE operator unspecified_bool_type() const