Initialize std::array with a range (pair of iterators)

后端 未结 3 779
北恋
北恋 2020-12-05 14:16

How can I initialize an std::array from a range (as defined by a pair of iterators)?

Something like this:

vector v;
...
// I kn         


        
3条回答
  •  无人及你
    2020-12-05 15:08

    Like you have noticed, std::array has no constructors at all (except for the compiler generated default constructor).

    This was done on purpose, so it can be statically initialized just like a C array. If you want to fill the array without a static initializer, you will have to copy your data.

提交回复
热议问题