Define an order for allMembers traits

Andrey Zherikov andrey.zherikov at gmail.com
Wed Aug 23 16:28:27 UTC 2023


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][1].
>
> [1]: https://dlang.org/spec/class.html#class_properties

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](https://dlang.org/spec/struct.html#struct_instance_properties).


More information about the Digitalmars-d mailing list