diff --git a/include/rsl/algorithm.hpp b/include/rsl/algorithm.hpp index d3b3c0f..523962f 100644 --- a/include/rsl/algorithm.hpp +++ b/include/rsl/algorithm.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_ALGORITHM_HPP +#define RSL_ALGORITHM_HPP #include @@ -40,3 +41,5 @@ template } } // namespace rsl + +#endif // RSL_ALGORITHM_HPP diff --git a/include/rsl/monad.hpp b/include/rsl/monad.hpp index d22eb42..e997384 100644 --- a/include/rsl/monad.hpp +++ b/include/rsl/monad.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_MONAD_HPP +#define RSL_MONAD_HPP #include @@ -165,6 +166,7 @@ constexpr inline bool is_optional = is_optional_impl>, typename = std::enable_if_t>::value_type>>> @@ -205,3 +207,6 @@ template , std::invoke_result_t> { return std::invoke(std::forward(fn), std::forward(val)); } +// NOLINTEND(modernize-use-constraints) + +#endif // RSL_MONAD_HPP diff --git a/include/rsl/no_discard.hpp b/include/rsl/no_discard.hpp index 418eb43..73ff972 100644 --- a/include/rsl/no_discard.hpp +++ b/include/rsl/no_discard.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_NO_DISCARD_HPP +#define RSL_NO_DISCARD_HPP #include @@ -26,3 +27,5 @@ class NoDiscard { }; } // namespace rsl + +#endif // RSL_NO_DISCARD_HPP diff --git a/include/rsl/overload.hpp b/include/rsl/overload.hpp index 7bb92d9..7f090cb 100644 --- a/include/rsl/overload.hpp +++ b/include/rsl/overload.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_OVERLOAD_HPP +#define RSL_OVERLOAD_HPP namespace rsl { @@ -18,3 +19,5 @@ template Overload(Ts...) -> Overload; } // namespace rsl + +#endif // RSL_OVERLOAD_HPP diff --git a/include/rsl/parameter_validators.hpp b/include/rsl/parameter_validators.hpp index b1fd52f..366fedd 100644 --- a/include/rsl/parameter_validators.hpp +++ b/include/rsl/parameter_validators.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_PARAMETER_VALIDATORS_HPP +#define RSL_PARAMETER_VALIDATORS_HPP #include #include @@ -320,3 +321,5 @@ template -> rcl_interfaces::msg::SetParametersResult; } // namespace rsl + +#endif // RSL_PARAMETER_VALIDATORS_HPP diff --git a/include/rsl/queue.hpp b/include/rsl/queue.hpp index 263f604..c6ae13c 100644 --- a/include/rsl/queue.hpp +++ b/include/rsl/queue.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_QUEUE_HPP +#define RSL_QUEUE_HPP #include #include @@ -26,7 +27,7 @@ class Queue { * @return Queue size */ [[nodiscard]] auto size() const noexcept { - auto const lock = std::lock_guard(mutex_); + auto const lock = std::scoped_lock(mutex_); return queue_.size(); } @@ -35,7 +36,7 @@ class Queue { * @return True if the queue is empty, otherwise false */ [[nodiscard]] auto empty() const noexcept { - auto const lock = std::lock_guard(mutex_); + auto const lock = std::scoped_lock(mutex_); return queue_.empty(); } @@ -44,7 +45,7 @@ class Queue { * @param value Data to push into the queue */ void push(T value) noexcept { - auto const lock = std::lock_guard(mutex_); + auto const lock = std::scoped_lock(mutex_); queue_.push(std::move(value)); cv_.notify_one(); } @@ -53,7 +54,7 @@ class Queue { * @brief Clear the queue */ void clear() noexcept { - auto const lock = std::lock_guard(mutex_); + auto const lock = std::scoped_lock(mutex_); // Swap queue with an empty queue of the same type to ensure queue_ is left in a // default-constructed state @@ -77,3 +78,5 @@ class Queue { } }; } // namespace rsl + +#endif // RSL_QUEUE_HPP diff --git a/include/rsl/random.hpp b/include/rsl/random.hpp index e431d7f..d27a6c9 100644 --- a/include/rsl/random.hpp +++ b/include/rsl/random.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_RANDOM_HPP +#define RSL_RANDOM_HPP #include @@ -68,3 +69,5 @@ template [[nodiscard]] RSL_EXPORT auto random_unit_quaternion() -> Eigen::Quaterniond; } // namespace rsl + +#endif // RSL_RANDOM_HPP diff --git a/include/rsl/static_string.hpp b/include/rsl/static_string.hpp index 34450b1..9c0613e 100644 --- a/include/rsl/static_string.hpp +++ b/include/rsl/static_string.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_STATIC_STRING_HPP +#define RSL_STATIC_STRING_HPP #include #include @@ -58,3 +59,5 @@ template } } // namespace rsl + +#endif // RSL_STATIC_STRING_HPP diff --git a/include/rsl/static_vector.hpp b/include/rsl/static_vector.hpp index ee6b8c2..81a5efd 100644 --- a/include/rsl/static_vector.hpp +++ b/include/rsl/static_vector.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_STATIC_VECTOR_HPP +#define RSL_STATIC_VECTOR_HPP #include @@ -82,3 +83,5 @@ template } } // namespace rsl + +#endif // RSL_STATIC_VECTOR_HPP diff --git a/include/rsl/strong_type.hpp b/include/rsl/strong_type.hpp index a21d0d2..eb71ef7 100644 --- a/include/rsl/strong_type.hpp +++ b/include/rsl/strong_type.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_STRONG_TYPE_HPP +#define RSL_STRONG_TYPE_HPP #include @@ -39,3 +40,5 @@ class StrongType { }; } // namespace rsl + +#endif // RSL_STRONG_TYPE_HPP diff --git a/include/rsl/try.hpp b/include/rsl/try.hpp index 51980a6..ae44038 100644 --- a/include/rsl/try.hpp +++ b/include/rsl/try.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef RSL_TRY_HPP +#define RSL_TRY_HPP #include @@ -33,3 +34,5 @@ if (!_expected.has_value()) return tl::unexpected(_expected.error()); \ _expected.value(); \ }) + +#endif // RSL_TRY_HPP diff --git a/src/random.cpp b/src/random.cpp index d613740..3449152 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -30,6 +30,7 @@ auto rng(std::seed_seq seed_sequence) -> std::mt19937& { } auto random_unit_quaternion() -> Eigen::Quaterniond { + // NOLINTNEXTLINE(modernize-use-std-numbers): RSL is documented as a C++17 library. static constexpr auto pi = 3.1415926535897932385; // From "Uniform Random Rotations", Ken Shoemake, Graphics Gems III, pg. 124-132 diff --git a/tests/queue.cpp b/tests/queue.cpp index 75f7cb8..68c685d 100644 --- a/tests/queue.cpp +++ b/tests/queue.cpp @@ -89,7 +89,7 @@ TEST_CASE("rsl::Queue") { for (auto& producer : producers) producer.join(); for (auto& consumer : consumers) consumer.join(); - CHECK(queue.size() == thread_count * item_count - items_removed); + CHECK(queue.size() == (thread_count * item_count) - items_removed); } } }