mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 13:30:31 +00:00
AK: Move move() into the "std" namespace
This makes GCC emit warnings about redundant and pessimizing moves. It also allows static analyzers like clang-tidy to detect common bugs like use-after-move.
This commit is contained in:
parent
f59ad2dc57
commit
ea81dc13cf
Notes:
sideshowbarker
2024-07-18 21:16:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ea81dc13cf9
1 changed files with 15 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -33,6 +33,20 @@ constexpr unsigned round_up_to_power_of_two(unsigned value, unsigned power_of_tw
|
|||
return ((value - 1) & ~(power_of_two - 1)) + power_of_two;
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
// NOTE: This is in the "std" namespace since some compiler features rely on it.
|
||||
|
||||
template<typename T>
|
||||
constexpr T&& move(T& arg)
|
||||
{
|
||||
return static_cast<T&&>(arg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using std::move;
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<typename T>
|
||||
|
@ -77,12 +91,6 @@ constexpr T ceil_div(T a, U b)
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T&& move(T& arg)
|
||||
{
|
||||
return static_cast<T&&>(arg);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
inline void swap(T& a, U& b)
|
||||
{
|
||||
|
@ -622,7 +630,6 @@ using AK::MakeSigned;
|
|||
using AK::MakeUnsigned;
|
||||
using AK::max;
|
||||
using AK::min;
|
||||
using AK::move;
|
||||
using AK::RemoveConst;
|
||||
using AK::swap;
|
||||
using AK::UnderlyingType;
|
||||
|
|
Loading…
Reference in a new issue