struct template constructors
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 22 12:17:13 PDT 2017
On 06/22/2017 12:06 PM, Boris-Barboris wrote:
> Hi
>
> https://dpaste.dzfl.pl/0def4e286564
>
> Is there a cleaner way to go than the one on the line 26? And why is the
> constructor
>
> /d475/f781.d(37): f781.UniquePtr!(A).UniquePtr.__ctor(DT)(ref scope
> UniquePtr!DT rhs)
>
> unfit for line 51?
> Is it because the expression " = UniquePtr!B.make()" cannot be
> interpreted as "scope ref"? It must release ownership of a pointer it
> holds, and looks like it cannot do it in this form.
(Going pedantic, you mean "struct constructor templates" or "templated
struct constructors".)
No time to think about the rest of the design but just to get the code
compiled, replace 'ref' with 'auto ref' like so:
this(DT)(scope auto ref UniquePtr!DT rhs)
{
// ...
}
Ali
More information about the Digitalmars-d-learn
mailing list