Re: Default struct constructors if a struct member is a union

2024-07-06 Thread cc via Digitalmars-d-learn
On Saturday, 29 June 2024 at 23:33:41 UTC, solidstate1991 wrote: My question is can I initialize structs like these in one line without relying on a second line? ```d template ValueOfUDAType(alias T, alias UDA) { static foreach (uidx, U; __traits(getAttributes, T)) static if (is(typeof(U) ==

Re: SumType extraction

2024-07-06 Thread An Pham via Digitalmars-d-learn
On Thursday, 27 June 2024 at 18:51:19 UTC, Josh Holtrop wrote: Hello all. In my application I came across a desire to store an ordered array of handles that could point to one of several different objects, and it seems like the tool I want for that is SumType. I started with something like (s

Re: SumType extraction

2024-07-06 Thread Christian Köstlin via Digitalmars-d-learn
On Thursday, 27 June 2024 at 18:51:19 UTC, Josh Holtrop wrote: Questions: 4. Any other general improvements to my solution? I know it's kind of an unpopular choice these days but one could go with inheritance and polymorphism or instanceof tests. something along the lines of ```d import std.

Re: Why does this mixin fail to compile?

2024-07-06 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 3 July 2024 at 03:52:41 UTC, Steven Schveighoffer wrote: On Tuesday, 2 July 2024 at 07:23:42 UTC, ryuukk_ wrote: I said it 2 times already, i don't want string concatenation, i'll benchmark later, but not right now, right now i'm looking for a functioning code without string conc