forked from OSchip/llvm-project
[libc++][chrono] Uses operator<=> in the calendar.
Since the calendar is added in C++20 the existing operators are removed. Implements part of: - P1614R2 The Mothership has Landed Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D129887
This commit is contained in:
parent
f6a7d7e45f
commit
41f7bb9975
|
@ -51,31 +51,28 @@ Section,Description,Dependencies,Assignee,Complete
|
|||
| `[range.iota.iterator] <https://wg21.link/range.iota.iterator>`_,| ranges::iota_view::iterator,[concepts.cmp],Unassigned,|Not Started|
|
||||
| `[range.transform.iterator] <https://wg21.link/range.transform.iterator>`_,| ranges::transform_view::iterator,[concepts.cmp],Unassigned,|Not Started|
|
||||
| `[range.elements.iterator] <https://wg21.link/range.elements.iterator>`_,| ranges::elements_view::iterator,[concepts.cmp],Unassigned,|Not Started|
|
||||
"| `[time.duration.comparisons] <https://wg21.link/time.duration.comparisons>`_
|
||||
| `[time.point.comparisons] <https://wg21.link/time.point.comparisons>`_
|
||||
| `[time.cal.day.nonmembers] <https://wg21.link/time.cal.day.nonmembers>`_
|
||||
| `[time.duration.comparisons] <https://wg21.link/time.duration.comparisons>`_, "chrono::duration", None, Mark de Wever, |Not Started|
|
||||
| `[time.point.comparisons] <https://wg21.link/time.point.comparisons>`_, "chrono::point", None, Mark de Wever, |Not Started|
|
||||
"| `[time.cal.day.nonmembers] <https://wg21.link/time.cal.day.nonmembers>`_
|
||||
| `[time.cal.month.nonmembers] <https://wg21.link/time.cal.month.nonmembers>`_
|
||||
| `[time.cal.year.nonmembers] <https://wg21.link/time.cal.year.nonmembers>`_
|
||||
| `[time.cal.md.nonmembers] <https://wg21.link/time.cal.md.nonmembers>`_
|
||||
| `[time.cal.mdlast] <https://wg21.link/time.cal.mdlast>`_
|
||||
| `[time.cal.ym.nonmembers] <https://wg21.link/time.cal.ym.nonmembers>`_
|
||||
| `[time.cal.ymd.nonmembers] <https://wg21.link/time.cal.ymd.nonmembers>`_
|
||||
| `[time.cal.ymdlast.nonmembers] <https://wg21.link/time.cal.ymdlast.nonmembers>`_
|
||||
| `[time.zone.nonmembers] <https://wg21.link/time.zone.nonmembers>`_
|
||||
| `[time.zone.leap.nonmembers] <https://wg21.link/time.zone.leap.nonmembers>`_
|
||||
| `[time.zone.link.nonmembers] <https://wg21.link/time.zone.link.nonmembers>`_","| chrono::duration
|
||||
| chrono::time_point
|
||||
| chrono::day
|
||||
| `[time.cal.ymdlast.nonmembers] <https://wg21.link/time.cal.ymdlast.nonmembers>`_","| chrono::day
|
||||
| chrono::month
|
||||
| chrono::year
|
||||
| chrono::month_day
|
||||
| chrono::month_day_last
|
||||
| chrono::year_month
|
||||
| chrono::year_month_day
|
||||
| chrono::year_month_day_last
|
||||
| chrono::time_zone
|
||||
| chrono::year_month_day_last",None,Mark de Wever,|Complete|
|
||||
"| `[time.zone.nonmembers] <https://wg21.link/time.zone.nonmembers>`_
|
||||
| `[time.zone.leap.nonmembers] <https://wg21.link/time.zone.leap.nonmembers>`_
|
||||
| `[time.zone.link.nonmembers] <https://wg21.link/time.zone.link.nonmembers>`_","| chrono::time_zone
|
||||
| chrono::leap_second
|
||||
| chrono::time_zone_link",None,Unassigned,|Not Started|
|
||||
| chrono::time_zone_link",A ``<chrono>`` implementation,Unassigned,|Not Started|
|
||||
| `[fs.path.nonmember] <https://wg21.link/fs.path.nonmember>`_,| filesystem::path,None,Unassigned,|Not Started|
|
||||
| `[fs.dir.entry.obs] <https://wg21.link/fs.dir.entry.obs>`_,| filesystem::directory_entry,None,Unassigned,|Not Started|
|
||||
| `[re.submatch.op] <https://wg21.link/re.submatch.op>`_,| sub_match,None,Unassigned,|Not Started|
|
||||
|
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <__chrono/duration.h>
|
||||
#include <__config>
|
||||
#include <compare>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
|
@ -45,25 +46,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
|
|||
bool operator==(const month& __lhs, const month& __rhs) noexcept
|
||||
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator!=(const month& __lhs, const month& __rhs) noexcept
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator< (const month& __lhs, const month& __rhs) noexcept
|
||||
{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator> (const month& __lhs, const month& __rhs) noexcept
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator<=(const month& __lhs, const month& __rhs) noexcept
|
||||
{ return !(__rhs < __lhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator>=(const month& __lhs, const month& __rhs) noexcept
|
||||
{ return !(__lhs < __rhs); }
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
|
||||
return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
month operator+ (const month& __lhs, const months& __rhs) noexcept
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <__chrono/day.h>
|
||||
#include <__chrono/month.h>
|
||||
#include <__config>
|
||||
#include <compare>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
|
@ -58,9 +59,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
|
|||
bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
|
||||
{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
|
||||
{ return !(__lhs == __rhs); }
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
|
||||
if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
|
||||
return __c;
|
||||
return __lhs.day() <=> __rhs.day();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
month_day operator/(const month& __lhs, const day& __rhs) noexcept
|
||||
|
@ -82,25 +85,6 @@ _LIBCPP_HIDE_FROM_ABI constexpr
|
|||
month_day operator/(const day& __lhs, int __rhs) noexcept
|
||||
{ return month(__rhs) / __lhs; }
|
||||
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
|
||||
{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
|
||||
{ return !(__rhs < __lhs);}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
|
||||
{ return !(__lhs < __rhs); }
|
||||
|
||||
|
||||
|
||||
class month_day_last {
|
||||
private:
|
||||
chrono::month __m;
|
||||
|
@ -115,25 +99,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
|
|||
bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||
{ return __lhs.month() == __rhs.month(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||
{ return __lhs.month() < __rhs.month(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||
{ return !(__rhs < __lhs);}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||
{ return !(__lhs < __rhs); }
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
|
||||
operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
|
||||
return __lhs.month() <=> __rhs.month();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
month_day_last operator/(const month& __lhs, last_spec) noexcept
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <__chrono/duration.h>
|
||||
#include <__config>
|
||||
#include <compare>
|
||||
#include <limits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
|
@ -56,25 +57,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
|
|||
bool operator==(const year& __lhs, const year& __rhs) noexcept
|
||||
{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator!=(const year& __lhs, const year& __rhs) noexcept
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator< (const year& __lhs, const year& __rhs) noexcept
|
||||
{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator> (const year& __lhs, const year& __rhs) noexcept
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator<=(const year& __lhs, const year& __rhs) noexcept
|
||||
{ return !(__rhs < __lhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator>=(const year& __lhs, const year& __rhs) noexcept
|
||||
{ return !(__lhs < __rhs); }
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year& __lhs, const year& __rhs) noexcept {
|
||||
return static_cast<int>(__lhs) <=> static_cast<int>(__rhs);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
year operator+ (const year& __lhs, const years& __rhs) noexcept
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <__chrono/month.h>
|
||||
#include <__chrono/year.h>
|
||||
#include <__config>
|
||||
#include <compare>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
|
@ -52,25 +53,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
|
|||
bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
|
||||
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
|
||||
{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
|
||||
{ return !(__rhs < __lhs);}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
|
||||
{ return !(__lhs < __rhs); }
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
|
||||
if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
|
||||
return __c;
|
||||
return __lhs.month() <=> __rhs.month();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr
|
||||
year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <__chrono/year.h>
|
||||
#include <__chrono/year_month.h>
|
||||
#include <__config>
|
||||
#include <compare>
|
||||
#include <limits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
|
@ -109,32 +110,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
|
|||
bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
||||
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
||||
{
|
||||
if (__lhs.year() < __rhs.year()) return true;
|
||||
if (__lhs.year() > __rhs.year()) return false;
|
||||
if (__lhs.month() < __rhs.month()) return true;
|
||||
if (__lhs.month() > __rhs.month()) return false;
|
||||
return __lhs.day() < __rhs.day();
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
|
||||
operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
|
||||
if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
|
||||
return __c;
|
||||
if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
|
||||
return __c;
|
||||
return __lhs.day() <=> __rhs.day();
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
||||
{ return __rhs < __lhs; }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
||||
{ return !(__rhs < __lhs);}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
||||
{ return !(__lhs < __rhs); }
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||
year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
|
||||
{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
|
||||
|
|
|
@ -336,11 +336,8 @@ constexpr days operator-(const day& x, const day& y) noexcept;
|
|||
// 25.8.4, class month // C++20
|
||||
class month;
|
||||
constexpr bool operator==(const month& x, const month& y) noexcept;
|
||||
constexpr bool operator!=(const month& x, const month& y) noexcept;
|
||||
constexpr bool operator< (const month& x, const month& y) noexcept;
|
||||
constexpr bool operator> (const month& x, const month& y) noexcept;
|
||||
constexpr bool operator<=(const month& x, const month& y) noexcept;
|
||||
constexpr bool operator>=(const month& x, const month& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
|
||||
|
||||
constexpr month operator+(const month& x, const months& y) noexcept;
|
||||
constexpr month operator+(const months& x, const month& y) noexcept;
|
||||
constexpr month operator-(const month& x, const months& y) noexcept;
|
||||
|
@ -349,11 +346,8 @@ constexpr months operator-(const month& x, const month& y) noexcept;
|
|||
// 25.8.5, class year // C++20
|
||||
class year;
|
||||
constexpr bool operator==(const year& x, const year& y) noexcept;
|
||||
constexpr bool operator!=(const year& x, const year& y) noexcept;
|
||||
constexpr bool operator< (const year& x, const year& y) noexcept;
|
||||
constexpr bool operator> (const year& x, const year& y) noexcept;
|
||||
constexpr bool operator<=(const year& x, const year& y) noexcept;
|
||||
constexpr bool operator>=(const year& x, const year& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
|
||||
|
||||
constexpr year operator+(const year& x, const years& y) noexcept;
|
||||
constexpr year operator+(const years& x, const year& y) noexcept;
|
||||
constexpr year operator-(const year& x, const years& y) noexcept;
|
||||
|
@ -385,22 +379,14 @@ constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept
|
|||
class month_day;
|
||||
|
||||
constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
|
||||
|
||||
|
||||
// 25.8.10, class month_day_last // C++20
|
||||
class month_day_last;
|
||||
|
||||
constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
|
||||
|
||||
// 25.8.11, class month_weekday // C++20
|
||||
class month_weekday;
|
||||
|
@ -419,11 +405,7 @@ constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last&
|
|||
class year_month;
|
||||
|
||||
constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
|
||||
|
||||
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
|
||||
constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
|
||||
|
@ -437,11 +419,7 @@ constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
|
|||
year_month_day;
|
||||
|
||||
constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
|
||||
constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
|
||||
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
|
||||
|
@ -454,18 +432,8 @@ constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) n
|
|||
// 25.8.15, class year_month_day_last // C++20
|
||||
class year_month_day_last;
|
||||
|
||||
constexpr bool operator==(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator!=(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator< (const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator> (const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator<=(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator>=(const year_month_day_last& x,
|
||||
const year_month_day_last& y) noexcept;
|
||||
constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
|
||||
constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept;
|
||||
|
||||
constexpr year_month_day_last
|
||||
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
||||
|
|
|
@ -11,13 +11,7 @@
|
|||
// class month_day;
|
||||
|
||||
// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
|
||||
// Returns: x.month() == y.month() && x.day() == y.day().
|
||||
//
|
||||
// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
|
||||
// Returns:
|
||||
// If x.month() < y.month() returns true.
|
||||
// Otherwise, if x.month() > y.month() returns false.
|
||||
// Otherwise, returns x.day() < y.day().
|
||||
// constexpr strong_comparison operator<=>(const month_day& x, const month_day& y) noexcept;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
@ -26,46 +20,50 @@
|
|||
#include "test_macros.h"
|
||||
#include "test_comparisons.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
using day = std::chrono::day;
|
||||
using month = std::chrono::month;
|
||||
using month_day = std::chrono::month_day;
|
||||
constexpr bool test() {
|
||||
using day = std::chrono::day;
|
||||
using month = std::chrono::month;
|
||||
using month_day = std::chrono::month_day;
|
||||
|
||||
AssertComparisonsAreNoexcept<month_day>();
|
||||
AssertComparisonsReturnBool<month_day>();
|
||||
assert(testOrder(
|
||||
month_day{std::chrono::January, day{1}}, month_day{std::chrono::January, day{1}}, std::strong_ordering::equal));
|
||||
|
||||
static_assert( testComparisons(
|
||||
month_day{std::chrono::January, day{1}},
|
||||
month_day{std::chrono::January, day{1}},
|
||||
true, false), "");
|
||||
assert(testOrder(
|
||||
month_day{std::chrono::January, day{1}}, month_day{std::chrono::January, day{2}}, std::strong_ordering::less));
|
||||
|
||||
static_assert( testComparisons(
|
||||
month_day{std::chrono::January, day{1}},
|
||||
month_day{std::chrono::January, day{2}},
|
||||
false, true), "");
|
||||
assert(testOrder(
|
||||
month_day{std::chrono::January, day{1}}, month_day{std::chrono::February, day{1}}, std::strong_ordering::less));
|
||||
|
||||
static_assert( testComparisons(
|
||||
month_day{std::chrono::January, day{1}},
|
||||
month_day{std::chrono::February, day{1}},
|
||||
false, true), "");
|
||||
// same day, different months
|
||||
for (unsigned i = 1; i < 12; ++i)
|
||||
for (unsigned j = 1; j < 12; ++j)
|
||||
assert((testOrder(
|
||||
month_day{month{i}, day{1}},
|
||||
month_day{month{j}, day{1}},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// same day, different months
|
||||
for (unsigned i = 1; i < 12; ++i)
|
||||
for (unsigned j = 1; j < 12; ++j)
|
||||
assert((testComparisons(
|
||||
month_day{month{i}, day{1}},
|
||||
month_day{month{j}, day{1}},
|
||||
i == j, i < j )));
|
||||
// same month, different days
|
||||
for (unsigned i = 1; i < 31; ++i)
|
||||
for (unsigned j = 1; j < 31; ++j)
|
||||
assert((testOrder(
|
||||
month_day{month{2}, day{i}},
|
||||
month_day{month{2}, day{j}},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// same month, different days
|
||||
for (unsigned i = 1; i < 31; ++i)
|
||||
for (unsigned j = 1; j < 31; ++j)
|
||||
assert((testComparisons(
|
||||
month_day{month{2}, day{i}},
|
||||
month_day{month{2}, day{j}},
|
||||
i == j, i < j )));
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
using month_day = std::chrono::month_day;
|
||||
AssertOrderAreNoexcept<month_day>();
|
||||
AssertOrderReturn<std::strong_ordering, month_day>();
|
||||
|
||||
test();
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,12 +11,7 @@
|
|||
// class month;
|
||||
|
||||
// constexpr bool operator==(const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator!=(const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator< (const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator> (const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator<=(const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator>=(const month& x, const month& y) noexcept;
|
||||
|
||||
// constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
@ -25,24 +20,30 @@
|
|||
#include "test_macros.h"
|
||||
#include "test_comparisons.h"
|
||||
|
||||
constexpr bool test() {
|
||||
using month = std::chrono::month;
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
using month = std::chrono::month;
|
||||
// Validate invalid values. The range [0, 255] is guaranteed to be allowed.
|
||||
assert(testOrderValues<month>(0U, 0U));
|
||||
assert(testOrderValues<month>(0U, 1U));
|
||||
assert(testOrderValues<month>(254U, 255U));
|
||||
assert(testOrderValues<month>(255U, 255U));
|
||||
|
||||
AssertComparisonsAreNoexcept<month>();
|
||||
AssertComparisonsReturnBool<month>();
|
||||
// Validate some valid values.
|
||||
for (unsigned i = 1; i <= 12; ++i)
|
||||
for (unsigned j = 1; j <= 12; ++j)
|
||||
assert(testOrderValues<month>(i, j));
|
||||
|
||||
static_assert(testComparisonsValues<month>(0U ,0U), "");
|
||||
static_assert(testComparisonsValues<month>(0U, 1U), "");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Some 'ok' values as well
|
||||
static_assert(testComparisonsValues<month>( 5U, 5U), "");
|
||||
static_assert(testComparisonsValues<month>( 5U, 10U), "");
|
||||
int main(int, char**) {
|
||||
using month = std::chrono::month;
|
||||
AssertOrderAreNoexcept<month>();
|
||||
AssertOrderReturn<std::strong_ordering, month>();
|
||||
|
||||
for (unsigned i = 1; i <= 12; ++i)
|
||||
for (unsigned j = 1; j <= 12; ++j)
|
||||
assert(testComparisonsValues<month>(i, j));
|
||||
test();
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,12 +11,7 @@
|
|||
// class year;
|
||||
|
||||
// constexpr bool operator==(const year& x, const year& y) noexcept;
|
||||
// constexpr bool operator!=(const year& x, const year& y) noexcept;
|
||||
// constexpr bool operator< (const year& x, const year& y) noexcept;
|
||||
// constexpr bool operator> (const year& x, const year& y) noexcept;
|
||||
// constexpr bool operator<=(const year& x, const year& y) noexcept;
|
||||
// constexpr bool operator>=(const year& x, const year& y) noexcept;
|
||||
|
||||
// constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
@ -25,24 +20,31 @@
|
|||
#include "test_macros.h"
|
||||
#include "test_comparisons.h"
|
||||
|
||||
constexpr bool test() {
|
||||
using year = std::chrono::year;
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
using year = std::chrono::year;
|
||||
// Validate valid value. The range [-32768, 32767] is guaranteed to be allowed.
|
||||
assert(testOrderValues<year>(-32768, -32768));
|
||||
assert(testOrderValues<year>(-32768, -32767));
|
||||
// Largest positive
|
||||
assert(testOrderValues<year>(32767, 32766));
|
||||
assert(testOrderValues<year>(32767, 32767));
|
||||
|
||||
AssertComparisonsAreNoexcept<year>();
|
||||
AssertComparisonsReturnBool<year>();
|
||||
// Validate some valid values.
|
||||
for (int i = 1; i < 10; ++i)
|
||||
for (int j = 1; j < 10; ++j)
|
||||
assert(testOrderValues<year>(i, j));
|
||||
|
||||
static_assert(testComparisonsValues<year>(0,0), "");
|
||||
static_assert(testComparisonsValues<year>(0,1), "");
|
||||
|
||||
// Some 'ok' values as well
|
||||
static_assert(testComparisonsValues<year>( 5, 5), "");
|
||||
static_assert(testComparisonsValues<year>( 5,10), "");
|
||||
|
||||
for (int i = 1; i < 10; ++i)
|
||||
for (int j = 1; j < 10; ++j)
|
||||
assert(testComparisonsValues<year>(i, j));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
using year = std::chrono::year;
|
||||
AssertOrderAreNoexcept<year>();
|
||||
AssertOrderReturn<std::strong_ordering, year>();
|
||||
|
||||
test();
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,13 +11,7 @@
|
|||
// class year_month;
|
||||
|
||||
// constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
|
||||
// Returns: x.year() == y.year() && x.month() == y.month().
|
||||
//
|
||||
// constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
|
||||
// Returns:
|
||||
// If x.year() < y.year() returns true.
|
||||
// Otherwise, if x.year() > y.year() returns false.
|
||||
// Otherwise, returns x.month() < y.month().
|
||||
// constexpr strong_order operator<=>(const year_month& x, const year_month& y) noexcept;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
@ -26,45 +20,56 @@
|
|||
#include "test_macros.h"
|
||||
#include "test_comparisons.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
using year = std::chrono::year;
|
||||
using month = std::chrono::month;
|
||||
using year_month = std::chrono::year_month;
|
||||
constexpr bool test() {
|
||||
using year = std::chrono::year;
|
||||
using month = std::chrono::month;
|
||||
using year_month = std::chrono::year_month;
|
||||
|
||||
AssertComparisonsAreNoexcept<year_month>();
|
||||
AssertComparisonsReturnBool<year_month>();
|
||||
assert(testOrder(
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
std::strong_ordering::equal));
|
||||
|
||||
static_assert( testComparisons(
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
true, false), "");
|
||||
assert(testOrder(
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
year_month{year{1234}, std::chrono::February},
|
||||
std::strong_ordering::less));
|
||||
|
||||
static_assert( testComparisons(
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
year_month{year{1234}, std::chrono::February},
|
||||
false, true), "");
|
||||
assert(testOrder(
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
year_month{year{1235}, std::chrono::January},
|
||||
std::strong_ordering::less));
|
||||
|
||||
static_assert( testComparisons(
|
||||
year_month{year{1234}, std::chrono::January},
|
||||
year_month{year{1235}, std::chrono::January},
|
||||
false, true), "");
|
||||
// same year, different months
|
||||
for (unsigned i = 1; i < 12; ++i)
|
||||
for (unsigned j = 1; j < 12; ++j)
|
||||
assert((testOrder(
|
||||
year_month{year{1234}, month{i}},
|
||||
year_month{year{1234}, month{j}},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// same year, different months
|
||||
for (unsigned i = 1; i < 12; ++i)
|
||||
for (unsigned j = 1; j < 12; ++j)
|
||||
assert((testComparisons(
|
||||
year_month{year{1234}, month{i}},
|
||||
year_month{year{1234}, month{j}},
|
||||
i == j, i < j )));
|
||||
// same month, different years
|
||||
for (int i = -5; i < 5; ++i)
|
||||
for (int j = -5; j < 5; ++j)
|
||||
assert((testOrder(
|
||||
year_month{year{i}, std::chrono::January},
|
||||
year_month{year{j}, std::chrono::January},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// same month, different years
|
||||
for (int i = 1000; i < 2000; ++i)
|
||||
for (int j = 1000; j < 2000; ++j)
|
||||
assert((testComparisons(
|
||||
year_month{year{i}, std::chrono::January},
|
||||
year_month{year{j}, std::chrono::January},
|
||||
i == j, i < j )));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
using year_month = std::chrono::year_month;
|
||||
AssertOrderAreNoexcept<year_month>();
|
||||
AssertOrderReturn<std::strong_ordering, year_month>();
|
||||
|
||||
test();
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,16 +11,7 @@
|
|||
// class year_month_day;
|
||||
|
||||
// constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
// Returns: x.year() == y.year() && x.month() == y.month().
|
||||
//
|
||||
// constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
|
||||
// Returns:
|
||||
// If x.year() < y.year() returns true.
|
||||
// Otherwise, if x.year() > y.year() returns false.
|
||||
// Otherwise, if x.month() < y.month() returns true.
|
||||
// Otherwise, if x.month() > y.month() returns false.
|
||||
// Otherwise, returns x.day() < y.day()
|
||||
|
||||
// constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
@ -29,91 +20,102 @@
|
|||
#include "test_macros.h"
|
||||
#include "test_comparisons.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
using day = std::chrono::day;
|
||||
using year = std::chrono::year;
|
||||
using month = std::chrono::month;
|
||||
using year_month_day = std::chrono::year_month_day;
|
||||
constexpr bool test() {
|
||||
using day = std::chrono::day;
|
||||
using year = std::chrono::year;
|
||||
using month = std::chrono::month;
|
||||
using year_month_day = std::chrono::year_month_day;
|
||||
|
||||
AssertComparisonsAreNoexcept<year_month_day>();
|
||||
AssertComparisonsReturnBool<year_month_day>();
|
||||
constexpr month January = std::chrono::January;
|
||||
constexpr month February = std::chrono::February;
|
||||
|
||||
constexpr month January = std::chrono::January;
|
||||
constexpr month February = std::chrono::February;
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
std::strong_ordering::equal));
|
||||
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
true, false), "");
|
||||
// different day
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1234}, January, day{2}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different day
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1234}, January, day{2}},
|
||||
false, true), "");
|
||||
// different month
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1234}, February, day{1}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different month
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1234}, February, day{1}},
|
||||
false, true), "");
|
||||
// different year
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different year
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, January, day{1}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
false, true), "");
|
||||
// different month and day
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, January, day{2}},
|
||||
year_month_day{year{1234}, February, day{1}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different year and month
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, February, day{1}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different month and day
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, January, day{2}},
|
||||
year_month_day{year{1234}, February, day{1}},
|
||||
false, true), "");
|
||||
// different year and day
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, January, day{2}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different year and month
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, February, day{1}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
false, true), "");
|
||||
// different year, month and day
|
||||
assert(testOrder(
|
||||
year_month_day{year{1234}, February, day{2}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
std::strong_ordering::less));
|
||||
|
||||
// different year and day
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, January, day{2}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
false, true), "");
|
||||
// same year, different days
|
||||
for (unsigned i = 1; i < 28; ++i)
|
||||
for (unsigned j = 1; j < 28; ++j)
|
||||
assert((testOrder(
|
||||
year_month_day{year{1234}, January, day{i}},
|
||||
year_month_day{year{1234}, January, day{j}},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// different year, month and day
|
||||
static_assert( testComparisons(
|
||||
year_month_day{year{1234}, February, day{2}},
|
||||
year_month_day{year{1235}, January, day{1}},
|
||||
false, true), "");
|
||||
// same year, different months
|
||||
for (unsigned i = 1; i < 12; ++i)
|
||||
for (unsigned j = 1; j < 12; ++j)
|
||||
assert((testOrder(
|
||||
year_month_day{year{1234}, month{i}, day{12}},
|
||||
year_month_day{year{1234}, month{j}, day{12}},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// same month, different years
|
||||
for (int i = -5; i < 5; ++i)
|
||||
for (int j = -5; j < 5; ++j)
|
||||
assert((testOrder(
|
||||
year_month_day{year{i}, January, day{12}},
|
||||
year_month_day{year{j}, January, day{12}},
|
||||
i == j ? std::strong_ordering::equal
|
||||
: i < j ? std::strong_ordering::less
|
||||
: std::strong_ordering::greater)));
|
||||
|
||||
// same year, different days
|
||||
for (unsigned i = 1; i < 28; ++i)
|
||||
for (unsigned j = 1; j < 28; ++j)
|
||||
assert((testComparisons(
|
||||
year_month_day{year{1234}, January, day{i}},
|
||||
year_month_day{year{1234}, January, day{j}},
|
||||
i == j, i < j )));
|
||||
|
||||
// same year, different months
|
||||
for (unsigned i = 1; i < 12; ++i)
|
||||
for (unsigned j = 1; j < 12; ++j)
|
||||
assert((testComparisons(
|
||||
year_month_day{year{1234}, month{i}, day{12}},
|
||||
year_month_day{year{1234}, month{j}, day{12}},
|
||||
i == j, i < j )));
|
||||
|
||||
// same month, different years
|
||||
for (int i = 1000; i < 2000; ++i)
|
||||
for (int j = 1000; j < 2000; ++j)
|
||||
assert((testComparisons(
|
||||
year_month_day{year{i}, January, day{12}},
|
||||
year_month_day{year{j}, January, day{12}},
|
||||
i == j, i < j )));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
using year_month_day = std::chrono::year_month_day;
|
||||
AssertOrderAreNoexcept<year_month_day>();
|
||||
AssertOrderReturn<std::strong_ordering, year_month_day>();
|
||||
|
||||
test();
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue