Re: Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn
On Monday, 3 July 2017 at 17:30:51 UTC, Ali Çehreli wrote: hOn 07/03/2017 10:13 AM, Paolo Invernizzi wrote: > [...] struct with > [...] I had difficulty understanding the requirements. For example, it's not clear whether you want the literal "first" and "second" names. [...] Thanks Ali,

Re: Accessing part of a struct in an easy way

2017-07-03 Thread Ali Çehreli via Digitalmars-d-learn
hOn 07/03/2017 10:13 AM, Paolo Invernizzi wrote: > It's not exactly the same, as first and second should be struct with > partial fields from Foo, of different types. I had difficulty understanding the requirements. For example, it's not clear whether you want the literal "first" and "second" n

Re: Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn
On Monday, 3 July 2017 at 16:41:51 UTC, vit wrote: On Monday, 3 July 2017 at 13:53:45 UTC, Paolo Invernizzi wrote: [...] //https://dpaste.dzfl.pl/d59469c264b2 import std.algorithm : map, copy, equal; import std.range : iota; struct Foo { int[3] a; string[2] b; } ref T first(R : T[],

Re: Accessing part of a struct in an easy way

2017-07-03 Thread vit via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:53:45 UTC, Paolo Invernizzi wrote: I've struct like that: struct Foo { int a_1; float a_2; string a_3; string b_1; double b_2; } I would like to transparently access that like: foo.a.first foo.b.second = "baz"; with an helper like: auto a(...) { ... } aut

Accessing part of a struct in an easy way

2017-07-03 Thread Paolo Invernizzi via Digitalmars-d-learn
I've struct like that: struct Foo { int a_1; float a_2; string a_3; string b_1; double b_2; } I would like to transparently access that like: foo.a.first foo.b.second = "baz"; with an helper like: auto a(...) { ... } auto b(...) { ... } that can be used also in functions that are exp