On 3/22/19 9:24 AM, Alex wrote:
On Friday, 22 March 2019 at 12:08:39 UTC, James Blachly wrote:
First, how do we deal with toString, std.format, writeln, etc. with un-copyable objects, when it is only a member that is uncopyable?  In my case I got around this by creating a pointer and moving the initialization to the constructor, but I wonder if there are other ways?

You could (and should) define your custom toString() method inside the struct S, where un-copyable (or other strange kinds) members are part of.
In such a way, you could
S s;
s.toString(), without any harm, possibly omitting the members, which you are sure of (such as UnrolledList?).

Hi Alex,

Thanks for replying. I attribute the lack of sensibleness in my post to lack of sleep.

I actually am defining toString as member function of S, but it only now occurred to me that structs are always passed by value, not by reference. Of course then it cannot be copied.

Thanks again =)

Reply via email to