mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Checked: Use default compiler-generated functions
Problem: - Compiler-generated functions are being defined which results in extra code to maintain. Solution: - Switch to compiler-generated default functions for default construction, copy assignment, move assignment, copy construction and move construction.
This commit is contained in:
parent
b4790010a8
commit
bd99083436
Notes:
sideshowbarker
2024-07-19 01:50:13 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/bd99083436f Pull-request: https://github.com/SerenityOS/serenity/pull/3798 Reviewed-by: https://github.com/awesomekling
1 changed files with 4 additions and 16 deletions
20
AK/Checked.h
20
AK/Checked.h
|
@ -112,10 +112,7 @@ inline constexpr bool is_within_range(Source value)
|
|||
template<typename T>
|
||||
class Checked {
|
||||
public:
|
||||
Checked()
|
||||
: m_value(0)
|
||||
{
|
||||
}
|
||||
Checked() = default;
|
||||
|
||||
Checked(T value)
|
||||
: m_value(value)
|
||||
|
@ -129,11 +126,7 @@ public:
|
|||
m_value = value;
|
||||
}
|
||||
|
||||
Checked(const Checked& other)
|
||||
: m_value(other.m_value)
|
||||
, m_overflow(other.m_overflow)
|
||||
{
|
||||
}
|
||||
Checked(const Checked&) = default;
|
||||
|
||||
Checked(Checked&& other)
|
||||
: m_value(exchange(other.m_value, 0))
|
||||
|
@ -147,12 +140,7 @@ public:
|
|||
return *this = Checked(value);
|
||||
}
|
||||
|
||||
Checked& operator=(const Checked& other)
|
||||
{
|
||||
m_value = other.value();
|
||||
m_overflow = other.m_overflow;
|
||||
return *this;
|
||||
}
|
||||
Checked& operator=(const Checked& other) = default;
|
||||
|
||||
Checked& operator=(Checked&& other)
|
||||
{
|
||||
|
@ -272,7 +260,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
T m_value;
|
||||
T m_value {};
|
||||
bool m_overflow { false };
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue