08/01/16 22:41:31
>>32
すいません。
コンパイルエラー
test.cpp:73: instantiated from here
/usr/include/c++/4.2.1/bits/stl_algo.h:936: error: no match for call to
'(std::unary_function<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, int>) (std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)'
vの型vector<string>
v2の型vector<int>
です。
先の関数はこんな感じ() {
int begin, end;
vector<string> v;
begin = end = 0;
while (line[end]) {
begin = end;
while (line[end] != delim && line[end]) {
end++;
}
v.push_back(line.substr(begin, end-begin));
end++;
}
vector<int> v2(v.size());
transform(v.begin(), v.end(), v2.begin(), func);
return v2;
}