meta: review meta containers' begin/end functions
This commit is contained in:
@@ -133,24 +133,24 @@ struct basic_meta_sequence_container_traits {
|
||||
* @brief Returns a possibly const iterator to the beginning.
|
||||
* @param area The context to pass to the newly created iterator.
|
||||
* @param container Opaque pointer to a container of the given type.
|
||||
* @param as_const True for const-only containers, false otherwise.
|
||||
* @param as_const Const opaque pointer fallback.
|
||||
* @return An iterator to the first element of the container.
|
||||
*/
|
||||
static iterator begin(const meta_ctx &area, const void *container, const bool as_const) {
|
||||
return as_const ? iterator{area, static_cast<const Type *>(container)->begin()}
|
||||
: iterator{area, static_cast<Type *>(const_cast<void *>(container))->begin()};
|
||||
static iterator begin(const meta_ctx &area, void *container, const void *as_const) {
|
||||
return container ? iterator{area, static_cast<Type *>(container)->begin()}
|
||||
: iterator{area, static_cast<const Type *>(as_const)->begin()};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a possibly const iterator to the end.
|
||||
* @param area The context to pass to the newly created iterator.
|
||||
* @param container Opaque pointer to a container of the given type.
|
||||
* @param as_const True for const-only containers, false otherwise.
|
||||
* @param as_const Const opaque pointer fallback.
|
||||
* @return An iterator that is past the last element of the container.
|
||||
*/
|
||||
static iterator end(const meta_ctx &area, const void *container, const bool as_const) {
|
||||
return as_const ? iterator{area, static_cast<const Type *>(container)->end()}
|
||||
: iterator{area, static_cast<Type *>(const_cast<void *>(container))->end()};
|
||||
static iterator end(const meta_ctx &area, void *container, const void *as_const) {
|
||||
return container ? iterator{area, static_cast<Type *>(container)->end()}
|
||||
: iterator{area, static_cast<const Type *>(as_const)->end()};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,24 +247,24 @@ struct basic_meta_associative_container_traits {
|
||||
* @brief Returns a possibly const iterator to the beginning.
|
||||
* @param area The context to pass to the newly created iterator.
|
||||
* @param container Opaque pointer to a container of the given type.
|
||||
* @param as_const True for const-only containers, false otherwise.
|
||||
* @param as_const Const opaque pointer fallback.
|
||||
* @return An iterator to the first element of the container.
|
||||
*/
|
||||
static iterator begin(const meta_ctx &area, const void *container, const bool as_const) {
|
||||
return as_const ? iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(container)->begin()}
|
||||
: iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(const_cast<void *>(container))->begin()};
|
||||
static iterator begin(const meta_ctx &area, void *container, const void *as_const) {
|
||||
return container ? iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(container)->begin()}
|
||||
: iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(as_const)->begin()};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a possibly const iterator to the end.
|
||||
* @param area The context to pass to the newly created iterator.
|
||||
* @param container Opaque pointer to a container of the given type.
|
||||
* @param as_const True for const-only containers, false otherwise.
|
||||
* @param as_const Const opaque pointer fallback.
|
||||
* @return An iterator that is past the last element of the container.
|
||||
*/
|
||||
static iterator end(const meta_ctx &area, const void *container, const bool as_const) {
|
||||
return as_const ? iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(container)->end()}
|
||||
: iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(const_cast<void *>(container))->end()};
|
||||
static iterator end(const meta_ctx &area, void *container, const void *as_const) {
|
||||
return container ? iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(container)->end()}
|
||||
: iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(as_const)->end()};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,13 +296,13 @@ struct basic_meta_associative_container_traits {
|
||||
* @brief Finds an element with a given key.
|
||||
* @param area The context to pass to the newly created iterator.
|
||||
* @param container Opaque pointer to a container of the given type.
|
||||
* @param as_const True for const-only containers, false otherwise.
|
||||
* @param as_const Const opaque pointer fallback.
|
||||
* @param key Opaque key value of an element to search for.
|
||||
* @return An iterator to the element with the given key, if any.
|
||||
*/
|
||||
static iterator find(const meta_ctx &area, const void *container, const bool as_const, const void *key) {
|
||||
return as_const ? iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(container)->find(*static_cast<const typename Type::key_type *>(key))}
|
||||
: iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(const_cast<void *>(container))->find(*static_cast<const typename Type::key_type *>(key))};
|
||||
static iterator find(const meta_ctx &area, void *container, const void *as_const, const void *key) {
|
||||
return container ? iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(container)->find(*static_cast<const typename Type::key_type *>(key))}
|
||||
: iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(as_const)->find(*static_cast<const typename Type::key_type *>(key))};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ private:
|
||||
bool (*clear_fn)(void *){};
|
||||
bool (*reserve_fn)(void *, const size_type){};
|
||||
bool (*resize_fn)(void *, const size_type){};
|
||||
iterator (*begin_fn)(const meta_ctx &, const void *, const bool){};
|
||||
iterator (*end_fn)(const meta_ctx &, const void *, const bool){};
|
||||
iterator (*begin_fn)(const meta_ctx &, void *, const void *){};
|
||||
iterator (*end_fn)(const meta_ctx &, void *, const void *){};
|
||||
iterator (*insert_fn)(const meta_ctx &, void *, const void *, const void *, const iterator &){};
|
||||
iterator (*erase_fn)(const meta_ctx &, void *, const iterator &){};
|
||||
const void *cdata{};
|
||||
@@ -171,11 +171,11 @@ private:
|
||||
size_type (*size_fn)(const void *){};
|
||||
bool (*clear_fn)(void *){};
|
||||
bool (*reserve_fn)(void *, const size_type){};
|
||||
iterator (*begin_fn)(const meta_ctx &, const void *, const bool){};
|
||||
iterator (*end_fn)(const meta_ctx &, const void *, const bool){};
|
||||
iterator (*begin_fn)(const meta_ctx &, void *, const void *){};
|
||||
iterator (*end_fn)(const meta_ctx &, void *, const void *){};
|
||||
bool (*insert_fn)(void *, const void *, const void *){};
|
||||
size_type (*erase_fn)(void *, const void *){};
|
||||
iterator (*find_fn)(const meta_ctx &, const void *, const bool, const void *){};
|
||||
iterator (*find_fn)(const meta_ctx &, void *, const void *, const void *){};
|
||||
const void *cdata{};
|
||||
void *data{};
|
||||
};
|
||||
@@ -1848,7 +1848,7 @@ inline bool meta_sequence_container::reserve(const size_type sz) {
|
||||
* @return An iterator to the first element of the container.
|
||||
*/
|
||||
[[nodiscard]] inline meta_sequence_container::iterator meta_sequence_container::begin() {
|
||||
return begin_fn(*ctx, cdata, data == nullptr);
|
||||
return begin_fn(*ctx, data, cdata);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1856,7 +1856,7 @@ inline bool meta_sequence_container::reserve(const size_type sz) {
|
||||
* @return An iterator that is past the last element of the container.
|
||||
*/
|
||||
[[nodiscard]] inline meta_sequence_container::iterator meta_sequence_container::end() {
|
||||
return end_fn(*ctx, cdata, data == nullptr);
|
||||
return end_fn(*ctx, data, cdata);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1950,12 +1950,12 @@ inline bool meta_associative_container::reserve(const size_type sz) {
|
||||
|
||||
/*! @copydoc meta_sequence_container::begin */
|
||||
[[nodiscard]] inline meta_associative_container::iterator meta_associative_container::begin() {
|
||||
return begin_fn(*ctx, cdata, data == nullptr);
|
||||
return begin_fn(*ctx, data, cdata);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_sequence_container::end */
|
||||
[[nodiscard]] inline meta_associative_container::iterator meta_associative_container::end() {
|
||||
return end_fn(*ctx, cdata, data == nullptr);
|
||||
return end_fn(*ctx, data, cdata);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1985,9 +1985,7 @@ inline meta_associative_container::size_type meta_associative_container::erase(m
|
||||
* @return An iterator to the element with the given key, if any.
|
||||
*/
|
||||
[[nodiscard]] inline meta_associative_container::iterator meta_associative_container::find(meta_any key) {
|
||||
return key.allow_cast(meta_type{*ctx, key_type_node(internal::meta_context::from(*ctx))})
|
||||
? find_fn(*ctx, cdata, data == nullptr, std::as_const(key).data())
|
||||
: iterator{*ctx};
|
||||
return key.allow_cast(meta_type{*ctx, key_type_node(internal::meta_context::from(*ctx))}) ? find_fn(*ctx, data, cdata, std::as_const(key).data()) : iterator{*ctx};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user