Formatted read consumes input
monarch_dodra
monarchdodra at gmail.com
Fri Sep 7 07:35:37 PDT 2012
On Friday, 7 September 2012 at 13:58:43 UTC, Steven Schveighoffer
wrote:
> On Thu, 23 Aug 2012 07:33:13 -0400, monarch_dodra
>
> The only issue is, what if you *do* want ref behavior for
> strings? You would need to wrap the string into a ref'd range.
> That is not a good proposition. Unfortunately, the way IFTI
> works, there isn't an opportunity to affect the parameter type
> IFTI decides to use.
>
> [SNIP]
>
> -Steve
If you want *do* ref behavior, I still don't see why you we don't
just do it the algorithm way of return by value:
----
Tuple!(uint, R)
formattedRead2(R, Char, S...)(R r, const(Char)[] fmt, S args)
{
auto ret = formattedRead(r, fmt, args);
return Tuple!(uint, R)(ret, r);
}
void main()
{
string s = "42 worlds";
int v;
s = formattedRead(s.save, "%d", &v)[1];
writefln("[%s][%s]", v, s);
}
----
More information about the Digitalmars-d
mailing list