Error: template std.conv.parse cannot deduce function from argument types

Ralph Doncaster nerdralph at github.com
Tue Feb 6 17:33:43 UTC 2018


I get this error when I try the following code:

struct Record {
     union { ubyte[8] bytes; ulong l;}
     uint key;
}

Record r;
r.l = parse!ulong("deadbeef", 16);

However the following works:
string s = "deadbeef";
r.l = parse!ulong(s, 16);

And another way that works:
r.l = "deadbeef".to!ulong(16);

I've been doing C/C++ for over 20 years and recently started 
playing with D.  I think the template overloading for parse is 
getting confused because it sees the lvalue r.l as being of type 
union rather than ulong.  Is this a bug or the way things are 
supposed to work?



More information about the Digitalmars-d-learn mailing list