typeof(string.front) should be char

Jacob Carlborg doob at me.com
Sat Mar 3 10:13:55 PST 2012


On 2012-03-03 15:10, Ali Çehreli wrote:
> On 03/03/2012 04:36 AM, Jacob Carlborg wrote:
>> On 2012-03-03 03:30, Piotr Szturmaj wrote:
>>> Hello,
>>>
>>> For this code:
>>>
>>> auto c = "test"c;
>>> auto w = "test"w;
>>> auto d = "test"d;
>>> pragma(msg, typeof(c.front));
>>> pragma(msg, typeof(w.front));
>>> pragma(msg, typeof(d.front));
>>>
>>> compiler prints:
>>>
>>> dchar
>>> dchar
>>> immutable(dchar)
>>
>> I thought all these would be either "dchar" or "immutable(dchar)". Why
>> are they of different types?
>
> In the case of char and wchar slices, the "elements" are decoded as the
> iteration happens. In other words, the returned values are not actual
> elements of the ranges.

Ah, I see, thanks.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list