Namespaces
Variants

std::modulus<void>

Von de.cppreference.net
 
 
Dienstprogrammbibliothek
Sprachunterstützung
Typunterstützung (Basistypen, RTTI)
Bibliotheks-Feature-Test-Makros (C++20)
Programm-Dienstprogramme
Variadische Funktionen
Koroutinen-Unterstützung (C++20)
Vertragsunterstützung (C++26)
Dreiseitiger Vergleich
(C++20)
(C++20)(C++20)(C++20)    
(C++20)(C++20)(C++20)

Allgemeine Dienstprogramme
Relationale Operatoren (veraltet in C++20)
Ganzzahl-Vergleichsfunktionen
(C++20)(C++20)(C++20)    
(C++20)
Tauschen und Typoperationen
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Allgemeine Vokabular-Typen
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
Funktionsobjekte
Funktionsaufruf
(C++17)(C++23)
Identitätsfunktionsobjekt
(C++20)
Transparente Operator-Wrapper
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

Alte Binder und Adaptoren
(bis C++17*)
(bis C++17*)
(bis C++17*)
(bis C++17*)
(bis C++17*)(bis C++17*)(bis C++17*)(bis C++17*)
(bis C++20*)
(bis C++20*)
(bis C++17*)(bis C++17*)
(bis C++17*)(bis C++17*)

(bis C++17*)
(bis C++17*)(bis C++17*)(bis C++17*)(bis C++17*)
(bis C++20*)
(bis C++20*)
 
Definiert im Header <functional>
template<>
class modulus<void>;
(seit C++14)

std::modulus<void> ist eine Spezialisierung von std::modulus, bei der Parameter- und Rückgabetyp abgeleitet werden.

Verschachtelte Typen

Geschachtelter Typ Definition
is_transparent unspecified

Memberfunktionen

operator()
gibt den Modulus zweier Argumente zurück
(öffentliche Elementfunktion)

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

template < class T, class U >

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

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

Gibt den Rest der Division von lhs durch rhs zurück.

Parameter

lhs, rhs - zu dividierende Werte

Rückgabewert

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

Beispiel

#include <functional>
#include <iostream>
struct M
{
    M(int x) { std::cout << "M(" << x << ");\n"; }
    M() {}
};
auto operator%(M, M) { std::cout << "operator%(M, M);\n"; return M{}; }
auto operator%(M, int) { std::cout << "operator%(M, int);\n"; return M{}; }
auto operator%(int, M) { std::cout << "operator%(int, M);\n"; return M{}; }
int main()
{
    M m;
    // 42 wird in ein temporäres Objekt M{42} konvertiert
    std::modulus<M>{}(m, 42);    // ruft operator%(M, M) auf
    // kein temporäres Objekt
    std::modulus<void>{}(m, 42); // ruft operator%(M, int) auf
    std::modulus<void>{}(42, m); // ruft operator%(int, M) auf
}

Ausgabe:

M(42);
operator%(M, M);
operator%(M, int);
operator%(int, M);