命名空间
变体
操作

std::chrono::day::operator++, std::chrono::day::operator--

来自 cppreference.cn
< cpp‎ | chrono‎ | day
 
 
 
 
constexpr std::chrono::day& operator++() noexcept;
(1) (自 C++20 起)
constexpr std::chrono::day operator++( int ) noexcept;
(2) (自 C++20 起)
constexpr std::chrono::day& operator--() noexcept;
(3) (自 C++20 起)
constexpr std::chrono::day operator--( int ) noexcept;
(4) (自 C++20 起)

将 day 值加 1 或减 1。

1,2) 执行 *this += std::chrono::days{1};
3,4) 执行 *this -= std::chrono::days{1};

目录

[编辑] 参数

(无)

[编辑] 返回值

1,3) 修改后对此 day 的引用。
2,4) 修改前制作的 day 的副本。

[编辑] 注解

如果结果超出范围 [0255],则实际存储的值是未指定的。

[编辑] 示例

#include <cassert>
#include <chrono>
 
int main()
{
    std::chrono::day d{15};
 
    ++d;
    assert(d == std::chrono::day(16));
 
    --d;
    assert(d == std::chrono::day(15));
}

[编辑] 参见

增加或减少天数
(公共成员函数) [编辑]
增加或减少天数和一个 day,或查找两个 day 之间的差值
(函数) [编辑]