6
将未知大小的std :: array传递给函数
在C ++ 11中,我将如何编写采用已知类型但大小未知的std :: array的函数(或方法)? // made up example void mulArray(std::array<int, ?>& arr, const int multiplier) { for(auto& e : arr) { e *= multiplier; } } // lets imagine these being full of numbers std::array<int, 17> arr1; std::array<int, 6> arr2; std::array<int, 95> arr3; mulArray(arr1, 3); mulArray(arr2, 5); mulArray(arr3, 2); …