std::chrono::operator/ (日历)
在标头 <chrono> 定义
|
||
year_month |
||
constexpr auto operator/(const std::chrono::year& y, const std::chrono::month& m) noexcept |
(1) | (C++20 起) |
constexpr auto operator/(const std::chrono::year& y, int m) noexcept -> std::chrono::year_month; |
(2) | (C++20 起) |
month_day |
||
constexpr auto operator/(const std::chrono::month& m, const std::chrono::day& d) noexcept |
(3) | (C++20 起) |
constexpr auto operator/(const std::chrono::month& m, int d) noexcept -> std::chrono::month_day; |
(4) | (C++20 起) |
constexpr auto operator/(int m, const std::chrono::day& d) noexcept -> std::chrono::month_day; |
(5) | (C++20 起) |
constexpr auto operator/(const std::chrono::day& d, const std::chrono::month& m) noexcept |
(6) | (C++20 起) |
constexpr auto operator/(const std::chrono::day& d, int m) noexcept -> std::chrono::month_day; |
(7) | (C++20 起) |
month_day_last |
||
constexpr auto operator/(const std::chrono::month& m, std::chrono::last_spec) noexcept |
(8) | (C++20 起) |
constexpr auto operator/(int m, std::chrono::last_spec) noexcept -> std::chrono::month_day_last; |
(9) | (C++20 起) |
constexpr auto operator/(std::chrono::last_spec, const std::chrono::month& m) noexcept |
(10) | (C++20 起) |
constexpr auto operator/(std::chrono::last_spec, int m) noexcept -> std::chrono::month_day_last; |
(11) | (C++20 起) |
month_weekday |
||
constexpr auto operator/(const std::chrono::month& m, const std::chrono::weekday_indexed& wdi) noexcept |
(12) | (C++20 起) |
constexpr auto operator/(int m, const std::chrono::weekday_indexed& wdi) noexcept -> std::chrono::month_weekday; |
(13) | (C++20 起) |
constexpr auto operator/(const std::chrono::weekday_indexed& wdi, const std::chrono::month& m) noexcept |
(14) | (C++20 起) |
constexpr auto operator/(const std::chrono::weekday_indexed& wdi, int m) noexcept -> std::chrono::month_weekday; |
(15) | (C++20 起) |
month_weekday_last |
||
constexpr auto operator/(const std::chrono::month& m, const std::chrono::weekday_last& wdl) noexcept |
(16) | (C++20 起) |
constexpr auto operator/(int m, const std::chrono::weekday_last& wdl) noexcept -> std::chrono::month_weekday_last; |
(17) | (C++20 起) |
constexpr auto operator/(const std::chrono::weekday_last& wdl, const std::chrono::month& m) noexcept |
(18) | (C++20 起) |
constexpr auto operator/(const std::chrono::weekday_last& wdl, int m) noexcept -> std::chrono::month_weekday_last; |
(19) | (C++20 起) |
year_month_day |
||
constexpr auto operator/(const std::chrono::year_month& ym, const std::chrono::day& d) noexcept |
(20) | (C++20 起) |
constexpr auto operator/(const std::chrono::year_month& ym, int d) noexcept -> std::chrono::year_month_day; |
(21) | (C++20 起) |
constexpr auto operator/(const std::chrono::year& y, const std::chrono::month_day& md) noexcept |
(22) | (C++20 起) |
constexpr auto operator/(int y, const std::chrono::month_day& md) noexcept -> std::chrono::year_month_day; |
(23) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_day& md, const std::chrono::year& y) noexcept |
(24) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_day& md, int y) noexcept -> std::chrono::year_month_day; |
(25) | (C++20 起) |
year_month_day_last |
||
constexpr auto operator/(const std::chrono::year_month& ym, std::chrono::last_spec) noexcept |
(26) | (C++20 起) |
constexpr auto operator/(const std::chrono::year& y, const std::chrono::month_day_last& mdl) noexcept |
(27) | (C++20 起) |
constexpr auto operator/(int y, const std::chrono::month_day_last& mdl) noexcept -> std::chrono::year_month_day_last; |
(28) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_day_last& mdl, const std::chrono::year& y) noexcept |
(29) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_day_last& mdl, int y) noexcept -> std::chrono::year_month_day_last; |
(30) | (C++20 起) |
year_month_weekday |
||
constexpr auto operator/(const std::chrono::year_month& ym, const std::chrono::weekday_indexed& wdi) noexcept |
(31) | (C++20 起) |
constexpr auto operator/(const std::chrono::year& y, const std::chrono::month_weekday& mwd) noexcept |
(32) | (C++20 起) |
constexpr auto operator/(int y, const std::chrono::month_weekday& mwd) noexcept -> std::chrono::year_month_weekday; |
(33) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_weekday& mwd, const std::chrono::year& y) noexcept |
(34) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_weekday& mwd, int y) noexcept -> std::chrono::year_month_weekday; |
(35) | (C++20 起) |
year_month_weekday_last |
||
constexpr auto operator/(const std::chrono::year_month& ym, const std::chrono::weekday_last& wdl) noexcept |
(36) | (C++20 起) |
constexpr auto operator/(const std::chrono::year& y, const std::chrono::month_weekday_last& mwdl) noexcept |
(37) | (C++20 起) |
constexpr auto operator/(int y, const std::chrono::month_weekday_last& mwdl) noexcept -> std::chrono::year_month_weekday_last; |
(38) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_weekday_last& mwdl, const std::chrono::year& y) noexcept |
(39) | (C++20 起) |
constexpr auto operator/(const std::chrono::month_weekday_last& mwdl, int y) noexcept -> std::chrono::year_month_weekday_last; |
(40) | (C++20 起) |
这些 operator/
为创建格里高利历日期提供约定语法。
对于创建完整日期,任何下列三种顺序都可接受:
-
year/month/day
-
month/day/year
-
day/month/year
每种情况中,能以下列之一替换 day
:
- std::chrono::last ,对于月的最后一日;
-
weekday[i]
,对于月的第 i 个 weekday ; -
weekday[std::chrono::last]
,对于该月的最后一个 weekday 。
若单纯的整数的含义相对于其他运算数的类型无歧义,则可接受它:允许 2005y/4/5 ,但不允许 5/April/2005 。
能够不以三种顺序之一应用第二个 operator/
创建部分日期类型( year_month 、 month_day 等)。
返回值
示例
#include <iostream> #include <chrono> using namespace std::chrono; int main() { std::cout << std::boolalpha; // 标准提供 2021y 作为 std::chrono::year(2021) 的备选 // 标准提供 15d 作为 std::chrono::day(15) 的备选 constexpr auto ym {year(2021)/8}; std::cout << (ym == year_month(year(2021), August)) << ' '; constexpr auto md {9/day(15)}; std::cout << (md == month_day(September, day(15))) << ' '; constexpr auto mdl {October/last}; std::cout << (mdl == month_day_last(month(10))) << ' '; constexpr auto mw {11/Monday[3]}; std::cout << (mw == month_weekday(November, Monday[3])) << ' '; constexpr auto mwdl {December/Sunday[last]}; std::cout << (mwdl == month_weekday_last(month(12), weekday_last(Sunday))) << ' '; constexpr auto ymd {year(2021)/January/day(23)}; std::cout << (ymd == year_month_day(2021y, month(January), 23d)) << '\n'; }
输出:
true true true true true true