|
|
@@ -16,167 +16,231 @@
|
|
|
namespace entt {
|
|
|
|
|
|
|
|
|
+namespace internal {
|
|
|
+
|
|
|
+
|
|
|
+template<typename Container, template<typename> class... Trait>
|
|
|
+struct container_traits: public Trait<Container>... {};
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * @brief Meta sequence container traits for `std::vector`s of any type.
|
|
|
- * @tparam Type The type of elements.
|
|
|
- * @tparam Args Other arguments.
|
|
|
+ * @brief Basic STL-compatible container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
*/
|
|
|
-template<typename Type, typename... Args>
|
|
|
-struct meta_sequence_container_traits<std::vector<Type, Args...>> {
|
|
|
- /*! @brief Iterator type of the sequence container. */
|
|
|
- using iterator = typename std::vector<Type, Args...>::iterator;
|
|
|
+template<typename Container>
|
|
|
+struct basic_container {
|
|
|
+ /*! @brief Iterator type of the container. */
|
|
|
+ using iterator = typename Container::iterator;
|
|
|
/*! @brief Unsigned integer type. */
|
|
|
- using size_type = typename std::vector<Type, Args...>::size_type;
|
|
|
- /*! @brief Value type of the sequence container. */
|
|
|
- using value_type = typename std::vector<Type, Args...>::value_type;
|
|
|
+ using size_type = typename Container::size_type;
|
|
|
+ /*! @brief Value type of the container. */
|
|
|
+ using value_type = typename Container::value_type;
|
|
|
|
|
|
/**
|
|
|
- * @brief Returns the size of given a container.
|
|
|
- * @param vec The container of which to return the size.
|
|
|
+ * @brief Returns the size of the given container.
|
|
|
+ * @param cont The container for which to return the size.
|
|
|
* @return The size of the given container.
|
|
|
*/
|
|
|
- [[nodiscard]] static size_type size(const std::vector<Type, Args...> &vec) ENTT_NOEXCEPT {
|
|
|
- return vec.size();
|
|
|
+ [[nodiscard]] static size_type size(const Container &cont) ENTT_NOEXCEPT {
|
|
|
+ return cont.size();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @brief Resizes a given container to contain a certain number of elements.
|
|
|
- * @param vec The container to resize.
|
|
|
- * @param sz The new size of the container.
|
|
|
- * @return True in case of success, false otherwise.
|
|
|
+ * @brief Returns an iterator to the first element of the given container.
|
|
|
+ * @param cont The container for which to return the iterator.
|
|
|
+ * @return An iterator to the first element of the given container.
|
|
|
*/
|
|
|
- [[nodiscard]] static bool resize(std::vector<Type, Args...> &vec, size_type sz) {
|
|
|
- return (vec.resize(sz), true);
|
|
|
+ [[nodiscard]] static iterator begin(Container &cont) {
|
|
|
+ return cont.begin();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @brief Clears the content of a given container.
|
|
|
- * @param vec The container of which to clear the content.
|
|
|
- * @return True in case of success, false otherwise.
|
|
|
+ * @brief Returns an iterator past the last element of the given container.
|
|
|
+ * @param cont The container for which to return the iterator.
|
|
|
+ * @return An iterator past the last element of the given container.
|
|
|
*/
|
|
|
- [[nodiscard]] static bool clear(std::vector<Type, Args...> &vec) {
|
|
|
- return vec.clear(), true;
|
|
|
+ [[nodiscard]] static iterator end(Container &cont) {
|
|
|
+ return cont.end();
|
|
|
}
|
|
|
+};
|
|
|
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the first element of a given container.
|
|
|
- * @param vec The container of which to return the iterator.
|
|
|
- * @return An iterator to the first element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator begin(std::vector<Type, Args...> &vec) {
|
|
|
- return vec.begin();
|
|
|
- }
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Basic STL-compatible associative container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct basic_associative_container {
|
|
|
+ /*! @brief Key type of the sequence container. */
|
|
|
+ using key_type = typename Container::key_type;
|
|
|
|
|
|
/**
|
|
|
- * @brief Returns an iterator past the last element of a given container.
|
|
|
- * @param vec The container of which to return the iterator.
|
|
|
- * @return An iterator past the last element of the given container.
|
|
|
+ * @brief Returns an iterator to the element with key equivalent to the given
|
|
|
+ * one, if any.
|
|
|
+ * @param cont The container in which to search for the element.
|
|
|
+ * @param key The key of the element to search.
|
|
|
+ * @return An iterator to the element with the given key, if any.
|
|
|
*/
|
|
|
- [[nodiscard]] static iterator end(std::vector<Type, Args...> &vec) {
|
|
|
- return vec.end();
|
|
|
+ [[nodiscard]] static typename Container::iterator find(Container &cont, const key_type &key) {
|
|
|
+ return cont.find(key);
|
|
|
}
|
|
|
+};
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Basic STL-compatible dynamic container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct basic_dynamic_container {
|
|
|
/**
|
|
|
- * @brief Inserts an element at a specified location of a given container.
|
|
|
- * @param vec The container in which to insert the element.
|
|
|
- * @param it Iterator before which the element will be inserted.
|
|
|
- * @param value Element value to insert.
|
|
|
- * @return A pair consisting of an iterator to the inserted element (in case
|
|
|
- * of success) and a bool denoting whether the insertion took place.
|
|
|
+ * @brief Clears the content of the given container.
|
|
|
+ * @param cont The container for which to clear the content.
|
|
|
+ * @return True in case of success, false otherwise.
|
|
|
*/
|
|
|
- [[nodiscard]] static std::pair<iterator, bool> insert(std::vector<Type, Args...> &vec, iterator it, const Type &value) {
|
|
|
- return { vec.insert(it, value), true };
|
|
|
+ [[nodiscard]] static bool clear(Container &cont) {
|
|
|
+ return cont.clear(), true;
|
|
|
}
|
|
|
+};
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Basic STL-compatible dynamic associative container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct basic_dynamic_associative_container {
|
|
|
/**
|
|
|
- * @brief Removes the specified element from a given container.
|
|
|
- * @param vec The container from which to remove the element.
|
|
|
- * @param it Iterator to the element to remove.
|
|
|
- * @return A pair consisting of an iterator following the last removed
|
|
|
- * element (in case of success) and a bool denoting whether the insertion
|
|
|
- * took place.
|
|
|
+ * @brief Removes the specified element from the given container.
|
|
|
+ * @param cont The container from which to remove the element.
|
|
|
+ * @param key The element to remove.
|
|
|
+ * @return A bool denoting whether the removal took place.
|
|
|
*/
|
|
|
- [[nodiscard]] static std::pair<iterator, bool> erase(std::vector<Type, Args...> &vec, iterator it) {
|
|
|
- return { vec.erase(it), true };
|
|
|
+ [[nodiscard]] static bool erase(Container &cont, const typename Container::key_type &key) {
|
|
|
+ const auto sz = cont.size();
|
|
|
+ return cont.erase(key) != sz;
|
|
|
}
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Basic STL-compatible sequence container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct basic_sequence_container {
|
|
|
/**
|
|
|
- * @brief Returns a reference to the element at a specified location of a
|
|
|
+ * @brief Returns a reference to the element at the specified location of the
|
|
|
* given container (no bounds checking is performed).
|
|
|
- * @param vec The container from which to get the element.
|
|
|
+ * @param cont The container from which to get the element.
|
|
|
* @param pos The position of the element to return.
|
|
|
* @return A reference to the requested element.
|
|
|
*/
|
|
|
- [[nodiscard]] static Type & get(std::vector<Type, Args...> &vec, size_type pos) {
|
|
|
- return vec[pos];
|
|
|
+ [[nodiscard]] static typename Container::value_type & get(Container &cont, typename Container::size_type pos) {
|
|
|
+ return cont[pos];
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @brief Meta sequence container traits for `std::array`s of any type.
|
|
|
- * @tparam Type The type of elements.
|
|
|
- * @tparam N The number of elements.
|
|
|
+ * @brief STL-compatible dynamic associative key-only container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
*/
|
|
|
-template<typename Type, auto N>
|
|
|
-struct meta_sequence_container_traits<std::array<Type, N>> {
|
|
|
- /*! @brief Iterator type of the sequence container. */
|
|
|
- using iterator = typename std::array<Type, N>::iterator;
|
|
|
- /*! @brief Unsigned integer type. */
|
|
|
- using size_type = typename std::array<Type, N>::size_type;
|
|
|
- /*! @brief Value type of the sequence container. */
|
|
|
- using value_type = typename std::array<Type, N>::value_type;
|
|
|
+template<typename Container>
|
|
|
+struct dynamic_associative_key_only_container {
|
|
|
+ /**
|
|
|
+ * @brief Inserts an element into the given container.
|
|
|
+ * @param cont The container in which to insert the element.
|
|
|
+ * @param key The element to insert.
|
|
|
+ * @return A bool denoting whether the insertion took place.
|
|
|
+ */
|
|
|
+ [[nodiscard]] static bool insert(Container &cont, const typename Container::key_type &key) {
|
|
|
+ return cont.insert(key).second;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
+/**
|
|
|
+ * @brief STL-compatible dynamic key-value associative container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct dynamic_associative_key_value_container {
|
|
|
/**
|
|
|
- * @brief Returns the size of given a container.
|
|
|
- * @param arr The container of which to return the size.
|
|
|
- * @return The size of the given container.
|
|
|
+ * @brief Inserts an element (a key/value pair) into the given container.
|
|
|
+ * @param cont The container in which to insert the element.
|
|
|
+ * @param key The key of the element to insert.
|
|
|
+ * @param value The value of the element to insert.
|
|
|
+ * @return A bool denoting whether the insertion took place.
|
|
|
*/
|
|
|
- [[nodiscard]] static size_type size(const std::array<Type, N> &arr) ENTT_NOEXCEPT {
|
|
|
- return arr.size();
|
|
|
+ [[nodiscard]] static bool insert(Container &cont, const typename Container::key_type &key, const typename Container::mapped_type &value) {
|
|
|
+ return cont.insert(std::make_pair(key, value)).second;
|
|
|
}
|
|
|
+};
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief STL-compatible dynamic sequence container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct dynamic_sequence_container {
|
|
|
/**
|
|
|
- * @brief Does nothing.
|
|
|
- * @return False to indicate failure in all cases.
|
|
|
+ * @brief Resizes the given container to contain the given number of elements.
|
|
|
+ * @param cont The container to resize.
|
|
|
+ * @param sz The new size of the container.
|
|
|
+ * @return True in case of success, false otherwise.
|
|
|
*/
|
|
|
- [[nodiscard]] static bool resize(const std::array<Type, N> &, size_type) {
|
|
|
- return false;
|
|
|
+ [[nodiscard]] static bool resize(Container &cont, typename Container::size_type sz) {
|
|
|
+ return (cont.resize(sz), true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @brief Does nothing.
|
|
|
- * @return False to indicate failure in all cases.
|
|
|
+ * @brief Inserts an element at the specified location of the given container.
|
|
|
+ * @param cont The container into which to insert the element.
|
|
|
+ * @param it Iterator before which the element will be inserted.
|
|
|
+ * @param value Element value to insert.
|
|
|
+ * @return A pair consisting of an iterator to the inserted element (in case
|
|
|
+ * of success) and a bool denoting whether the insertion took place.
|
|
|
*/
|
|
|
- [[nodiscard]] static bool clear(const std::array<Type, N> &) {
|
|
|
- return false;
|
|
|
+ [[nodiscard]] static std::pair<typename Container::iterator, bool> insert(Container &cont, typename Container::iterator it, const typename Container::value_type &value) {
|
|
|
+ return { cont.insert(it, value), true };
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @brief Returns an iterator to the first element of a given container.
|
|
|
- * @param arr The container of which to return the iterator.
|
|
|
- * @return An iterator to the first element of the given container.
|
|
|
+ * @brief Removes the element at the specified location from the given container.
|
|
|
+ * @param cont The container from which to remove the element.
|
|
|
+ * @param it Iterator to the element to remove.
|
|
|
+ * @return A pair consisting of an iterator following the last removed
|
|
|
+ * element (in case of success) and a bool denoting whether the insertion
|
|
|
+ * took place.
|
|
|
*/
|
|
|
- [[nodiscard]] static iterator begin(std::array<Type, N> &arr) {
|
|
|
- return arr.begin();
|
|
|
+ [[nodiscard]] static std::pair<typename Container::iterator, bool> erase(Container &cont, typename Container::iterator it) {
|
|
|
+ return { cont.erase(it), true };
|
|
|
}
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
+/**
|
|
|
+ * @brief STL-compatible fixed sequence container traits
|
|
|
+ * @tparam Container The type of the container.
|
|
|
+ */
|
|
|
+template<typename Container>
|
|
|
+struct fixed_sequence_container {
|
|
|
/**
|
|
|
- * @brief Returns an iterator past the last element of a given container.
|
|
|
- * @param arr The container of which to return the iterator.
|
|
|
- * @return An iterator past the last element of the given container.
|
|
|
+ * @brief Does nothing.
|
|
|
+ * @return False to indicate failure in all cases.
|
|
|
*/
|
|
|
- [[nodiscard]] static iterator end(std::array<Type, N> &arr) {
|
|
|
- return arr.end();
|
|
|
+ [[nodiscard]] static bool resize(const Container &, typename Container::size_type) {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @brief Does nothing.
|
|
|
- * @return A pair consisting of an invalid iterator and a false value to
|
|
|
- * indicate failure in all cases.
|
|
|
+ * @return False to indicate failure in all cases.
|
|
|
*/
|
|
|
- [[nodiscard]] static std::pair<iterator, bool> insert(const std::array<Type, N> &, iterator, const Type &) {
|
|
|
- return { {}, false };
|
|
|
+ [[nodiscard]] static bool clear(const Container &) {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -184,23 +248,57 @@ struct meta_sequence_container_traits<std::array<Type, N>> {
|
|
|
* @return A pair consisting of an invalid iterator and a false value to
|
|
|
* indicate failure in all cases.
|
|
|
*/
|
|
|
- [[nodiscard]] static std::pair<iterator, bool> erase(const std::array<Type, N> &, iterator) {
|
|
|
+ [[nodiscard]] static std::pair<typename Container::iterator, bool> insert(const Container &, typename Container::iterator, const typename Container::value_type &) {
|
|
|
return { {}, false };
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @brief Returns a reference to the element at a specified location of a
|
|
|
- * given container (no bounds checking is performed).
|
|
|
- * @param arr The container from which to get the element.
|
|
|
- * @param pos The position of the element to return.
|
|
|
- * @return A reference to the requested element.
|
|
|
+ * @brief Does nothing.
|
|
|
+ * @return A pair consisting of an invalid iterator and a false value to
|
|
|
+ * indicate failure in all cases.
|
|
|
*/
|
|
|
- [[nodiscard]] static Type & get(std::array<Type, N> &arr, size_type pos) {
|
|
|
- return arr[pos];
|
|
|
+ [[nodiscard]] static std::pair<typename Container::iterator, bool> erase(const Container &, typename Container::iterator) {
|
|
|
+ return { {}, false };
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Meta sequence container traits for `std::vector`s of any type.
|
|
|
+ * @tparam Type The type of elements.
|
|
|
+ * @tparam Args Other arguments.
|
|
|
+ */
|
|
|
+template<typename Type, typename... Args>
|
|
|
+struct meta_sequence_container_traits<std::vector<Type, Args...>>
|
|
|
+ : internal::container_traits<
|
|
|
+ std::vector<Type, Args...>,
|
|
|
+ internal::basic_container,
|
|
|
+ internal::basic_dynamic_container,
|
|
|
+ internal::basic_sequence_container,
|
|
|
+ internal::dynamic_sequence_container
|
|
|
+ >
|
|
|
+{};
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Meta sequence container traits for `std::array`s of any type.
|
|
|
+ * @tparam Type The type of elements.
|
|
|
+ * @tparam N The number of elements.
|
|
|
+ */
|
|
|
+template<typename Type, auto N>
|
|
|
+struct meta_sequence_container_traits<std::array<Type, N>>
|
|
|
+ : internal::container_traits<
|
|
|
+ std::array<Type, N>,
|
|
|
+ internal::basic_container,
|
|
|
+ internal::basic_sequence_container,
|
|
|
+ internal::fixed_sequence_container
|
|
|
+ >
|
|
|
+{};
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @brief Meta associative container traits for `std::map`s of any type.
|
|
|
* @tparam Key The key type of elements.
|
|
|
@@ -208,86 +306,18 @@ struct meta_sequence_container_traits<std::array<Type, N>> {
|
|
|
* @tparam Args Other arguments.
|
|
|
*/
|
|
|
template<typename Key, typename Value, typename... Args>
|
|
|
-struct meta_associative_container_traits<std::map<Key, Value, Args...>> {
|
|
|
- /*! @brief Iterator type of the associative container. */
|
|
|
- using iterator = typename std::map<Key, Value, Args...>::iterator;
|
|
|
- /*! @brief Unsigned integer type. */
|
|
|
- using size_type = typename std::map<Key, Value, Args...>::size_type;
|
|
|
- /*! @brief Key type of the sequence container. */
|
|
|
- using key_type = typename std::map<Key, Value, Args...>::key_type;
|
|
|
+struct meta_associative_container_traits<std::map<Key, Value, Args...>>
|
|
|
+ : internal::container_traits<
|
|
|
+ std::map<Key, Value, Args...>,
|
|
|
+ internal::basic_container,
|
|
|
+ internal::basic_associative_container,
|
|
|
+ internal::basic_dynamic_container,
|
|
|
+ internal::basic_dynamic_associative_container,
|
|
|
+ internal::dynamic_associative_key_value_container
|
|
|
+ >
|
|
|
+{
|
|
|
/*! @brief Mapped type of the sequence container. */
|
|
|
using mapped_type = typename std::map<Key, Value, Args...>::mapped_type;
|
|
|
- /*! @brief Value type of the sequence container. */
|
|
|
- using value_type = typename std::map<Key, Value, Args...>::value_type;
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns the size of given a container.
|
|
|
- * @param map The container of which to return the size.
|
|
|
- * @return The size of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static size_type size(const std::map<Key, Value, Args...> &map) ENTT_NOEXCEPT {
|
|
|
- return map.size();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Clears the content of a given container.
|
|
|
- * @param map The container of which to clear the content.
|
|
|
- * @return True in case of success, false otherwise.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool clear(std::map<Key, Value, Args...> &map) {
|
|
|
- return map.clear(), true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the first element of a given container.
|
|
|
- * @param map The container of which to return the iterator.
|
|
|
- * @return An iterator to the first element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator begin(std::map<Key, Value, Args...> &map) {
|
|
|
- return map.begin();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator past the last element of a given container.
|
|
|
- * @param map The container of which to return the iterator.
|
|
|
- * @return An iterator past the last element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator end(std::map<Key, Value, Args...> &map) {
|
|
|
- return map.end();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Inserts an element (a key/value pair) into a given container.
|
|
|
- * @param map The container in which to insert the element.
|
|
|
- * @param key The key of the element to insert.
|
|
|
- * @param value The value of the element to insert.
|
|
|
- * @return A bool denoting whether the insertion took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool insert(std::map<Key, Value, Args...> &map, const key_type &key, const mapped_type &value) {
|
|
|
- return map.insert(std::make_pair(key, value)).second;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Removes the specified element from a given container.
|
|
|
- * @param map The container from which to remove the element.
|
|
|
- * @param key The key of the element to remove.
|
|
|
- * @return A bool denoting whether the removal took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool erase(std::map<Key, Value, Args...> &map, const key_type &key) {
|
|
|
- const auto sz = map.size();
|
|
|
- return map.erase(key) != sz;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the element with key equivalent to a given
|
|
|
- * one, if any.
|
|
|
- * @param map The container in which to search for the element.
|
|
|
- * @param key The key of the element to search.
|
|
|
- * @return An iterator to the element with the given key, if any.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator find(std::map<Key, Value, Args...> &map, const key_type &key) {
|
|
|
- return map.find(key);
|
|
|
- }
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -299,86 +329,18 @@ struct meta_associative_container_traits<std::map<Key, Value, Args...>> {
|
|
|
* @tparam Args Other arguments.
|
|
|
*/
|
|
|
template<typename Key, typename Value, typename... Args>
|
|
|
-struct meta_associative_container_traits<std::unordered_map<Key, Value, Args...>> {
|
|
|
- /*! @brief Iterator type of the associative container. */
|
|
|
- using iterator = typename std::unordered_map<Key, Value, Args...>::iterator;
|
|
|
- /*! @brief Unsigned integer type. */
|
|
|
- using size_type = typename std::unordered_map<Key, Value, Args...>::size_type;
|
|
|
- /*! @brief Key type of the sequence container. */
|
|
|
- using key_type = typename std::unordered_map<Key, Value, Args...>::key_type;
|
|
|
+struct meta_associative_container_traits<std::unordered_map<Key, Value, Args...>>
|
|
|
+ : internal::container_traits<
|
|
|
+ std::unordered_map<Key, Value, Args...>,
|
|
|
+ internal::basic_container,
|
|
|
+ internal::basic_associative_container,
|
|
|
+ internal::basic_dynamic_container,
|
|
|
+ internal::basic_dynamic_associative_container,
|
|
|
+ internal::dynamic_associative_key_value_container
|
|
|
+ >
|
|
|
+{
|
|
|
/*! @brief Mapped type of the sequence container. */
|
|
|
using mapped_type = typename std::unordered_map<Key, Value, Args...>::mapped_type;
|
|
|
- /*! @brief Value type of the sequence container. */
|
|
|
- using value_type = typename std::unordered_map<Key, Value, Args...>::value_type;
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns the size of given a container.
|
|
|
- * @param map The container of which to return the size.
|
|
|
- * @return The size of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static size_type size(const std::unordered_map<Key, Value, Args...> &map) ENTT_NOEXCEPT {
|
|
|
- return map.size();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Clears the content of a given container.
|
|
|
- * @param map The container of which to clear the content.
|
|
|
- * @return True in case of success, false otherwise.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool clear(std::unordered_map<Key, Value, Args...> &map) {
|
|
|
- return map.clear(), true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the first element of a given container.
|
|
|
- * @param map The container of which to return the iterator.
|
|
|
- * @return An iterator to the first element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator begin(std::unordered_map<Key, Value, Args...> &map) {
|
|
|
- return map.begin();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator past the last element of a given container.
|
|
|
- * @param map The container of which to return the iterator.
|
|
|
- * @return An iterator past the last element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator end(std::unordered_map<Key, Value, Args...> &map) {
|
|
|
- return map.end();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Inserts an element (a key/value pair) into a given container.
|
|
|
- * @param map The container in which to insert the element.
|
|
|
- * @param key The key of the element to insert.
|
|
|
- * @param value The value of the element to insert.
|
|
|
- * @return A bool denoting whether the insertion took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool insert(std::unordered_map<Key, Value, Args...> &map, const key_type &key, const mapped_type &value) {
|
|
|
- return map.insert(std::make_pair(key, value)).second;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Removes the specified element from a given container.
|
|
|
- * @param map The container from which to remove the element.
|
|
|
- * @param key The key of the element to remove.
|
|
|
- * @return A bool denoting whether the removal took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool erase(std::unordered_map<Key, Value, Args...> &map, const key_type &key) {
|
|
|
- const auto sz = map.size();
|
|
|
- return map.erase(key) != sz;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the element with key equivalent to a given
|
|
|
- * one, if any.
|
|
|
- * @param map The container in which to search for the element.
|
|
|
- * @param key The key of the element to search.
|
|
|
- * @return An iterator to the element with the given key, if any.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator find(std::unordered_map<Key, Value, Args...> &map, const key_type &key) {
|
|
|
- return map.find(key);
|
|
|
- }
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -388,83 +350,16 @@ struct meta_associative_container_traits<std::unordered_map<Key, Value, Args...>
|
|
|
* @tparam Args Other arguments.
|
|
|
*/
|
|
|
template<typename Key, typename... Args>
|
|
|
-struct meta_associative_container_traits<std::set<Key, Args...>> {
|
|
|
- /*! @brief Iterator type of the associative container. */
|
|
|
- using iterator = typename std::set<Key, Args...>::iterator;
|
|
|
- /*! @brief Unsigned integer type. */
|
|
|
- using size_type = typename std::set<Key, Args...>::size_type;
|
|
|
- /*! @brief Key type of the sequence container. */
|
|
|
- using key_type = typename std::set<Key, Args...>::key_type;
|
|
|
- /*! @brief Value type of the sequence container. */
|
|
|
- using value_type = typename std::set<Key, Args...>::value_type;
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns the size of given a container.
|
|
|
- * @param set The container of which to return the size.
|
|
|
- * @return The size of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static size_type size(const std::set<Key, Args...> &set) ENTT_NOEXCEPT {
|
|
|
- return set.size();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Clears the content of a given container.
|
|
|
- * @param set The container of which to clear the content.
|
|
|
- * @return True in case of success, false otherwise.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool clear(std::set<Key, Args...> &set) {
|
|
|
- return set.clear(), true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the first element of a given container.
|
|
|
- * @param set The container of which to return the iterator.
|
|
|
- * @return An iterator to the first element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator begin(std::set<Key, Args...> &set) {
|
|
|
- return set.begin();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator past the last element of a given container.
|
|
|
- * @param set The container of which to return the iterator.
|
|
|
- * @return An iterator past the last element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator end(std::set<Key, Args...> &set) {
|
|
|
- return set.end();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Inserts an element into a given container.
|
|
|
- * @param set The container in which to insert the element.
|
|
|
- * @param key The element to insert.
|
|
|
- * @return A bool denoting whether the insertion took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool insert(std::set<Key, Args...> &set, const key_type &key) {
|
|
|
- return set.insert(key).second;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Removes the specified element from a given container.
|
|
|
- * @param set The container from which to remove the element.
|
|
|
- * @param key The element to remove.
|
|
|
- * @return A bool denoting whether the removal took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool erase(std::set<Key, Args...> &set, const key_type &key) {
|
|
|
- const auto sz = set.size();
|
|
|
- return set.erase(key) != sz;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to a given element, if any.
|
|
|
- * @param set The container in which to search for the element.
|
|
|
- * @param key The element to search.
|
|
|
- * @return An iterator to the given element, if any.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator find(std::set<Key, Args...> &set, const key_type &key) {
|
|
|
- return set.find(key);
|
|
|
- }
|
|
|
-};
|
|
|
+struct meta_associative_container_traits<std::set<Key, Args...>>
|
|
|
+ : internal::container_traits<
|
|
|
+ std::set<Key, Args...>,
|
|
|
+ internal::basic_container,
|
|
|
+ internal::basic_associative_container,
|
|
|
+ internal::basic_dynamic_container,
|
|
|
+ internal::basic_dynamic_associative_container,
|
|
|
+ internal::dynamic_associative_key_only_container
|
|
|
+ >
|
|
|
+{};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -474,83 +369,16 @@ struct meta_associative_container_traits<std::set<Key, Args...>> {
|
|
|
* @tparam Args Other arguments.
|
|
|
*/
|
|
|
template<typename Key, typename... Args>
|
|
|
-struct meta_associative_container_traits<std::unordered_set<Key, Args...>> {
|
|
|
- /*! @brief Iterator type of the associative container. */
|
|
|
- using iterator = typename std::unordered_set<Key, Args...>::iterator;
|
|
|
- /*! @brief Unsigned integer type. */
|
|
|
- using size_type = typename std::unordered_set<Key, Args...>::size_type;
|
|
|
- /*! @brief Key type of the sequence container. */
|
|
|
- using key_type = typename std::unordered_set<Key, Args...>::key_type;
|
|
|
- /*! @brief Value type of the sequence container. */
|
|
|
- using value_type = typename std::unordered_set<Key, Args...>::value_type;
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns the size of given a container.
|
|
|
- * @param set The container of which to return the size.
|
|
|
- * @return The size of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static size_type size(const std::unordered_set<Key, Args...> &set) ENTT_NOEXCEPT {
|
|
|
- return set.size();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Clears the content of a given container.
|
|
|
- * @param set The container of which to clear the content.
|
|
|
- * @return True in case of success, false otherwise.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool clear(std::unordered_set<Key, Args...> &set) {
|
|
|
- return set.clear(), true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to the first element of a given container.
|
|
|
- * @param set The container of which to return the iterator.
|
|
|
- * @return An iterator to the first element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator begin(std::unordered_set<Key, Args...> &set) {
|
|
|
- return set.begin();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator past the last element of a given container.
|
|
|
- * @param set The container of which to return the iterator.
|
|
|
- * @return An iterator past the last element of the given container.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator end(std::unordered_set<Key, Args...> &set) {
|
|
|
- return set.end();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Inserts an element into a given container.
|
|
|
- * @param set The container in which to insert the element.
|
|
|
- * @param key The element to insert.
|
|
|
- * @return A bool denoting whether the insertion took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool insert(std::unordered_set<Key, Args...> &set, const key_type &key) {
|
|
|
- return set.insert(key).second;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Removes the specified element from a given container.
|
|
|
- * @param set The container from which to remove the element.
|
|
|
- * @param key The element to remove.
|
|
|
- * @return A bool denoting whether the removal took place.
|
|
|
- */
|
|
|
- [[nodiscard]] static bool erase(std::unordered_set<Key, Args...> &set, const key_type &key) {
|
|
|
- const auto sz = set.size();
|
|
|
- return set.erase(key) != sz;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns an iterator to a given element, if any.
|
|
|
- * @param set The container in which to search for the element.
|
|
|
- * @param key The element to search.
|
|
|
- * @return An iterator to the given element, if any.
|
|
|
- */
|
|
|
- [[nodiscard]] static iterator find(std::unordered_set<Key, Args...> &set, const key_type &key) {
|
|
|
- return set.find(key);
|
|
|
- }
|
|
|
-};
|
|
|
+struct meta_associative_container_traits<std::unordered_set<Key, Args...>>
|
|
|
+ : internal::container_traits<
|
|
|
+ std::unordered_set<Key, Args...>,
|
|
|
+ internal::basic_container,
|
|
|
+ internal::basic_associative_container,
|
|
|
+ internal::basic_dynamic_container,
|
|
|
+ internal::basic_dynamic_associative_container,
|
|
|
+ internal::dynamic_associative_key_only_container
|
|
|
+ >
|
|
|
+{};
|
|
|
|
|
|
|
|
|
}
|