Skip to content

Commit

Permalink
Remove use of std::allocator::rebind (google#174)
Browse files Browse the repository at this point in the history
This is deprecated in C++17 and has been removed in C++20.

Use std::allocator_traits::rebind_alloc instead.

https://en.cppreference.com/w/cpp/memory/allocator
https://en.cppreference.com/w/cpp/memory/allocator_traits

Fixes google#173.
  • Loading branch information
jmr authored Mar 12, 2021
1 parent a4dddf4 commit d72715f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/s2/util/gtl/compact_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ class compact_array_base {
return const_cast<compact_array_base<T, A>*>(this)->Array();
}

typedef typename A::template rebind<T>::other value_allocator_type;
using value_allocator_type =
typename std::allocator_traits<A>::template rebind_alloc<T>;

public:
typedef T value_type;
Expand Down
9 changes: 6 additions & 3 deletions src/s2/util/gtl/densehashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ struct dense_hashtable_const_iterator;
template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
struct dense_hashtable_iterator {
private:
typedef typename A::template rebind<V>::other value_alloc_type;
using value_alloc_type =
typename std::allocator_traits<A>::template rebind_alloc<V>;

public:
typedef dense_hashtable_iterator<V, K, HF, ExK, SetK, EqK, A>
Expand Down Expand Up @@ -245,7 +246,8 @@ struct dense_hashtable_iterator {
template <class V, class K, class HF, class ExK, class SetK, class EqK, class A>
struct dense_hashtable_const_iterator {
private:
typedef typename A::template rebind<V>::other value_alloc_type;
using value_alloc_type =
typename std::allocator_traits<A>::template rebind_alloc<V>;

public:
typedef dense_hashtable_iterator<V, K, HF, ExK, SetK, EqK, A>
Expand Down Expand Up @@ -311,7 +313,8 @@ template <class Value, class Key, class HashFcn,
class ExtractKey, class SetKey, class EqualKey, class Alloc>
class dense_hashtable {
private:
typedef typename Alloc::template rebind<Value>::other value_alloc_type;
using value_alloc_type =
typename std::allocator_traits<Alloc>::template rebind_alloc<Value>;


public:
Expand Down

0 comments on commit d72715f

Please sign in to comment.