meta: further reduce symbol size of meta seq traits ::size function

This commit is contained in:
Michele Caini
2023-06-29 12:07:21 +02:00
parent 7efbc3f72d
commit 5e7e4a4b11
2 changed files with 7 additions and 5 deletions

View File

@@ -49,9 +49,9 @@ struct basic_meta_sequence_container_traits {
return any_cast<const Type &>(container).size();
}
[[nodiscard]] static bool resize([[maybe_unused]] any &container, [[maybe_unused]] size_type sz) {
[[nodiscard]] static bool resize([[maybe_unused]] void *container, [[maybe_unused]] size_type sz) {
if constexpr(is_dynamic_sequence_container<Type>::value) {
any_cast<Type &>(container).resize(sz);
static_cast<Type *>(container)->resize(sz);
return true;
} else {
return false;

View File

@@ -74,7 +74,7 @@ private:
const meta_ctx *ctx{};
internal::meta_type_node (*value_type_node)(const internal::meta_context &){};
size_type (*size_fn)(const any &) noexcept {};
bool (*resize_fn)(any &, size_type){};
bool (*resize_fn)(void *, size_type){};
iterator (*iter_fn)(const meta_ctx &, any &, const bool){};
iterator (*insert_or_erase_fn)(const meta_ctx &, any &, const any &, meta_any &){};
any storage{};
@@ -1840,7 +1840,8 @@ private:
* @return True in case of success, false otherwise.
*/
inline bool meta_sequence_container::resize(const size_type sz) {
return storage.data() && resize_fn(storage, sz);
void *elem = storage.data();
return elem && resize_fn(elem, sz);
}
/**
@@ -1848,7 +1849,8 @@ inline bool meta_sequence_container::resize(const size_type sz) {
* @return True in case of success, false otherwise.
*/
inline bool meta_sequence_container::clear() {
return storage.data() && resize_fn(storage, 0u);
void *elem = storage.data();
return elem && resize_fn(elem, 0u);
}
/**