Template type inference problem
Steven Schveighoffer
schveiguy at gmail.com
Thu Oct 3 14:08:15 UTC 2024
On Wednesday, 2 October 2024 at 08:55:15 UTC, Manu wrote:
> Does anyone understand why this doesn't work?
>
> ```d
> void f(T)(const(T)[] x, const(T)* y) {}
> void test()
> {
> int*[] x;
> const int* y;
> f(x, &y);
> }
> ```
I think it's a bug.
```d
void f(T)(const(T)[] x, const(T)* y) {}
void f2(T)(const(T)[] x) { pragma(msg, T);}
void f3(T)(const(T)* y) { pragma(msg, T);}
void test()
{
int*[] x;
const int* y;
f2(x); // int *
f3(&y); // const(int)*
f!(const(int)*)(x, &y); // ok
}
```
I tried reversing the order to see if it figures out to use
`const(int)*`, but it doesn't work.
-Steve
More information about the Digitalmars-d
mailing list