standard ranges

Jonathan M Davis jmdavisProg at gmx.com
Wed Jun 27 08:49:33 PDT 2012


On Wednesday, June 27, 2012 19:47:41 Gor Gyolchanyan wrote:
> On Wed, Jun 27, 2012 at 7:41 PM, Jonathan M Davis 
<jmdavisProg at gmx.com>wrote:
> > On Wednesday, June 27, 2012 17:58:46 Gor Gyolchanyan wrote:
> > > I tested it out and the string literal without qualifiers counts as a
> > > dstring.
> > 
> > That depends entirely on what you assign it to.
> > writeln(typeof("hello").stringof) prints string, not dstring. So, the
> > literal
> > by itself is a string by default.
> > 
> > - Jonathan M Davis
> 
> this is weird. I wrote a function, which transforms anything, which
> qualifies as isForwardRange into an implementation of ForwardRange. And the
> type inference of that function produced a ForwardRangeImpl!dchar when I
> passed it a string literal.
> 
> Although string and wstring also qualify as a forward range.

_All_ strings are considered to be ranges of dchar. That's why string and 
wstring are not random access ranges and hasLength is false for them.

- Jonathan M Davis


More information about the Digitalmars-d mailing list