AK/Tuple: Require this to be a {r,l}value when calling get()

This ensures that the result of calling get() on a temporary Tuple
cannot be assigned to a lvalue reference.
This commit is contained in:
Nick Erdmann authored and Nico Weber committed 2025-08-31 14:04:15 -04:00
1 parent afa2895230
commit 924780eb75
1 file changed
+33 -9
+33 -9
View File
@@ -141,29 +141,53 @@ struct Tuple : Detail::Tuple<Ts...> {
}
template<typename T>
auto& get()
auto& get() &
{
return Detail::Tuple<Ts...>::template get<T>();
}
template<size_t index>
auto& get()
{
return Detail::Tuple<Ts...>::template get_with_index<typename Types::template Type<index>, index>();
}
template<typename T>
auto& get() const
auto&& get() &&
{
return move(Detail::Tuple<Ts...>::template get<T>());
}
template<size_t index>
auto& get() &
{
return Detail::Tuple<Ts...>::template get_with_index<typename Types::template Type<index>, index>();
}
template<size_t index>
auto&& get() &&
{
return move(Detail::Tuple<Ts...>::template get_with_index<typename Types::template Type<index>, index>());
}
template<typename T>
auto& get() const&
{
return Detail::Tuple<Ts...>::template get<T>();
}
template<typename T>
auto&& get() const&&
{
return move(Detail::Tuple<Ts...>::template get<T>());
}
template<size_t index>
auto& get() const
auto& get() const&
{
return Detail::Tuple<Ts...>::template get_with_index<typename Types::template Type<index>, index>();
}
template<size_t index>
auto&& get() const&&
{
return move(Detail::Tuple<Ts...>::template get_with_index<typename Types::template Type<index>, index>());
}
template<typename F>
auto apply_as_args(F&& f)
{