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>
|
template<typename T>
|
||||||
class Checked {
|
class Checked {
|
||||||
public:
|
public:
|
||||||
Checked()
|
Checked() = default;
|
||||||
: m_value(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Checked(T value)
|
Checked(T value)
|
||||||
: m_value(value)
|
: m_value(value)
|
||||||
|
@ -129,11 +126,7 @@ public:
|
||||||
m_value = value;
|
m_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Checked(const Checked& other)
|
Checked(const Checked&) = default;
|
||||||
: m_value(other.m_value)
|
|
||||||
, m_overflow(other.m_overflow)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Checked(Checked&& other)
|
Checked(Checked&& other)
|
||||||
: m_value(exchange(other.m_value, 0))
|
: m_value(exchange(other.m_value, 0))
|
||||||
|
@ -147,12 +140,7 @@ public:
|
||||||
return *this = Checked(value);
|
return *this = Checked(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Checked& operator=(const Checked& other)
|
Checked& operator=(const Checked& other) = default;
|
||||||
{
|
|
||||||
m_value = other.value();
|
|
||||||
m_overflow = other.m_overflow;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Checked& operator=(Checked&& other)
|
Checked& operator=(Checked&& other)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +260,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_value;
|
T m_value {};
|
||||||
bool m_overflow { false };
|
bool m_overflow { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue