std:: modulus<void>
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Old binders and adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definiert in Header
<functional>
|
||
|
template
<>
class modulus < void > ; |
(seit C++14) | |
std:: modulus < void > ist eine Spezialisierung von std::modulus mit abgeleitetem Parameter- und Rückgabetyp.
Inhaltsverzeichnis |
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
|
||
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);