Initialization of all elements of an array to one default value in C++?

前端 未结 13 1037
礼貌的吻别
礼貌的吻别 2020-11-22 07:59

C++ Notes: Array Initialization has a nice list over initialization of arrays. I have a

int array[100] = {-1};

expecting it to be full with

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 08:32

    In C++, it is also possible to use meta programming and variadic templates. The following post shows how to do it: Programmatically create static arrays at compile time in C++.

提交回复
热议问题