mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
Use void for auto function without return statement
This commit is contained in:
parent
2c8166318b
commit
b82ae35fd7
9 changed files with 62 additions and 69 deletions
|
@ -4586,7 +4586,7 @@ if (isInputRange!R && !isInfinite!R)
|
|||
F[64] store = void;
|
||||
size_t idx = 0;
|
||||
|
||||
auto collapseStore(T)(T k)
|
||||
void collapseStore(T)(T k)
|
||||
{
|
||||
auto lastToKeep = idx - cast(uint)bsf(k+1);
|
||||
while (idx > lastToKeep)
|
||||
|
|
10
std/array.d
10
std/array.d
|
@ -162,7 +162,7 @@ if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range)
|
|||
struct Foo
|
||||
{
|
||||
int a;
|
||||
auto opAssign(Foo foo)
|
||||
void opAssign(Foo foo)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
@ -1055,7 +1055,7 @@ private template isInputRangeOrConvertible(E)
|
|||
assert(test([1, 2, 3, 4], 2, 23, [1, 2, 23, 3, 4]));
|
||||
assert(test([1, 2, 3, 4], 4, 24, [1, 2, 3, 4, 24]));
|
||||
|
||||
auto testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
|
||||
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
|
||||
{
|
||||
|
||||
auto l = to!T("hello");
|
||||
|
@ -2149,7 +2149,7 @@ T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff)
|
|||
assert(replace(a, 2, 4, filter!"true"([5, 6, 7])) == [1, 2, 5, 6, 7]);
|
||||
assert(a == [ 1, 2, 3, 4 ]);
|
||||
|
||||
auto testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
|
||||
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
|
||||
{
|
||||
|
||||
auto l = to!T("hello");
|
||||
|
@ -2370,7 +2370,7 @@ void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff
|
|||
assert(test([1, 2, 3, 4], 0, 2, filter!"true"([5, 6, 7]), [5, 6, 7, 3, 4]));
|
||||
assert(test([1, 2, 3, 4], 2, 4, filter!"true"([5, 6, 7]), [1, 2, 5, 6, 7]));
|
||||
|
||||
auto testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
|
||||
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
|
||||
{
|
||||
|
||||
auto l = to!T("hello");
|
||||
|
@ -3057,7 +3057,7 @@ if (isDynamicArray!A)
|
|||
this.arr = arr;
|
||||
}
|
||||
|
||||
auto opDispatch(string fn, Args...)(Args args) if (is(typeof(mixin("impl." ~ fn ~ "(args)"))))
|
||||
void opDispatch(string fn, Args...)(Args args) if (is(typeof(mixin("impl." ~ fn ~ "(args)"))))
|
||||
{
|
||||
// we do it this way because we can't cache a void return
|
||||
scope(exit) *this.arr = impl.data;
|
||||
|
|
|
@ -732,7 +732,7 @@ auto csvReader(Contents = string,
|
|||
return text.empty;
|
||||
}
|
||||
|
||||
auto popFront()
|
||||
void popFront()
|
||||
{
|
||||
text.popFront();
|
||||
}
|
||||
|
|
|
@ -34052,8 +34052,6 @@ static int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow) @safe pure nothrow
|
|||
}
|
||||
|
||||
|
||||
version(StdDdoc)
|
||||
{
|
||||
/++
|
||||
Function for starting to a stop watch time when the function is called
|
||||
and stopping it when its return value goes out of scope and is destroyed.
|
||||
|
@ -34088,10 +34086,6 @@ version(StdDdoc)
|
|||
See_Also:
|
||||
$(LREF benchmark)
|
||||
+/
|
||||
auto measureTime(alias func)();
|
||||
}
|
||||
else
|
||||
{
|
||||
@safe auto measureTime(alias func)()
|
||||
if (isSafe!((){StopWatch sw; unaryFun!func(sw.peek());}))
|
||||
{
|
||||
|
@ -34127,7 +34121,6 @@ else
|
|||
}
|
||||
return Result(Yes.autoStart);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify Example.
|
||||
@safe unittest
|
||||
|
|
|
@ -588,7 +588,7 @@ nothrow @safe @nogc unittest
|
|||
import std.experimental.allocator.mallocator : Mallocator;
|
||||
alias alloc = Mallocator.instance;
|
||||
|
||||
auto test(T, Args...)(auto ref Args args)
|
||||
void test(T, Args...)(auto ref Args args)
|
||||
{
|
||||
auto k = alloc.make!T(args);
|
||||
() @trusted { alloc.dispose(k); }();
|
||||
|
@ -607,7 +607,7 @@ nothrow @safe @nogc unittest
|
|||
|
||||
alias alloc = GCAllocator.instance;
|
||||
|
||||
auto test(T, Args...)(auto ref Args args)
|
||||
void test(T, Args...)(auto ref Args args)
|
||||
{
|
||||
auto k = alloc.make!T(args);
|
||||
(a) @trusted { a.dispose(k); }(alloc);
|
||||
|
|
|
@ -3080,7 +3080,7 @@ pure nothrow unittest
|
|||
{
|
||||
import std.experimental.ndslice.selection : iotaSlice;
|
||||
|
||||
auto fun(ref size_t x) { x *= 3; }
|
||||
void fun(ref size_t x) { x *= 3; }
|
||||
|
||||
auto tensor = iotaSlice(8, 9, 10).slice;
|
||||
|
||||
|
|
|
@ -262,12 +262,12 @@ if (isBidirectionalRange!(Unqual!Range))
|
|||
|
||||
static if (hasAssignableElements!R)
|
||||
{
|
||||
@property auto front(ElementType!R val)
|
||||
@property void front(ElementType!R val)
|
||||
{
|
||||
source.back = val;
|
||||
}
|
||||
|
||||
@property auto back(ElementType!R val)
|
||||
@property void back(ElementType!R val)
|
||||
{
|
||||
source.front = val;
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ body
|
|||
|
||||
static if (hasAssignableElements!R)
|
||||
{
|
||||
@property auto front(ElementType!R val)
|
||||
@property void front(ElementType!R val)
|
||||
{
|
||||
source.front = val;
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ body
|
|||
|
||||
static if (hasAssignableElements!R)
|
||||
{
|
||||
@property auto back(ElementType!R val)
|
||||
@property void back(ElementType!R val)
|
||||
{
|
||||
eliminateSlackElements();
|
||||
source.back = val;
|
||||
|
@ -1911,7 +1911,7 @@ if (isInputRange!(Unqual!Range) &&
|
|||
|
||||
static if (hasAssignableElements!R)
|
||||
/// ditto
|
||||
@property auto front(ElementType!R v)
|
||||
@property void front(ElementType!R v)
|
||||
{
|
||||
assert(!empty,
|
||||
"Attempting to assign to the front of an empty "
|
||||
|
@ -1999,7 +1999,7 @@ if (isInputRange!(Unqual!Range) &&
|
|||
static if (hasAssignableElements!R)
|
||||
{
|
||||
/// ditto
|
||||
@property auto back(ElementType!R v)
|
||||
@property void back(ElementType!R v)
|
||||
{
|
||||
// This has to return auto instead of void because of Bug 4706.
|
||||
assert(!empty,
|
||||
|
@ -3364,7 +3364,7 @@ struct Cycle(R)
|
|||
static if (hasAssignableElements!R)
|
||||
{
|
||||
/// ditto
|
||||
@property auto front(ElementType!R val)
|
||||
@property void front(ElementType!R val)
|
||||
{
|
||||
_original[_index] = val;
|
||||
}
|
||||
|
@ -3400,7 +3400,7 @@ struct Cycle(R)
|
|||
static if (hasAssignableElements!R)
|
||||
{
|
||||
/// ditto
|
||||
auto opIndexAssign(ElementType!R val, size_t n)
|
||||
void opIndexAssign(ElementType!R val, size_t n)
|
||||
{
|
||||
_original[(n + _index) % _original.length] = val;
|
||||
}
|
||||
|
@ -5811,7 +5811,7 @@ struct FrontTransversal(Ror,
|
|||
|
||||
static if (hasAssignableElements!RangeType)
|
||||
{
|
||||
@property auto front(ElementType val)
|
||||
@property void front(ElementType val)
|
||||
{
|
||||
_input.front.front = val;
|
||||
}
|
||||
|
@ -5868,7 +5868,7 @@ struct FrontTransversal(Ror,
|
|||
|
||||
static if (hasAssignableElements!RangeType)
|
||||
{
|
||||
@property auto back(ElementType val)
|
||||
@property void back(ElementType val)
|
||||
{
|
||||
_input.back.front = val;
|
||||
}
|
||||
|
@ -6127,7 +6127,7 @@ struct Transversal(Ror,
|
|||
/// Ditto
|
||||
static if (hasAssignableElements!InnerRange)
|
||||
{
|
||||
@property auto front(E val)
|
||||
@property void front(E val)
|
||||
{
|
||||
_input.front[_n] = val;
|
||||
}
|
||||
|
@ -6185,7 +6185,7 @@ struct Transversal(Ror,
|
|||
/// Ditto
|
||||
static if (hasAssignableElements!InnerRange)
|
||||
{
|
||||
@property auto back(E val)
|
||||
@property void back(E val)
|
||||
{
|
||||
_input.back[_n] = val;
|
||||
}
|
||||
|
@ -8851,7 +8851,7 @@ public:
|
|||
}
|
||||
|
||||
/++ +/
|
||||
auto opAssign(typeof(null) rhs)
|
||||
void opAssign(typeof(null) rhs)
|
||||
{
|
||||
_range = null;
|
||||
}
|
||||
|
|
|
@ -531,7 +531,7 @@ unittest
|
|||
assert(kick.length == length, text(C.stringof, " == ", kick.length));
|
||||
return kick;
|
||||
}
|
||||
auto searches(C)(const (C)[] source, ShiftOr!C kick, uint[] results...)
|
||||
void searches(C)(const (C)[] source, ShiftOr!C kick, uint[] results...)
|
||||
{
|
||||
auto inp = Input!C(source);
|
||||
foreach (r; results)
|
||||
|
|
|
@ -2701,7 +2701,7 @@ private:
|
|||
|
||||
//may break sorted property - but we need std.sort to access it
|
||||
//hence package protection attribute
|
||||
package @property auto front(CodepointInterval val)
|
||||
package @property void front(CodepointInterval val)
|
||||
{
|
||||
slice[start] = val.a;
|
||||
slice[start+1] = val.b;
|
||||
|
@ -2715,7 +2715,7 @@ private:
|
|||
}
|
||||
|
||||
//ditto about package
|
||||
package @property auto back(CodepointInterval val)
|
||||
package @property void back(CodepointInterval val)
|
||||
{
|
||||
slice[end-2] = val.a;
|
||||
slice[end-1] = val.b;
|
||||
|
@ -2739,7 +2739,7 @@ private:
|
|||
}
|
||||
|
||||
//ditto about package
|
||||
package auto opIndexAssign(CodepointInterval val, size_t idx)
|
||||
package void opIndexAssign(CodepointInterval val, size_t idx)
|
||||
{
|
||||
slice[start+idx*2] = val.a;
|
||||
slice[start+idx*2+1] = val.b;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue