meta no longer uses named types

This commit is contained in:
Michele Caini
2019-12-01 17:25:38 +01:00
parent eb4689d2f1
commit 5be1bf7d82
2 changed files with 8 additions and 36 deletions

View File

@@ -381,7 +381,13 @@ class meta_factory<Type> {
return node && (node->identifier == identifier || duplicate(identifier, node->next));
}
auto record(const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT {
public:
/**
* @brief Extends a meta type by assigning it an identifier.
* @param identifier Unique identifier.
* @return An extended meta factory for the given type.
*/
auto type(const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT {
auto * const node = internal::meta_info<Type>::resolve();
ENTT_ASSERT(!duplicate(identifier, *internal::meta_info<>::global));
@@ -393,32 +399,6 @@ class meta_factory<Type> {
return meta_factory<Type, Type>{&node->prop};
}
public:
/**
* @brief Extends a meta type by assigning it an identifier.
*
* This function is intended only for unnamed types.
*
* @param identifier Unique identifier.
* @return An extended meta factory for the given type.
*/
auto type(const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT {
static_assert(!is_named_type_v<Type>);
return record(identifier);
}
/**
* @brief Extends a meta type by assigning it an identifier.
*
* This function is intended only for named types
*
* @return An extended meta factory for the given type.
*/
auto type() ENTT_NOEXCEPT {
static_assert(is_named_type_v<Type>);
return record(named_type_traits_t<Type>::value);
}
/**
* @brief Assigns a meta base to a meta type.
*

View File

@@ -264,15 +264,7 @@ struct meta_node<Type> {
}
};
if constexpr(is_named_type_v<Type>) {
auto *candidate = internal::find_if([](const auto *curr) {
return curr->identifier == named_type_traits_v<Type>;
}, *meta_node<>::global);
return candidate ? candidate : &node;
} else {
return &node;
}
return &node;
}
};