meta:
* avoid copies from meta_type::invoke (small perf improvement) * meta_handle::operator* no longer available * added meta_handle::operator bool
This commit is contained in:
@@ -792,11 +792,11 @@ struct meta_handle {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dereference operator for accessing the contained opaque object.
|
||||
* @return A meta any that shares a reference to an unmanaged object.
|
||||
* @brief Returns false if a handle is invalid, true otherwise.
|
||||
* @return False if the handle is invalid, true otherwise.
|
||||
*/
|
||||
[[nodiscard]] meta_any operator*() const {
|
||||
return any;
|
||||
[[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
|
||||
return static_cast<bool>(any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1550,7 +1550,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return (candidate && !ambiguous) ? candidate->invoke(instance, args) : meta_any{};
|
||||
return (candidate && !ambiguous) ? candidate->invoke(std::move(instance), args) : meta_any{};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -746,7 +746,7 @@ TEST_F(MetaAny, ConstConvert) {
|
||||
TEST_F(MetaAny, UnmanageableType) {
|
||||
unmanageable_t instance;
|
||||
entt::meta_any any{std::ref(instance)};
|
||||
entt::meta_any other = any;
|
||||
entt::meta_any other = as_ref(any);
|
||||
|
||||
std::swap(any, other);
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ TEST_F(MetaHandle, Functionalities) {
|
||||
clazz_t instance{};
|
||||
entt::meta_handle handle{};
|
||||
|
||||
ASSERT_FALSE(*handle);
|
||||
ASSERT_FALSE(handle);
|
||||
|
||||
handle = entt::meta_handle{instance};
|
||||
|
||||
ASSERT_TRUE(*handle);
|
||||
ASSERT_TRUE((*handle).invoke("incr"_hs));
|
||||
ASSERT_TRUE(handle);
|
||||
ASSERT_TRUE(handle->invoke("incr"_hs));
|
||||
ASSERT_EQ(instance.value, 1);
|
||||
|
||||
entt::meta_any any{std::ref(instance)};
|
||||
|
||||
Reference in New Issue
Block a user