[Issue 9563] (2.062) typeof(T[0]) no longer works with array T's
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 22 07:35:54 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9563
--- Comment #3 from siegelords_abode at yahoo.com 2013-02-22 07:35:52 PST ---
> What do you mean "only the class one works"? I'm getting a failure for both
> asserts.
I am not with DMD 2.062. This code compiles without any error and prints "int":
template ElemTypeOf( T )
{
alias typeof(T[0]) ElemTypeOf;
}
class A
{
int opIndex(size_t i)
{
return 0;
}
}
void main()
{
ElemTypeOf!(A) a;
pragma(msg, typeof(a).stringof);
static assert(is(typeof(a) == int));
}
> This worked in 2.060, but was fixed starting in 2.061.
>
> Try something like this:
>
> template ElemTypeOf( T )
> {
> static private T t = T.init;
> alias typeof(t[0]) ElemTypeOf;
> }
I guess that works (with some simplification of course), although the existence
of a workaround does not negate the existence of the regression.
> Or better yet, std.range's ElementType or ElementEncodingType.
Not using Phobos.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list