std::not_equal_to in C++ with Examples Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The std::not_equal_to is a functional object class for non-equality comparison and binary function object class. It returns a boolean value depending upon the condition whether the two arguments are not equal or not.Header File: #include <functional.h> Template Class: template struct not_equal_to : binary_function { // Declaration of the // not equal to operation bool operator() (const T& x, const T& y) const { return x!=y; } // Type of first parameter typedef T first_argument_type; // Type of second parameter typedef T second_argument_type; // The result is returned // as bool type typedef bool result_type; } Syntax: std::not_equal_to <int> () Parameter: This function accepts the type of the arguments T, as the parameter, to be compared by the functional call.Return Type: It return a boolean value depending upon condition(let a & b are 2 element): True: If a is not equals to b.False: If a is equals to b. Below is the illustration of std::not_equal_to in C++:Program 1: CPP // C++ code to illustrate std::not_equal_to #include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; // Driver Code int main() { // Initialise vectors vector<int> v1 = { 50, 55, 60, 65, 70 }; vector<int> v2 = { 50, 55, 85, 65, 70 }; // Declaring pointer of pairs pair<vector<int>::iterator, vector<int>::iterator> pairs1; // Use mismatch() function to // search first match between // v1 and v2 pairs1 = mismatch(v1.begin(), v1.end(), v2.begin(), not_equal_to<int>()); // Print the match pair cout << "The 1st match element" << " of 1st container : "; cout << *pairs1.first << endl; cout << "The 1st match element " << "of 2nd container : "; cout << *pairs1.second << endl; return 0; } Output: The 1st match element of 1st container : 50 The 1st match element of 2nd container : 50 Program 2: CPP // C++ program to illustrate // std::not_equals_to #include <algorithm> #include <functional> #include <iostream> using namespace std; // Template template <typename A, typename B, typename U = not_equal_to<int> > // Function to check if a != b or not bool f(A a, B b, U u = U()) { return u(a, b); } // Driver Code int main() { int X = 1, Y = 2; // If X is not equals to Y or not cout << boolalpha; cout << f(X, Y) << '\n'; X = -1, Y = -1; // If X is not equals to Y or not cout << f(X, Y) << '\n'; return 0; } Output: true false Reference: https://cplusplus.com/reference/functional/not_equal_to/ Comment More infoAdvertise with us Next Article ratio_equal() in C++ with examples M mehta_tanuj Follow Improve Article Tags : C++ Practice Tags : CPP Similar Reads ratio_not_equal() in C++ with examples The ratio_not_equal is an inbuilt function in C++ STL that checks if two given ratios are not equal or equal. Syntax: template < class ratio1_name, class ratio2_name > ratio_not_equal Template Parameters: The function accepts two template parameters ratio1 and ratio2 which are to be compared. 1 min read ratio_equal() in C++ with examples The ratio_equal() is an inbuilt function in C++ STL that checks if two given ratios are equal or not. Syntax: template < class ratio1_name, class ratio2_name > ratio_equal Template Parameters: The function accepts two template parameters ratio1 and ratio2 which are to be compared. Return value 1 min read std::unary_negate() in C++ with Examples The std::unary_negate() is a wrapper function object returning the complement of the unary predicate it holds. A wrapper function is a subroutine in a software library or a computer program whose main purpose is to call a second subroutine or a system call with little or no additional computation. A 3 min read std::is_nothrow_destructible in C++ with Examples The std::is_nothrow_destructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_denstructible template of C++ STL is used to check whether T is destructible type or not and this is known for not to throw any exception. It return the boolean value true if T 3 min read std::is_nothrow_destructible in C++ with Examples The std::is_nothrow_destructible template of C++ STL is present in the <type_traits> header file. The std::is_nothrow_denstructible template of C++ STL is used to check whether T is destructible type or not and this is known for not to throw any exception. It return the boolean value true if T 3 min read std::mismatch() with examples in C++ C++ STL has lots of useful functions that helps us to achieve various programming tasks. One such function is "mismatch()" . This function, defined in "algorithm" header file, helps to compare 2 containers for mismatches. This function has 2 versions. Both are discussed in this article. mismatch( st 4 min read Like