Bibliothèque C ++ Forward_list - opérateur> Fonction

La description

La fonction C ++ std::forward_list::operator> teste si la première forward_list est supérieure ou non à other.

Déclaration

Voici la déclaration pour l'en-tête std :: forward_list :: operator> function std :: forward_list.

C ++ 11

template <class T, class Alloc>
bool operator> (const forward_list<T,Alloc>& first, const forward_list<T,Alloc>& second);

Paramètres

  • first - Premier objet forward_list.

  • second - Deuxième objet forward_list du même type.

Valeur de retour

Renvoie true si la première forward_list est supérieure à la seconde, sinon false.

Des exceptions

Cette fonction membre ne lève jamais d'exception.

Complexité temporelle

Linéaire ie O (n)

Exemple

L'exemple suivant montre l'utilisation de la fonction std :: forward_list :: operator>.

#include <iostream>
#include <forward_list>

using namespace std;

int main(void) {

   forward_list<int> fl1 = {1, 2, 3, 4, 5};
   forward_list<int> fl2 = {1, 2, 3, 4};

   if (fl1 > fl2)
      cout << "First list is greter than second." << endl;

   fl1 = fl2;

   if (!(fl1 > fl2))
      cout << "First list is not greter than second." << endl;

   return 0;
}

Compilons et exécutons le programme ci-dessus, cela produira le résultat suivant -

First list is greter than second.
First list is not greter than second.