array of elements of various sybtypes

Steven Schveighoffer schveiguy at yahoo.com
Fri Jan 28 08:08:28 PST 2011


On Thu, 27 Jan 2011 07:49:06 -0500, spir <denis.spir at gmail.com> wrote:

> On 01/27/2011 03:54 AM, Steven Schveighoffer wrote:
>> On Wed, 26 Jan 2011 18:33:45 -0500, spir <denis.spir at gmail.com> wrote:
>>
>>> On 01/26/2011 07:23 PM, Steven Schveighoffer wrote:
>>>> On Wed, 26 Jan 2011 12:27:37 -0500, spir <denis.spir at gmail.com> wrote:
>>>>
>
>>>> auto ts = cast(T0[])[t1, t2];
>>>
>>> Nope, refused for the same reason (tried to construct [t1,t2] before  
>>> casting
>>> it).
>>
>> Hm.. maybe that only works on array literals with all literal elements.  
>> I
>> expected the cast to affect the type the compiler is expecting.
>>
>> For example, this works:
>>
>> cast(ubyte[])[1,2]; // without cast typed as int[]
>
> Yes, but with [1,2] the compiler has no difficulty to create the initial  
> array in the first place ;-)

But the cast affects how the array is created.  See my post elsewhere in  
this thread.

-Steve


More information about the Digitalmars-d-learn mailing list