mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +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
1 changed files with 4 additions and 2 deletions
|
@ -13,6 +13,8 @@ namespace AK {
|
||||||
|
|
||||||
template<typename T, size_t Size>
|
template<typename T, size_t Size>
|
||||||
struct Array {
|
struct Array {
|
||||||
|
using ValueType = T;
|
||||||
|
|
||||||
[[nodiscard]] constexpr T const* data() const { return __data; }
|
[[nodiscard]] constexpr T const* data() const { return __data; }
|
||||||
[[nodiscard]] constexpr T* data() { return __data; }
|
[[nodiscard]] constexpr T* data() { return __data; }
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ struct Array {
|
||||||
return Size;
|
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");
|
static_assert(Size > 0, "No values to max() over");
|
||||||
|
|
||||||
|
@ -76,7 +78,7 @@ struct Array {
|
||||||
return value;
|
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");
|
static_assert(Size > 0, "No values to min() over");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue