diff options
author | Pasta <pasta@dashboost.org> | 2021-10-04 22:49:21 -0400 |
---|---|---|
committer | pasta <pasta@dashboost.org> | 2021-10-20 18:36:40 -0400 |
commit | ea4b61a1570178ebe5851b5fb4065222e3926f7e (patch) | |
tree | faecd02c58a61d944c68a98339f12db0f3b07e67 /src/support | |
parent | 991753e4d50ea5c973f4d3330e5afba797b1b1e7 (diff) |
refactor: remove references to deprecated values under std::allocator
Includes 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 prefer `using` over `typedef` see: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/allocators/secure.h | 17 | ||||
-rw-r--r-- | src/support/allocators/zeroafterfree.h | 16 |
2 files changed, 15 insertions, 18 deletions
diff --git a/src/support/allocators/secure.h b/src/support/allocators/secure.h index 0e31ad3ce3..c4923dc56f 100644 --- a/src/support/allocators/secure.h +++ b/src/support/allocators/secure.h @@ -9,6 +9,7 @@ #include <support/lockedpool.h> #include <support/cleanse.h> +#include <memory> #include <string> // @@ -17,15 +18,13 @@ // template <typename T> struct secure_allocator : public std::allocator<T> { - // MSVC8 default copy constructor is broken - typedef std::allocator<T> 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<T>; + using traits = std::allocator_traits<base>; + 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 <typename U> diff --git a/src/support/allocators/zeroafterfree.h b/src/support/allocators/zeroafterfree.h index 418f0ee656..77de4b1e69 100644 --- a/src/support/allocators/zeroafterfree.h +++ b/src/support/allocators/zeroafterfree.h @@ -13,15 +13,13 @@ template <typename T> struct zero_after_free_allocator : public std::allocator<T> { - // MSVC8 default copy constructor is broken - typedef std::allocator<T> 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<T>; + using traits = std::allocator_traits<base>; + 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 <typename U> |