meta: make meta_template_node context aware

This commit is contained in:
Michele Caini
2022-10-05 12:15:19 +02:00
parent 9c969fb6ac
commit 9ee084fc40
2 changed files with 8 additions and 6 deletions

View File

@@ -1129,7 +1129,8 @@ public:
* @return The tag for the class template of the underlying type.
*/
[[nodiscard]] inline meta_type template_type() const noexcept {
return node.templ.type ? meta_type{node.templ.type()} : meta_type{};
const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
return node.templ.type ? meta_type{node.templ.type(ctx_TODO)} : meta_type{};
}
/**
@@ -1138,7 +1139,8 @@ public:
* @return The type of the i-th template argument of a type.
*/
[[nodiscard]] inline meta_type template_arg(const size_type index) const noexcept {
return index < template_arity() ? meta_type{node.templ.arg(index)} : meta_type{};
const auto &ctx_TODO = internal::meta_context::from(locator<meta_ctx>::value_or());
return index < template_arity() ? meta_type{node.templ.arg(ctx_TODO, index)} : meta_type{};
}
/**

View File

@@ -102,8 +102,8 @@ struct meta_template_node {
using size_type = std::size_t;
size_type arity{0u};
meta_type_node (*type)() noexcept {};
meta_type_node (*arg)(const size_type) noexcept {};
meta_type_node (*type)(const meta_context &) noexcept {};
meta_type_node (*arg)(const meta_context &, const size_type) noexcept {};
};
struct meta_type_descriptor {
@@ -224,8 +224,8 @@ template<typename Type>
if constexpr(is_complete_v<meta_template_traits<Type>>) {
node.templ = meta_template_node{
meta_template_traits<Type>::args_type::size,
&resolve_TODO<typename meta_template_traits<Type>::class_type>,
+[](const std::size_t index) noexcept { return meta_arg_node_TODO(typename meta_template_traits<Type>::args_type{}, index); }};
&resolve<typename meta_template_traits<Type>::class_type>,
+[](const meta_context &context, const std::size_t index) noexcept { return meta_arg_node(typename meta_template_traits<Type>::args_type{}, context, index); }};
}
return node;