0
for_each()
の有効な発現を下回っているは構文的に正しいC++発現for_each(V、[](文字列x)は
for_each(v,[](string x){
cout<<x<<endl;
});
文献:?CppCoreGuidelines.md#p3-express-intent
上記式は、エラーの下スロー:
をerror: no matching function for call to ‘for_each(std::vector<std::__cxx11::basic_string<char> >&, main()::<lambda(std::__cxx11::string)>)’ }); ^ In file included from /usr/include/c++/5/algorithm:62:0, from test.cpp:4: /usr/include/c++/5/bits/stl_algo.h:3761:5: note: candidate: template<class _IIter, class _Funct> _Funct std::for_each(_IIter, _IIter, _Funct) for_each(_InputIterator __first, _InputIterator __last, _Function __f) ^ /usr/include/c++/5/bits/stl_algo.h:3761:5: note: template argument deduction/substitution failed: test.cpp:60:6: note: deduced conflicting types for parameter ‘_IIter’ (‘std::vector<std::__cxx11::basic_string<char> >’ and ‘main()::<lambda(std::__cxx11::string)>’) });
いや、それはない..です – DeiDei
彼らが使用することができます(http [TS範囲]:/を/en.cppreference.com/w/cpp/experimental/ranges) 'for_each'。 – NathanOliver
あなたのコードを詳しく説明できますか?それはあいまいだ。 –