some consts here and there
This commit is contained in:
+14
-14
@@ -94,8 +94,8 @@ bool setter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any index
|
||||
using helper_type = meta_function_helper_t<decltype(Data)>;
|
||||
using data_type = std::tuple_element_t<!std::is_member_function_pointer_v<decltype(Data)>, typename helper_type::args_type>;
|
||||
static_assert(std::is_invocable_v<decltype(Data), Type &, data_type>);
|
||||
auto *clazz = meta_any{handle}.try_cast<Type>();
|
||||
auto *direct = value.try_cast<data_type>();
|
||||
auto * const clazz = meta_any{handle}.try_cast<Type>();
|
||||
auto * const direct = value.try_cast<data_type>();
|
||||
|
||||
if(clazz && (direct || value.convert<data_type>())) {
|
||||
std::invoke(Data, *clazz, direct ? *direct : value.cast<data_type>());
|
||||
@@ -104,19 +104,19 @@ bool setter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any index
|
||||
} else if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
|
||||
using data_type = std::remove_cv_t<std::remove_reference_t<decltype(std::declval<Type>().*Data)>>;
|
||||
static_assert(std::is_invocable_v<decltype(Data), Type *>);
|
||||
auto *clazz = meta_any{handle}.try_cast<Type>();
|
||||
auto * const clazz = meta_any{handle}.try_cast<Type>();
|
||||
|
||||
if constexpr(std::is_array_v<data_type>) {
|
||||
using underlying_type = std::remove_extent_t<data_type>;
|
||||
auto *direct = value.try_cast<underlying_type>();
|
||||
auto *idx = index.try_cast<std::size_t>();
|
||||
auto * const direct = value.try_cast<underlying_type>();
|
||||
auto * const idx = index.try_cast<std::size_t>();
|
||||
|
||||
if(clazz && idx && (direct || value.convert<underlying_type>())) {
|
||||
std::invoke(Data, clazz)[*idx] = direct ? *direct : value.cast<underlying_type>();
|
||||
accepted = true;
|
||||
}
|
||||
} else {
|
||||
auto *direct = value.try_cast<data_type>();
|
||||
auto * const direct = value.try_cast<data_type>();
|
||||
|
||||
if(clazz && (direct || value.convert<data_type>())) {
|
||||
std::invoke(Data, clazz) = (direct ? *direct : value.cast<data_type>());
|
||||
@@ -129,15 +129,15 @@ bool setter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any index
|
||||
|
||||
if constexpr(std::is_array_v<data_type>) {
|
||||
using underlying_type = std::remove_extent_t<data_type>;
|
||||
auto *direct = value.try_cast<underlying_type>();
|
||||
auto *idx = index.try_cast<std::size_t>();
|
||||
auto * const direct = value.try_cast<underlying_type>();
|
||||
auto * const idx = index.try_cast<std::size_t>();
|
||||
|
||||
if(idx && (direct || value.convert<underlying_type>())) {
|
||||
(*Data)[*idx] = (direct ? *direct : value.cast<underlying_type>());
|
||||
accepted = true;
|
||||
}
|
||||
} else {
|
||||
auto *direct = value.try_cast<data_type>();
|
||||
auto * const direct = value.try_cast<data_type>();
|
||||
|
||||
if(direct || value.convert<data_type>()) {
|
||||
*Data = (direct ? *direct : value.cast<data_type>());
|
||||
@@ -166,15 +166,15 @@ meta_any getter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any i
|
||||
|
||||
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>> || std::is_member_function_pointer_v<decltype(Data)>) {
|
||||
static_assert(std::is_invocable_v<decltype(Data), Type &>);
|
||||
auto *clazz = meta_any{handle}.try_cast<Type>();
|
||||
auto * const clazz = meta_any{handle}.try_cast<Type>();
|
||||
return clazz ? dispatch(std::invoke(Data, *clazz)) : meta_any{};
|
||||
} else if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
|
||||
using data_type = std::remove_cv_t<std::remove_reference_t<decltype(std::declval<Type>().*Data)>>;
|
||||
static_assert(std::is_invocable_v<decltype(Data), Type *>);
|
||||
auto *clazz = meta_any{handle}.try_cast<Type>();
|
||||
auto * const clazz = meta_any{handle}.try_cast<Type>();
|
||||
|
||||
if constexpr(std::is_array_v<data_type>) {
|
||||
auto *idx = index.try_cast<std::size_t>();
|
||||
auto * const idx = index.try_cast<std::size_t>();
|
||||
return (clazz && idx) ? dispatch(std::invoke(Data, clazz)[*idx]) : meta_any{};
|
||||
} else {
|
||||
return clazz ? dispatch(std::invoke(Data, clazz)) : meta_any{};
|
||||
@@ -183,7 +183,7 @@ meta_any getter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any i
|
||||
static_assert(std::is_pointer_v<std::decay_t<decltype(Data)>>);
|
||||
|
||||
if constexpr(std::is_array_v<std::remove_pointer_t<decltype(Data)>>) {
|
||||
auto *idx = index.try_cast<std::size_t>();
|
||||
auto * const idx = index.try_cast<std::size_t>();
|
||||
return idx ? dispatch((*Data)[*idx]) : meta_any{};
|
||||
} else {
|
||||
return dispatch(*Data);
|
||||
@@ -221,7 +221,7 @@ meta_any invoke([[maybe_unused]] meta_handle handle, meta_any *args, std::index_
|
||||
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Candidate)>>) {
|
||||
return (std::get<Indexes>(direct) && ...) ? dispatch(std::get<Indexes>(direct)...) : meta_any{};
|
||||
} else {
|
||||
auto *clazz = meta_any{handle}.try_cast<Type>();
|
||||
auto * const clazz = meta_any{handle}.try_cast<Type>();
|
||||
return (clazz && (std::get<Indexes>(direct) && ...)) ? dispatch(clazz, std::get<Indexes>(direct)...) : meta_any{};
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -216,7 +216,7 @@ auto find_if(Op op, const meta_type_node *node) ENTT_NOEXCEPT
|
||||
|
||||
template<typename Type>
|
||||
const Type * try_cast(const meta_type_node *node, void *instance) ENTT_NOEXCEPT {
|
||||
const auto *type = meta_info<Type>::resolve();
|
||||
const auto * const type = meta_info<Type>::resolve();
|
||||
void *ret = nullptr;
|
||||
|
||||
if(node == type) {
|
||||
@@ -293,8 +293,8 @@ class meta_any {
|
||||
}
|
||||
|
||||
static void destroy(void *instance) {
|
||||
auto *node = internal::meta_info<Type>::resolve();
|
||||
auto *actual = static_cast<Type *>(instance);
|
||||
auto * const node = internal::meta_info<Type>::resolve();
|
||||
auto * const actual = static_cast<Type *>(instance);
|
||||
[[maybe_unused]] const bool destroyed = node->meta().destroy(*actual);
|
||||
ENTT_ASSERT(destroyed);
|
||||
delete actual;
|
||||
@@ -307,7 +307,7 @@ class meta_any {
|
||||
}
|
||||
|
||||
static void * steal(storage_type &to, void *from, destroy_fn_type *) {
|
||||
auto *instance = static_cast<Type *>(from);
|
||||
auto * const instance = static_cast<Type *>(from);
|
||||
new (&to) Type *{instance};
|
||||
return instance;
|
||||
}
|
||||
@@ -321,8 +321,8 @@ class meta_any {
|
||||
}
|
||||
|
||||
static void destroy(void *instance) {
|
||||
auto *node = internal::meta_info<Type>::resolve();
|
||||
auto *actual = static_cast<Type *>(instance);
|
||||
auto * const node = internal::meta_info<Type>::resolve();
|
||||
auto * const actual = static_cast<Type *>(instance);
|
||||
[[maybe_unused]] const bool destroyed = node->meta().destroy(*actual);
|
||||
ENTT_ASSERT(destroyed);
|
||||
actual->~Type();
|
||||
@@ -333,7 +333,7 @@ class meta_any {
|
||||
}
|
||||
|
||||
static void * steal(storage_type &to, void *from, destroy_fn_type *destroy_fn) {
|
||||
void *instance = new (&to) Type{std::move(*static_cast<Type *>(from))};
|
||||
void * const instance = new (&to) Type{std::move(*static_cast<Type *>(from))};
|
||||
destroy_fn(from);
|
||||
return instance;
|
||||
}
|
||||
@@ -518,7 +518,7 @@ public:
|
||||
*/
|
||||
template<typename Type>
|
||||
const Type & cast() const ENTT_NOEXCEPT {
|
||||
auto *actual = try_cast<Type>();
|
||||
auto * const actual = try_cast<Type>();
|
||||
ENTT_ASSERT(actual);
|
||||
return *actual;
|
||||
}
|
||||
@@ -539,10 +539,10 @@ public:
|
||||
meta_any convert() const {
|
||||
meta_any any{};
|
||||
|
||||
if(const auto *type = internal::meta_info<Type>::resolve(); node == type) {
|
||||
if(const auto * const type = internal::meta_info<Type>::resolve(); node == type) {
|
||||
any = *static_cast<const Type *>(instance);
|
||||
} else {
|
||||
const auto *conv = internal::find_if<&internal::meta_type_node::conv>([type](auto *other) {
|
||||
const auto * const conv = internal::find_if<&internal::meta_type_node::conv>([type](auto *other) {
|
||||
return other->type() == type;
|
||||
}, node);
|
||||
|
||||
@@ -611,7 +611,7 @@ public:
|
||||
friend void swap(meta_any &lhs, meta_any &rhs) ENTT_NOEXCEPT {
|
||||
if(lhs.steal_fn && rhs.steal_fn) {
|
||||
storage_type buffer;
|
||||
auto *temp = lhs.steal_fn(buffer, lhs.instance, lhs.destroy_fn);
|
||||
auto * const temp = lhs.steal_fn(buffer, lhs.instance, lhs.destroy_fn);
|
||||
lhs.instance = rhs.steal_fn(lhs.storage, rhs.instance, rhs.destroy_fn);
|
||||
rhs.instance = lhs.steal_fn(rhs.storage, temp, lhs.destroy_fn);
|
||||
} else if(lhs.steal_fn) {
|
||||
@@ -1034,7 +1034,7 @@ public:
|
||||
template<typename Key>
|
||||
std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
|
||||
prop(Key &&key) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
const auto * const curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
return candidate->key() == key;
|
||||
}, node->prop);
|
||||
|
||||
@@ -1299,7 +1299,7 @@ public:
|
||||
template<typename Key>
|
||||
std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
|
||||
prop(Key &&key) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
const auto * const curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
return candidate->key() == key;
|
||||
}, node->prop);
|
||||
|
||||
@@ -1468,7 +1468,7 @@ public:
|
||||
template<typename Key>
|
||||
std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
|
||||
prop(Key &&key) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
const auto * const curr = internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
return candidate->key() == key;
|
||||
}, node->prop);
|
||||
|
||||
@@ -1682,7 +1682,7 @@ public:
|
||||
* @return The meta base associated with the given identifier, if any.
|
||||
*/
|
||||
meta_base base(const ENTT_ID_TYPE identifier) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if<&internal::meta_type_node::base>([identifier](auto *candidate) {
|
||||
const auto * const curr = internal::find_if<&internal::meta_type_node::base>([identifier](auto *candidate) {
|
||||
return candidate->type()->identifier == identifier;
|
||||
}, node);
|
||||
|
||||
@@ -1717,7 +1717,7 @@ public:
|
||||
*/
|
||||
template<typename Type>
|
||||
meta_conv conv() const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if<&internal::meta_type_node::conv>([type = internal::meta_info<Type>::resolve()](auto *candidate) {
|
||||
const auto * const curr = internal::find_if<&internal::meta_type_node::conv>([type = internal::meta_info<Type>::resolve()](auto *candidate) {
|
||||
return candidate->type() == type;
|
||||
}, node);
|
||||
|
||||
@@ -1743,7 +1743,7 @@ public:
|
||||
*/
|
||||
template<typename... Args>
|
||||
meta_ctor ctor() const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::ctor<Args...>(std::make_index_sequence<sizeof...(Args)>{}, node);
|
||||
const auto * const curr = internal::ctor<Args...>(std::make_index_sequence<sizeof...(Args)>{}, node);
|
||||
return curr ? curr->meta() : meta_ctor{};
|
||||
}
|
||||
|
||||
@@ -1783,7 +1783,7 @@ public:
|
||||
* @return The meta data associated with the given identifier, if any.
|
||||
*/
|
||||
meta_data data(const ENTT_ID_TYPE identifier) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if<&internal::meta_type_node::data>([identifier](auto *candidate) {
|
||||
const auto * const curr = internal::find_if<&internal::meta_type_node::data>([identifier](auto *candidate) {
|
||||
return candidate->identifier == identifier;
|
||||
}, node);
|
||||
|
||||
@@ -1819,7 +1819,7 @@ public:
|
||||
* @return The meta function associated with the given identifier, if any.
|
||||
*/
|
||||
meta_func func(const ENTT_ID_TYPE identifier) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if<&internal::meta_type_node::func>([identifier](auto *candidate) {
|
||||
const auto * const curr = internal::find_if<&internal::meta_type_node::func>([identifier](auto *candidate) {
|
||||
return candidate->identifier == identifier;
|
||||
}, node);
|
||||
|
||||
@@ -1900,7 +1900,7 @@ public:
|
||||
template<typename Key>
|
||||
std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
|
||||
prop(Key &&key) const ENTT_NOEXCEPT {
|
||||
const auto *curr = internal::find_if<&internal::meta_type_node::prop>([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
const auto * const curr = internal::find_if<&internal::meta_type_node::prop>([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
|
||||
return candidate->key() == key;
|
||||
}, node);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user