template Foo(T)
if (is(T U : U*))
{
pragma(msg, U);
}
Foo!(int*) f;
foo.d(4): Error: undefined identifier U, did you mean variable f?
__error
foo.d(6): Error: template instance Foo!(int*) error instantiating
foo.d(6): Error: Foo!(int*) is used as a type
Comment #1 by andrej.mitrovich — 2013-09-01T17:00:35Z
*** Issue 10945 has been marked as a duplicate of this issue. ***
Comment #2 by andrej.mitrovich — 2013-09-01T17:05:19Z
Maybe this should be marked as an enhancement, unless the spec says it's supposed to be supported. http://d.puremagic.com/issues/show_bug.cgi?id=10945 has a more elaborate example of why this feature would be useful.
Comment #3 by b2.temp — 2019-07-21T13:08:43Z
This not convenient to do because when the IsExpr is evaluated the scope that's provided is not the one for the function/aggregate body but the one of the parent. In the examples this matches to the global scope. But otherwise that's a good idea.
Comment #4 by ag0aep6g — 2019-08-18T23:03:19Z
*** Issue 3750 has been marked as a duplicate of this issue. ***
Comment #5 by nick — 2022-09-22T11:30:36Z
I thought fixing this might break the `static if` workaround, but it seems fine at least with a template specialization:
//struct S(T)
//if (is(T : U*, U))
struct S(T : U*, U)
{
static if (is(T : U*, U)){} // no error though U exists
pragma(msg, U);
}
alias A = S!(int*);
I think because U already exists, the `is` in the `static if` does not try to introduce another U.
Comment #6 by robert.schadek — 2024-12-13T17:55:44Z