From 40f3c3f66f532941ca9576852827d636000f2477 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 19 Dec 2020 12:20:43 +0100 Subject: Clean up special member functions --- include/.clang-tidy | 1 - include/raul/Deletable.hpp | 7 ++++++- include/raul/DoubleBuffer.hpp | 5 +++++ include/raul/Maid.hpp | 12 ++++++++++++ include/raul/Noncopyable.hpp | 3 +++ include/raul/Path.hpp | 11 ++++++----- include/raul/RingBuffer.hpp | 11 +++++++---- include/raul/Semaphore.hpp | 3 +++ include/raul/Socket.hpp | 3 +++ include/raul/Symbol.hpp | 11 ++++++----- include/raul/TimeStamp.hpp | 7 ++++++- 11 files changed, 57 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/.clang-tidy b/include/.clang-tidy index c385440..792d991 100644 --- a/include/.clang-tidy +++ b/include/.clang-tidy @@ -3,7 +3,6 @@ Checks: > -*-avoid-c-arrays, -*-magic-numbers, -*-no-malloc, - -*-special-member-functions, -*-uppercase-literal-suffix, -android-cloexec-accept, -bugprone-branch-clone, diff --git a/include/raul/Deletable.hpp b/include/raul/Deletable.hpp index 9b80d54..191daaf 100644 --- a/include/raul/Deletable.hpp +++ b/include/raul/Deletable.hpp @@ -1,4 +1,3 @@ - /* This file is part of Raul. Copyright 2007-2013 David Robillard @@ -29,6 +28,12 @@ class Deletable public: Deletable() = default; + Deletable(const Deletable&) = default; + Deletable& operator=(const Deletable&) = default; + + Deletable(Deletable&&) = default; + Deletable& operator=(Deletable&&) = default; + virtual ~Deletable() = default; }; diff --git a/include/raul/DoubleBuffer.hpp b/include/raul/DoubleBuffer.hpp index f6ab826..9163e0c 100644 --- a/include/raul/DoubleBuffer.hpp +++ b/include/raul/DoubleBuffer.hpp @@ -44,6 +44,11 @@ public: DoubleBuffer(const DoubleBuffer&) = delete; DoubleBuffer& operator=(const DoubleBuffer&) = delete; + DoubleBuffer(DoubleBuffer&&) = delete; + DoubleBuffer& operator=(DoubleBuffer&&) = delete; + + ~DoubleBuffer() = default; + inline const T& get() const { switch (_state.load(std::memory_order_acquire)) { case State::READ_WRITE: diff --git a/include/raul/Maid.hpp b/include/raul/Maid.hpp index 9841f82..34061ad 100644 --- a/include/raul/Maid.hpp +++ b/include/raul/Maid.hpp @@ -43,9 +43,15 @@ public: class Disposable : public Deletable { public: Disposable() = default; + Disposable(const Disposable&) = delete; Disposable& operator=(const Disposable&) = delete; + Disposable(Disposable&&) = delete; + Disposable& operator=(Disposable&&) = delete; + + ~Disposable() override = default; + private: friend class Maid; Disposable* _maid_next{}; @@ -87,6 +93,12 @@ public: Maid() : _disposed(nullptr) {} + Maid(const Maid&) = delete; + Maid& operator=(const Maid&) = delete; + + Maid(Maid&&) = delete; + Maid& operator=(Maid&&) = delete; + inline ~Maid() { cleanup(); } /** Return false iff there is currently no garbage. */ diff --git a/include/raul/Noncopyable.hpp b/include/raul/Noncopyable.hpp index 876cee8..7559f84 100644 --- a/include/raul/Noncopyable.hpp +++ b/include/raul/Noncopyable.hpp @@ -24,6 +24,9 @@ public: Noncopyable(const Noncopyable&) = delete; const Noncopyable& operator=(const Noncopyable&) = delete; + Noncopyable(Noncopyable&&) = delete; + Noncopyable& operator=(Noncopyable&&) = delete; + protected: Noncopyable() = default; ~Noncopyable() = default; diff --git a/include/raul/Path.hpp b/include/raul/Path.hpp index 4fb3da1..984d95b 100644 --- a/include/raul/Path.hpp +++ b/include/raul/Path.hpp @@ -70,12 +70,13 @@ public: } } - /** Copy a Path. - * - * Note this is faster than constructing a Path from another Path's string - * since validation is unnecessary. - */ Path(const Path& path) = default; + Path& operator=(const Path& path) = default; + + Path(Path&& path) = default; + Path& operator=(Path&& path) = default; + + ~Path() = default; /** Return true iff `c` is a valid Path character. */ static inline bool is_valid_char(char c) { diff --git a/include/raul/RingBuffer.hpp b/include/raul/RingBuffer.hpp index b83f442..b6bde0d 100644 --- a/include/raul/RingBuffer.hpp +++ b/include/raul/RingBuffer.hpp @@ -52,10 +52,13 @@ public: assert(write_space() == _size - 1); } - /** - Destroy a RingBuffer. - */ - inline ~RingBuffer() = default; + RingBuffer(const RingBuffer&) = delete; + RingBuffer& operator=(const RingBuffer&) = delete; + + RingBuffer(RingBuffer&&) = delete; + RingBuffer& operator=(RingBuffer&&) = delete; + + ~RingBuffer() = default; /** Reset (empty) the RingBuffer. diff --git a/include/raul/Semaphore.hpp b/include/raul/Semaphore.hpp index ee2325f..a6203dc 100644 --- a/include/raul/Semaphore.hpp +++ b/include/raul/Semaphore.hpp @@ -64,6 +64,9 @@ public: inline Semaphore(const Semaphore&) = delete; inline Semaphore& operator=(const Semaphore&) = delete; + inline Semaphore(Semaphore&&) = delete; + inline Semaphore& operator=(Semaphore&&) = delete; + inline ~Semaphore() { destroy(); } diff --git a/include/raul/Socket.hpp b/include/raul/Socket.hpp index 74a1595..f3a4b07 100644 --- a/include/raul/Socket.hpp +++ b/include/raul/Socket.hpp @@ -53,6 +53,9 @@ public: Socket(const Socket&) = delete; Socket& operator=(const Socket&) = delete; + Socket(Socket&&) = delete; + Socket& operator=(Socket&&) = delete; + ~Socket(); /** Bind a server socket to an address. diff --git a/include/raul/Symbol.hpp b/include/raul/Symbol.hpp index 4f762f8..35cd39d 100644 --- a/include/raul/Symbol.hpp +++ b/include/raul/Symbol.hpp @@ -69,12 +69,13 @@ public: } } - /** Copy a Symbol. - * - * Note this is faster than constructing a Symbol from another Symbol's - * string since validation is unnecessary. - */ Symbol(const Symbol& symbol) = default; + Symbol& operator=(const Symbol& symbol) = default; + + Symbol(Symbol&& symbol) = default; + Symbol& operator=(Symbol&& symbol) = default; + + ~Symbol() = default; /** Return true iff `c` is a valid Symbol start character. */ static inline bool is_valid_start_char(char c) { diff --git a/include/raul/TimeStamp.hpp b/include/raul/TimeStamp.hpp index ed9b479..5fd2353 100644 --- a/include/raul/TimeStamp.hpp +++ b/include/raul/TimeStamp.hpp @@ -99,9 +99,14 @@ public: _subticks = static_cast(fractional * unit.ppt()); } - inline TimeStamp(const TimeStamp&) = default; + TimeStamp(const TimeStamp&) = default; TimeStamp& operator=(const TimeStamp&) = default; + TimeStamp(TimeStamp&&) = default; + TimeStamp& operator=(TimeStamp&&) = default; + + ~TimeStamp() = default; + inline TimeUnit unit() const { return _unit; } inline uint32_t ticks() const { return _ticks; } inline uint32_t subticks() const { return _subticks; } -- cgit v1.2.1