Skip to content

Commit

Permalink
fix: do not use recursion in last_one(Ts...)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToruNiina committed Aug 10, 2024
1 parent 3498af0 commit 5d74160
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions include/toml11/find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,14 @@ find_or(const basic_value<TC>& v, const K& ky, T opt)

namespace detail
{
template<typename T>
T& last_one(T& arg)
{
return arg;
}
template<typename T1, typename T2, typename ...Ts>
auto last_one(T1&, T2& arg, Ts& ... args) -> decltype(last_one(arg, args...))

template<typename ...Ts>
auto last_one(Ts&&... args)
-> decltype(std::get<sizeof...(Ts)-1>(std::forward_as_tuple(std::forward<Ts>(args)...)))
{
return last_one(arg, args...);
return std::get<sizeof...(Ts)-1>(std::forward_as_tuple(std::forward<Ts>(args)...));
}

} // detail

template<typename Value, typename K1, typename K2, typename K3, typename ... Ks>
Expand Down

0 comments on commit 5d74160

Please sign in to comment.