(1) | template <class T, class Alloc> bool operator== (const forward_list<T,Alloc>& lhs, const forward_list<T,Alloc>& rhs); |
(2) | template <class T, class Alloc> bool operator!= (const forward_list<T,Alloc>& lhs, const forward_list<T,Alloc>& rhs); |
(3) | template <class T, class Alloc> bool operator< (const forward_list<T,Alloc>& lhs, const forward_list<T,Alloc>& rhs); |
(4) | template <class T, class Alloc> bool operator<= (const forward_list<T,Alloc>& lhs, const forward_list<T,Alloc>& rhs); |
(5) | template <class T, class Alloc> bool operator> (const forward_list<T,Alloc>& lhs, const forward_list<T,Alloc>& rhs); |
(6) | template <class T, class Alloc> bool operator>= (const forward_list<T,Alloc>& lhs, const forward_list<T,Alloc>& rhs); |
操作符 | 等价操作 |
a!=b | !(a==b) |
a>b | b<a |
a<=b | !(b<a) |
a>=b | !(a<b) |
// forward_list comparisons #include <iostream> #include <forward_list> int main () { std::forward_list<int> a = {10, 20, 30}; std::forward_list<int> b = {10, 20, 30}; std::forward_list<int> c = {30, 20, 10}; if (a==b) std::cout << "a and b are equal\n"; if (b!=c) std::cout << "b and c are not equal\n"; if (b<c) std::cout << "b is less than c\n"; if (c>b) std::cout << "c is greater than b\n"; if (a<=b) std::cout << "a is less than or equal to b\n"; if (a>=b) std::cout << "a is greater than or equal to b\n"; return 0; } |
forward_list::swap | 交换内容(公众成员函数) |
forward_list::unique | 删除重复的值(公众成员函数) |