diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-04 18:08:57 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-04 18:08:57 +0100 |
commit | fa4009dd0a1718491fe0530d23847374f5dc0932 (patch) | |
tree | cc8f8d4649eb877734a85dae9d0828bde3855816 /lib | |
parent | Replace messy uasprintf with std::format (diff) | |
download | ilt-fa4009dd0a1718491fe0530d23847374f5dc0932.tar.bz2 ilt-fa4009dd0a1718491fe0530d23847374f5dc0932.tar.xz ilt-fa4009dd0a1718491fe0530d23847374f5dc0932.zip |
Tidy of glRef
Still doesn't fix the weird LTO warning about uninitialised variables
Diffstat (limited to 'lib')
-rw-r--r-- | lib/glRef.h | 15 |
1 files changed, 6 insertions, 9 deletions
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 <special_members.h> #include <stdexcept> +#include <utility> template<typename IdType, auto get, auto release, auto... fixed> 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 {}; }; |