Bibliothèque C ++ Forward_list - opérateur! = Fonction

La description

La fonction C ++ std::forward_list::operator!= teste si deux forward_lists sont égales ou non.

Déclaration

Voici la déclaration de l'en-tête std :: forward_list :: operator! = Function form 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 n'est pas la même que la seconde sinon false.

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 std :: forward_list :: operator! = Function.

#include <iostream>
#include <forward_list>

using namespace std;

int main(void) {

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

   if (fl1 != fl2)
      cout << "Both lists not are equal." << endl;

   fl1.push_front(1);

   if (!(fl1 != fl2))
      cout << "Both lists not equal." << endl;

   return 0;
}

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

Both lists not are equal.
Both lists not equal.