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 <laanwj@protonmail.com>
This commit is contained in:
PastaPastaPasta 2021-10-23 12:26:55 -04:00 committed by GitHub
parent 1b99d2793e
commit cd29362eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 36 deletions

View File

@ -16,15 +16,13 @@
// //
template <typename T> template <typename T>
struct mt_pooled_secure_allocator : public std::allocator<T> { struct mt_pooled_secure_allocator : public std::allocator<T> {
// MSVC8 default copy constructor is broken using base = std::allocator<T>;
typedef std::allocator<T> base; using traits = std::allocator_traits<base>;
typedef typename base::size_type size_type; using size_type = typename traits::size_type;
typedef typename base::difference_type difference_type; using difference_type = typename traits::difference_type;
typedef typename base::pointer pointer; using pointer = typename traits::pointer;
typedef typename base::const_pointer const_pointer; using const_pointer = typename traits::const_pointer;
typedef typename base::reference reference; using value_type = typename traits::value_type;
typedef typename base::const_reference const_reference;
typedef typename base::value_type value_type;
mt_pooled_secure_allocator(size_type nrequested_size = 32, mt_pooled_secure_allocator(size_type nrequested_size = 32,
size_type nnext_size = 32, size_type nnext_size = 32,
size_type nmax_size = 0) noexcept size_type nmax_size = 0) noexcept

View File

@ -19,15 +19,13 @@
// //
template <typename T> template <typename T>
struct pooled_secure_allocator : public std::allocator<T> { struct pooled_secure_allocator : public std::allocator<T> {
// MSVC8 default copy constructor is broken using base = std::allocator<T>;
typedef std::allocator<T> base; using traits = std::allocator_traits<base>;
typedef typename base::size_type size_type; using size_type = typename traits::size_type;
typedef typename base::difference_type difference_type; using difference_type = typename traits::difference_type;
typedef typename base::pointer pointer; using pointer = typename traits::pointer;
typedef typename base::const_pointer const_pointer; using const_pointer = typename traits::const_pointer;
typedef typename base::reference reference; using value_type = typename traits::value_type;
typedef typename base::const_reference const_reference;
typedef typename base::value_type value_type;
pooled_secure_allocator(const size_type nrequested_size = 32, pooled_secure_allocator(const size_type nrequested_size = 32,
const size_type nnext_size = 32, const size_type nnext_size = 32,
const size_type nmax_size = 0) noexcept : const size_type nmax_size = 0) noexcept :

View File

@ -9,6 +9,7 @@
#include <support/lockedpool.h> #include <support/lockedpool.h>
#include <support/cleanse.h> #include <support/cleanse.h>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
@ -18,15 +19,13 @@
// //
template <typename T> template <typename T>
struct secure_allocator : public std::allocator<T> { struct secure_allocator : public std::allocator<T> {
// MSVC8 default copy constructor is broken using base = std::allocator<T>;
typedef std::allocator<T> base; using traits = std::allocator_traits<base>;
typedef typename base::size_type size_type; using size_type = typename traits::size_type;
typedef typename base::difference_type difference_type; using difference_type = typename traits::difference_type;
typedef typename base::pointer pointer; using pointer = typename traits::pointer;
typedef typename base::const_pointer const_pointer; using const_pointer = typename traits::const_pointer;
typedef typename base::reference reference; using value_type = typename traits::value_type;
typedef typename base::const_reference const_reference;
typedef typename base::value_type value_type;
secure_allocator() noexcept {} secure_allocator() noexcept {}
secure_allocator(const secure_allocator& a) noexcept : base(a) {} secure_allocator(const secure_allocator& a) noexcept : base(a) {}
template <typename U> template <typename U>

View File

@ -13,15 +13,13 @@
template <typename T> template <typename T>
struct zero_after_free_allocator : public std::allocator<T> { struct zero_after_free_allocator : public std::allocator<T> {
// MSVC8 default copy constructor is broken using base = std::allocator<T>;
typedef std::allocator<T> base; using traits = std::allocator_traits<base>;
typedef typename base::size_type size_type; using size_type = typename traits::size_type;
typedef typename base::difference_type difference_type; using difference_type = typename traits::difference_type;
typedef typename base::pointer pointer; using pointer = typename traits::pointer;
typedef typename base::const_pointer const_pointer; using const_pointer = typename traits::const_pointer;
typedef typename base::reference reference; using value_type = typename traits::value_type;
typedef typename base::const_reference const_reference;
typedef typename base::value_type value_type;
zero_after_free_allocator() noexcept {} zero_after_free_allocator() noexcept {}
zero_after_free_allocator(const zero_after_free_allocator& a) noexcept : base(a) {} zero_after_free_allocator(const zero_after_free_allocator& a) noexcept : base(a) {}
template <typename U> template <typename U>