Default initialization of std::array?

前端 未结 5 974
青春惊慌失措
青春惊慌失措 2020-11-28 04:40

With C++11 std::array, do I have the guarantee that the syntax std::array x; will default-initialize all the elements of the array ?

5条回答
  •  清酒与你
    2020-11-28 04:51

    First of all, T x[N] does default initialize the elements, although default initialization of a scalar type T actually does nothing. The above also holds for std::array x. I think what you need is list initialization.

提交回复
热议问题