mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-13 11:17:06 +07:00
fix type duplication in the registry
This commit is contained in:
@@ -4163,92 +4163,79 @@ namespace meta_hpp::detail
|
||||
template < array_kind Array >
|
||||
[[nodiscard]] array_type resolve_array_type() {
|
||||
using array_t = std::remove_cv_t<Array>;
|
||||
static array_type type{ensure_type<array_type_data>(type_list<array_t>{})};
|
||||
return type;
|
||||
return array_type{ensure_type<array_type_data>(type_list<array_t>{})};
|
||||
}
|
||||
|
||||
template < class_kind Class >
|
||||
[[nodiscard]] class_type resolve_class_type() {
|
||||
using class_t = std::remove_cv_t<Class>;
|
||||
static class_type type{ensure_type<class_type_data>(type_list<class_t>{})};
|
||||
return type;
|
||||
return class_type{ensure_type<class_type_data>(type_list<class_t>{})};
|
||||
}
|
||||
|
||||
template < class_kind Class, typename... Args >
|
||||
[[nodiscard]] constructor_type resolve_constructor_type() {
|
||||
using class_t = std::remove_cv_t<Class>;
|
||||
static constructor_type type{ensure_type<constructor_type_data>(type_list<class_t>{}, type_list<Args...>{})};
|
||||
return type;
|
||||
return constructor_type{ensure_type<constructor_type_data>(type_list<class_t>{}, type_list<Args...>{})};
|
||||
}
|
||||
|
||||
template < class_kind Class >
|
||||
[[nodiscard]] destructor_type resolve_destructor_type() {
|
||||
using class_t = std::remove_cv_t<Class>;
|
||||
static destructor_type type{ensure_type<destructor_type_data>(type_list<class_t>{})};
|
||||
return type;
|
||||
return destructor_type{ensure_type<destructor_type_data>(type_list<class_t>{})};
|
||||
}
|
||||
|
||||
template < enum_kind Enum >
|
||||
[[nodiscard]] enum_type resolve_enum_type() {
|
||||
using enum_t = std::remove_cv_t<Enum>;
|
||||
static enum_type type{ensure_type<enum_type_data>(type_list<enum_t>{})};
|
||||
return type;
|
||||
return enum_type{ensure_type<enum_type_data>(type_list<enum_t>{})};
|
||||
}
|
||||
|
||||
template < function_kind Function >
|
||||
[[nodiscard]] function_type resolve_function_type() {
|
||||
using function_t = std::remove_cv_t<Function>;
|
||||
static function_type type{ensure_type<function_type_data>(type_list<function_t>{})};
|
||||
return type;
|
||||
return function_type{ensure_type<function_type_data>(type_list<function_t>{})};
|
||||
}
|
||||
|
||||
template < member_pointer_kind Member >
|
||||
[[nodiscard]] member_type resolve_member_type() {
|
||||
using member_t = std::remove_cv_t<Member>;
|
||||
static member_type type{ensure_type<member_type_data>(type_list<member_t>{})};
|
||||
return type;
|
||||
return member_type{ensure_type<member_type_data>(type_list<member_t>{})};
|
||||
}
|
||||
|
||||
template < method_pointer_kind Method >
|
||||
[[nodiscard]] method_type resolve_method_type() {
|
||||
using method_t = std::remove_cv_t<Method>;
|
||||
static method_type type{ensure_type<method_type_data>(type_list<method_t>{})};
|
||||
return type;
|
||||
return method_type{ensure_type<method_type_data>(type_list<method_t>{})};
|
||||
}
|
||||
|
||||
template < nullptr_kind Nullptr >
|
||||
[[nodiscard]] nullptr_type resolve_nullptr_type() {
|
||||
using nullptr_t = std::remove_cv_t<Nullptr>;
|
||||
static nullptr_type type{ensure_type<nullptr_type_data>(type_list<nullptr_t>{})};
|
||||
return type;
|
||||
return nullptr_type{ensure_type<nullptr_type_data>(type_list<nullptr_t>{})};
|
||||
}
|
||||
|
||||
template < number_kind Number >
|
||||
[[nodiscard]] number_type resolve_number_type() {
|
||||
using number_t = std::remove_cv_t<Number>;
|
||||
static number_type type{ensure_type<number_type_data>(type_list<number_t>{})};
|
||||
return type;
|
||||
return number_type{ensure_type<number_type_data>(type_list<number_t>{})};
|
||||
}
|
||||
|
||||
template < pointer_kind Pointer >
|
||||
[[nodiscard]] pointer_type resolve_pointer_type() {
|
||||
using pointer_t = std::remove_cv_t<Pointer>;
|
||||
static pointer_type type{ensure_type<pointer_type_data>(type_list<pointer_t>{})};
|
||||
return type;
|
||||
return pointer_type{ensure_type<pointer_type_data>(type_list<pointer_t>{})};
|
||||
}
|
||||
|
||||
template < reference_kind Reference >
|
||||
[[nodiscard]] reference_type resolve_reference_type() {
|
||||
using reference_t = std::remove_cv_t<Reference>;
|
||||
static reference_type type{ensure_type<reference_type_data>(type_list<reference_t>{})};
|
||||
return type;
|
||||
return reference_type{ensure_type<reference_type_data>(type_list<reference_t>{})};
|
||||
}
|
||||
|
||||
template < void_kind Void >
|
||||
[[nodiscard]] void_type resolve_void_type() {
|
||||
using void_t = std::remove_cv_t<Void>;
|
||||
static void_type type{ensure_type<void_type_data>(type_list<void_t>{})};
|
||||
return type;
|
||||
return void_type{ensure_type<void_type_data>(type_list<void_t>{})};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -4256,11 +4243,14 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename TypeData, typename... Args >
|
||||
TypeData* ensure_type(Args&&... args) {
|
||||
static auto data{std::make_unique<TypeData>(std::forward<Args>(args)...)};
|
||||
static auto data = [this](Args&&... args) {
|
||||
auto new_type_data = std::make_unique<TypeData>(META_HPP_FWD(args)...);
|
||||
|
||||
const locker lock;
|
||||
types_.emplace_back(data.get());
|
||||
types_.emplace_back(new_type_data.get());
|
||||
|
||||
return new_type_data;
|
||||
}(META_HPP_FWD(args)...);
|
||||
return data.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,92 +70,79 @@ namespace meta_hpp::detail
|
||||
template < array_kind Array >
|
||||
[[nodiscard]] array_type resolve_array_type() {
|
||||
using array_t = std::remove_cv_t<Array>;
|
||||
static array_type type{ensure_type<array_type_data>(type_list<array_t>{})};
|
||||
return type;
|
||||
return array_type{ensure_type<array_type_data>(type_list<array_t>{})};
|
||||
}
|
||||
|
||||
template < class_kind Class >
|
||||
[[nodiscard]] class_type resolve_class_type() {
|
||||
using class_t = std::remove_cv_t<Class>;
|
||||
static class_type type{ensure_type<class_type_data>(type_list<class_t>{})};
|
||||
return type;
|
||||
return class_type{ensure_type<class_type_data>(type_list<class_t>{})};
|
||||
}
|
||||
|
||||
template < class_kind Class, typename... Args >
|
||||
[[nodiscard]] constructor_type resolve_constructor_type() {
|
||||
using class_t = std::remove_cv_t<Class>;
|
||||
static constructor_type type{ensure_type<constructor_type_data>(type_list<class_t>{}, type_list<Args...>{})};
|
||||
return type;
|
||||
return constructor_type{ensure_type<constructor_type_data>(type_list<class_t>{}, type_list<Args...>{})};
|
||||
}
|
||||
|
||||
template < class_kind Class >
|
||||
[[nodiscard]] destructor_type resolve_destructor_type() {
|
||||
using class_t = std::remove_cv_t<Class>;
|
||||
static destructor_type type{ensure_type<destructor_type_data>(type_list<class_t>{})};
|
||||
return type;
|
||||
return destructor_type{ensure_type<destructor_type_data>(type_list<class_t>{})};
|
||||
}
|
||||
|
||||
template < enum_kind Enum >
|
||||
[[nodiscard]] enum_type resolve_enum_type() {
|
||||
using enum_t = std::remove_cv_t<Enum>;
|
||||
static enum_type type{ensure_type<enum_type_data>(type_list<enum_t>{})};
|
||||
return type;
|
||||
return enum_type{ensure_type<enum_type_data>(type_list<enum_t>{})};
|
||||
}
|
||||
|
||||
template < function_kind Function >
|
||||
[[nodiscard]] function_type resolve_function_type() {
|
||||
using function_t = std::remove_cv_t<Function>;
|
||||
static function_type type{ensure_type<function_type_data>(type_list<function_t>{})};
|
||||
return type;
|
||||
return function_type{ensure_type<function_type_data>(type_list<function_t>{})};
|
||||
}
|
||||
|
||||
template < member_pointer_kind Member >
|
||||
[[nodiscard]] member_type resolve_member_type() {
|
||||
using member_t = std::remove_cv_t<Member>;
|
||||
static member_type type{ensure_type<member_type_data>(type_list<member_t>{})};
|
||||
return type;
|
||||
return member_type{ensure_type<member_type_data>(type_list<member_t>{})};
|
||||
}
|
||||
|
||||
template < method_pointer_kind Method >
|
||||
[[nodiscard]] method_type resolve_method_type() {
|
||||
using method_t = std::remove_cv_t<Method>;
|
||||
static method_type type{ensure_type<method_type_data>(type_list<method_t>{})};
|
||||
return type;
|
||||
return method_type{ensure_type<method_type_data>(type_list<method_t>{})};
|
||||
}
|
||||
|
||||
template < nullptr_kind Nullptr >
|
||||
[[nodiscard]] nullptr_type resolve_nullptr_type() {
|
||||
using nullptr_t = std::remove_cv_t<Nullptr>;
|
||||
static nullptr_type type{ensure_type<nullptr_type_data>(type_list<nullptr_t>{})};
|
||||
return type;
|
||||
return nullptr_type{ensure_type<nullptr_type_data>(type_list<nullptr_t>{})};
|
||||
}
|
||||
|
||||
template < number_kind Number >
|
||||
[[nodiscard]] number_type resolve_number_type() {
|
||||
using number_t = std::remove_cv_t<Number>;
|
||||
static number_type type{ensure_type<number_type_data>(type_list<number_t>{})};
|
||||
return type;
|
||||
return number_type{ensure_type<number_type_data>(type_list<number_t>{})};
|
||||
}
|
||||
|
||||
template < pointer_kind Pointer >
|
||||
[[nodiscard]] pointer_type resolve_pointer_type() {
|
||||
using pointer_t = std::remove_cv_t<Pointer>;
|
||||
static pointer_type type{ensure_type<pointer_type_data>(type_list<pointer_t>{})};
|
||||
return type;
|
||||
return pointer_type{ensure_type<pointer_type_data>(type_list<pointer_t>{})};
|
||||
}
|
||||
|
||||
template < reference_kind Reference >
|
||||
[[nodiscard]] reference_type resolve_reference_type() {
|
||||
using reference_t = std::remove_cv_t<Reference>;
|
||||
static reference_type type{ensure_type<reference_type_data>(type_list<reference_t>{})};
|
||||
return type;
|
||||
return reference_type{ensure_type<reference_type_data>(type_list<reference_t>{})};
|
||||
}
|
||||
|
||||
template < void_kind Void >
|
||||
[[nodiscard]] void_type resolve_void_type() {
|
||||
using void_t = std::remove_cv_t<Void>;
|
||||
static void_type type{ensure_type<void_type_data>(type_list<void_t>{})};
|
||||
return type;
|
||||
return void_type{ensure_type<void_type_data>(type_list<void_t>{})};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -163,11 +150,14 @@ namespace meta_hpp::detail
|
||||
|
||||
template < typename TypeData, typename... Args >
|
||||
TypeData* ensure_type(Args&&... args) {
|
||||
static auto data{std::make_unique<TypeData>(std::forward<Args>(args)...)};
|
||||
static auto data = [this](Args&&... args) {
|
||||
auto new_type_data = std::make_unique<TypeData>(META_HPP_FWD(args)...);
|
||||
|
||||
const locker lock;
|
||||
types_.emplace_back(data.get());
|
||||
types_.emplace_back(new_type_data.get());
|
||||
|
||||
return new_type_data;
|
||||
}(META_HPP_FWD(args)...);
|
||||
return data.get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user