Libreria stack C ++ - operatore <= Funzione
Descrizione
La funzione C ++ std::stack::operator<= controlla se il primo stack è minore o uguale ad altri oppure no.
Dichiarazione
Di seguito è riportata la dichiarazione per std :: stack :: operator <= function form std :: stack header.
C ++ 98
template <class T, class Container>
bool operator<= (const stack<T,Container>& stack1,
                 const stack<T,Container>& stack2);Parametri
- stack1 - Primo stack. 
- stack2 - Secondo stack. 
Valore di ritorno
Restituisce vero se il primo stack è minore o uguale al secondo, altrimenti falso.
Eccezioni
Questa funzione non genera mai eccezioni.
Complessità temporale
Lineare cioè O (n)
Esempio
L'esempio seguente mostra l'utilizzo della funzione std :: stack :: operator <=.
#include <iostream>
#include <stack>
using namespace std;
int main(void) {
   stack<int> s1;
   stack<int> s2;
   for (int i = 0; i < 5; ++i) {
      s1.push(i + 1);
      s2.push(i + 1);
   }
   if (s1 <= s2)
      cout << "Stack s1 is less than or equal to s2." << endl;
   s1.push(6);
   if (!(s1 <= s2))
      cout << "Stack s1 is not less than or equal to s2." << endl;
   return 0;
}Compiliamo ed eseguiamo il programma sopra, questo produrrà il seguente risultato:
Stack s1 is less than or equal to s2.
Stack s1 is not less than or equal to s2.