I dun a DIP, possibly the best DIP ever
Timon Gehr
timon.gehr at gmx.ch
Sat May 9 15:28:39 UTC 2020
On 24.04.20 23:00, Steven Schveighoffer wrote:
> On 4/24/20 4:15 PM, Walter Bright wrote:
>
>>
>> Since then it's an array, use the existing array folding methods.
>
> This is probably good enough, because we can generate arrays at
> compile-time and process them via CTFE.
>
> Some key targets within std.meta are anySatisfy/allSatisfy.
>
> A quick stab at this (I'm going to stick with the ellipsis version as
> it's easy to ):
>
> import std.algorithm : canFind;
> enum anySatisfy(alias F, T...) = [F!(T)...].canFind(true);
> enum allSatisfy(alias F, T...) = ![F!(T)...].canFind(false);
>
> Wow, that reads so clean.
>
> I'm so in love with this feature, when can we get it in?
>
> -Steve
This is not equivalent to the current implementations.
import std.meta;
enum Foo(int x)=true;
// true now, but compile error with your approach:
pragma(msg, anySatisfy!(Foo, 1, int));
More information about the Digitalmars-d
mailing list