Skip to content

Commit f0046fa

Browse files
committed
[liblemon] Apply patches for C++20 compatibility
1 parent 1bc153d commit f0046fa

File tree

3 files changed

+121
-1
lines changed

3 files changed

+121
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/lemon/adaptors.h b/lemon/adaptors.h
2+
index 1a40f8e..ffeb12d 100644
3+
--- a/lemon/adaptors.h
4+
+++ b/lemon/adaptors.h
5+
@@ -37,7 +37,7 @@
6+
7+
namespace lemon {
8+
9+
-#ifdef _MSC_VER
10+
+#if defined _MSC_VER and __cplusplus < 202002L
11+
#define LEMON_SCOPE_FIX(OUTER, NESTED) OUTER::NESTED
12+
#else
13+
#define LEMON_SCOPE_FIX(OUTER, NESTED) typename OUTER::template NESTED
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
diff --git a/lemon/bits/array_map.h b/lemon/bits/array_map.h
2+
index 355ee00..c3992cf 100644
3+
--- a/lemon/bits/array_map.h
4+
+++ b/lemon/bits/array_map.h
5+
@@ -88,7 +88,7 @@ namespace lemon {
6+
Item it;
7+
for (nf->first(it); it != INVALID; nf->next(it)) {
8+
int id = nf->id(it);;
9+
- allocator.construct(&(values[id]), Value());
10+
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
11+
}
12+
}
13+
14+
@@ -102,7 +102,7 @@ namespace lemon {
15+
Item it;
16+
for (nf->first(it); it != INVALID; nf->next(it)) {
17+
int id = nf->id(it);;
18+
- allocator.construct(&(values[id]), value);
19+
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), value);
20+
}
21+
}
22+
23+
@@ -121,7 +121,7 @@ namespace lemon {
24+
Item it;
25+
for (nf->first(it); it != INVALID; nf->next(it)) {
26+
int id = nf->id(it);;
27+
- allocator.construct(&(values[id]), copy.values[id]);
28+
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), copy.values[id]);
29+
}
30+
}
31+
32+
@@ -218,15 +218,15 @@ namespace lemon {
33+
for (nf->first(it); it != INVALID; nf->next(it)) {
34+
int jd = nf->id(it);;
35+
if (id != jd) {
36+
- allocator.construct(&(new_values[jd]), values[jd]);
37+
- allocator.destroy(&(values[jd]));
38+
+ std::allocator_traits<Allocator>::construct(allocator, &(new_values[jd]), values[jd]);
39+
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[jd]));
40+
}
41+
}
42+
if (capacity != 0) allocator.deallocate(values, capacity);
43+
values = new_values;
44+
capacity = new_capacity;
45+
}
46+
- allocator.construct(&(values[id]), Value());
47+
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
48+
}
49+
50+
// \brief Adds more new keys to the map.
51+
@@ -260,8 +260,8 @@ namespace lemon {
52+
}
53+
}
54+
if (found) continue;
55+
- allocator.construct(&(new_values[id]), values[id]);
56+
- allocator.destroy(&(values[id]));
57+
+ std::allocator_traits<Allocator>::construct(allocator, &(new_values[id]), values[id]);
58+
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
59+
}
60+
if (capacity != 0) allocator.deallocate(values, capacity);
61+
values = new_values;
62+
@@ -269,7 +269,7 @@ namespace lemon {
63+
}
64+
for (int i = 0; i < int(keys.size()); ++i) {
65+
int id = nf->id(keys[i]);
66+
- allocator.construct(&(values[id]), Value());
67+
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
68+
}
69+
}
70+
71+
@@ -279,7 +279,7 @@ namespace lemon {
72+
// and it overrides the erase() member function of the observer base.
73+
virtual void erase(const Key& key) {
74+
int id = Parent::notifier()->id(key);
75+
- allocator.destroy(&(values[id]));
76+
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
77+
}
78+
79+
// \brief Erase more keys from the map.
80+
@@ -289,7 +289,7 @@ namespace lemon {
81+
virtual void erase(const std::vector<Key>& keys) {
82+
for (int i = 0; i < int(keys.size()); ++i) {
83+
int id = Parent::notifier()->id(keys[i]);
84+
- allocator.destroy(&(values[id]));
85+
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
86+
}
87+
}
88+
89+
@@ -303,7 +303,7 @@ namespace lemon {
90+
Item it;
91+
for (nf->first(it); it != INVALID; nf->next(it)) {
92+
int id = nf->id(it);;
93+
- allocator.construct(&(values[id]), Value());
94+
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value());
95+
}
96+
}
97+
98+
@@ -317,7 +317,7 @@ namespace lemon {
99+
Item it;
100+
for (nf->first(it); it != INVALID; nf->next(it)) {
101+
int id = nf->id(it);
102+
- allocator.destroy(&(values[id]));
103+
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id]));
104+
}
105+
allocator.deallocate(values, capacity);
106+
capacity = 0;

ports/liblemon/portfile.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ vcpkg_extract_source_archive(
1414
SOURCE_BASE "${VERSION}"
1515
PATCHES
1616
fix-cmake.patch
17+
cpp-20-arraymap.patch
18+
cpp-20-adaptors.patch
1719
)
1820

1921
vcpkg_cmake_configure(
2022
SOURCE_PATH "${SOURCE_PATH}"
2123
OPTIONS
22-
-DCMAKE_CXX_STANDARD=14
2324
-DLEMON_ENABLE_GLPK=OFF
2425
-DLEMON_ENABLE_ILOG=OFF
2526
-DLEMON_ENABLE_COIN=OFF

0 commit comments

Comments
 (0)