On Thursday, 5 October 2023 at 22:24:06 UTC, mw wrote:
On Thursday, 5 October 2023 at 21:41:38 UTC, cc wrote:
If you have `T info`, T.tupleof[n] will always match up with
info.tupleof[n]. You can think of `info.tupleof[n]` as being
rewritten by the compiler in-place as
On Thursday, 5 October 2023 at 21:41:38 UTC, cc wrote:
If you have `T info`, T.tupleof[n] will always match up with
info.tupleof[n]. You can think of `info.tupleof[n]` as being
rewritten by the compiler in-place as info.whateverFieldThatIs.
You might try this version (note the double {{ }}
On Sunday, 1 May 2016 at 09:42:37 UTC, ParticlePeter wrote:
I am logging arbitrary POD struct types with member names and
data:
void printStructInfo( T )( T info ) {
foreach( i, A; typeof( T.tupleof )) {
enum attribName = T.tupleof[i].stringof;
writefln( "%s : %s", attribName, mixin(
On Sunday, 1 May 2016 at 10:13:47 UTC, H. S. Teoh wrote:
Using typeof(T.tupleof) seems a bit circuitous. Here's how I'd
do it:
void printStructInfo( T )( T info ) {
import std.stdio : writefln;
foreach (memb; __traits(allMembers, T)) {
On Sunday, 1 May 2016 at 10:13:47 UTC, H. S. Teoh wrote:
On Sun, May 01, 2016 at 09:42:37AM +, ParticlePeter via
Digitalmars-d-learn wrote:
I am logging arbitrary POD struct types with member names and
data:
void printStructInfo( T )( T info ) {
foreach( i, A; typeof( T.tupleof )) {
On Sun, May 01, 2016 at 09:42:37AM +, ParticlePeter via Digitalmars-d-learn
wrote:
> I am logging arbitrary POD struct types with member names and data:
>
> void printStructInfo( T )( T info ) {
> foreach( i, A; typeof( T.tupleof )) {
> enum attribName = T.tupleof[i].stringof;
>
I am logging arbitrary POD struct types with member names and
data:
void printStructInfo( T )( T info ) {
foreach( i, A; typeof( T.tupleof )) {
enum attribName = T.tupleof[i].stringof;
writefln( "%s : %s", attribName, mixin( "info." ~ attribName
));
}
}
Is there is some other way