From 5518b2b1559342fadec14ad979819d15a8542d43 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 14 Apr 2021 13:09:25 +0900 Subject: [PATCH] refactor: simplify last_one_in_pack meta func --- toml/utility.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/toml/utility.hpp b/toml/utility.hpp index 96e53db..4a6b430 100644 --- a/toml/utility.hpp +++ b/toml/utility.hpp @@ -117,10 +117,8 @@ decltype(auto) last_one(T&& /*head*/, Ts&& ... tail) noexcept // line #3, so `decltype()` cannot deduce the type returned from `last_one`. // So we need to determine return type in a different way, like a meta func. -template -struct last_one_in_pack; template -struct last_one_in_pack +struct last_one_in_pack { using type = typename last_one_in_pack::type; }; @@ -137,9 +135,8 @@ T&& last_one(T&& tail) noexcept { return std::forward(tail); } - template -last_one_in_pack_t +enable_if_t<(sizeof...(Ts) > 0), last_one_in_pack_t> last_one(T&& /*head*/, Ts&& ... tail) { return last_one(std::forward(tail)...);