cat > bug.d << CODE
struct Bar(T) {}
template Foo26(T:Bar!(const T))
{
pragma(msg, "const", T);
}
template Foo26(T:Bar!(T))
{
pragma(msg, "mod", T);
}
void main()
{
alias Foo26!(Bar!int) foo;
}
CODE
dmd -c bug
--------
I'm not sure whether Bar!int should match Bar!(const T) in the first place.
However if it does it must be a MATCHconst.
Comment #1 by nick — 2023-02-28T18:20:32Z
The error is:
> tempspecconst.d(14): Error: template `tempspecconst.Foo26` matches more than one template declaration:
> I'm not sure whether Bar!int should match Bar!(const T) in the first place.
Well this fails so I'd say no:
Bar!int b;
Bar!(const int) c = b;
Comment #2 by nick — 2023-02-28T18:24:53Z
With only the top overload present, the code compiles even though the argument is `Bar!int`, not `Bar!(const int)`:
> template Foo26(T:Bar!(const T))
Comment #3 by robert.schadek — 2024-12-13T17:58:59Z