forked from fmtlib/fmt
fix get
This commit is contained in:
committed by
Victor Zverovich
parent
ccc8f5db02
commit
f6a783ad2e
@@ -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;
|
||||||
|
Reference in New Issue
Block a user