|
|
@@ -397,6 +397,58 @@ struct value_list_element<0u, value_list<Value, Other...>> {
|
|
|
template<std::size_t Index, typename List>
|
|
|
inline constexpr auto value_list_element_v = value_list_element<Index, List>::value;
|
|
|
|
|
|
+/*! @brief Primary template isn't defined on purpose. */
|
|
|
+template<auto, typename>
|
|
|
+struct value_list_index;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Provides compile-time type access to the values of a value list.
|
|
|
+ * @tparam Value Value to look for and for which to return the index.
|
|
|
+ * @tparam First First value provided by the value list.
|
|
|
+ * @tparam Other Other values provided by the value list.
|
|
|
+ */
|
|
|
+template<auto Value, auto First, auto... Other>
|
|
|
+struct value_list_index<Value, value_list<First, Other...>> {
|
|
|
+ /*! @brief Unsigned integer type. */
|
|
|
+ using value_type = std::size_t;
|
|
|
+ /*! @brief Compile-time position of the given value in the sublist. */
|
|
|
+ static constexpr value_type value = 1u + value_list_index<Value, value_list<Other...>>::value;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Provides compile-time type access to the values of a value list.
|
|
|
+ * @tparam Value Value to look for and for which to return the index.
|
|
|
+ * @tparam Other Other values provided by the value list.
|
|
|
+ */
|
|
|
+template<auto Value, auto... Other>
|
|
|
+struct value_list_index<Value, value_list<Value, Other...>> {
|
|
|
+ static_assert(value_list_index<Value, value_list<Other...>>::value == sizeof...(Other), "Non-unique type");
|
|
|
+ /*! @brief Unsigned integer type. */
|
|
|
+ using value_type = std::size_t;
|
|
|
+ /*! @brief Compile-time position of the given value in the sublist. */
|
|
|
+ static constexpr value_type value = 0u;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Provides compile-time type access to the values of a value list.
|
|
|
+ * @tparam Value Value to look for and for which to return the index.
|
|
|
+ */
|
|
|
+template<auto Value>
|
|
|
+struct value_list_index<Value, value_list<>> {
|
|
|
+ /*! @brief Unsigned integer type. */
|
|
|
+ using value_type = std::size_t;
|
|
|
+ /*! @brief Compile-time position of the given type in the sublist. */
|
|
|
+ static constexpr value_type value = 0u;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Helper variable template.
|
|
|
+ * @tparam List Value list.
|
|
|
+ * @tparam Value Value to look for and for which to return the index.
|
|
|
+ */
|
|
|
+template<auto Value, typename List>
|
|
|
+inline constexpr std::size_t value_list_index_v = value_list_index<Value, List>::value;
|
|
|
+
|
|
|
/**
|
|
|
* @brief Concatenates multiple value lists.
|
|
|
* @tparam Value Values provided by the first value list.
|