mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 01:18:02 +02:00
Sized array .InitAll
elemented initializer
This commit is contained in:
parent
05e002d8f5
commit
77a99bdacc
3 changed files with 45 additions and 7 deletions
|
@ -15,6 +15,8 @@ namespace System
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public explicit static operator T[CSize] (Self val)
|
||||
{
|
||||
return val.mVal;
|
||||
|
@ -109,6 +111,28 @@ namespace System
|
|||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public static T[CSize] InitAll
|
||||
{
|
||||
[Error("Element type has no default constructor")]
|
||||
get
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SizedArray<T, CSize> where T : struct, new
|
||||
{
|
||||
public static T[CSize] InitAll
|
||||
{
|
||||
get
|
||||
{
|
||||
T[CSize] val;
|
||||
for (int i < CSize)
|
||||
val[i] = T();
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue