Re: Better way to append to array than ~= ?

2018-04-04 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 19:02:25 UTC, Vladimirs Nordholm wrote: Hello people. I currently have a function which multiple times per second takes in arguments, and appends the argument as my special type. The following code should explain what I do more properly: struct MySpecialType

Re: Better way to append to array than ~= ?

2018-04-04 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 20:41:01 UTC, Alex wrote: On Tuesday, 3 April 2018 at 20:02:46 UTC, Vladimirs Nordholm wrote: On Tuesday, 3 April 2018 at 19:53:11 UTC, Meta wrote: [...] I don't think I know the size of the arguments. If I pass in "123" and MySpecialType('a'), the result should

Re: Better way to append to array than ~= ?

2018-04-03 Thread Alex via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 20:02:46 UTC, Vladimirs Nordholm wrote: On Tuesday, 3 April 2018 at 19:53:11 UTC, Meta wrote: On Tuesday, 3 April 2018 at 19:02:25 UTC, Vladimirs Nordholm wrote: [...] In this specific case, since you know the length of `Args`, you can pre-allocate an array of

Re: Better way to append to array than ~= ?

2018-04-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 20:02:46 UTC, Vladimirs Nordholm wrote: On Tuesday, 3 April 2018 at 19:53:11 UTC, Meta wrote: On Tuesday, 3 April 2018 at 19:02:25 UTC, Vladimirs Nordholm wrote: [...] In this specific case, since you know the length of `Args`, you can pre-allocate an array of

Re: Better way to append to array than ~= ?

2018-04-03 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 19:53:11 UTC, Meta wrote: On Tuesday, 3 April 2018 at 19:02:25 UTC, Vladimirs Nordholm wrote: [...] In this specific case, since you know the length of `Args`, you can pre-allocate an array of that size and loop through it doing your initialization. However, if

Re: Better way to append to array than ~= ?

2018-04-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 19:02:25 UTC, Vladimirs Nordholm wrote: Hello people. I currently have a function which multiple times per second takes in arguments, and appends the argument as my special type. The following code should explain what I do more properly: struct MySpecialType

Better way to append to array than ~= ?

2018-04-03 Thread Vladimirs Nordholm via Digitalmars-d-learn
Hello people. I currently have a function which multiple times per second takes in arguments, and appends the argument as my special type. The following code should explain what I do more properly: struct MySpecialType { char c; } auto foo(Args...)(Args args) {