operator<= (<stack>)

如果在运算符左侧的堆栈对象小于或等于右侧,的堆栈测试对象。

bool operator<=(
   const stack <Type, Container>& _Left,
   const stack <Type, Container>& _Right
);

参数

  • _Left
    类型 stack对象。

  • _Right
    类型 stack对象。

返回值

true,如果在运算符左侧的堆栈小于或等于堆栈在运算符的右侧;否则 false

备注

堆栈对象之间的比较根据其元素的比较pairwise。小于或等于两个堆栈对象之间的关系于比较的第一对不相等元素。

示例

// stack_op_le.cpp
// compile with: /EHsc
#include <stack>
#include <iostream>

int main( )
{
   using namespace std;

   // Declares stacks with default deque base container
   stack <int> s1, s2, s3;

   s1.push( 5 );
   s1.push( 10 );
   s2.push( 1 );
   s2.push( 2 );
   s3.push( 5 );
   s3.push( 10 );

   if ( s1 <= s2 )
      cout << "The stack s1 is less than or equal to "
           << "the stack s2." << endl;
   else
      cout << "The stack s1 is greater than "
           << "the stack s2." << endl;

   if ( s1 <= s3 )
      cout << "The stack s1 is less than or equal to "
           << "the stack s3." << endl;
   else
      cout << "The stack s1 is greater than "
           << "the stack s3." << endl;
}
  
  

要求

标头: <stack>

命名空间: std

请参见

参考

标准模板库