Skip to content

Commit

Permalink
Fix move temp const check (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw authored Dec 11, 2023
1 parent 6e4b350 commit e7f2343
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions private/Scene/Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down
5 changes: 3 additions & 2 deletions public/Base/Template.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ namespace cd
template<typename T>
[[nodiscard]] constexpr std::remove_reference_t<T>&& MoveTemp(T&& value) noexcept
{
using CastType = std::remove_reference_t<T>;
static_assert(std::is_lvalue_reference_v<T>, "T is lvalue reference object.");
static_assert(!std::is_const_v<T>, "For a const object, MoveTemp doesn't take effect.");
return static_cast<std::remove_reference_t<T>&&>(value);
static_assert(!std::is_same_v<CastType&, const CastType&>, "For a const object, MoveTemp doesn't take effect.");
return static_cast<CastType&&>(value);
}

}

0 comments on commit e7f2343

Please sign in to comment.