From e7f2343e0d64bbd3b2d12203b4df4abdba563751 Mon Sep 17 00:00:00 2001 From: Jiajun <75730859+T-rvw@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:55:01 +0800 Subject: [PATCH] Fix move temp const check (#261) --- private/Scene/Light.cpp | 4 ++-- public/Base/Template.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/private/Scene/Light.cpp b/private/Scene/Light.cpp index a1691f41..24ac0dc7 100644 --- a/private/Scene/Light.cpp +++ b/private/Scene/Light.cpp @@ -177,7 +177,7 @@ const cd::Point& Light::GetPosition() const return m_pLightImpl->GetPosition(); } -void Light::SetColor(const cd::Vec3f color) +void Light::SetColor(cd::Vec3f color) { m_pLightImpl->SetColor(cd::MoveTemp(color)); } @@ -207,7 +207,7 @@ const cd::Direction& Light::GetDirection() const return m_pLightImpl->GetDirection(); } -void Light::SetUp(const cd::Direction up) +void Light::SetUp(cd::Direction up) { m_pLightImpl->SetUp(cd::MoveTemp(up)); } diff --git a/public/Base/Template.h b/public/Base/Template.h index 94de276f..b8edb24d 100644 --- a/public/Base/Template.h +++ b/public/Base/Template.h @@ -12,9 +12,10 @@ namespace cd template [[nodiscard]] constexpr std::remove_reference_t&& MoveTemp(T&& value) noexcept { + using CastType = std::remove_reference_t; static_assert(std::is_lvalue_reference_v, "T is lvalue reference object."); - static_assert(!std::is_const_v, "For a const object, MoveTemp doesn't take effect."); - return static_cast&&>(value); + static_assert(!std::is_same_v, "For a const object, MoveTemp doesn't take effect."); + return static_cast(value); } } \ No newline at end of file