Stop writeln from calling object destructor
Ali Çehreli
acehreli at yahoo.com
Sun Oct 2 18:24:51 UTC 2022
On 10/2/22 10:55, data pulverizer wrote:
> On Sunday, 2 October 2022 at 17:28:51 UTC, data pulverizer wrote:
>> Sorry I'll need to implement all the overloaded copy constructors and
>> see if that fixes it.
>
> I've got it, something weird happened to my copy constructor. This was
> my original attempt and was ignored (didn't run in the copy constructor):
>
> ```
> this(T)(ref return scope T original)
> if(is(T == RVector!(Type)))
> {
> //... code ...
> }
> ```
I've just tested. That is used only for explicit constructor syntax:
auto b = RVector!int(a); // templatized
>
>
> But this now works:
>
>
> ```
> this(ref return scope RVector!(Type) original)
> {
> //... code ...
> }
> ```
That one works for both syntaxes:
auto b = RVector!int(a); // templatized
auto c = a; // non-templatized
Certainly confusing and potentially a bug... :/
> No idea why. `Type` is a template parameter of the object.
Minor convenience: You can replace all RVector!(Type) with just RVector
in the implementation of RVector because the name of the struct template
*is* that specific instantiation of it:
struct RVector(Type) {
// RVector below means RVector!Type:
this(ref return scope RVector original)
{
// ...
}
}
Ali
More information about the Digitalmars-d-learn
mailing list