struct field initialization
bitwise via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 16 11:24:30 PDT 2017
On Wednesday, 16 August 2017 at 18:11:05 UTC, bitwise wrote:
> [...]
I'm asking this because I need to forward args to a container's
node's value.
Something like this:
struct Node(T)
{
int flags;
T value; // maybe const
this(Args...)(int flags, auto ref Args args)
{
this.flags = flags;
// this?
emplace(&value, args);
// or this?
value = T(args);
// ?
}
}
struct Container(T)
{
Node!T[] nodes;
void add(Args...)(auto ref Args args)
{
int flags = 1234;
auto p = cast(Node!T*)malloc(Node!T.sizeof);
nodes ~= emplace(p, flags, args);
}
}
More information about the Digitalmars-d-learn
mailing list