当我编译(g++ -std=c++14 map.cpp
并运行该程序时,它似乎没有终止。谁能解释为什么?但是,当我确实找到('a')而不是'c'时,它给出了零。
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
map<char,float> m;
m['a'] = 3.4;
m['b'] = 5.3;
m['c'] = 33.3;
m['d'] = 43.;
auto it = m.find( 'c' );
cout << "distance : " << std::distance( it,m.begin() ) << endl;
}