В приведенном ниже коде.
int main() {
list<int> m_list;
m_list.push_back(1);
list<int>::iterator it1 = (--m_list.end()); // it works, *it1 return 1;
list<int>::iterator it2 = (m_list.end() - 1); // compile issue?
}
Кто-нибудь объяснит, почему в списке (m_list.end () - 1) есть проблема компиляции?и почему (--m_list.end ()) в порядке?Если мы изменим на другие, вектор, строка.оба случая работают.
int main() {
vector<int> m_vector;
m_vector.push_back(1);
vector<int>::iterator it1 = (--m_vector.end()); // both work
vector<int>::iterator it2 = (m_vector.end() - 1); // both work
}