Kaynağa Gözat

type_info::id: family-like fallback

Michele Caini 6 yıl önce
ebeveyn
işleme
89635f6583
2 değiştirilmiş dosya ile 37 ekleme ve 5 silme
  1. 1 0
      TODO
  2. 36 5
      src/entt/core/type_info.hpp

+ 1 - 0
TODO

@@ -25,5 +25,6 @@
   - ::group improve, reduce code
   - ::group improve, reduce code
 
 
 * Mission: get rid of named types
 * Mission: get rid of named types
+  - make family-like fallback for type_info::id work across boundaries
   - update doc: dispatcher, emitter, registry, meta, across boundaries
   - update doc: dispatcher, emitter, registry, meta, across boundaries
   - review and suppress warnings, if any
   - review and suppress warnings, if any

+ 36 - 5
src/entt/core/type_info.hpp

@@ -15,22 +15,53 @@ namespace entt {
  */
  */
 template<typename Type, typename = void>
 template<typename Type, typename = void>
 struct type_info {
 struct type_info {
-#if defined _MSC_VER
     /**
     /**
      * @brief Returns the numeric representation of a given type.
      * @brief Returns the numeric representation of a given type.
      * @return The numeric representation of the given type.
      * @return The numeric representation of the given type.
      */
      */
+#if defined _MSC_VER
     static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
     static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
         return entt::hashed_string{__FUNCSIG__};
         return entt::hashed_string{__FUNCSIG__};
     }
     }
 #elif defined __GNUC__
 #elif defined __GNUC__
-    /**
-     * @brief Returns the numeric representation of a given type.
-     * @return The numeric representation of the given type.
-     */
     static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
     static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
         return entt::hashed_string{__PRETTY_FUNCTION__};
         return entt::hashed_string{__PRETTY_FUNCTION__};
     }
     }
+#else
+    static ENTT_ID_TYPE id() ENTT_NOEXCEPT;
+};
+
+
+/**
+ * @cond TURN_OFF_DOXYGEN
+ * Internal details not to be documented.
+ */
+
+
+namespace internal {
+
+
+struct type_id_generator {
+    static ENTT_ID_TYPE next() ENTT_NOEXCEPT {
+        static ENTT_ID_TYPE value{};
+        return value++;
+    }
+};
+
+
+}
+
+
+/**
+ * Internal details not to be documented.
+ * @endcond TURN_OFF_DOXYGEN
+ */
+
+
+template<typename Type, typename Cond>
+ENTT_ID_TYPE type_info<Type, Cond>::id() ENTT_NOEXCEPT {
+    static const ENTT_ID_TYPE value = internal::type_id_generator::next();
+    return value;
 #endif
 #endif
 };
 };