Search code examples
c++parallel-processingc++17visual-studio-2019

"no instance of overloaded function "transform" matches the argument list" error with parallel execution


I have a seemingly simple problem with C++17. In below code only the last line is producing an error where I am trying to go with a parallel execution:

  vector<double> v(1000);
  transform(v.begin(), v.end(), v.begin(), [](double a) { return 2.0 * a; });                           // This is fine
  transform(std::execution::par, v.begin(), v.end(), v.begin(), [](double a) { return 2.0 * a; });      // std::execution::par does not seem to of the right type

Looks like std::execution::par is of the wrong type which is leading to "no instance of overloaded function "transform" matches the argument list" error. I am using C++17 with Visual Studio 19 where the intellisense is okay with it. The error is appearing during compilation. What could be the problem?

Edit: Here is the full error message:

1>c:\users\*\file_path_name.cpp(128): error : name followed by "::" must be a class or namespace name
1>
1>c:\users\*\file_path_name.cpp(128): error : no instance of overloaded function "transform" matches the argument list
1>            argument types are: (<error-type>, std::_Vector_iterator<std::_Vector_val<std::conditional_t<true, std::_Simple_types<double>, std::_Vec_iter_types<double, size_t, ptrdiff_t, double *, const double *, double &, const double &>>>>, std::_Vector_iterator<std::_Vector_val<std::conditional_t<true, std::_Simple_types<double>, std::_Vec_iter_types<double, size_t, ptrdiff_t, double *, const double *, double &, const double &>>>>, std::_Vector_iterator<std::_Vector_val<std::conditional_t<true, std::_Simple_types<double>, std::_Vec_iter_types<double, size_t, ptrdiff_t, double *, const double *, double &, const double &>>>>, lambda [](double)->double)
1>

Solution

  • Found out the problem. Cuda was interfering with it. Switching to a non cuda console project fixed the problem.