Copy Constructor DIP and implementation
Nicholas Wilson
iamthewilsonator at hotmail.com
Mon Sep 17 23:49:39 UTC 2018
On Monday, 17 September 2018 at 23:14:28 UTC, tide wrote:
> From what I've read, the copy constructor can be used with
> different types:
>
> struct B
> {
> }
>
> struct A
> {
> @implicit this(ref B b)
> {
> }
> }
>
>
> B foo();
>
> A a;
> a = foo(); // ok because of @implicit
> a = A(foo()); // ok without @implicit
>
> That's why it exists, otherwise I wouldn't want two types to be
> implicitly convertible unless i explicitly tell it to be
> implicit.
This DIP does not allow this, but apparently it is on the
horizon[1],
>>> it will be easier to extend the feature to copy construct
>>> from any type to any type
>> Is this a thing we are even considering?
> Yes.
I don't agree with it.
[1]: https://github.com/dlang/DIPs/pull/129#discussion_r218006614
More information about the Digitalmars-d-announce
mailing list