QuadriFlow: Fix std::allocator deprecation warnings

https://en.cppreference.com/w/cpp/memory/allocator/construct
"(deprecated in C++17) (removed in C++20)"
Same for `destroy`.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D9657
This commit is contained in:
Ankit Meel 2020-11-29 16:12:34 +05:30
parent 11f0169e88
commit 176324aa5c
2 changed files with 99 additions and 11 deletions

View File

@ -88,7 +88,7 @@ namespace lemon {
Item it;
for (nf->first(it); it != INVALID; nf->next(it)) {
int id = nf->id(it);;
allocator.construct(&(values[id]), Value());
std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
}
@ -218,15 +218,15 @@ namespace lemon {
for (nf->first(it); it != INVALID; nf->next(it)) {
int jd = nf->id(it);;
if (id != jd) {
allocator.construct(&(new_values[jd]), values[jd]);
allocator.destroy(&(values[jd]));
std::allocator_traits<Allocator>::construct(allocator, &(new_values[jd]), values[jd]);
std::allocator_traits<Allocator>::destroy(allocator, &(values[jd]));
}
}
if (capacity != 0) allocator.deallocate(values, capacity);
values = new_values;
capacity = new_capacity;
}
allocator.construct(&(values[id]), Value());
std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
// \brief Adds more new keys to the map.
@ -260,8 +260,8 @@ namespace lemon {
}
}
if (found) continue;
allocator.construct(&(new_values[id]), values[id]);
allocator.destroy(&(values[id]));
std::allocator_traits<Allocator>::construct(allocator, &(new_values[id]), values[id]);
std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
if (capacity != 0) allocator.deallocate(values, capacity);
values = new_values;
@ -269,7 +269,7 @@ namespace lemon {
}
for (int i = 0; i < int(keys.size()); ++i) {
int id = nf->id(keys[i]);
allocator.construct(&(values[id]), Value());
std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
}
@ -279,7 +279,7 @@ namespace lemon {
// and it overrides the erase() member function of the observer base.
virtual void erase(const Key& key) {
int id = Parent::notifier()->id(key);
allocator.destroy(&(values[id]));
std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
// \brief Erase more keys from the map.
@ -289,7 +289,7 @@ namespace lemon {
virtual void erase(const std::vector<Key>& keys) {
for (int i = 0; i < int(keys.size()); ++i) {
int id = Parent::notifier()->id(keys[i]);
allocator.destroy(&(values[id]));
std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
}
@ -303,7 +303,7 @@ namespace lemon {
Item it;
for (nf->first(it); it != INVALID; nf->next(it)) {
int id = nf->id(it);;
allocator.construct(&(values[id]), Value());
std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
}
@ -317,7 +317,7 @@ namespace lemon {
Item it;
for (nf->first(it); it != INVALID; nf->next(it)) {
int id = nf->id(it);
allocator.destroy(&(values[id]));
std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
allocator.deallocate(values, capacity);
capacity = 0;

View File

@ -143,3 +143,91 @@ index 8de74ede8a9..f9861f39169 100644
num = length - shift;
while (num--) {
diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h
index 355ee008246..a770bbee60c 100644
--- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h
+++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h
@@ -88,7 +88,7 @@ namespace lemon {
Item it;
for (nf->first(it); it != INVALID; nf->next(it)) {
int id = nf->id(it);;
- allocator.construct(&(values[id]), Value());
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
}
@@ -218,15 +218,15 @@ namespace lemon {
for (nf->first(it); it != INVALID; nf->next(it)) {
int jd = nf->id(it);;
if (id != jd) {
- allocator.construct(&(new_values[jd]), values[jd]);
- allocator.destroy(&(values[jd]));
+ std::allocator_traits<Allocator>::construct(allocator, &(new_values[jd]), values[jd]);
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[jd]));
}
}
if (capacity != 0) allocator.deallocate(values, capacity);
values = new_values;
capacity = new_capacity;
}
- allocator.construct(&(values[id]), Value());
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
// \brief Adds more new keys to the map.
@@ -260,8 +260,8 @@ namespace lemon {
}
}
if (found) continue;
- allocator.construct(&(new_values[id]), values[id]);
- allocator.destroy(&(values[id]));
+ std::allocator_traits<Allocator>::construct(allocator, &(new_values[id]), values[id]);
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
if (capacity != 0) allocator.deallocate(values, capacity);
values = new_values;
@@ -269,7 +269,7 @@ namespace lemon {
}
for (int i = 0; i < int(keys.size()); ++i) {
int id = nf->id(keys[i]);
- allocator.construct(&(values[id]), Value());
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
}
@@ -279,7 +279,7 @@ namespace lemon {
// and it overrides the erase() member function of the observer base.
virtual void erase(const Key& key) {
int id = Parent::notifier()->id(key);
- allocator.destroy(&(values[id]));
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
// \brief Erase more keys from the map.
@@ -289,7 +289,7 @@ namespace lemon {
virtual void erase(const std::vector<Key>& keys) {
for (int i = 0; i < int(keys.size()); ++i) {
int id = Parent::notifier()->id(keys[i]);
- allocator.destroy(&(values[id]));
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
}
@@ -303,7 +303,7 @@ namespace lemon {
Item it;
for (nf->first(it); it != INVALID; nf->next(it)) {
int id = nf->id(it);;
- allocator.construct(&(values[id]), Value());
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
}
}
@@ -317,7 +317,7 @@ namespace lemon {
Item it;
for (nf->first(it); it != INVALID; nf->next(it)) {
int id = nf->id(it);
- allocator.destroy(&(values[id]));
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
}
allocator.deallocate(values, capacity);
capacity = 0;