Best way to make Until! into string

Jonathan M Davis jmdavisProg at gmail.com
Mon Jun 21 23:38:07 PDT 2010


Jonathan M Davis wrote:

> Okay. If you call until like so
> 
> str.until('\"')
> 
> you get a Until!(pred,string,char). I want to turn that into a string.
> array() doesn't seem to do the trick right now. It used to work, but now
> it gives me
> 
> main.d(47): Error: template std.array.array(Range) if (isForwardRange!
> (Range)) does not match any function template declaration
> main.d(47): Error: template std.array.array(Range) if (isForwardRange!
> (Range)) cannot deduce template function from argument types !()(Until!
> (pred,string,char))
> 
> to!string just converts it into a string with the Until! stuff being
> included in the string rather than giving me the actual result, so that
> doesn't work.
> 
> So, what is the correct and preferred way to convert the result of Until!
> to as string when you were searching on a string in the first place? The
> std.algorithm functions are definitely nice, but they have tendancy to
> return hard-to-use types.
> 
> - Jonathan M Davis

I should say that array() used to work if you used to!string on the result, 
but in either case, it won't compile for me now with DMD 2.047 (it did with 
DMD 2.046) if I feed the result of until() to array(). Maybe it's a bug, or 
maybe I've just been doing the conversion in the wrong way in the first 
place, but I don't know how to do it now.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list