The problem is probably that Visual Studio 2010 does not support C++11 initialization lists for vectors. Although I cannot test with VS2010, I could imagine that this task could be solved with a template function. Here, a two-dimensional vector is initialized with predefined values.
template<typename T, size_t N, size_t M>
void initializeVector(std::vector<std::vector<T>>&targetVector, const T(&sourceArray)[N][M]) {
for (size_t i = 0; i < N; ++i) {
std::vector<T> row;
for (size_t j = 0; j < M; ++j) {
row.push_back(sourceArray[i][j]);
}
targetVector.push_back(row);
}
}
This could then be used as follows:
std::vector<std::vector<double>> myArray;
const double predefinedValues[3][3] = {
{1.0, 2.0, 3.0},
{4.0, 5.0, 6.0},
{7.0, 8.0, 9.0}
};
initializeVector(myArray, predefinedValues);