From fa4009dd0a1718491fe0530d23847374f5dc0932 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 4 Jun 2024 18:08:57 +0100 Subject: Tidy of glRef Still doesn't fix the weird LTO warning about uninitialised variables --- lib/glRef.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/glRef.h b/lib/glRef.h index 3031cf5..c65451a 100644 --- a/lib/glRef.h +++ b/lib/glRef.h @@ -2,6 +2,7 @@ #include #include +#include template class glRef { public: @@ -13,10 +14,7 @@ public: } } - glRef(glRef && other) : id {other.id} - { - other.id = {}; - } + glRef(glRef && other) noexcept : id {std::exchange(other.id, {})} { } ~glRef() { @@ -28,15 +26,14 @@ public: NO_COPY(glRef); - const auto & - operator=(glRef && other) + auto & + operator=(glRef && other) noexcept { if (id) { // cppcheck-suppress redundantPointerOp (*release)(id); } - id = other.id; - other.id = {}; + id = std::exchange(other.id, {}); return *this; } @@ -58,5 +55,5 @@ public: } private: - IdType id; + IdType id {}; }; -- cgit v1.2.3