mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Array can tell its inner type
Array should be able to tell the type of the elements it contains.
This commit is contained in:
parent
107872db8e
commit
6a0cac7cdb
Notes:
sideshowbarker
2024-07-17 18:13:39 +09:00
Author: https://github.com/standardexe Commit: https://github.com/SerenityOS/serenity/commit/6a0cac7cdb Pull-request: https://github.com/SerenityOS/serenity/pull/12749
1 changed files with 4 additions and 2 deletions
|
@ -13,6 +13,8 @@ namespace AK {
|
|||
|
||||
template<typename T, size_t Size>
|
||||
struct Array {
|
||||
using ValueType = T;
|
||||
|
||||
[[nodiscard]] constexpr T const* data() const { return __data; }
|
||||
[[nodiscard]] constexpr T* data() { return __data; }
|
||||
|
||||
|
@ -66,7 +68,7 @@ struct Array {
|
|||
return Size;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T max() requires(requires(T x, T y) { x < y; })
|
||||
[[nodiscard]] constexpr T max() const requires(requires(T x, T y) { x < y; })
|
||||
{
|
||||
static_assert(Size > 0, "No values to max() over");
|
||||
|
||||
|
@ -76,7 +78,7 @@ struct Array {
|
|||
return value;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T min() requires(requires(T x, T y) { x > y; })
|
||||
[[nodiscard]] constexpr T min() const requires(requires(T x, T y) { x > y; })
|
||||
{
|
||||
static_assert(Size > 0, "No values to min() over");
|
||||
|
||||
|
|
Loading…
Reference in a new issue