meta: make meta_conv_node context aware

This commit is contained in:
Michele Caini
2022-10-05 19:05:36 +02:00
parent e5c6559836
commit de3ecbdd28
3 changed files with 7 additions and 6 deletions

View File

@@ -184,7 +184,7 @@ public:
*info,
type_id<conv_type>().hash(),
internal::meta_conv_node{
+[](const void *instance) {
+[](const void *instance, const meta_ctx &ctx/*_TODO*/) {
return forward_as_meta(std::invoke(Candidate, *static_cast<const Type *>(instance)));
}});
@@ -209,7 +209,7 @@ public:
*info,
type_id<conv_type>().hash(),
internal::meta_conv_node{
+[](const void *instance) {
+[](const void *instance, const meta_ctx &ctx/*_TODO*/) {
return forward_as_meta(static_cast<To>(*static_cast<const Type *>(instance)));
}});

View File

@@ -1451,9 +1451,10 @@ bool meta_any::set(const id_type id, Type &&value) {
}
if(const auto *value = data(); node.details) {
auto &&ctx_TODO = locator<meta_ctx>::value_or();
auto &&context_TODO = internal::meta_context::from(ctx_TODO);
for(auto &&curr: node.details->base) {
auto &&ctx_TODO = locator<meta_ctx>::value_or();
auto &&context_TODO = internal::meta_context::from(ctx_TODO);
const auto &as_const = curr.second.type(context_TODO).from_void(nullptr, curr.second.cast(value), ctx_TODO);
if(auto other = as_const.allow_cast(type); other) {
@@ -1462,7 +1463,7 @@ bool meta_any::set(const id_type id, Type &&value) {
}
if(auto it = node.details->conv.find(type.info().hash()); it != node.details->conv.cend()) {
return it->second.conv(data());
return it->second.conv(data(), ctx_TODO);
}
}

View File

@@ -59,7 +59,7 @@ struct meta_base_node {
};
struct meta_conv_node {
meta_any (*conv)(const void *){};
meta_any (*conv)(const void *, const meta_ctx &){};
};
struct meta_ctor_node {