emplace doesn't forward aeguments

vitamin vit at vit.vit
Thu Jan 28 21:15:49 UTC 2021


Is there reason why std.conv.emplace doesn't forward arguments to 
__ctor?

this doesn't work:

import std.conv : emplace;
import std.functional : forward;

struct Bar{
	
     @disable this(const ref typeof(this) rhs)pure nothrow @safe 
@nogc;
}

class Foo{
     Bar bar;

     this(Bar bar){
     	this.bar = forward!bar;
     }
}

void main(){
     void[__traits(classInstanceSize, Foo)] tmp = void;

     emplace!Foo(cast(Foo)tmp.ptr, Bar.init);   //error
}


More information about the Digitalmars-d-learn mailing list