Skip to content

Commit

Permalink
Merge pull request #8691 from ntrel/return-type
Browse files Browse the repository at this point in the history
More avoidance of std.traits.ReturnType
  • Loading branch information
RazvanN7 authored Feb 20, 2023
2 parents 0cec16a + 1c397ee commit c9d1bd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions std/range/primitives.d
Original file line number Diff line number Diff line change
Expand Up @@ -1674,8 +1674,8 @@ The following expression must be true for `hasSlicing` to be `true`:
----
isForwardRange!R
&& !isNarrowString!R
&& is(ReturnType!((R r) => r[1 .. 1].length) == size_t)
&& !(isAutodecodableString!R && !isAggregateType!R)
&& is(typeof((R r) { return r[1 .. 1].length; } (R.init)) == size_t)
&& (is(typeof(lvalueOf!R[1 .. 1]) == R) || isInfinite!R)
&& (!is(typeof(lvalueOf!R[0 .. $])) || is(typeof(lvalueOf!R[0 .. $]) == R))
&& (!is(typeof(lvalueOf!R[0 .. $])) || isInfinite!R
Expand Down
8 changes: 6 additions & 2 deletions std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,10 @@ private template fqnType(T,
* or a class with an `opCall`. Please note that $(D_KEYWORD ref)
* is not part of a type, but the attribute of the function
* (see template $(LREF functionAttributes)).
*
* $(NOTE To reduce template instantiations, consider instead using
* $(D typeof(() { return func(args); } ())) if the argument types are known or
* $(D static if (is(typeof(func) Ret == return))) if only that basic test is needed.)
*/
template ReturnType(alias func)
if (isCallable!func)
Expand Down Expand Up @@ -7969,15 +7973,15 @@ has both opApply and a range interface.
*/
template ForeachType(T)
{
alias ForeachType = ReturnType!(typeof(
alias ForeachType = typeof(
(inout int x = 0)
{
foreach (elem; T.init)
{
return elem;
}
assert(0);
}));
}());
}

///
Expand Down

0 comments on commit c9d1bd5

Please sign in to comment.