Commit f6a783ad authored by Daumantas Kavolis's avatar Daumantas Kavolis Committed by Victor Zverovich

fix `get`

parent ccc8f5db
...@@ -331,11 +331,12 @@ template <typename... Args> struct type_list {}; ...@@ -331,11 +331,12 @@ template <typename... Args> struct type_list {};
// Returns a reference to the argument at index N from [first, rest...]. // Returns a reference to the argument at index N from [first, rest...].
template <int N, typename T, typename... Args> template <int N, typename T, typename... Args>
const auto& get(const T& first, const Args&... rest) { constexpr const auto& get(const T& first, const Args&... rest) {
if constexpr (sizeof...(Args) == 0) static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
if constexpr (N == 0)
return first; return first;
else else
return get(rest...); return get<N - 1>(rest...);
} }
template <int N, typename> struct get_type_impl; template <int N, typename> struct get_type_impl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment