Skip to content

Commit f871b10

Browse files
committed
Update for c++20
Signed-off-by: Matt Liberty <[email protected]>
1 parent 62ac753 commit f871b10

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lemon/bits/array_map.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace lemon {
7575
typedef typename Notifier::ObserverBase Parent;
7676

7777
typedef std::allocator<Value> Allocator;
78+
typedef std::allocator_traits<Allocator> AllocatorTraits;
7879

7980
public:
8081

@@ -88,7 +89,7 @@ namespace lemon {
8889
Item it;
8990
for (nf->first(it); it != INVALID; nf->next(it)) {
9091
int id = nf->id(it);;
91-
allocator.construct(&(values[id]), Value());
92+
AllocatorTraits::construct(allocator, &(values[id]), Value());
9293
}
9394
}
9495

@@ -102,7 +103,7 @@ namespace lemon {
102103
Item it;
103104
for (nf->first(it); it != INVALID; nf->next(it)) {
104105
int id = nf->id(it);;
105-
allocator.construct(&(values[id]), value);
106+
AllocatorTraits::construct(allocator, &(values[id]), value);
106107
}
107108
}
108109

@@ -121,7 +122,7 @@ namespace lemon {
121122
Item it;
122123
for (nf->first(it); it != INVALID; nf->next(it)) {
123124
int id = nf->id(it);;
124-
allocator.construct(&(values[id]), copy.values[id]);
125+
AllocatorTraits::construct(allocator, &(values[id]), copy.values[id]);
125126
}
126127
}
127128

@@ -218,15 +219,15 @@ namespace lemon {
218219
for (nf->first(it); it != INVALID; nf->next(it)) {
219220
int jd = nf->id(it);;
220221
if (id != jd) {
221-
allocator.construct(&(new_values[jd]), values[jd]);
222-
allocator.destroy(&(values[jd]));
222+
AllocatorTraits::construct(allocator, &(new_values[jd]), values[jd]);
223+
AllocatorTraits::destroy(allocator, &(values[jd]));
223224
}
224225
}
225226
if (capacity != 0) allocator.deallocate(values, capacity);
226227
values = new_values;
227228
capacity = new_capacity;
228229
}
229-
allocator.construct(&(values[id]), Value());
230+
AllocatorTraits::construct(allocator, &(values[id]), Value());
230231
}
231232

232233
// \brief Adds more new keys to the map.
@@ -260,16 +261,16 @@ namespace lemon {
260261
}
261262
}
262263
if (found) continue;
263-
allocator.construct(&(new_values[id]), values[id]);
264-
allocator.destroy(&(values[id]));
264+
AllocatorTraits::construct(allocator, &(new_values[id]), values[id]);
265+
AllocatorTraits::destroy(allocator, &(values[id]));
265266
}
266267
if (capacity != 0) allocator.deallocate(values, capacity);
267268
values = new_values;
268269
capacity = new_capacity;
269270
}
270271
for (int i = 0; i < int(keys.size()); ++i) {
271272
int id = nf->id(keys[i]);
272-
allocator.construct(&(values[id]), Value());
273+
AllocatorTraits::construct(allocator, &(values[id]), Value());
273274
}
274275
}
275276

@@ -279,7 +280,7 @@ namespace lemon {
279280
// and it overrides the erase() member function of the observer base.
280281
virtual void erase(const Key& key) {
281282
int id = Parent::notifier()->id(key);
282-
allocator.destroy(&(values[id]));
283+
AllocatorTraits::destroy(allocator, &(values[id]));
283284
}
284285

285286
// \brief Erase more keys from the map.
@@ -289,7 +290,7 @@ namespace lemon {
289290
virtual void erase(const std::vector<Key>& keys) {
290291
for (int i = 0; i < int(keys.size()); ++i) {
291292
int id = Parent::notifier()->id(keys[i]);
292-
allocator.destroy(&(values[id]));
293+
AllocatorTraits::destroy(allocator, &(values[id]));
293294
}
294295
}
295296

@@ -303,7 +304,7 @@ namespace lemon {
303304
Item it;
304305
for (nf->first(it); it != INVALID; nf->next(it)) {
305306
int id = nf->id(it);;
306-
allocator.construct(&(values[id]), Value());
307+
AllocatorTraits::construct(allocator, &(values[id]), Value());
307308
}
308309
}
309310

@@ -317,7 +318,7 @@ namespace lemon {
317318
Item it;
318319
for (nf->first(it); it != INVALID; nf->next(it)) {
319320
int id = nf->id(it);
320-
allocator.destroy(&(values[id]));
321+
AllocatorTraits::destroy(allocator, &(values[id]));
321322
}
322323
allocator.deallocate(values, capacity);
323324
capacity = 0;

0 commit comments

Comments
 (0)