Re: Problem using std::prev on ustring iterator
- From: Jonathan Wakely <gtkmm kayari org>
- To: "jeremy.harmon" <jeremy harmon zoho com>
- Cc: "gtkmm-list gnome org" <gtkmm-list gnome org>
- Subject: Re: Problem using std::prev on ustring iterator
- Date: Fri, 18 Mar 2016 18:11:22 +0000
On 18 March 2016 at 17:57, jeremy.harmon wrote:
Hello,
When I try to use std::prev on a ustring const_iterator nothing
happens, operator-- works fine.
Glib::ustring str = "test";
Glib::ustring::iterator iter = str.begin();
std::advance(iter);
printf("%c\n", *iter);
std::prev(iter);
printf("%c\n", *iter);
iter--;
printf("%c\n", *iter);
Output is
e
e
t
Any ideas why it doesn't work?
Because unlike std::advance, std::prev doesn't modify its argument, it
returns the new iterator instead.
http://en.cppreference.com/w/cpp/iterator/prev
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]