Given an istream_iterator<int>
and multimap<char, int> output
.
I want to copy all the values into output
's 'a'
key.
How's the best way to handle that?
I had tried to use:
transform(
istream_iterator<int>(input),
istream_iterator<int>(),
begin(output),
[](const auto value){
return make_pair('a', value);
}
)
But I'm getting the error:
error: assignment of read-only member
std::pair<const char, int>::first
I think this means I can't write to begin(output)
. Is my only option to use for_each
?