From 76181729bcd74b1409f07cdbc3b4e2f70af49a54 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 16 Dec 2020 17:04:24 +0100 Subject: C++: Clean up special member functions --- lilv/lilvmm.hpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lilv/lilvmm.hpp b/lilv/lilvmm.hpp index 0b7ee4d..a5de6c6 100644 --- a/lilv/lilvmm.hpp +++ b/lilv/lilvmm.hpp @@ -93,7 +93,28 @@ uri_to_path(const char* uri) { struct Node { inline Node(const LilvNode* node) : me(lilv_node_duplicate(node)) {} - inline Node(const Node& copy) : me(lilv_node_duplicate(copy.me)) {} + + inline Node(const Node& copy) : me(lilv_node_duplicate(copy.me)) {} + + inline Node& operator=(const Node& rhs) + { + if (&rhs != this) { + lilv_node_free(me); + me = lilv_node_duplicate(rhs.me); + } + return *this; + } + + inline Node(Node&& other) noexcept : me(other.me) { other.me = nullptr; } + + inline Node& operator=(Node&& rhs) noexcept + { + if (&rhs != this) { + me = rhs.me; + rhs.me = nullptr; + } + return *this; + } inline ~Node() { lilv_node_free(me); } @@ -334,6 +355,12 @@ struct World { inline World() : me(lilv_world_new()) {} inline ~World() { lilv_world_free(me); } + World(const World&) = delete; + World& operator=(const World&) = delete; + + World(World&&) = delete; + World& operator=(World&&) = delete; + inline LilvNode* new_uri(const char* uri) { return lilv_new_uri(me, uri); } -- cgit v1.2.1