mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
refactor: simplify last_one_in_pack meta func
This commit is contained in:
@@ -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`.
|
// 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.
|
// So we need to determine return type in a different way, like a meta func.
|
||||||
|
|
||||||
template<typename ... Ts>
|
|
||||||
struct last_one_in_pack;
|
|
||||||
template<typename T, typename ... Ts>
|
template<typename T, typename ... Ts>
|
||||||
struct last_one_in_pack<T, Ts...>
|
struct last_one_in_pack
|
||||||
{
|
{
|
||||||
using type = typename last_one_in_pack<Ts...>::type;
|
using type = typename last_one_in_pack<Ts...>::type;
|
||||||
};
|
};
|
||||||
@@ -137,9 +135,8 @@ T&& last_one(T&& tail) noexcept
|
|||||||
{
|
{
|
||||||
return std::forward<T>(tail);
|
return std::forward<T>(tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename ... Ts>
|
template<typename T, typename ... Ts>
|
||||||
last_one_in_pack_t<Ts&& ...>
|
enable_if_t<(sizeof...(Ts) > 0), last_one_in_pack_t<Ts&& ...>>
|
||||||
last_one(T&& /*head*/, Ts&& ... tail)
|
last_one(T&& /*head*/, Ts&& ... tail)
|
||||||
{
|
{
|
||||||
return last_one(std::forward<Ts>(tail)...);
|
return last_one(std::forward<Ts>(tail)...);
|
||||||
|
Reference in New Issue
Block a user