std::rel_ops::operator>=

From Cppreference

Jump to: navigation, search
Defined in header <utility>

template< class T >
bool operator>=( const T& lhs, const T& rhs );

Given a user-defined operator< for objects of type T, implements the usual semantics of operator>=.

Contents

[edit] Parameters

lhs - left-hand argument
rhs - right-hand argument

[edit] Return value

Returns true if lhs is greater or equal rhs, false otherwise.

[edit] Equivalent function

[edit] Example

#include <iostream>
#include <utility>
struct Foo {
    int n;
};
bool operator<(const Foo& lhs, const Foo& rhs)
{
    return lhs.n < rhs.n;
}
int main()
{
    Foo f1 = {2};
    Foo f2 = {1};
    using namespace std::rel_ops;
    if(f1 >= f2)
        std::cout << "Greater or equal\n";
 
}

Output:

Greater or equal

[edit] See also

operator!=
automatically generated operator!= based on user-defined operator==
(function template)
opreator>
automatically generated operator> based on user-defined operator<
(function template)
operator<=
automatically generated operator<= based on user-defined operator<
(function template)