소스 검색

type_traits: updated choice utility (template variable)

Michele Caini 6 년 전
부모
커밋
6a656a1b0a
1개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  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. */