lambdas with types

Stefan Koch uplink.coder at googlemail.com
Sat Nov 21 10:57:09 UTC 2020


On Friday, 20 November 2020 at 14:08:23 UTC, jmh530 wrote:
> Doing something like below fails because I don't seem to be 
> able to make a templated lambda that just takes types. Is the 
> only way to do something similar to create a separate function 
> to handle the condition, or is there some other way to do 
> something with similar flexibility?
>
> import std.stdio: writeln;
> import std.meta: allSatisfy;
>
> void foo(Args...)(Args args)
>     if (allSatisfy!(x => is(x == double), Args))
> {
>     writeln("works");
> }
>
> void main() {
>     foo(1.0, 2.0);
> }

with type functions this syntax should work.


More information about the Digitalmars-d-learn mailing list