diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 8617ef85..952c1087 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -331,11 +331,12 @@ template struct type_list {}; // Returns a reference to the argument at index N from [first, rest...]. template -const auto& get(const T& first, const Args&... rest) { - if constexpr (sizeof...(Args) == 0) +constexpr const auto& get(const T& first, const Args&... rest) { + static_assert(N < 1 + sizeof...(Args), "index is out of bounds"); + if constexpr (N == 0) return first; else - return get(rest...); + return get(rest...); } template struct get_type_impl;