From 8a591ce76910e0d429a325d9c7a2e0400770f463 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 15 Jun 2026 22:27:12 +0300 Subject: [PATCH] added nodiscard message --- include/omath/utility/color.hpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/omath/utility/color.hpp b/include/omath/utility/color.hpp index 0f848ee..8e6db59 100644 --- a/include/omath/utility/color.hpp +++ b/include/omath/utility/color.hpp @@ -34,13 +34,13 @@ namespace omath m_value.clamp(0.f, 1.f); } constexpr explicit Color() noexcept = default; - [[nodiscard]] + [[nodiscard("color result should not be discarded")]] constexpr static Color from_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a) noexcept { return Color(Vector4(r, g, b, a) / 255.f); } - [[nodiscard]] + [[nodiscard("color result should not be discarded")]] constexpr static Color from_hsv(float hue, const float saturation, const float value) noexcept { float r{}, g{}, b{}; @@ -80,13 +80,13 @@ namespace omath return {r, g, b, 1.f}; } - [[nodiscard]] + [[nodiscard("color result should not be discarded")]] constexpr static Color from_hsv(const Hsv& hsv) noexcept { return from_hsv(hsv.hue, hsv.saturation, hsv.value); } - [[nodiscard]] + [[nodiscard("hsv result should not be discarded")]] constexpr Hsv to_hsv() const noexcept { Hsv hsv_data; @@ -141,33 +141,33 @@ namespace omath *this = from_hsv(hsv); } - [[nodiscard]] + [[nodiscard("blended color result should not be discarded")]] constexpr Color blend(const Color& other, float ratio) const noexcept { ratio = std::clamp(ratio, 0.f, 1.f); return Color(this->m_value * (1.f - ratio) + other.m_value * ratio); } - [[nodiscard]] static constexpr Color red() + [[nodiscard("color result should not be discarded")]] static constexpr Color red() { return {1.f, 0.f, 0.f, 1.f}; } - [[nodiscard]] static constexpr Color green() + [[nodiscard("color result should not be discarded")]] static constexpr Color green() { return {0.f, 1.f, 0.f, 1.f}; } - [[nodiscard]] static constexpr Color blue() + [[nodiscard("color result should not be discarded")]] static constexpr Color blue() { return {0.f, 0.f, 1.f, 1.f}; } #ifdef OMATH_IMGUI_INTEGRATION - [[nodiscard]] + [[nodiscard("ImColor result should not be discarded")]] ImColor to_im_color() const noexcept { return {m_value.to_im_vec4()}; } #endif - [[nodiscard]] std::string to_string() const noexcept + [[nodiscard("string result should not be discarded")]] std::string to_string() const noexcept { return std::format("[r:{}, g:{}, b:{}, a:{}]", static_cast(m_value.x * 255.f), @@ -175,24 +175,24 @@ namespace omath static_cast(m_value.z * 255.f), static_cast(m_value.w * 255.f)); } - [[nodiscard]] std::string to_rgbf_string() const noexcept + [[nodiscard("string result should not be discarded")]] std::string to_rgbf_string() const noexcept { return std::format("[r:{}, g:{}, b:{}, a:{}]", m_value.x, m_value.y, m_value.z, m_value.w); } - [[nodiscard]] std::string to_hsv_string() const noexcept + [[nodiscard("string result should not be discarded")]] std::string to_hsv_string() const noexcept { const auto [hue, saturation, value] = to_hsv(); return std::format("[h:{}, s:{}, v:{}]", hue, saturation, value); } - [[nodiscard]] std::wstring to_wstring() const noexcept + [[nodiscard("wide string result should not be discarded")]] std::wstring to_wstring() const noexcept { const auto ascii_string = to_string(); return {ascii_string.cbegin(), ascii_string.cend()}; } // ReSharper disable once CppInconsistentNaming - [[nodiscard]] std::u8string to_u8string() const noexcept + [[nodiscard("UTF-8 string result should not be discarded")]] std::u8string to_u8string() const noexcept { const auto ascii_string = to_string(); return {ascii_string.cbegin(), ascii_string.cend()}; @@ -254,4 +254,4 @@ struct std::formatter // NOLINT(*-dcl58-cpp) std::unreachable(); } -}; \ No newline at end of file +};