opConcatAll?

jmh530 john.michael.hall at gmail.com
Thu Jul 2 19:18:49 UTC 2020


On Thursday, 2 July 2020 at 18:40:21 UTC, Steven Schveighoffer 
wrote:
>> [snip]
>> 
>> With a few small changes, you could just as easily have written
>> 
>> int[] newArr;
>> newArr[] = [0, 0, 0] + arr[] + [4, 5, 6];
>> 
>> which is similar to the traditional type of problem that 
>> expression templates were designed to solve.
>
> Hm.. I think you misunderstand the example.
>
> -Steve

I think I understand the example, but I may not have made my 
point clear enough...

You are concerned about a ~ b ~ c and avoiding unnecessary 
allocations.

Expression templates are concerned with problems like a + b + c 
and avoiding the use of unnecessary temporaries.

They seem like similar problems to me. Temporaries and 
allocations are obviously different, but the structure of the 
problem is similar. You yourself note that "most of the 
allocations as temporaries".

If my point makes sense, then the implication is that this is a 
problem that is not unique to concatenation and also applies to 
the mathematical operators, in their own way.


More information about the Digitalmars-d mailing list