Accessing iterators in a range for loop (c++11)

Viewed 260

Can I use the range for-loop to access the actual iterators instead of the value_type of a container?

Sample code of what I want to do (does not compile, as x is pair ):

#include <iostream>
#include <map>

using namespace std;

std::map<int, float> v;

int main()
{
   for(auto x : v)    
       cout<<x->first<<", "<<x->second<<endl;
   return 0;
}
2 Answers
Related