Given a std::list iterator called it, it1++ is equivalent to it1=it1+1. So why then does it1++ work fine, but it1=it1+1 is giving an error in the below code?
Code
#include <iostream>
#include <list>
int main()
{
std::list<int> l1{19, 2, 3, 21, 5, 19, 7, 11};
std::list<int>::iterator it1;
std::cout << "1st\n";
it1 = l1.begin();
it1++;
it1 = it1 + 1; // This giving error
}
Output
Invalid operands to binary expression
('std::list<int>::iterator' (aka '_List_iterator<int>') and 'int')