1

Please tell me why std::deque - you can add a "step" to the iterator, but it doesn't work for std::multimap ?

#include <iostream>
#include <deque>
#include <map>

int main()
{    
    std::deque<int>my_deq;
    std::deque<int>::iterator iterator_deq;
    iterator_deq = my_deq.begin() + 1;    

    std::multimap<std::string, int>my_multimap;
    std::multimap<std::string, int>::iterator iterator;
    iterator = my_multimap.begin() + 1;       //This is not possible, VS2019 gives an error.    
}
Evg
  • 25,259
  • 5
  • 41
  • 83
Optimus1
  • 444
  • 2
  • 13
  • 2
    `std::deque` provides a random-access iterator, and `std::multimap` only a bidirectional one. Only random-access iterators support addition because only for those iterator addition can be a O(1) operation. – Evg Jun 22 '22 at 16:23

0 Answers0