Namespaces
Variants

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

From cppreference.net
constexpr std:: chrono :: month & operator ++ ( ) noexcept ;
(1) (начиная с C++20)
constexpr std:: chrono :: month operator ++ ( int ) noexcept ;
(2) (начиная с C++20)
constexpr std:: chrono :: month & operator -- ( ) noexcept ;
(3) (начиная с C++20)
constexpr std:: chrono :: month operator -- ( int ) noexcept ;
(4) (начиная с C++20)

Добавляет или вычитает 1 из значения месяца, приводя результат по модулю 12 к целому числу в диапазоне [ 1 , 12 ] .

1,2) Выполняет * this + = std:: chrono :: months { 1 } ; .
3,4) Выполняет * this - = std:: chrono :: months { 1 } ; .

Содержание

Параметры

(нет)

Возвращаемое значение

1,3) Ссылка на этот month после модификации.
2,4) Копия month созданная до модификации.

Примечания

После вызова одной из этих функций ok ( ) всегда true .

Пример

#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++; // переходит к Январю
    assert(m.ok());
    std::cout << unsigned(m) << '\n';
    m = std::chrono::January;
    m--; // переходит к Декабрю
    assert(m.ok());
    std::cout << unsigned(m) << '\n';
}

Вывод:

1
12

Смотрите также

добавляет или вычитает количество месяцев
(public member function)
выполняет арифметические операции с month s
(function)