C++ specify array indexes in initializer, like C

后端 未结 3 648
余生分开走
余生分开走 2021-01-17 12:18

I used C before (embedded stuff), and I can initialize my arrays like that:

int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };

i

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 12:43

    After years, I tested it just by chance, and I can confirm that it works in g++ -std=c++11, g++ version is 4.8.2.

提交回复
热议问题