A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_forward_list_operator_not_equal_to.htm below:

C++ Forward_list Library - operator!= Function

C++ Forward_list Library - operator!= Function Description

The C++ function std::forward_list::operator!= tests whether two forward_lists are equal or not.

Declaration

Following is the declaration for std::forward_list::operator!= function form std::forward_list header.

C++11
template <class T, class Alloc>
bool operator!= (const forward_list<T,Alloc>& first, const forward_list<T,Alloc>& second);
Parameters Return value

Returns true if first forward_list is not same as second otherwise false.

Exceptions

This member function never throws exception.

Time complexity

Linear i.e. O(n)

Example

The following example shows the usage of 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;
}

Let us compile and run the above program, this will produce the following result −

Both lists not are equal.
Both lists not equal.

forward_list.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4