Bug 1733 – parse() function does not handle all build-in types

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2007-12-16T08:48:00Z
Last change time
2015-06-09T01:14:23Z
Keywords
rejects-valid
Assigned to
andrei
Creator
aarti

Comments

Comment #0 by aarti — 2007-12-16T08:48:48Z
string str = "aaaaa"; writefln(parse!(char)(str)); -- Result: conv.d(650): static assert "Dunno how to parse a char" --- Should work for generic code.
Comment #1 by aarti — 2007-12-26T10:07:26Z
Types which should at least be handled: - char, wchar, dchar - cfloat, cdouble, creal - ifloat, idouble, ireal Probably also (with default behaviour e.g. bool -> "true" -> true, "false" -> false): - bool - string, wstring, dstring
Comment #2 by aarti — 2007-12-26T10:13:54Z
I initially thought that more types are covered by parse, but find out after looking at code that it works only for integral and real types. So at least documentation should be improved.
Comment #3 by bugzilla — 2010-06-15T01:45:00Z
to() and parse() can now convert from string to bool: http://www.dsource.org/projects/phobos/changeset/1646
Comment #4 by andrei — 2010-09-26T12:04:13Z