Cannot dup an associative array but why?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 10 12:11:37 PDT 2017


On 07/10/2017 11:46 AM, Jean-Louis Leroy wrote:
 > Is there something special about ClassInfo that confuses? Look at this
 > example:
 >
 > struct Foo
 > {
 >
 > }
 >
 > class Bar
 > {
 > }
 >
 > void main()
 > {
 >   Foo*[Bar] a;
 >   auto aa = a.dup; // OK
 >   Foo*[ClassInfo] b; // Error: static assert  "cannot call
 > Foo*[TypeInfo_Class].dup because Foo* is not copyable"

I think you're hitting the same TypeInfo.init issue again. :/ This is 
the assert that fails inside object.dup:

     static assert(is(typeof({ V v = aa[K.init]; })),
         "cannot call " ~ T.stringof ~ ".dup because " ~ V.stringof ~ " 
is not copyable");

Jean-Louis, a little more patience please. :) Hopefully this will be 
resolved with 2.075, which you should be able to test yourself already. 
(?) 2.075 is in its fourth beta release.

Ali



More information about the Digitalmars-d-learn mailing list