meta: better support to rvalue references for forward_as_meta

This commit is contained in:
Michele Caini
2022-10-08 19:00:13 +02:00
parent b16cefd534
commit 4b10981d75
2 changed files with 2 additions and 2 deletions

View File

@@ -564,7 +564,7 @@ meta_any make_meta(Args &&...args) {
*/
template<typename Type>
meta_any forward_as_meta(Type &&value) {
return meta_any{std::in_place_type<std::conditional_t<std::is_rvalue_reference_v<Type>, std::decay_t<Type>, Type>>, std::forward<Type>(value)};
return meta_any{std::in_place_type<Type>, std::forward<Type>(value)};
}
/**

View File

@@ -1365,9 +1365,9 @@ TEST_F(MetaAny, MakeMeta) {
TEST_F(MetaAny, ForwardAsMeta) {
int value = 42;
auto any = entt::forward_as_meta(std::move(value));
auto ref = entt::forward_as_meta(value);
auto cref = entt::forward_as_meta(std::as_const(value));
auto any = entt::forward_as_meta(std::move(value));
ASSERT_TRUE(any);
ASSERT_TRUE(ref);