+ 1

how to compare current and previous element in list

Hi Refer code below: map<string, vector<string>> data; has vector as value. If I need list as value, how to iterate over list? We can iterate with begin and end, but how to compare last element with current element for list? https://www.sololearn.com/compiler-playground/cn5CwUsYlr6Y

26th Sep 2022, 7:04 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Answers
26th Sep 2022, 4:12 PM
Arsenic
Arsenic - avatar
+ 2
Ketan Lalcheta "std::advance ()" doesn't return anything, it simple advances the iterator passed to it.
27th Sep 2022, 11:32 AM
Arsenic
Arsenic - avatar
+ 1
I was trying advance with -1.. is it correct ? I was getting incomplete type error with below : auto pv = std::advance(it,-1);
27th Sep 2022, 5:45 AM
Ketan Lalcheta
Ketan Lalcheta - avatar