當我正在與我應該使用哪種樣式的c樣式函數進行交互時。vector vs unique_ptr to c style function
我打算從c函數返回後將數據存儲在向量中。一個優於另一個有什麼優勢?
{
auto test = std::make_unique<double[]>(10);
fooCstyle(test);
}
或
{
auto test = std::vector<double>;
test.reserve(10);
fooCstyle(test);
}
什麼是你要調用的函數的簽名和語義? –
fooCstyle(double array [],size_t sizeOfArray); – CodeSlapper