Skip to content

Commit

Permalink
Fix MultiConfiguredPC.hxx compilation with C++20 (#737)
Browse files Browse the repository at this point in the history
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 #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.
  • Loading branch information
atanisoft authored Sep 23, 2023
1 parent 3d4f8ef commit 4bc7ab2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/openlcb/MultiConfiguredPC.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -153,7 +154,7 @@ public:
std::allocator<debouncer_type> alloc;
for (unsigned i = 0; i < size_; ++i)
{
alloc.destroy(debouncers_ + i);
alloc_traits::destroy(alloc, debouncers_ + i);
}
alloc.deallocate(debouncers_, size_);
}
Expand Down Expand Up @@ -336,6 +337,8 @@ public:
}

private:
using alloc_traits = std::allocator_traits<std::allocator<debouncer_type>>;

/// Removes registration of this event handler from the global event
/// registry.
void do_unregister()
Expand Down

0 comments on commit 4bc7ab2

Please sign in to comment.