Skip to content

[entt::meta] How do I safely insert a component instance into a registry with only its entt::meta_type info? #1223

Answered by skypjack
JuanDiegoMontoya asked this question in Q&A
Discussion options

You must be logged in to vote

This question has been asked many times and I think there are several discussions with different examples. Have you seen those already?
The main problem is that the registry cannot create a storage for you if it doesn't know the C++ type, and it's unknown when you invoke storage with a type info object.
Briefly, you've literally two options here: attach to the meta type a let's create the storage function to which you pass the registry, or set up a sort of emplace-or-replace function that returns the element wrapped in a meta_any by reference.
Let me know if you can't find a proper answer to your doubts and need more details. 👍

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@JuanDiegoMontoya
Comment options

@skypjack
Comment options

Answer selected by JuanDiegoMontoya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
discussion it sounds interesting, let's discuss it
2 participants