meta: removed dependency on <algorithm> from internal.hpp
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
#define ENTT_META_INTERNAL_HPP
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include "../core/attribute.h"
|
||||
@@ -200,13 +200,19 @@ template<auto Member, typename Op>
|
||||
auto find_if(const Op &op, const meta_type_node *node)
|
||||
-> std::decay_t<decltype(node->*Member)> {
|
||||
std::decay_t<decltype(node->*Member)> ret = nullptr;
|
||||
meta_range range{node->*Member};
|
||||
|
||||
if(ret = std::find_if(range.begin(), range.end(), [&op](const auto &curr) { return op(&curr); }).operator->(); !ret) {
|
||||
meta_range base{node->base};
|
||||
for(auto &&curr: meta_range{node->*Member}) {
|
||||
if(op(&curr)) {
|
||||
ret = &curr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(auto first = base.begin(), last = base.end(); first != last && !ret; ++first) {
|
||||
ret = find_if<Member>(op, first->type());
|
||||
if(!ret) {
|
||||
for(auto &&curr: meta_range{node->base}) {
|
||||
if(ret = find_if<Member>(op, curr.type()); ret) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,15 +43,16 @@ class meta_any {
|
||||
}
|
||||
|
||||
static void destroy(meta_any &any) {
|
||||
const auto * const node = internal::meta_info<Type>::resolve();
|
||||
if(node->dtor) { node->dtor->invoke(any.instance); }
|
||||
if(const auto * const node = internal::meta_info<Type>::resolve(); node->dtor) {
|
||||
node->dtor->invoke(any.instance);
|
||||
}
|
||||
|
||||
delete static_cast<Type *>(any.instance);
|
||||
}
|
||||
|
||||
static void copy(meta_any &to, const meta_any &from) {
|
||||
auto *instance = new Type{*static_cast<const Type *>(from.instance)};
|
||||
new (&to.storage) Type *{instance};
|
||||
to.instance = instance;
|
||||
to.instance = new Type{*static_cast<const Type *>(from.instance)};
|
||||
new (&to.storage) Type *{static_cast<Type *>(to.instance)};
|
||||
}
|
||||
|
||||
static void steal(meta_any &to, meta_any &from) {
|
||||
@@ -68,8 +69,10 @@ class meta_any {
|
||||
}
|
||||
|
||||
static void destroy(meta_any &any) {
|
||||
const auto * const node = internal::meta_info<Type>::resolve();
|
||||
if(node->dtor) { node->dtor->invoke(any.instance); }
|
||||
if(const auto * const node = internal::meta_info<Type>::resolve(); node->dtor) {
|
||||
node->dtor->invoke(any.instance);
|
||||
}
|
||||
|
||||
static_cast<Type *>(any.instance)->~Type();
|
||||
}
|
||||
|
||||
@@ -114,11 +117,10 @@ public:
|
||||
node = internal::meta_info<Type>::resolve();
|
||||
|
||||
if constexpr(!std::is_void_v<Type>) {
|
||||
using traits_type = type_traits<std::remove_cv_t<std::remove_reference_t<Type>>>;
|
||||
traits_type::instance(*this, std::forward<Args>(args)...);
|
||||
destroy_fn = &traits_type::destroy;
|
||||
copy_fn = &traits_type::copy;
|
||||
steal_fn = &traits_type::steal;
|
||||
type_traits<Type>::instance(*this, std::forward<Args>(args)...);
|
||||
destroy_fn = &type_traits<Type>::destroy;
|
||||
copy_fn = &type_traits<Type>::copy;
|
||||
steal_fn = &type_traits<Type>::steal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,10 +160,6 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Move constructor.
|
||||
*
|
||||
* After move construction, instances that have been moved from are placed
|
||||
* in a valid but unspecified state.
|
||||
*
|
||||
* @param other The instance to move from.
|
||||
*/
|
||||
meta_any(meta_any &&other)
|
||||
|
||||
Reference in New Issue
Block a user