I don't get how I can create a dynamic array of Cycle buffers of size 2 which use a struct.

 struct ms {
   int a;
   int b;
 }
 ms[2] msBuffer;
 alias circularStructBuffersT = typeof(cycle(msBuffer));
 circularStructBuffersT[int] circularStructBuffers;

 int i = 2;
 auto x = circularStructBuffers.require(i, (){
   ms[2] t;
   return cycle(t,2);
 });

This give an error:

Error: template object.require cannot deduce function from argument types !()(Cycle!(ms[2])[int], int, Cycle!(ms[2]) function() pure nothrow @nogc @system), candidates are: /Library/D/dmd/src/druntime/import/object.d(3225): require(K, V)(ref V[K] aa, K key, lazy V value = V.init)

Not sure if the `m[2] t` survives the scope exit in form of a closure (?) or if cycle takes a reference to it...

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

Reply via email to