std.conv.parse is similar:
http://dlang.org/phobos/std_conv.html#parse
An example is a string, although it can also be used with other character sources.
import std.conv;
import std.stdio;
void main() {
auto source = LockingTextReader(stdin);
int a = parse!int(source);
writeln("you wrote ", a);
for(; !source.empty; source.popFront()) {
auto ch = source.front;
if(ch != ' ' && ch != '\n')
break;
}
int b = parse!int(source);
writeln("then you wrote ", b);
}
$. / test56 12 23 you wrote 12 then you wrote 23
source
share