[meta] How do you assign to an instance of a type through entt::meta_any? #1235
-
In my example, I have an instance of an enum class which I am unsuccessfully trying to set through entt::meta_any. I would like to know how it is done. enum class Foo
{
BAR = 1,
BAZ = 2,
};
auto value = Foo::BAZ;
auto meta = entt::forward_as_meta(value);
// Returns false
bool succeeded = meta.type().set({}, value, Foo::BAR); The full runnable code can be found here: https://godbolt.org/z/4PTj9nefT I just cannot figure out how to set The tests only seem to test the case where data members are set. Likewise, the docs don't mention it explicitly. None of the discussions or issues I've looked at mentioned anything similar as well. I expect that this is either a limitation that I'm not aware of (and so I'd have to register an assignment function at runtime), or for a simple solution to have been hiding under my nose the whole time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
.set
is used to work with (meta) members. Your value is an integral type. What you're looking for is likelymeta.assign(Foo::BAR)
.