Creating Tuple or AliasSeq

Graham Fawcett via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 7 18:45:26 PDT 2017


On Friday, 7 April 2017 at 10:26:24 UTC, ANtlord wrote:
> On Friday, 7 April 2017 at 07:46:40 UTC, Ali Çehreli wrote:
>> [...]
>
> I can't understand. Documentation of cartesianProduct points 
> out about finite arrays. At least one of arrays must be a 
> inifinte array. As far as I know finite arrays is `int[3]` and 
> infinite is `int[]` 
> (https://dlang.org/library/std/range/primitives/is_infinite.html). Am I right?
>
> If I am then I can't understand why DMD return error about 
> finite ranges compiling following code.
>
> 	struct Hay {
> 		int a;
> 		@disable this(this);
> 		@disable this();
> 		this(int a){
> 			this.a = a;
> 		}
> 		
> 	}
> 	Hay[] params = [ Hay(1), Hay(23) ];
> 	auto products = cartesianProduct(params, params);
>
> Error text:
>
>> [...]
>
> I noticed that removing disabling default constructors helps. 
> Does that mean an array contains objects of a struct with 
> disabled default constructor is finite?

No, int[] is a finite array. isInfinite is meant to test for 
ranges which are statically defined to *never* be empty, no 
matter how many times you consume them. See std.range.repeat(T) 
for an example of such a range.


More information about the Digitalmars-d-learn mailing list