Namespaces
Variants

std::chrono::month:: operator++, std::chrono::month:: operator--

From cppreference.net
constexpr std:: chrono :: month & operator ++ ( ) noexcept ;
(1) (seit C++20)
constexpr std:: chrono :: month operator ++ ( int ) noexcept ;
(2) (seit C++20)
constexpr std:: chrono :: month & operator -- ( ) noexcept ;
(3) (seit C++20)
constexpr std:: chrono :: month operator -- ( int ) noexcept ;
(4) (seit C++20)

Addiert oder subtrahiert 1 vom Monatswert und reduziert das Ergebnis modulo 12 auf eine Ganzzahl im Bereich [ 1 , 12 ] .

1,2) Führt * this + = std:: chrono :: months { 1 } ; aus.
3,4) Führt * this - = std:: chrono :: months { 1 } ; aus.

Inhaltsverzeichnis

Parameter

(keine)

Rückgabewert

1,3) Ein Verweis auf diesen month nach der Modifikation.
2,4) Eine Kopie des month vor der Änderung erstellt.

Hinweise

Nach einem Aufruf einer dieser Funktionen ist ok ( ) immer true .

Beispiel

#include <cassert>
#include <chrono>
#include <iostream>
int main()
{
    std::chrono::month m{6};
    ++m;
    assert(m == std::chrono::month(7));
    --m;
    assert(m == std::chrono::month(6));
    m = std::chrono::December;
    m++; // rundet auf Januar auf
    assert(m.ok());
    std::cout << unsigned(m) << '\n';
    m = std::chrono::January;
    m--; // rundet auf Dezember ab
    assert(m.ok());
    std::cout << unsigned(m) << '\n';
}

Ausgabe:

1
12

Siehe auch

addiert oder subtrahiert eine Anzahl von Monaten
(öffentliche Elementfunktion)
führt arithmetische Operationen auf month s aus
(Funktion)