move semantics are a mess
Per Nordlöw
per.nordlow at gmail.com
Wed May 29 13:58:51 UTC 2019
On Sunday, 26 May 2019 at 18:24:17 UTC, Manu wrote:
> I've been trying to do some initial work with copy ctor's, and
> that has lead me to closely scritinise the various construction
> flow's, and it's revealed a whole bunch of issues with move
> semantics.
A cumbersome but working way of experimenting with the potential
(performance) benefits of eliding copy construction of the
elements in `args` would be to replace
void emplaceRef(UT, Args...)(ref UT chunk, auto ref Args args)
if (is(UT == core.internal.traits.Unqual!UT))
{
emplaceRef!(UT, UT)(chunk, args);
}
with
void emplaceRef(UT, Args...)(ref UT chunk, auto ref Args args)
if (is(UT == core.internal.traits.Unqual!UT))
{
static if (args.length == 1)
{
emplaceRef!(UT, UT)(chunk, move(args[0]));
}
else static if (args.length == 2)
{
emplaceRef!(UT, UT)(chunk, move(args[0]), move(args[1]));
}
else ...up to args.length
}
and similarly for the calls to
p.__ctor(args)
in
void emplaceRef(T, UT, Args...)(ref UT chunk, auto ref Args args)
.
More information about the Digitalmars-d
mailing list