J
Jess
Hello,
The C++ reference says the return result of "copy" is an output
iterator. I'm wondering how I can assign the returned iterator to
some other iterator. I tried
int main(){
string s("abcdefg");
vector<char> v;
vector<char>::iterator k = copy(s.begin(),s.end(),back_inserter(v));
return 0;
}
because for "copy", the returned iterator should point to the last
element in the destination range. However, the code above couldn't
compile. What's my problem? Moreover, does "copy" return the iterator
pointing to the last element or one past the last element?
As for "remove_copy", does it return the iterator pointing to one past
the last element? How can I assign the return result to some
iterator? I think it should be the same as for "copy".
Thanks,
Jess
The C++ reference says the return result of "copy" is an output
iterator. I'm wondering how I can assign the returned iterator to
some other iterator. I tried
int main(){
string s("abcdefg");
vector<char> v;
vector<char>::iterator k = copy(s.begin(),s.end(),back_inserter(v));
return 0;
}
because for "copy", the returned iterator should point to the last
element in the destination range. However, the code above couldn't
compile. What's my problem? Moreover, does "copy" return the iterator
pointing to the last element or one past the last element?
As for "remove_copy", does it return the iterator pointing to one past
the last element? How can I assign the return result to some
iterator? I think it should be the same as for "copy".
Thanks,
Jess