On Sunday, 11 March 2018 at 13:44:38 UTC, Basile B. wrote:

The first version works here:

```
template aliasOf(T) {
    enum aliasOf(alias a) = is(typeof(a) == T);
}

string s;

pragma(msg, allSatisfy!(aliasOf!string, s, "string"));
```


I can see that my description was a little confusing, sorry about that, I meant to ask how would you call that without using the allSatisfy meta template. If I were to call it as a stand alone, ie:

writeln(aliasOf!string<how do I pass argument to inner template?>);

I hope that makes it clearer.

Now on the fact that what is done is correct is another story.
If the literal passed is supposed to be a type then it's clearly wrong.
You'd have to mix it:

```
template aliasOf(T)
{
    template aliasOf(alias a)
    {
        mixin("alias A = " ~ a ~ ";");
        enum aliasOf = is(A == T);
    }
}

alias myString1 = string;
alias myString2 = string;

pragma(msg, allSatisfy!(aliasOf!string, "myString1", "myString2"));
```

Aye, I see what you mean, but it is supposed to be a literal of a specific type. I.e. 3, "some string", SomeType(), etc.

So aliasOf!int.aliasOf!3 // true

Also, if I define it like this:

template aliasOf(T) {
    auto aliasOf(U)(U) { return is(U == T); }
}

Then at least I can call it like:

writeln(aliasOf!int(3)); // prints true

But then I can't do:

allSatisfy!(aliasOf!int, 3)

I guess because it's a function now and not a template anymore so can't be used by allSatisfy.





Reply via email to