forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#17338) coin-lemon: allow to consume coin-lemon with C++20 o…
…r higher * allow to consume coin-lemon with C++20 or higher * allow C++20 without dropping C++98 support
- Loading branch information
Showing
5 changed files
with
209 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
199 changes: 199 additions & 0 deletions
199
recipes/coin-lemon/all/patches/0003-cpp20-compat-alloc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
--- a/lemon/bits/array_map.h | ||
+++ b/lemon/bits/array_map.h | ||
@@ -88,7 +88,11 @@ namespace lemon { | ||
Item it; | ||
for (nf->first(it); it != INVALID; nf->next(it)) { | ||
int id = nf->id(it);; | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value()); | ||
+#else | ||
allocator.construct(&(values[id]), Value()); | ||
+#endif | ||
} | ||
} | ||
|
||
@@ -102,7 +106,11 @@ namespace lemon { | ||
Item it; | ||
for (nf->first(it); it != INVALID; nf->next(it)) { | ||
int id = nf->id(it);; | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), value); | ||
+#else | ||
allocator.construct(&(values[id]), value); | ||
+#endif | ||
} | ||
} | ||
|
||
@@ -121,7 +129,11 @@ namespace lemon { | ||
Item it; | ||
for (nf->first(it); it != INVALID; nf->next(it)) { | ||
int id = nf->id(it);; | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), copy.values[id]); | ||
+#else | ||
allocator.construct(&(values[id]), copy.values[id]); | ||
+#endif | ||
} | ||
} | ||
|
||
@@ -218,15 +230,24 @@ namespace lemon { | ||
for (nf->first(it); it != INVALID; nf->next(it)) { | ||
int jd = nf->id(it);; | ||
if (id != jd) { | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(new_values[jd]), values[jd]); | ||
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[jd])); | ||
+#else | ||
allocator.construct(&(new_values[jd]), values[jd]); | ||
allocator.destroy(&(values[jd])); | ||
+#endif | ||
} | ||
} | ||
if (capacity != 0) allocator.deallocate(values, capacity); | ||
values = new_values; | ||
capacity = new_capacity; | ||
} | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value()); | ||
+#else | ||
allocator.construct(&(values[id]), Value()); | ||
+#endif | ||
} | ||
|
||
// \brief Adds more new keys to the map. | ||
@@ -260,8 +281,13 @@ namespace lemon { | ||
} | ||
} | ||
if (found) continue; | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(new_values[id]), values[id]); | ||
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id])); | ||
+#else | ||
allocator.construct(&(new_values[id]), values[id]); | ||
allocator.destroy(&(values[id])); | ||
+#endif | ||
} | ||
if (capacity != 0) allocator.deallocate(values, capacity); | ||
values = new_values; | ||
@@ -269,7 +295,11 @@ namespace lemon { | ||
} | ||
for (int i = 0; i < int(keys.size()); ++i) { | ||
int id = nf->id(keys[i]); | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value()); | ||
+#else | ||
allocator.construct(&(values[id]), Value()); | ||
+#endif | ||
} | ||
} | ||
|
||
@@ -279,7 +309,11 @@ 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); | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id])); | ||
+#else | ||
allocator.destroy(&(values[id])); | ||
+#endif | ||
} | ||
|
||
// \brief Erase more keys from the map. | ||
@@ -289,7 +323,11 @@ 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]); | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id])); | ||
+#else | ||
allocator.destroy(&(values[id])); | ||
+#endif | ||
} | ||
} | ||
|
||
@@ -303,7 +341,11 @@ namespace lemon { | ||
Item it; | ||
for (nf->first(it); it != INVALID; nf->next(it)) { | ||
int id = nf->id(it);; | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::construct(allocator, &(values[id]), Value()); | ||
+#else | ||
allocator.construct(&(values[id]), Value()); | ||
+#endif | ||
} | ||
} | ||
|
||
@@ -317,7 +359,11 @@ namespace lemon { | ||
Item it; | ||
for (nf->first(it); it != INVALID; nf->next(it)) { | ||
int id = nf->id(it); | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<Allocator>::destroy(allocator, &(values[id])); | ||
+#else | ||
allocator.destroy(&(values[id])); | ||
+#endif | ||
} | ||
allocator.deallocate(values, capacity); | ||
capacity = 0; | ||
--- a/lemon/path.h | ||
+++ b/lemon/path.h | ||
@@ -582,7 +582,11 @@ namespace lemon { | ||
void clear() { | ||
while (first != 0) { | ||
last = first->next; | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<std::allocator<Node>>::destroy(alloc, first); | ||
+#else | ||
alloc.destroy(first); | ||
+#endif | ||
alloc.deallocate(first, 1); | ||
first = last; | ||
} | ||
@@ -596,7 +600,11 @@ namespace lemon { | ||
/// \brief Add a new arc before the current path | ||
void addFront(const Arc& arc) { | ||
Node *node = alloc.allocate(1); | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<std::allocator<Node>>::construct(alloc, node, Node()); | ||
+#else | ||
alloc.construct(node, Node()); | ||
+#endif | ||
node->prev = 0; | ||
node->next = first; | ||
node->arc = arc; | ||
@@ -617,7 +625,11 @@ namespace lemon { | ||
} else { | ||
last = 0; | ||
} | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<std::allocator<Node>>::destroy(alloc, node); | ||
+#else | ||
alloc.destroy(node); | ||
+#endif | ||
alloc.deallocate(node, 1); | ||
} | ||
|
||
@@ -629,7 +641,11 @@ namespace lemon { | ||
/// \brief Add a new arc behind the current path. | ||
void addBack(const Arc& arc) { | ||
Node *node = alloc.allocate(1); | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<std::allocator<Node>>::construct(alloc, node, Node()); | ||
+#else | ||
alloc.construct(node, Node()); | ||
+#endif | ||
node->next = 0; | ||
node->prev = last; | ||
node->arc = arc; | ||
@@ -650,7 +666,11 @@ namespace lemon { | ||
} else { | ||
first = 0; | ||
} | ||
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) || __cplusplus >= 202002L) | ||
+ std::allocator_traits<std::allocator<Node>>::destroy(alloc, node); | ||
+#else | ||
alloc.destroy(node); | ||
+#endif | ||
alloc.deallocate(node, 1); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(LEMON CONFIG REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE LEMON::LEMON) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) |