From f6a783ad2ed5c4f9070274221e6e99c8dd406373 Mon Sep 17 00:00:00 2001 From: Daumantas Kavolis <12998363+dkavolis@users.noreply.github.com> Date: Tue, 24 Sep 2019 10:53:55 +0100 Subject: [PATCH] fix `get` --- include/fmt/compile.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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;