DIP 1018--The Copy Constructor--Final Review
Paolo Invernizzi
paolo.invernizzi at gmail.com
Fri Mar 1 14:13:53 UTC 2019
On Friday, 1 March 2019 at 13:59:41 UTC, Olivier FAURE wrote:
> On Thursday, 28 February 2019 at 10:44:36 UTC, Mike Parker
> wrote:
>> Thanks in advance for your participation.
>
> So, the big point of contention seems to be the possibility
> that structs have copy constructors taking non-const arguments.
>
> I'll note that the language could allow only const arguments
> for copy constructor at first, and allow non-const arguments
> later (whereas the opposite order would be a breaking change).
>
> Also, to the people on this forum who don't like non-const copy
> constructors, how do you propose to deal with this case?
>
> struct RefCounted(T) {
> int* refcount;
> T* payload;
>
> /* ... */
> }
>
> RefCounted p1(10);
> RefCounted p2 = p1;
>
> One possibility would be to introduce a new "head_const" type
> qualifier, that would be used for cases like that. But
> honestly, I'm not sure
>
> this(ref head_const(RefCounted) other);
>
> would bring much to the table compared to
>
> this(ref RefCounted other);
>
> especially since then you have to consider introducing
> head_immutable and how they interact with scope and inout, etc.
A way to express mutable data in an immutable / const graph is
needed since a long time.
- P
More information about the Digitalmars-d
mailing list