Browse Source

type_traits: updated choice utility (template variable)

Michele Caini 6 years ago
parent
commit
6a656a1b0a
1 changed files with 13 additions and 5 deletions
  1. 13 5
      src/entt/core/type_traits.hpp

+ 13 - 5
src/entt/core/type_traits.hpp

@@ -13,20 +13,28 @@ namespace entt {
 
 /**
  * @brief Utility class to disambiguate overloaded functions.
- * @tparam N Current step.
+ * @tparam N Number of choices available.
  */
 template<std::size_t N>
-struct choice
+struct choice_t
         // Unfortunately, doxygen cannot parse such a construct.
         /*! @cond TURN_OFF_DOXYGEN */
-        : choice<N-1>
+        : choice_t<N-1>
         /*! @endcond TURN_OFF_DOXYGEN */
 {};
 
 
-/*! @copybrief choice */
+/*! @copybrief choice_t */
 template<>
-struct choice<0> {};
+struct choice_t<0> {};
+
+
+/**
+ * @brief Variable template for the choice trick.
+ * @tparam N Number of choices available.
+ */
+template<std::size_t N>
+constexpr choice_t<N> choice{};
 
 
 /*! @brief A class to use to push around lists of types, nothing more. */