On Wednesday, 2 October 2024 at 08:55:15 UTC, Manu wrote:
>Does anyone understand why this doesn't work?
void f(T)(const(T)[] x, const(T)* y) {}
void test()
{
int*[] x;
const int* y;
f(x, &y);
} /* Error:
template `f` is not callable using argument types `!()(int*[],
const(int*)*)`
Candidate is: `f(T)(const(T)[] x, const(T)* y)` */
Should this work? It looks like it should work to me.
Hi Manu, what did you do, any progress? So why don't you use 2 aliases like T, R? For example:
template func(T : const T, R : const R)
{
void func(const(T)[] x, const(R)* y)/*
void func(T[] x, R* y)//*/
{
typeid(x).writeln(": ", T.stringof);
typeid(y).writeln(": ", R.stringof);
}
}
import std.stdio;
void main()
{
const
int[] x;
//const
int y;
func(x, &y); /* Output:
const(int)[]: int
const(int)*: int */
const
int* [] a;
//const
int* b;
func(a, &b); /* Output
const(const(int)*)[]: const(int)*
const(const(int)*)*: int* */
}
SDB79