Просмотр исходного кода

type_traits: added support for the choice trick

Michele Caini 6 лет назад
Родитель
Сommit
71d0958398
1 измененных файлов с 19 добавлено и 0 удалено
  1. 19 0
      src/entt/core/type_traits.hpp

+ 19 - 0
src/entt/core/type_traits.hpp

@@ -2,6 +2,7 @@
 #define ENTT_CORE_TYPE_TRAITS_HPP
 
 
+#include <cstddef>
 #include <type_traits>
 #include "../config/config.h"
 #include "../core/hashed_string.hpp"
@@ -10,6 +11,24 @@
 namespace entt {
 
 
+/**
+ * @brief Utility class to disambiguate overloaded functions.
+ * @tparam N Current step.
+ */
+template<std::size_t N>
+struct choice
+        // Unfortunately, doxygen cannot parse such a construct.
+        /*! @cond TURN_OFF_DOXYGEN */
+        : choice<N-1>
+        /*! @endcond TURN_OFF_DOXYGEN */
+{};
+
+
+/*! @copybrief choice */
+template<>
+struct choice<0> {};
+
+
 /*! @brief A class to use to push around lists of types, nothing more. */
 template<typename...>
 struct type_list {};