Member is @disable this(this), parent uncopyable
James Blachly
james.blachly at gmail.com
Fri Mar 22 12:08:39 UTC 2019
I have a struct S with member containers.UnrolledList [1]. UnrolledList
is @disable this(this), but this unfortunately makes my struct S also
un-copyable, which now breaks some of my debugging statements which rely
on toString, as writeln, format, etc. all copy the object. This leaves
me in the unfortunate situation that my release builds work, but debug
builds do not.
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?
Second, why must an object in its entirety be copy-able for these
functions to call toString() ?
Finally, the error message gave no clue that it was a member
(UnrolledList in my case) that was @disable 'd and it took some digging
back through several commits to figure out what was happening -- how
could we improve the error messaging?
Thanks as always in advance
[1] https://github.com/dlang-community/containers
More information about the Digitalmars-d-learn
mailing list