Namespaces
Variants

std:: greater<void>

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
Défini dans l'en-tête <functional>
template <>
class greater < void > ;
(depuis C++14)

std:: greater < void > est une spécialisation de std::greater avec le type de paramètre et de retour déduit.

Table des matières

Types imbriqués

Type imbriqué Définition
is_transparent unspecified

Fonctions membres

operator()
teste si lhs est supérieur à rhs
(fonction membre publique)

std::greater<void>:: operator()

template < class T, class U >

constexpr auto operator ( ) ( T && lhs, U && rhs ) const

- > decltype ( std:: forward < T > ( lhs ) > std:: forward < U > ( rhs ) ) ;

Retourne le résultat de std:: forward < T > ( lhs ) > std:: forward < U > ( rhs ) .

Paramètres

lhs, rhs - valeurs à comparer

Valeur de retour

std:: forward < T > ( lhs ) > std:: forward < U > ( rhs ) .

Si un opérateur natif comparant des pointeurs est appelé, le résultat est cohérent avec l'ordre total strict défini par l'implémentation sur les pointeurs .

Exceptions

Peut lever des exceptions définies par l'implémentation.

Exemple

#include <algorithm>
#include <cstdint>
#include <functional>
constexpr bool strictly_positive(int lhs)
{
    return std::greater<>()(lhs, 0);
}
int main()
{
    constexpr std::int64_t low = 0B11;
    constexpr std::uint16_t high = 0X11;
    std::greater<> greater{};
    static_assert(greater(high, low));
    constexpr static auto arr = {0, 1, 2, 3, 4, 5};
    static_assert(!std::all_of(arr.begin(), arr.end(), strictly_positive));
    static_assert(std::all_of(arr.begin() + 1, arr.end(), strictly_positive));
}

Rapports de défauts

Les rapports de défauts modifiant le comportement suivants ont été appliqués rétroactivement aux normes C++ précédemment publiées.

DR Appliqué à Comportement publié Comportement correct
LWG 2562 C++98 l'ordre total des pointeurs pourrait être incohérent garanti d'être cohérent