Re: Is there an opposite of .toString()?

2017-10-14 Thread myst via Digitalmars-d-learn
On Saturday, 14 October 2017 at 03:47:29 UTC, Jonathan M Davis wrote: The function to use for conversions in general is std.conv.to. And really, there isn't much of a reason to ever call toString. Functions like writeln, format, and to may use it internally, but it's more or less an

Re: Is there an opposite of .toString()?

2017-10-13 Thread myst via Digitalmars-d-learn
On Saturday, 14 October 2017 at 02:16:12 UTC, Fra Mecca wrote: On Saturday, 14 October 2017 at 00:18:35 UTC, myst wrote: ... some snippet of a c++ code that does what you mean #include #include struct S { std::string s; int p; int n; }; std::istream& operator>>(std::istream&

Is there an opposite of .toString()?

2017-10-13 Thread myst via Digitalmars-d-learn
I'm sorry if this has been answered already, it seems like a very basic question. There is .toString() method convention for printing, but I can not find anything alike for reading. Is there something like operator>>() in C++? What's an ideomatic way of reading an object?