Dynamic arrays / ~= giving an exception...
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jul 2 18:46:28 UTC 2018
On 7/1/18 4:55 PM, Robert M. Münch wrote:
> I'm a bit puzzled because I think this is pretty straight forward but
> doesn't work...
>
> struct mystruct {
> myPtr* root;
>
> opApply(...){
> myPtr*[] childs;
>
> childs ~= root;
> ...
> }
> }
>
> foreach(node; mystruct(myRoot)){
> ...
> }
>
> It compiles but the line with ~= gives the nice "bing" under Windows and
> the application hangs...
>
> What doesn't this work?
>
It should work. We need more context to try and help figure it out. Even
if you can't post the entire program, maybe more context from mystruct.
In general:
T*[] arr;
arr ~= someTPtr;
should ALWAYS work. There is absolutely no postblits or dangling
pointers happening at THIS point, and you are allocating an array to
hold a pointer.
I suspect that your diagnosis of where the problem is happening is faulty.
-Steve
More information about the Digitalmars-d-learn
mailing list