digitalmars.D.learn - opCast and std.conv.to
- "Jacques =?UTF-8?B?TcO8bGxlciI=?= <jacques.mueller gmx.de> (5/5) Feb 22 2015 I tried to override the opCast operator in a class to be able to
- Adam D. Ruppe (7/10) Feb 22 2015 to!string actually forwards to a special function, "string
- "Jacques =?UTF-8?B?TcO8bGxlciI=?= <jacques.mueller gmx.de> (3/6) Feb 22 2015 Thanks, that's good to know.
I tried to override the opCast operator in a class to be able to explicitly convert the class to a string, but to!string just returns the name of the class. Do opCast and to! together not work with strings and does that mean that i have to use alias this?
Feb 22 2015
On Sunday, 22 February 2015 at 13:04:56 UTC, Jacques Müller wrote:I tried to override the opCast operator in a class to be able to explicitly convert the class to a string, but to!string just returns the name of the class.to!string actually forwards to a special function, "string toString() {}" which you'll need to implement and override from the base class. It might need to be const too override string toString() const { } the compiler will tell you.
Feb 22 2015
On Sunday, 22 February 2015 at 13:15:31 UTC, Adam D. Ruppe wrote:to!string actually forwards to a special function, "string toString() {}" which you'll need to implement and override from the base class.Thanks, that's good to know. I was just wondering why my code wasn't working correctly.
Feb 22 2015