From 4bc7ab2f28bed3720391fcfbc7be930e5379a19e Mon Sep 17 00:00:00 2001 From: Mike Dunston Date: Sat, 23 Sep 2023 08:16:18 -0700 Subject: [PATCH] Fix MultiConfiguredPC.hxx compilation with C++20 (#737) Due to the C++20 standard removing the construct and destruct methods from std::allocator, it was necessary to adjust the code to use std::allocator_traits instead which has provided these methods since C++11. Fixes #711 === * Fix MultiConfiguredPC.hxx compilation with C++20 C++20 removed the construct / destruct methods from std::allocator with the replacement methods being part of std::allocator_traits intead. Fixes https://github.com/bakerstu/openmrn/issues/711 * Update MultiConfiguredPC.hxx Fix missing } * Update MultiConfiguredPC.hxx Due to the C++20 standard removing the construct and destruct methods from std::allocator, it was necessary to adjust the code to use std::allocator_traits instead which has provided these methods since C++11. --- src/openlcb/MultiConfiguredPC.hxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/openlcb/MultiConfiguredPC.hxx b/src/openlcb/MultiConfiguredPC.hxx index 707241209..dcb183f60 100644 --- a/src/openlcb/MultiConfiguredPC.hxx +++ b/src/openlcb/MultiConfiguredPC.hxx @@ -41,6 +41,7 @@ #include "openlcb/RefreshLoop.hxx" #include "utils/ConfigUpdateListener.hxx" #include "utils/ConfigUpdateService.hxx" +#include "utils/Debouncer.hxx" #include "utils/format_utils.hxx" namespace openlcb @@ -141,7 +142,7 @@ public: debouncers_ = alloc.allocate(size_); for (unsigned i = 0; i < size_; ++i) { - alloc.construct(debouncers_ + i, 3); + alloc_traits::construct(alloc, debouncers_ + i, 3); } } @@ -153,7 +154,7 @@ public: std::allocator alloc; for (unsigned i = 0; i < size_; ++i) { - alloc.destroy(debouncers_ + i); + alloc_traits::destroy(alloc, debouncers_ + i); } alloc.deallocate(debouncers_, size_); } @@ -336,6 +337,8 @@ public: } private: + using alloc_traits = std::allocator_traits>; + /// Removes registration of this event handler from the global event /// registry. void do_unregister()