iota result as member variable

Alex via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 24 01:41:54 PDT 2016


On Thursday, 24 March 2016 at 08:13:27 UTC, Edwin van Leeuwen 
wrote:
> Yeah this is one of the downsides of voldermort types. In these 
> cases typeof and ReturnType are your friend. It often takes me 
> a couple of tries to get it right, but the following seems to 
> work:
>
> import std.traits : ReturnType;
> import std.range : iota;
> class A
> {
>     ReturnType!(A.testIter4) member;
>     auto testIter4()
>     {
>         return iota(0,5);
>     }
> }
>
> void main()
> {
>
>      A a = new A();
>      a.member = a.testIter4();
> 	
> }

Ah... thanks! The "ReturnType" is what I looked for. This also 
makes some kind of semantic statement about "how slim should be 
the interface of my class members"...


More information about the Digitalmars-d-learn mailing list