我无法弄清楚如何在recursive_directory_iterator上使用Concurrency :: parallel_for,编译器不喜欢Step param。
你可以将parallel_for [each]东西用于除数组以外的任何东西吗?
简单代码:
recursive_directory_iterator dir(cwd, directory_options::skip_permission_denied);
recursive_directory_iterator end_dir;
parallel_for(begin(dir), end(dir), begin(dir), [&](recursive_directory_iterator dir) {
});
导致关于第三个参数_Step:
的大量错误Error C2678 binary '<': no operator found which takes a left-hand operand of type 'std::filesystem::recursive_directory_iterator' (or there is no acceptable conversion) app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2501
Error C2678 binary '>=': no operator found which takes a left-hand operand of type 'std::filesystem::recursive_directory_iterator' (or there is no acceptable conversion) app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2507
Error C2784 'unknown-type std::operator -(const std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &)': could not deduce template argument for 'const std::move_iterator<_RanIt> &' from 'std::filesystem::recursive_directory_iterator' app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2514
Error C2784 'unknown-type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)': could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::filesystem::recursive_directory_iterator' app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2514
Error C2676 binary '-': 'std::filesystem::recursive_directory_iterator' does not define this operator or a conversion to a type acceptable to the predefined operator app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2514
Error C2672 '_Parallel_for_partitioned_impl': no matching overloaded function found app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2525
Error C2893 Failed to specialize function template 'void Concurrency::_Parallel_for_partitioned_impl(_Index_type,_Diff_type,_Diff_type,const _Function &,const Concurrency::auto_partitioner &)' app c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\ppl.h 2525
看起来我需要以某种方式调整迭代器,但我不确定如何 - 我可以将dir recurse转换为数组,但这感觉不太正确。
有什么想法吗?
TIA