Why does std::array not have an constructor that takes a value for the array to be filled with?

前端 未结 4 1713
南方客
南方客 2020-11-30 05:38

Is the absence of

std::array::array(const T& value);

an oversight? It seems mighty useful to me, and dynamic containers (

4条回答
  •  伪装坚强ぢ
    2020-11-30 05:59

    First of all, it is not std::array, it is std::array where N is compile time constant integral expression.

    Second, std::array is made aggregate by design. So it doesn't have anything which makes it non-aggregate, which is why it doesn't have constructor... and destructor, virtual functions, etc.

提交回复
热议问题