operator<= |
C++ Library |
template<class T, class A> bool operator<=(const multimap<T, A>&mm1, const multimap<T, A>&mm2) ;
Returns true if !(mm1 > mm2).
#include <map> #include <iostream> #include <utility> int main() { std::multimap<int, int> c1, c2, c3, c4 ; int i ; typedef std::pair<int, int> INT_PAIR ; for (i = 0; i < 10; i++) { c1.insert(INT_PAIR(i, i)) ; c2.insert(INT_PAIR(i*i, i*i)) ; c3.insert(INT_PAIR(i*i*i, i*i*i)) ; c4.insert(INT_PAIR(i, i)) ; } if (c1 == c4) std::cout << "c1 == c4" << std::endl ; if (c2 != c3) std::cout << "c2 != c3" << std::endl ; if(c2 < c3) std::cout << "c2 < c3" << std::endl ; if(c3 > c2) std::cout << "c3 > c2" << std::endl ; c4.insert(INT_PAIR(29, 29)) ; if (c1 <= c4) std::cout << "after c4.insert(INT_PAIR(29,29)), c1 <= c4" << std::endl ; if (c3 >= c2) std::cout << "c3 >= c2" << std::endl ; std::swap(c3, c2) ; std::cout << "after swapping c3 with c2, " ; if (c3 >= c2) std::cout << "c3 >= c2" << std::endl ; else std::cout << "c3 < c2" << std::endl ; return 0 ; }
c1 == c4 c2 != c3 c2 < c3 c3 > c2 after c4.insert(INT_PAIR(29,29)), c1 <= c4 c3 >= c2 after swapping c3 with c2, c3 < c2