Anon @ Sun Feb 24, 2008 11:37 am wrote:
code: |
grid some_function(); |
The primary disadvantage is that you are really copying the array. Note that what you are doing is likely having an
automatic array inside the function, and even if it is a static array, you are getting a temporary created (and associated
copying) when you return the aggregate from the function. If you are doing assignment after, you copy yet again. If you expect a compiler to optimize this away then let us hope you have one with good Inter-Procedural Analysis. (It is likely that a compiler could take care of the last copy when you are assigning the result directly).