First life-signs of type functions
Nick Treleaven
nick at geany.org
Sun May 10 08:39:42 UTC 2020
On Saturday, 9 May 2020 at 06:39:20 UTC, Stefan Koch wrote:
> alias p;
> p = t;
> bool good = is(typeof(__traits(parent, p)));
> while(good)
> {
> p = __traits(parent, p);
> result = p.stringof ~ "." ~ result;
> // result = __traits(identifier, parent) ~ "." ~ result;
> good = is(typeof(__traits(parent, p)));
> }
Very cool!
When `alias[]` is implemented, would this work:
bool anySatisfy(alias Tem, alias[] S)
{
bool found;
alias E;
while (S.length)
{
E = S[0];
if (Tem!E)
return true;
S = S[1..$];
}
return false;
}
enum isPointer(T) = is(T : E*, E);
pragma(msg, anySatisfy!(isPointer, int, char, void, int*, byte));
Any idea how fast this would be compared to `core.internal.traits
: anySatisfy` (which doesn't use template recursion)?
More information about the Digitalmars-d
mailing list