diff options
| author | untodesu <kirill@untode.su> | 2025-03-15 16:22:09 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-03-15 16:22:09 +0500 |
| commit | 3bf42c6ff3805a0d42bbc661794a95ff31bedc26 (patch) | |
| tree | 05049955847504808d6bed2bb7b155f8b03807bb /deps/include/entt/core/ident.hpp | |
| parent | 02294547dcde0d4ad76e229106702261e9f10a51 (diff) | |
| download | voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.tar.bz2 voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.zip | |
Add whatever I was working on for the last month
Diffstat (limited to 'deps/include/entt/core/ident.hpp')
| -rw-r--r-- | deps/include/entt/core/ident.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/deps/include/entt/core/ident.hpp b/deps/include/entt/core/ident.hpp new file mode 100644 index 0000000..5944ea2 --- /dev/null +++ b/deps/include/entt/core/ident.hpp @@ -0,0 +1,35 @@ +#ifndef ENTT_CORE_IDENT_HPP
+#define ENTT_CORE_IDENT_HPP
+
+#include <cstddef>
+#include <type_traits>
+#include <utility>
+#include "fwd.hpp"
+#include "type_traits.hpp"
+
+namespace entt {
+
+/**
+ * @brief Type integral identifiers.
+ * @tparam Type List of types for which to generate identifiers.
+ */
+template<typename... Type>
+class ident {
+ template<typename Curr, std::size_t... Index>
+ [[nodiscard]] static constexpr id_type get(std::index_sequence<Index...>) noexcept {
+ static_assert((std::is_same_v<Curr, Type> || ...), "Invalid type");
+ return (0 + ... + (std::is_same_v<Curr, type_list_element_t<Index, type_list<std::decay_t<Type>...>>> ? id_type{Index} : id_type{}));
+ }
+
+public:
+ /*! @brief Unsigned integer type. */
+ using value_type = id_type;
+
+ /*! @brief Statically generated unique identifier for the given type. */
+ template<typename Curr>
+ static constexpr value_type value = get<std::decay_t<Curr>>(std::index_sequence_for<Type...>{});
+};
+
+} // namespace entt
+
+#endif
|
