digitalmars.D.learn - Parsing string to octal(for umask) at runtime?
- Ryan David Sheasby (13/13) Dec 22 2017 Hi. Struggling to figure this out. At the bottom of this page:
- Ryan David Sheasby (6/19) Dec 22 2017 Nevermind. I've just figured it out from this forum post :-)
Hi. Struggling to figure this out. At the bottom of this page: https://dlang.org/library/std/conv/octal.html is a vague reference to using parse. However, when I use what I would assume to be correct based on this: https://dlang.org/phobos/std_conv.html#.parse.3 and the fact that in the octal page it says octal is also a enum, I see no reason this syntax shouldn't work: import std.conv; umaskVal = parse!octal(data.umask); Yet I get an error saying the compiler cannot deduce which overload of parse to use... How do I do this parse? Am I going about this the wrong way? Is there a better way to parse a string as a normal base8 ushort?
Dec 22 2017
On Friday, 22 December 2017 at 21:36:20 UTC, Ryan David Sheasby wrote:Hi. Struggling to figure this out. At the bottom of this page: https://dlang.org/library/std/conv/octal.html is a vague reference to using parse. However, when I use what I would assume to be correct based on this: https://dlang.org/phobos/std_conv.html#.parse.3 and the fact that in the octal page it says octal is also a enum, I see no reason this syntax shouldn't work: import std.conv; umaskVal = parse!octal(data.umask); Yet I get an error saying the compiler cannot deduce which overload of parse to use... How do I do this parse? Am I going about this the wrong way? Is there a better way to parse a string as a normal base8 ushort?Nevermind. I've just figured it out from this forum post :-) http://forum.dlang.org/thread/nbvdebjxodabukfbeheq forum.dlang.org All I needed to do was: umaskVal = parse!ushort(data.umask, 8);
Dec 22 2017