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 version of parse to use :

---
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 here is :

---
std.conv.parse(Target, Source)(ref Source s, uint radix) if (isSomeChar!(ElementType!Source) && isIntegral!Target && !is(Target == enum))
---

And I can't see which template constraint is not respected when I call it with a slice.

Thanks

Reply via email to