Cleanest way to copy a constant size array in c++11

前端 未结 5 1028
孤街浪徒
孤街浪徒 2020-12-13 17:29

I often find myself wanting to copy the contents of arrays that have a constant size, I usually just write something along the lines of:

float a[4] = {0,1,2,         


        
5条回答
  •  青春惊慌失措
    2020-12-13 17:45

    Below method works for usual arrays as well std:array.

    float a[4] = {0,1,2,3};
    float b[4];
    
    std::copy(std::begin(a), std::end(a), b);
    

提交回复
热议问题