On 12/11/21 10:02 PM, apz28 wrote:
On Sunday, 12 December 2021 at 00:02:25 UTC, Stanislav Blinov wrote:
@apz28, I can't figure out the intent here. To convert result of abs to an unsigned?

The function logic works only for unsigned type and the parameter value can be altered in body hence Unqual. If not Unqual, must declare a local var and make a copy. Just asking if this can be done to avoid a cast by caller

To translate a bit here, what apz28 is looking for is, given ANY value type that implicitly converts from the qualified value to the unqualified value, generate *one* function that only accepts the unqualified value.

You can wrap like:

```d
void foo2(T)(T v) if (!is(Unqual!T == T))
{
   foo(Unqual!T(t));
}
```

This will inline as if you called it directly (which should just whittle down to a direct call to the correct foo2).

But D isn't currently smart enough to see through aliases, so IFTI will not work for what you are doing, even in a case like:

```d
template foo2(T) if (!isUnqual!T == T)
{
   alias foo2 = .foo2!(Unqual!T);
}
```

It would be nice if IFTI gave some hooks between the parameter and the deduction, but it currently doesn't.

-Steve

Reply via email to