g++ 不喜欢:
vector<int> x;
x += 1,2,3,4,5;
vector<string> y(x.size());
transform(x.begin(), x.end(), y.begin(), lexical_cast<string>);
错误信息是:
error: no matching function for call to 'transform(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, <unresolved overloaded function type>)'
这清楚地表明 lexical_cast 作为 transform 的最后一个参数存在问题......有没有办法避免编写包装 lexical_cast 的函数对象?
谢谢!