mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 05:35:52 +03:00
AK: Explicitly require Checked types to be Integral
These were already implicitly required to be integral via the usage of the is_within_range templated function, but making them explicit should produce nicer error messages when building, and make the IDE highlight the incorrect usage.
This commit is contained in:
parent
301c1a3a58
commit
9321d9d83d
Notes:
sideshowbarker
2024-07-18 10:27:36 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/9321d9d83d3 Pull-request: https://github.com/SerenityOS/serenity/pull/8438
@ -28,6 +28,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
@ -109,17 +110,17 @@ template<typename Destination, typename Source>
|
||||
return TypeBoundsChecker<Destination, Source>::is_within_range(value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<Integral T>
|
||||
class Checked {
|
||||
public:
|
||||
constexpr Checked() = default;
|
||||
|
||||
constexpr Checked(T value)
|
||||
explicit constexpr Checked(T value)
|
||||
: m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
template<Integral U>
|
||||
constexpr Checked(U value)
|
||||
{
|
||||
m_overflow = !is_within_range<T>(value);
|
||||
|
Loading…
Reference in New Issue
Block a user