Thread overview |
---|
January 28, 2021 emplace doesn't forward aeguments | ||||
---|---|---|---|---|
| ||||
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 } |
January 28, 2021 Re: emplace doesn't forward aeguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to vitamin | On Thursday, 28 January 2021 at 21:15:49 UTC, vitamin wrote: > Is there reason why std.conv.emplace doesn't forward arguments to __ctor? Yeah, a bug in the emplace() version for classes, some missing `forward!args` in there (it works when emplacing a struct with identical ctor). E.g. https://github.com/dlang/druntime/blob/e2e304e1709b0b30ab65471a98023131f0e7620c/src/core/lifetime.d#L124-L128 if you want to fix it (std.conv.emplace is now an alias for core.lifetime.emplace in Phobos master). |
January 30, 2021 Re: emplace doesn't forward aeguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Thursday, 28 January 2021 at 23:18:21 UTC, kinke wrote:
> On Thursday, 28 January 2021 at 21:15:49 UTC, vitamin wrote:
>> Is there reason why std.conv.emplace doesn't forward arguments to __ctor?
>
> Yeah, a bug in the emplace() version for classes, some missing `forward!args` in there (it works when emplacing a struct with identical ctor). E.g. https://github.com/dlang/druntime/blob/e2e304e1709b0b30ab65471a98023131f0e7620c/src/core/lifetime.d#L124-L128 if you want to fix it (std.conv.emplace is now an alias for core.lifetime.emplace in Phobos master).
thanks;
|
February 01, 2021 Re: emplace doesn't forward aeguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to vitamin | On Saturday, 30 January 2021 at 17:29:15 UTC, vitamin wrote: > On Thursday, 28 January 2021 at 23:18:21 UTC, kinke wrote: >> On Thursday, 28 January 2021 at 21:15:49 UTC, vitamin wrote: >>> Is there reason why std.conv.emplace doesn't forward arguments to __ctor? >> >> Yeah, a bug in the emplace() version for classes, some missing `forward!args` in there (it works when emplacing a struct with identical ctor). E.g. https://github.com/dlang/druntime/blob/e2e304e1709b0b30ab65471a98023131f0e7620c/src/core/lifetime.d#L124-L128 if you want to fix it (std.conv.emplace is now an alias for core.lifetime.emplace in Phobos master). > > thanks; It's already fixed: https://github.com/dlang/druntime/pull/3352 |
Copyright © 1999-2021 by the D Language Foundation