On 2017-02-16 01:37, ZombineDev wrote:
BTW, shouldn't we use `enum`, instead of `auto`, since everywhere else
`enum` means guaranteed to be computed at compile-time whereas `auto`
means the opposite?
Far enough, since it's not possible to change the parameter inside the
function anyway.
Question though, what happens with an array literal, example:
void foo(int[] a = [1, 2, 3])()
{
auto b = a; // allocation ?
auto c = a; // allocation ?
}
As far as I understand, if an array is declared as a manifest constant
it will cause a new allocation for each time it's used.
enum a = [1, 2, 3];
auto b = a; // new allocation
auto c = a; // new allocation
What happens when an array literal is a default value for a template
parameter?
--
/Jacob Carlborg