From ddf302fcc26d4dfb5176b45182fdc83f62859718 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 26 Jan 2018 18:59:11 +0000 Subject: [PATCH] Use `boost::to_pointer` instead of `pointer<..>::get` To get C++20 style recursive calls to `operator->`. --- .../boost/unordered/detail/implementation.hpp | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 44bff527..f041f7fd 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -553,21 +554,6 @@ namespace boost { { template convert_from_anything(T const&); }; - - // Get a pointer from a smart pointer, a bit simpler than pointer_traits - // as we already know the pointer type that we want. - template struct pointer - { - template static T* get(Ptr const& x) - { - return static_cast(x.operator->()); - } - - template static T* get(T2* x) - { - return static_cast(x); - } - }; } } } @@ -1814,7 +1800,7 @@ namespace boost { BOOST_FWD_REF(A0), BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2) { boost::unordered::detail::func::construct_from_tuple( - alloc, boost::addressof(address->first), boost::forward(a1)); + alloc, boost::addressof (address->first), boost::forward(a1)); BOOST_TRY { boost::unordered::detail::func::construct_from_tuple( @@ -2002,7 +1988,7 @@ namespace boost { template node_constructor::~node_constructor() { if (node_) { - boost::unordered::detail::func::destroy(pointer::get(node_)); + boost::unordered::detail::func::destroy(boost::to_pointer(node_)); node_allocator_traits::deallocate(alloc_, node_, 1); } } @@ -2011,7 +1997,7 @@ namespace boost { { BOOST_ASSERT(!node_); node_ = node_allocator_traits::allocate(alloc_, 1); - new (pointer::get(node_)) node(); + new ((void*) boost::to_pointer(node_)) node(); } template struct node_tmp @@ -2042,7 +2028,7 @@ namespace boost { if (node_) { BOOST_UNORDERED_CALL_DESTROY( node_allocator_traits, alloc_, node_->value_ptr()); - boost::unordered::detail::func::destroy(pointer::get(node_)); + boost::unordered::detail::func::destroy(boost::to_pointer(node_)); node_allocator_traits::deallocate(alloc_, node_, 1); } } @@ -2574,7 +2560,7 @@ namespace boost { BOOST_UNORDERED_CALL_DESTROY( node_allocator_traits, constructor_.alloc_, p->value_ptr()); - boost::unordered::detail::func::destroy(pointer::get(p)); + boost::unordered::detail::func::destroy(boost::to_pointer(p)); node_allocator_traits::deallocate(constructor_.alloc_, p, 1); } } @@ -3234,9 +3220,9 @@ namespace boost { bucket_pointer end = buckets_ + static_cast(new_count); for (bucket_pointer i = buckets_; i != end; ++i) { - new (pointer::get(i)) bucket(); + new ((void*) boost::to_pointer(i)) bucket(); } - new (pointer::get(end)) bucket(dummy_node); + new ((void*) boost::to_pointer(end)) bucket(dummy_node); } //////////////////////////////////////////////////////////////////////// @@ -3364,7 +3350,7 @@ namespace boost { { BOOST_UNORDERED_CALL_DESTROY( node_allocator_traits, node_alloc(), n->value_ptr()); - boost::unordered::detail::func::destroy(pointer::get(n)); + boost::unordered::detail::func::destroy(boost::to_pointer(n)); node_allocator_traits::deallocate(node_alloc(), n, 1); } @@ -3376,7 +3362,7 @@ namespace boost { if (bucket::extra_node) { node_pointer next = next_node(n); - boost::unordered::detail::func::destroy(pointer::get(n)); + boost::unordered::detail::func::destroy(boost::to_pointer(n)); node_allocator_traits::deallocate(node_alloc(), n, 1); n = next; } @@ -3398,7 +3384,7 @@ namespace boost { { bucket_pointer end = get_bucket_pointer(bucket_count_ + 1); for (bucket_pointer it = buckets_; it != end; ++it) { - boost::unordered::detail::func::destroy(pointer::get(it)); + boost::unordered::detail::func::destroy(boost::to_pointer(it)); } bucket_allocator_traits::deallocate(