lambdas with types

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Nov 20 14:57:42 UTC 2020


On Fri, Nov 20, 2020 at 02:47:52PM +0000, Paul Backus via Digitalmars-d-learn wrote:
[...]
> In this specific case, you could also make `foo` a type-safe variadic
> function [1], which would eliminate the need for `allSatisfy`:
> 
>     void foo(double[] args...)
>     {
>         // ...
>     }
[...]

Yes, and this will also eliminate the template bloat associated with
.foo, which would have been instantiated once per call with a different
number of arguments.  But of course, this only works if all arguments
are of the same type, and if the function body does not depend on
accessing the number of arguments at compile-time.


T

-- 
What do you get if you drop a piano down a mineshaft? A flat minor.


More information about the Digitalmars-d-learn mailing list