File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 3131* allow passing arguments to meta setter/getter (we can fallback on meta invoke probably)
3232* FetchContent_Populate -> FetchContent_MakeAvailable warnings
3333* doc: IMPLICIT_DIR_DOCS for dir docs or \dir
34+ * meta non-const allow_cast overloads: (const int &) to (int &) is not allowed, but (const int &) to (double &) is allowed
35+ * improve non-const allow cast with in-place switch
Original file line number Diff line number Diff line change @@ -514,8 +514,8 @@ class meta_any {
514514 if constexpr (std::is_reference_v<Type> && !std::is_const_v<std::remove_reference_t <Type>>) {
515515 return meta_any{meta_ctx_arg, *ctx};
516516 } else {
517- auto other = internal::resolve<std:: remove_cv_t <std:: remove_reference_t <Type>>>( internal::meta_context::from (*ctx));
518- return allow_cast (meta_type{*ctx, other });
517+ // also support early return for performance reasons
518+ return ((node. info != nullptr ) && (*node. info == entt::type_id<Type>())) ? as_ref () : allow_cast (meta_type{*ctx, internal::resolve<std:: remove_cv_t <std:: remove_reference_t <Type>>>( internal::meta_context::from (*ctx)) });
519519 }
520520 }
521521
@@ -526,8 +526,9 @@ class meta_any {
526526 */
527527 template <typename Type>
528528 [[nodiscard]] bool allow_cast () {
529- auto other = internal::resolve<std::remove_cv_t <std::remove_reference_t <Type>>>(internal::meta_context::from (*ctx));
530- return allow_cast (meta_type{*ctx, other}) && (!(std::is_reference_v<Type> && !std::is_const_v<std::remove_reference_t <Type>>) || storage.data () != nullptr );
529+ // also support early return for performance reasons
530+ return (((node.info != nullptr ) && (*node.info == entt::type_id<Type>())) || allow_cast (meta_type{*ctx, internal::resolve<std::remove_cv_t <std::remove_reference_t <Type>>>(internal::meta_context::from (*ctx))}))
531+ && (!(std::is_reference_v<Type> && !std::is_const_v<std::remove_reference_t <Type>>) || storage.data () != nullptr );
531532 }
532533
533534 /* ! @copydoc any::emplace */
You can’t perform that action at this time.
0 commit comments