C++ STL Map에서 lowerbound()를 사용하려고했습니다. I 사용하기 전에, I는 다음과 같은 과정을 통해 그 기능을 테스트 I 1 테스트시 C++ map lowerbound()
int main()
{
std::map<int,int> mymap;
std::map<int,int>::iterator itlow;
mymap[1]=20;
mymap[3]=60;
mymap[4]=80;
mymap[5]=100;
itlow=mymap.lower_bound (2);
//Test1
std::cout<<(--itlow)->first<<'\n'; //print 1
std::cout<<itlow->second<<'\n'; //print 20
//Test2
std::cout<<(--itlow)->first<<": "<<itlow->second<<'\n'; //print 1 : 60
}
내가 의미하는 별도 1 및 2를 테스트 I는 Test2를 댓글과 역방향 동일. 테스트 1의 결과가 예상보다 낮지 만, Test2가 20 대신 두 번째 필드 60을 인쇄하는 이유를 모르겠습니다.
테스트 2에는 정의되지 않은 동작이 있습니다. – chris
좀 더 구체적으로 말씀해 주시겠습니까? 감사! – diane
[예제보기] (http://stackoverflow.com/questions/949433/why-are-these-constructs-undefined-behavior) 많은 예제가 있습니다. [이] (http://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points?rq=1)도 있습니다. – chris