Re: How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Jack via Digitalmars-d-learn
On Sunday, 7 February 2021 at 21:55:34 UTC, Adam D. Ruppe wrote: On Sunday, 7 February 2021 at 21:40:12 UTC, Jack wrote: I think it would be fine except it assumes the number of items of the array to doesn't grow, it rather overwritten new elements from docs: "Use this only when it is

Re: How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 7 February 2021 at 21:40:12 UTC, Jack wrote: I think it would be fine except it assumes the number of items of the array to doesn't grow, it rather overwritten new elements from docs: "Use this only when it is certain there are no elements in use beyond the array in the memory

Re: How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Jack via Digitalmars-d-learn
On Sunday, 7 February 2021 at 21:34:22 UTC, Adam D. Ruppe wrote: On Sunday, 7 February 2021 at 21:31:11 UTC, Jack wrote: assumeSafeAppend() wouldn't work in this case because I don't know the number of items that is going to be added to the array. I don't think that matters. assumeSafeAppend

Re: How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 7 February 2021 at 21:31:11 UTC, Jack wrote: assumeSafeAppend() wouldn't work in this case because I don't know the number of items that is going to be added to the array. I don't think that matters. assumeSafeAppend seems appropriate for your need.

How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Jack via Digitalmars-d-learn
How can I do that? I though something like this: auto arr = [1, 2, 3, 4]; arr = arr[0 .. 0]; arr ~= 6; // does this cause reallocation? assumeSafeAppend() wouldn't work in this case because I don't know the number of items that is going to be added to the array. I thought into setting the

Re: Is there a generic type such as void* or C#'s object?

2021-02-07 Thread Jack via Digitalmars-d-learn
Thanks for your answers guys!

GC.addRange in pure function

2021-02-07 Thread vitamin via Digitalmars-d-learn
Why using 'new' is allowed in pure functions but calling GC.addRange or GC.removeRange isn't allowed?

Need help for opencvd git submoduling

2021-02-07 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
I am wrapping opencv::cuda modules based on c/c++ wrapper files of gocv. This might be more of a git question. Can one link a folder from a repo to be a subfolder of another git repo? Do I have any option other than submoduling the entire Go repo? I want

Re: Vibe.d diet template help

2021-02-07 Thread Arjan via Digitalmars-d-learn
On Sunday, 7 February 2021 at 00:05:51 UTC, Tim wrote: Hi all, I'm trying to render a diet template out to a WebSocket as a string to be inserted into a specific portion of the currently served page. Does anyone know how to go about this? Is the websocket really needed? Otherwise a plain