Replace short preconditions in the main package

This commit is contained in:
2021-05-25 09:03:00 +02:00
parent b62cbb0647
commit 938a1bb5b4
23 changed files with 1024 additions and 295 deletions

View File

@@ -72,7 +72,11 @@ if (L > ubyte.sizeof && L <= ulong.sizeof)
*/
this(T)(T value)
if (isUnsigned!T)
in (value <= (2 ^^ (L * 8)) - 1)
in
{
assert(value <= (2 ^^ (L * 8)) - 1);
}
do
{
this.value = value & StorageType.max;
}
@@ -83,7 +87,11 @@ if (L > ubyte.sizeof && L <= ulong.sizeof)
* Precondition: $(D_INLINECODE length > 0).
*/
@property ubyte back() const
in (this.length > 0)
in
{
assert(this.length > 0);
}
do
{
return this.value & 0xff;
}
@@ -94,7 +102,11 @@ if (L > ubyte.sizeof && L <= ulong.sizeof)
* Precondition: $(D_INLINECODE length > 0).
*/
@property ubyte front() const
in (this.length > 0)
in
{
assert(this.length > 0);
}
do
{
return (this.value >> ((this.length - 1) * 8)) & 0xff;
}
@@ -105,7 +117,11 @@ if (L > ubyte.sizeof && L <= ulong.sizeof)
* Precondition: $(D_INLINECODE length > 0).
*/
void popBack()
in (this.length > 0)
in
{
assert(this.length > 0);
}
do
{
this.value >>= 8;
--this.size;
@@ -117,7 +133,11 @@ if (L > ubyte.sizeof && L <= ulong.sizeof)
* Precondition: $(D_INLINECODE length > 0).
*/
void popFront()
in (this.length > 0)
in
{
assert(this.length > 0);
}
do
{
this.value &= StorageType.max >> ((StorageType.sizeof - this.length) * 8);
--this.size;