Fixed some more or less valid clang and clang-tidy errors.

This commit is contained in:
2023-08-05 17:47:59 +02:00
parent 97d68d31e8
commit 1549ef27a7
2 changed files with 6 additions and 3 deletions

View File

@@ -7,7 +7,7 @@
#include "./common_macros.hpp"
#define MIJIN_SCOPE_EXIT_NAMED(name) \
mijin::ScopeExitGuard name = [&]()
const mijin::ScopeExitGuard name = [&]()
#define MIJIN_SCOPE_EXIT MIJIN_SCOPE_EXIT_NAMED(MIJIN_CONCAT(MIJIN_CONCAT(scope_guard_, __LINE__), __))
@@ -16,7 +16,7 @@ namespace mijin
class ScopeExitGuard
{
private:
std::function<void(void)> func;
mutable std::function<void(void)> func; // variable is declared const to make clang-tidy happy, but we still want to be able to reset()
public:
template<typename TFunc>
inline ScopeExitGuard(TFunc&& func_) noexcept : func(std::forward<TFunc>(func_)) {}
@@ -32,7 +32,7 @@ public:
ScopeExitGuard& operator=(const ScopeExitGuard&) noexcept = delete;
ScopeExitGuard& operator=(ScopeExitGuard&&) noexcept = delete;
inline void reset() noexcept
inline void reset() const noexcept
{
func = {};
}