Using .require for struct types

Erdem Demir kerdemdemir at
Sat Sep 10 16:33:03 UTC 2022

import std;

     struct A
         double val;
         bool isBig;

     void main() {
         alias DListOfA = DList!A;
         DListOfA[string] temp;
         A a = {2.0, true};

         DListOfA returnVal = temp.require("a", DListOfA());--> I 
wish I could use ref DListOfA here


On the reference page there is an example with class types only 
( but my type in associative 
array is a DList which is a struct type and that causes I am 
having a copy of my DList after require an operation. And of 
course my insert is happening to the copy and is not affecting to 
the associative array. ,

I wish I could use ref DListOfA returnVal = .... but we can't in 

Can you please suggest alternatives?

More information about the Digitalmars-d-learn mailing list