Search code examples
c++vectorinitializationinfinity

C++ - Vector initialization failing


I'm attempting to initialize a multi-dimensional vector with:

vector<double> v0(point_list.size(), numeric_limits<double>::max);
vector<vector<double> > v1(point_list.size(),v0);

Unfortunately, I'm getting the error:

error: no matching function for call to ‘std::vector<double>::vector(std::vector<std::vector<int> >::size_type, double (&)()throw ())’

Can anyone explain this to me and how to fix it?

Thanks!


Solution

  • numeric_limits<double>::max is a function. You wanted to say:

    vector<double> v0(point_list.size(), numeric_limits<double>::max());