2013-05-09 2 views
1

나는 다음과 같은 한 :으로 반복 C++에서

map<boost::tuple<int, string>, int> edges; 
edges[boost::make_tuple(1, "a")] = 1; 

간단한 cout << edges[boost::make_tuple(1, "a")] << endl; 그것이 한 것으로 확인;

어떻게 반복 할 수 있습니까? 다음은 작동하지 않는 것 같습니다.

typedef map<boost::tuple<int, string>, int>::iterator it_type; 
for(it_type i = edges.begin(); i != edges.end(); i++) { 
    cout << i->first << endl; 
} 

고마워요!

+2

'i-> second'를 원하셨습니까? –

답변

5

i->firsttuple입니다. 따라서 당신은 단지 cout 일 수 없습니다.

터플에 액세스하는 방법을 알고 싶다면 accessing members of boost:: tuple을 참조하십시오.

이므로 i->second을 사용하면 cout을 사용할 수 있습니다.