mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
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:
1 parent
afa2895230
commit
924780eb75
1 file changed
+33
-9
+33
-9
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user