Has the ban on returning function nested structs been lifted?

Simen kjaeraas simen.kjaras at gmail.com
Sat Mar 19 03:25:15 PDT 2011


On Sat, 19 Mar 2011 11:18:17 +0100, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

>> There are times when I've wanted something like this because I don't
>> know the resultant type of a bunch of range operations, but have to
>> save it in a struct or class.
>
> typeof is your friend.

Only when there is a definite type. Consider:

struct foo {
     Range!int rng;

     this( int[] arr, bool b ) {
         if ( b ) {
             rng = arr;
         } else {
             rng = map!"a+b"( arr );
         }
     }
}


-- 
Simen


More information about the Digitalmars-d mailing list