Skip to content

Commit

Permalink
refactor(core): use std::move instead of static_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 19, 2023
1 parent b11bb29 commit 2d42254
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/include/cubos/core/reflection/traits/fields.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ namespace cubos::core::reflection
/// @param pointer Field pointer.
/// @return Trait.
template <typename O, typename F>
FieldsTrait&& withField(const std::string& field, F O::*pointer)
FieldsTrait&& withField(const std::string& field, F O::*pointer) &&
{
return static_cast<FieldsTrait&&>(*this).withField(reflect<F>(), field, new AddressOfImpl<O, F>(pointer));
return std::move(*this).withField(reflect<F>(), field, new AddressOfImpl<O, F>(pointer));
}

/// @brief Gets the field with the given type.
Expand Down
2 changes: 1 addition & 1 deletion core/include/cubos/core/reflection/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace cubos::core::reflection
template <typename T>
Type& with(T trait)
{
return this->with(Type::id<T>(), new T(static_cast<T&&>(trait)),
return this->with(Type::id<T>(), new T(std::move(trait)),
[](void* trait) { delete static_cast<T*>(trait); });
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/cubos/core/reflection/traits/fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ FieldsTrait&& FieldsTrait::withField(const Type& type, std::string name, Address
mFirstField = field;
mLastField = field;
}
return static_cast<FieldsTrait&&>(*this);

return std::move(*this);
}

const FieldsTrait::Field* FieldsTrait::field(const std::string& name) const
Expand Down

0 comments on commit 2d42254

Please sign in to comment.