Intermediate HW 16 - Problem 2 error with istream_iterator
Posted: May 8th, 2019, 2:52 pm
I have been a huge fan of the Chili C++ series' for a while, and was working on the solution for problem 2 in the I-16 Homework. In this transform function:
I get the following errors with the first istream_iterator:
I attached a screenshot of what I am seeing.
Code: Select all
std::transform(
std::istream_iterator<std::string>( std::istringstream( nambies)),
std::istream_iterator<std::string>(),
std::ostream_iterator<int>(std::cout),
[&numbers](const std::string& word)
{
return std::find_if(numbers.begin(), numbers.end(),
[&word](const Pube& p)
{
return p.str == word;
}
)->num;
}
);
- no instance of constructor "std::istream_iterator<_Ty, _Elem, _Traits, _Diff>::istream_iterator [with _Ty=std::string, _Elem=char, _Traits=std::char_traits<char>, _Diff=ptrdiff_t]" matches the argument list
- '<function-style-cast>': cannot convert from 'std::istringstream' to 'std::istream_iterator<std::string,char,std::char_traits<char>,ptrdiff_t>'
I attached a screenshot of what I am seeing.