From cd29362eea7e8f53e782f2f951c747ec4739b2b9 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Sat, 23 Oct 2021 12:26:55 -0400 Subject: [PATCH] Merge bitcoin#23181: refactor: remove references to deprecated values under std::allocator (#4534) * Merge bitcoin/bitcoin#23181: refactor: remove references to deprecated values under std::allocator ea4b61a1570178ebe5851b5fb4065222e3926f7e refactor: remove references to deprecated values under std::allocator (Pasta) Pull request description: Removes usages of allocator::pointer, allocator::const_pointer, allocator::reference and allocator::const_reference which are deprecated in c++17 and **removed** in c++20. See https://en.cppreference.com/w/cpp/memory/allocator Also prefers `using` over `typedef` see: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using I'll be happy to revert this if requested so ACKs for top commit: laanwj: Re-ACK ea4b61a1570178ebe5851b5fb4065222e3926f7e Tree-SHA512: 9353e47a7de27bcd91b341eb2d832318b51fce9f508fcc791f05c02c5a160f430f4e7214e76f4b3e29639750d311c679789d8b7409255b13637391e4575c9ebe * extend 23181 Co-authored-by: W. J. van der Laan --- src/support/allocators/mt_pooled_secure.h | 16 +++++++--------- src/support/allocators/pooled_secure.h | 16 +++++++--------- src/support/allocators/secure.h | 17 ++++++++--------- src/support/allocators/zeroafterfree.h | 16 +++++++--------- 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/support/allocators/mt_pooled_secure.h b/src/support/allocators/mt_pooled_secure.h index 38bd003e2c..a659a4812c 100644 --- a/src/support/allocators/mt_pooled_secure.h +++ b/src/support/allocators/mt_pooled_secure.h @@ -16,15 +16,13 @@ // template struct mt_pooled_secure_allocator : public std::allocator { - // MSVC8 default copy constructor is broken - typedef std::allocator base; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::value_type value_type; + using base = std::allocator; + using traits = std::allocator_traits; + using size_type = typename traits::size_type; + using difference_type = typename traits::difference_type; + using pointer = typename traits::pointer; + using const_pointer = typename traits::const_pointer; + using value_type = typename traits::value_type; mt_pooled_secure_allocator(size_type nrequested_size = 32, size_type nnext_size = 32, size_type nmax_size = 0) noexcept diff --git a/src/support/allocators/pooled_secure.h b/src/support/allocators/pooled_secure.h index 32414a77f7..8eba0be8f8 100644 --- a/src/support/allocators/pooled_secure.h +++ b/src/support/allocators/pooled_secure.h @@ -19,15 +19,13 @@ // template struct pooled_secure_allocator : public std::allocator { - // MSVC8 default copy constructor is broken - typedef std::allocator base; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::value_type value_type; + using base = std::allocator; + using traits = std::allocator_traits; + using size_type = typename traits::size_type; + using difference_type = typename traits::difference_type; + using pointer = typename traits::pointer; + using const_pointer = typename traits::const_pointer; + using value_type = typename traits::value_type; pooled_secure_allocator(const size_type nrequested_size = 32, const size_type nnext_size = 32, const size_type nmax_size = 0) noexcept : diff --git a/src/support/allocators/secure.h b/src/support/allocators/secure.h index b9d376fec6..64739d27dd 100644 --- a/src/support/allocators/secure.h +++ b/src/support/allocators/secure.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -18,15 +19,13 @@ // template struct secure_allocator : public std::allocator { - // MSVC8 default copy constructor is broken - typedef std::allocator base; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::value_type value_type; + using base = std::allocator; + using traits = std::allocator_traits; + using size_type = typename traits::size_type; + using difference_type = typename traits::difference_type; + using pointer = typename traits::pointer; + using const_pointer = typename traits::const_pointer; + using value_type = typename traits::value_type; secure_allocator() noexcept {} secure_allocator(const secure_allocator& a) noexcept : base(a) {} template diff --git a/src/support/allocators/zeroafterfree.h b/src/support/allocators/zeroafterfree.h index 23ef96c13f..6bcf192b5f 100644 --- a/src/support/allocators/zeroafterfree.h +++ b/src/support/allocators/zeroafterfree.h @@ -13,15 +13,13 @@ template struct zero_after_free_allocator : public std::allocator { - // MSVC8 default copy constructor is broken - typedef std::allocator base; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::value_type value_type; + using base = std::allocator; + using traits = std::allocator_traits; + using size_type = typename traits::size_type; + using difference_type = typename traits::difference_type; + using pointer = typename traits::pointer; + using const_pointer = typename traits::const_pointer; + using value_type = typename traits::value_type; zero_after_free_allocator() noexcept {} zero_after_free_allocator(const zero_after_free_allocator& a) noexcept : base(a) {} template