Getting the overload set of a template
Arafel
er.krali at gmail.com
Thu Apr 19 15:36:15 UTC 2018
Well, if that's the lowering, then it's indeed hard. That doesn't mean
it shouldn't happen, though... perhaps changing the lowering? I'm no
compiles expert, so no idea how).
What I'd like to get is the same that I get using
__traits(getMember,...), but repeated n times (AliasSeq perhaps?), like
with regular overloads.
Then, whatever I can do with the first entry (the only one I can get
currently) should also be possible with the rest. In my case, I'd like
to access the UDAs, but I can imagine that the use case that allows us
to get a template keeps being valid for all the "hidden" alternatives.
Also, I think that whether to use "getOverloads" or to add a new trait
is rather an implementation detail
It's a bit frustrating being able to access only the first of a set...
A.
> Would it be possible at all? I mean, if the two following codes are
equivalent
> ´´´
> @S("Has foo_A") template foo(string s) if (s == "a") {
> enum foo = "foo_A";
> }
> @S("Has foo_B") template foo(string s) if (s == "b") {
> enum foo = "foo_B";
> }
> ´´´
>
>
> ´´´
> template foo(string s)
> {
> static if (s == "a")
> {
> @S("Has foo_A") enum foo = "foo_A";
> }
> else static if (s == "b")
> {
> @S("Has foo_B") enum foo = "foo_B";
> }
> }
> ´´´
>
> How would you define a "template overload"?
> And which "overloads" would you like to get if constraints are more
general?
> And last but not least, the getOverloads is defined on functions,
which are callable, whereas templates are not, in general...
More information about the Digitalmars-d-learn
mailing list