summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--test/.clang-tidy1
-rw-r--r--test/headers/.clang-tidy1
-rw-r--r--test/maid_test.cpp2
9 files changed, 23 insertions, 19 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();
diff --git a/test/.clang-tidy b/test/.clang-tidy
index 7563367..b51e83e 100644
--- a/test/.clang-tidy
+++ b/test/.clang-tidy
@@ -29,7 +29,6 @@ Checks: >
-llvmlibc-*,
-modernize-make-unique,
-modernize-return-braced-init-list,
- -modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-function-cognitive-complexity,
-readability-identifier-length,
diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy
index 1a91f8b..1beaf9e 100644
--- a/test/headers/.clang-tidy
+++ b/test/headers/.clang-tidy
@@ -21,7 +21,6 @@ Checks: >
-hicpp-no-array-decay,
-llvmlibc-*,
-modernize-return-braced-init-list,
- -modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-identifier-length,
-readability-implicit-bool-conversion,
diff --git a/test/maid_test.cpp b/test/maid_test.cpp
index cb4e461..2a936f9 100644
--- a/test/maid_test.cpp
+++ b/test/maid_test.cpp
@@ -38,7 +38,7 @@ public:
~Junk() override { --n_junk; }
- size_t value() const { return _val; }
+ [[nodiscard]] size_t value() const { return _val; }
private:
size_t _val;