[Issue 9563] (2.062) typeof(T[0]) no longer works with array T's

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 21 22:39:49 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9563


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #2 from monarchdodra at gmail.com 2013-02-21 22:39:48 PST ---
(In reply to comment #0)
> Both invocations of ElemTypeOf used to work fine with DMD 2.061 but with DMD
> 2.062 only the class one works. Either none of them should work, or preferably
> both should work as they had since D1:

What do you mean "only the class one works"? I'm getting a failure for both
asserts.

Furthermore, I expect a failure. Your ElemTypeOf simply declares a static array
of size 0 of your type, it is not actually calling opIndex. Then combining it
with calling "typeof" on something that is already a type, makes this dobly
wrong code.

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;
}

Or better yet, std.range's ElementType or ElementEncodingType.

-- 
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