Member is @disable this(this), parent uncopyable

James Blachly james.blachly at gmail.com
Sat Mar 23 00:39:29 UTC 2019


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 =)


More information about the Digitalmars-d-learn mailing list