using parse with string slice

2015-12-05 Thread Quentin Ladeveze via Digitalmars-d-learn
Hi, I try to parse some hexadecimal numbers stocked in a string. So I use this code --- import std.conv; string s = "B"; int value = parse!int(s, 16); assert(value == 11); --- But when I have several hexadecimal numbers in the string, and I slice it, the compiler can't deduce which

Re: using parse with string slice

2015-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 December 2015 at 22:05:11 UTC, anonymous wrote: You can use std.conv.to instead or assign the slice to a variable first. This is a bit of a FAQ I think because people don't realize you can use to and parse to do the same thing. The big difference is parse will advance the

Re: using parse with string slice

2015-12-05 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 5 December 2015 at 22:05:11 UTC, anonymous wrote: On 05.12.2015 22:59, Quentin Ladeveze wrote: --- import std.conv; string s = "1B2A"; int value = parse!int(s[0..2], 16); //template std.conv.parse cannot deduce function from argument types !(int)(string, int) --- Does someone

Re: using parse with string slice

2015-12-05 Thread anonymous via Digitalmars-d-learn
On 05.12.2015 22:59, Quentin Ladeveze wrote: --- import std.conv; string s = "1B2A"; int value = parse!int(s[0..2], 16); //template std.conv.parse cannot deduce function from argument types !(int)(string, int) --- Does someone have an idea of why it happens ? The version of parse that is used