summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-06-29 09:45:46 -0400
committerDavid Robillard <d@drobilla.net>2022-07-20 16:24:23 -0400
commitd855f8f67a4588f44ade0ed19744c99bfe81e76c (patch)
tree83128be6067bdd21a4c6a9440e15f387e20e9025 /include
parentcf72f2855fccaf1c579388bcdba2a219a9983d96 (diff)
downloadraul-d855f8f67a4588f44ade0ed19744c99bfe81e76c.tar.gz
raul-d855f8f67a4588f44ade0ed19744c99bfe81e76c.tar.bz2
raul-d855f8f67a4588f44ade0ed19744c99bfe81e76c.zip
Use nodiscard attribute
Diffstat (limited to 'include')
-rw-r--r--include/raul/Array.hpp6
-rw-r--r--include/raul/DoubleBuffer.hpp2
-rw-r--r--include/raul/Exception.hpp5
-rw-r--r--include/raul/Maid.hpp5
-rw-r--r--include/raul/Path.hpp16
-rw-r--r--include/raul/Socket.hpp4
6 files changed, 22 insertions, 16 deletions
diff --git a/include/raul/Array.hpp b/include/raul/Array.hpp
index 3c6234c..0ed0ae0 100644
--- a/include/raul/Array.hpp
+++ b/include/raul/Array.hpp
@@ -126,15 +126,15 @@ public:
}
}
- size_t size() const { return _size; }
+ [[nodiscard]] size_t size() const { return _size; }
- T& operator[](size_t i) const
+ [[nodiscard]] T& operator[](size_t i) const
{
assert(i < _size);
return _elems[i];
}
- T& at(size_t i) const
+ [[nodiscard]] T& at(size_t i) const
{
assert(i < _size);
return _elems[i];
diff --git a/include/raul/DoubleBuffer.hpp b/include/raul/DoubleBuffer.hpp
index e391bb4..78ad6a0 100644
--- a/include/raul/DoubleBuffer.hpp
+++ b/include/raul/DoubleBuffer.hpp
@@ -39,7 +39,7 @@ public:
~DoubleBuffer() = default;
- const T& get() const
+ [[nodiscard]] const T& get() const
{
switch (_state.load(std::memory_order_acquire)) {
case State::READ_WRITE:
diff --git a/include/raul/Exception.hpp b/include/raul/Exception.hpp
index ef5b764..74f694a 100644
--- a/include/raul/Exception.hpp
+++ b/include/raul/Exception.hpp
@@ -19,7 +19,10 @@ class Exception : public std::exception
{
public:
// NOLINTNEXTLINE(modernize-use-override, hicpp-use-override)
- const char* what() const noexcept final override { return _what.c_str(); }
+ [[nodiscard]] const char* what() const noexcept final override
+ {
+ return _what.c_str();
+ }
protected:
explicit Exception(std::string what)
diff --git a/include/raul/Maid.hpp b/include/raul/Maid.hpp
index db957d3..51e2dca 100644
--- a/include/raul/Maid.hpp
+++ b/include/raul/Maid.hpp
@@ -103,7 +103,10 @@ public:
~Maid() { cleanup(); }
/// Return false iff there is currently no garbage
- bool empty() const { return !_disposed.load(std::memory_order_relaxed); }
+ [[nodiscard]] bool empty() const
+ {
+ return !_disposed.load(std::memory_order_relaxed);
+ }
/**
Enqueue an object for deletion when cleanup() is called next.
diff --git a/include/raul/Path.hpp b/include/raul/Path.hpp
index acd9e83..0be7e99 100644
--- a/include/raul/Path.hpp
+++ b/include/raul/Path.hpp
@@ -111,17 +111,17 @@ public:
}
/// Return true iff this path is the root path ("/")
- bool is_root() const { return *this == "/"; }
+ [[nodiscard]] bool is_root() const { return *this == "/"; }
/// Return true iff this path is a child of `parent` at any depth
- bool is_child_of(const Path& parent) const
+ [[nodiscard]] bool is_child_of(const Path& parent) const
{
const std::string parent_base = parent.base();
return substr(0, parent_base.length()) == parent_base;
}
/// Return true iff this path is a parent of `child` at any depth
- bool is_parent_of(const Path& child) const
+ [[nodiscard]] bool is_parent_of(const Path& child) const
{
return child.is_child_of(*this);
}
@@ -133,7 +133,7 @@ public:
for OSC paths, and so on. Since the root path does not have a symbol,
this does not return a raul::Symbol but may return the empty string.
*/
- const char* symbol() const
+ [[nodiscard]] const char* symbol() const
{
if (!is_root()) {
const size_t last_sep = rfind('/');
@@ -150,7 +150,7 @@ public:
Calling this on the path "/" will return "/".
This is the (deepest) "container path" for OSC paths.
*/
- Path parent() const
+ [[nodiscard]] Path parent() const
{
if (is_root()) {
return *this;
@@ -162,13 +162,13 @@ public:
}
/// Return a child Path of this path
- Path child(const Path& p) const
+ [[nodiscard]] Path child(const Path& p) const
{
return p.is_root() ? *this : Path(base() + p.substr(1));
}
/// Return a direct child Path of this Path with the given Symbol
- Path child(const raul::Symbol& symbol) const
+ [[nodiscard]] Path child(const raul::Symbol& symbol) const
{
return Path(base() + symbol.c_str());
}
@@ -179,7 +179,7 @@ public:
The returned string is such that appending a valid Symbol to it is
guaranteed to form a valid path.
*/
- std::string base() const
+ [[nodiscard]] std::string base() const
{
if (is_root()) {
return *this;
diff --git a/include/raul/Socket.hpp b/include/raul/Socket.hpp
index bd8ea35..e62ffb8 100644
--- a/include/raul/Socket.hpp
+++ b/include/raul/Socket.hpp
@@ -76,9 +76,9 @@ public:
std::shared_ptr<Socket> accept();
/// Return the file descriptor for the socket
- int fd() const { return _sock; }
+ [[nodiscard]] int fd() const { return _sock; }
- const std::string& uri() const { return _uri; }
+ [[nodiscard]] const std::string& uri() const { return _uri; }
/// Close the socket
void close();