Replace enforce(!empty with assert(!empty at the beginning of range members

This commit is contained in:
Per Nordlöw 2022-10-08 23:37:30 +02:00
parent 29a71efbae
commit ee64840397
3 changed files with 18 additions and 18 deletions

View file

@ -639,7 +639,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
void popFront()
{
enforce(!empty, new Base64Exception("Cannot call popFront on Encoder with no data remaining"));
assert(!empty, "Cannot call popFront on Encoder with no data remaining");
range_.popFront();
@ -757,7 +757,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
void popFront()
{
enforce(!empty, new Base64Exception("Cannot call popFront on Encoder with no data remaining"));
assert(!empty, "Cannot call popFront on Encoder with no data remaining");
static if (Padding != NoPadding)
if (padding)
@ -1414,7 +1414,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
void popFront()
{
enforce(!empty, new Base64Exception("Cannot call popFront on Decoder with no data remaining."));
assert(!empty, "Cannot call popFront on Decoder with no data remaining.");
range_.popFront();

View file

@ -991,7 +991,7 @@ if (!is(immutable T == immutable bool))
*/
void removeBack()
{
enforce(!empty);
assert(!empty);
static if (hasElaborateDestructor!T)
.destroy(_data._payload[$ - 1]);
@ -1812,49 +1812,49 @@ if (is(immutable T == immutable bool))
/// Ditto
@property T front()
{
enforce(!empty, "Attempting to access the front of an empty Array");
assert(!empty, "Attempting to access the front of an empty Array");
return _outer[_a];
}
/// Ditto
@property void front(bool value)
{
enforce(!empty, "Attempting to set the front of an empty Array");
assert(!empty, "Attempting to set the front of an empty Array");
_outer[_a] = value;
}
/// Ditto
T moveFront()
{
enforce(!empty, "Attempting to move the front of an empty Array");
assert(!empty, "Attempting to move the front of an empty Array");
return _outer.moveAt(_a);
}
/// Ditto
void popFront()
{
enforce(!empty, "Attempting to popFront an empty Array");
assert(!empty, "Attempting to popFront an empty Array");
++_a;
}
/// Ditto
@property T back()
{
enforce(!empty, "Attempting to access the back of an empty Array");
assert(!empty, "Attempting to access the back of an empty Array");
return _outer[_b - 1];
}
/// Ditto
@property void back(bool value)
{
enforce(!empty, "Attempting to set the back of an empty Array");
assert(!empty, "Attempting to set the back of an empty Array");
_outer[_b - 1] = value;
}
/// Ditto
T moveBack()
{
enforce(!empty, "Attempting to move the back of an empty Array");
assert(!empty, "Attempting to move the back of an empty Array");
return _outer.moveAt(_b - 1);
}
/// Ditto
void popBack()
{
enforce(!empty, "Attempting to popBack an empty Array");
assert(!empty, "Attempting to popBack an empty Array");
--_b;
}
/// Ditto
@ -2029,14 +2029,14 @@ if (is(immutable T == immutable bool))
*/
@property bool front()
{
enforce(!empty);
assert(!empty);
return data.ptr[0] & 1;
}
/// Ditto
@property void front(bool value)
{
enforce(!empty);
assert(!empty);
if (value) data.ptr[0] |= 1;
else data.ptr[0] &= ~cast(size_t) 1;
}
@ -2052,14 +2052,14 @@ if (is(immutable T == immutable bool))
*/
@property bool back()
{
enforce(!empty);
assert(!empty);
return cast(bool)(data.back & (cast(size_t) 1 << ((_store._length - 1) % bitsPerWord)));
}
/// Ditto
@property void back(bool value)
{
enforce(!empty);
assert(!empty);
if (value)
{
data.back |= (cast(size_t) 1 << ((_store._length - 1) % bitsPerWord));

View file

@ -249,7 +249,7 @@ according to `less`.
*/
@property ElementType!Store front()
{
enforce(!empty, "Cannot call front on an empty heap.");
assert(!empty, "Cannot call front on an empty heap.");
return _store.front;
}
@ -317,7 +317,7 @@ Removes the largest element from the heap.
*/
void removeFront()
{
enforce(!empty, "Cannot call removeFront on an empty heap.");
assert(!empty, "Cannot call removeFront on an empty heap.");
if (_length > 1)
{
auto t1 = _store[].moveFront();