On Wednesday, 23 August 2023 at 16:28:27 UTC, Andrey Zherikov wrote:
>On Wednesday, 23 August 2023 at 15:32:02 UTC, Paul Backus wrote:
>For this use case, you should use .tupleof
instead of __traits(allMembers)
, which is guaranteed by the spec to give the fields in declaration order.
This link says "The order of the fields in the tuple matches the order in which the fields are declared" for the classes. I don't see such statement for structs here.
The spec isn't totally clear, but I believe the intent is to say that it works the same way for structs unless otherwise stated. Certainly, in practice, the fields are always in declaration order.