December 22, 2017 Parsing string to octal(for umask) at runtime? | ||||
---|---|---|---|---|
| ||||
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? |
December 22, 2017 Re: Parsing string to octal(for umask) at runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ryan David Sheasby | 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); |
Copyright © 1999-2021 by the D Language Foundation