traits getOverload of a template method

Basile B. b2.temp at gmx.com
Tue Sep 11 09:23:58 UTC 2018


On Thursday, 6 February 2014 at 23:06:03 UTC, QAston wrote:
> How do i get aliases to overloads of a template method like
>
> Class A
> {
>     int a(T)(T tq,T tw);
>     int a(T)(T tq);
> }
> __traits(getOverloads, A, "a(int)")doesnt work

Support for template in the getOverloads trait has been added 
recently.
You have to set an optional trailing parameter to `true`:

```
class A
{
     int a(T)(T,T){}
     int a(T)(T){}
}

enum include_templates = true;
static foreach (overload; __traits(getOverloads, A, "a", 
include_templates))
     pragma(msg, overload.stringof);
```

> a(T)(T, T)
> a(T)(T)

specs: https://dlang.org/spec/traits.html#getOverloads



More information about the Digitalmars-d-learn mailing list