Why can't you omit the array size in a new initializer?

前端 未结 3 1950
执念已碎
执念已碎 2021-01-04 01:01

This is allowed:

int a[]{1, 2, 3};

But not this:

auto a = new int[]{1, 2, 3};

You have to specify the bou

3条回答
  •  無奈伤痛
    2021-01-04 01:22

    As Jonathan Wakely already pointed out in the comments, this is in fact a closed issue. The resolution "should be handled in Evolution Work Group" essentially means WG21 thinks it's not a bad idea per se, but at the same time they don't consider it a defect in the current standard. Which makes sense - there's no hint somewhere that is should work, it's just by analogy.

提交回复
热议问题