std::chrono::day:: operator++, std::chrono::day:: operator--
From cppreference.net
|
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 起) |
对日期值加1或减1。
1,2)
执行
*
this
+
=
std::
chrono
::
days
{
1
}
;
。
3,4)
执行
*
this
-
=
std::
chrono
::
days
{
1
}
;
。
目录 |
参数
(无)
返回值
1,3)
修改后对此
day
的引用。
2,4)
修改前创建的
day
副本。
注释
如果结果超出范围
[
0
,
255
]
,实际存储的值是未指定的。
示例
运行此代码
#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)); }
参见
|
增加或减少若干天数
(公开成员函数) |
|
|
(C++20)
|
增加或减少若干天数和一个
day
,或计算两个
day
之间的差值
(函数) |