Skip to content

Commit ea4b61a

Browse files
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
1 parent 991753e commit ea4b61a

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/support/allocators/secure.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <support/lockedpool.h>
1010
#include <support/cleanse.h>
1111

12+
#include <memory>
1213
#include <string>
1314

1415
//
@@ -17,15 +18,13 @@
1718
//
1819
template <typename T>
1920
struct secure_allocator : public std::allocator<T> {
20-
// MSVC8 default copy constructor is broken
21-
typedef std::allocator<T> base;
22-
typedef typename base::size_type size_type;
23-
typedef typename base::difference_type difference_type;
24-
typedef typename base::pointer pointer;
25-
typedef typename base::const_pointer const_pointer;
26-
typedef typename base::reference reference;
27-
typedef typename base::const_reference const_reference;
28-
typedef typename base::value_type value_type;
21+
using base = std::allocator<T>;
22+
using traits = std::allocator_traits<base>;
23+
using size_type = typename traits::size_type;
24+
using difference_type = typename traits::difference_type;
25+
using pointer = typename traits::pointer;
26+
using const_pointer = typename traits::const_pointer;
27+
using value_type = typename traits::value_type;
2928
secure_allocator() noexcept {}
3029
secure_allocator(const secure_allocator& a) noexcept : base(a) {}
3130
template <typename U>

src/support/allocators/zeroafterfree.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313

1414
template <typename T>
1515
struct zero_after_free_allocator : public std::allocator<T> {
16-
// MSVC8 default copy constructor is broken
17-
typedef std::allocator<T> base;
18-
typedef typename base::size_type size_type;
19-
typedef typename base::difference_type difference_type;
20-
typedef typename base::pointer pointer;
21-
typedef typename base::const_pointer const_pointer;
22-
typedef typename base::reference reference;
23-
typedef typename base::const_reference const_reference;
24-
typedef typename base::value_type value_type;
16+
using base = std::allocator<T>;
17+
using traits = std::allocator_traits<base>;
18+
using size_type = typename traits::size_type;
19+
using difference_type = typename traits::difference_type;
20+
using pointer = typename traits::pointer;
21+
using const_pointer = typename traits::const_pointer;
22+
using value_type = typename traits::value_type;
2523
zero_after_free_allocator() noexcept {}
2624
zero_after_free_allocator(const zero_after_free_allocator& a) noexcept : base(a) {}
2725
template <typename U>

0 commit comments

Comments
 (0)