mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 07:26:07 +00:00
[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.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.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|
|
| `[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.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>`_
|
| `[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.day.nonmembers] <https://wg21.link/time.cal.day.nonmembers>`_
|
||||||
| `[time.cal.month.nonmembers] <https://wg21.link/time.cal.month.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.year.nonmembers] <https://wg21.link/time.cal.year.nonmembers>`_
|
||||||
| `[time.cal.md.nonmembers] <https://wg21.link/time.cal.md.nonmembers>`_
|
| `[time.cal.md.nonmembers] <https://wg21.link/time.cal.md.nonmembers>`_
|
||||||
| `[time.cal.mdlast] <https://wg21.link/time.cal.mdlast>`_
|
| `[time.cal.mdlast] <https://wg21.link/time.cal.mdlast>`_
|
||||||
| `[time.cal.ym.nonmembers] <https://wg21.link/time.cal.ym.nonmembers>`_
|
| `[time.cal.ym.nonmembers] <https://wg21.link/time.cal.ym.nonmembers>`_
|
||||||
| `[time.cal.ymd.nonmembers] <https://wg21.link/time.cal.ymd.nonmembers>`_
|
| `[time.cal.ymd.nonmembers] <https://wg21.link/time.cal.ymd.nonmembers>`_
|
||||||
| `[time.cal.ymdlast.nonmembers] <https://wg21.link/time.cal.ymdlast.nonmembers>`_
|
| `[time.cal.ymdlast.nonmembers] <https://wg21.link/time.cal.ymdlast.nonmembers>`_","| chrono::day
|
||||||
| `[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
|
|
||||||
| chrono::month
|
| chrono::month
|
||||||
| chrono::year
|
| chrono::year
|
||||||
| chrono::month_day
|
| chrono::month_day
|
||||||
| chrono::month_day_last
|
| chrono::month_day_last
|
||||||
| chrono::year_month
|
| chrono::year_month
|
||||||
| chrono::year_month_day
|
| chrono::year_month_day
|
||||||
| chrono::year_month_day_last
|
| chrono::year_month_day_last",None,Mark de Wever,|Complete|
|
||||||
| chrono::time_zone
|
"| `[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::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.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|
|
| `[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|
|
| `[re.submatch.op] <https://wg21.link/re.submatch.op>`_,| sub_match,None,Unassigned,|Not Started|
|
||||||
|
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <__chrono/duration.h>
|
#include <__chrono/duration.h>
|
||||||
#include <__config>
|
#include <__config>
|
||||||
|
#include <compare>
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
# pragma GCC 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
|
bool operator==(const month& __lhs, const month& __rhs) noexcept
|
||||||
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
|
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
|
||||||
bool operator!=(const month& __lhs, const month& __rhs) noexcept
|
return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
|
||||||
{ 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 inline constexpr
|
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||||
month operator+ (const month& __lhs, const months& __rhs) noexcept
|
month operator+ (const month& __lhs, const months& __rhs) noexcept
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <__chrono/day.h>
|
#include <__chrono/day.h>
|
||||||
#include <__chrono/month.h>
|
#include <__chrono/month.h>
|
||||||
#include <__config>
|
#include <__config>
|
||||||
|
#include <compare>
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
# pragma GCC 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
|
bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
|
||||||
{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
|
{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
|
||||||
bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
|
if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
|
||||||
{ return !(__lhs == __rhs); }
|
return __c;
|
||||||
|
return __lhs.day() <=> __rhs.day();
|
||||||
|
}
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||||
month_day operator/(const month& __lhs, const day& __rhs) noexcept
|
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
|
month_day operator/(const day& __lhs, int __rhs) noexcept
|
||||||
{ return month(__rhs) / __lhs; }
|
{ 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 {
|
class month_day_last {
|
||||||
private:
|
private:
|
||||||
chrono::month __m;
|
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
|
bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
||||||
{ return __lhs.month() == __rhs.month(); }
|
{ return __lhs.month() == __rhs.month(); }
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
|
||||||
bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
|
operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
|
||||||
{ return !(__lhs == __rhs); }
|
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.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 inline constexpr
|
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||||
month_day_last operator/(const month& __lhs, last_spec) noexcept
|
month_day_last operator/(const month& __lhs, last_spec) noexcept
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <__chrono/duration.h>
|
#include <__chrono/duration.h>
|
||||||
#include <__config>
|
#include <__config>
|
||||||
|
#include <compare>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#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
|
bool operator==(const year& __lhs, const year& __rhs) noexcept
|
||||||
{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
|
{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year& __lhs, const year& __rhs) noexcept {
|
||||||
bool operator!=(const year& __lhs, const year& __rhs) noexcept
|
return static_cast<int>(__lhs) <=> static_cast<int>(__rhs);
|
||||||
{ 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 inline constexpr
|
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||||
year operator+ (const year& __lhs, const years& __rhs) noexcept
|
year operator+ (const year& __lhs, const years& __rhs) noexcept
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <__chrono/month.h>
|
#include <__chrono/month.h>
|
||||||
#include <__chrono/year.h>
|
#include <__chrono/year.h>
|
||||||
#include <__config>
|
#include <__config>
|
||||||
|
#include <compare>
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
# pragma GCC 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
|
bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
|
||||||
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
|
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
|
||||||
bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
|
if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
|
||||||
{ return !(__lhs == __rhs); }
|
return __c;
|
||||||
|
return __lhs.month() <=> __rhs.month();
|
||||||
_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
|
_LIBCPP_HIDE_FROM_ABI constexpr
|
||||||
year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
|
year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <__chrono/year.h>
|
#include <__chrono/year.h>
|
||||||
#include <__chrono/year_month.h>
|
#include <__chrono/year_month.h>
|
||||||
#include <__config>
|
#include <__config>
|
||||||
|
#include <compare>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#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
|
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(); }
|
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
|
||||||
bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
|
||||||
{ return !(__lhs == __rhs); }
|
if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
|
||||||
|
return __c;
|
||||||
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
|
||||||
bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
|
return __c;
|
||||||
{
|
return __lhs.day() <=> __rhs.day();
|
||||||
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 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
|
_LIBCPP_HIDE_FROM_ABI inline constexpr
|
||||||
year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
|
year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
|
||||||
{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
|
{ 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
|
// 25.8.4, class month // C++20
|
||||||
class month;
|
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 strong_ordering 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 month operator+(const month& x, const months& 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 months& x, const month& y) noexcept;
|
||||||
constexpr month operator-(const month& x, const months& 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
|
// 25.8.5, class year // C++20
|
||||||
class year;
|
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 strong_ordering 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 year operator+(const year& x, const years& 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 years& x, const year& y) noexcept;
|
||||||
constexpr year operator-(const year& x, const years& 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;
|
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 strong_ordering 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;
|
|
||||||
|
|
||||||
|
|
||||||
// 25.8.10, class month_day_last // C++20
|
// 25.8.10, class month_day_last // C++20
|
||||||
class month_day_last;
|
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 strong_ordering 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;
|
|
||||||
|
|
||||||
// 25.8.11, class month_weekday // C++20
|
// 25.8.11, class month_weekday // C++20
|
||||||
class month_weekday;
|
class month_weekday;
|
||||||
@ -419,11 +405,7 @@ constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last&
|
|||||||
class year_month;
|
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 strong_ordering 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 year_month operator+(const year_month& ym, const months& dm) 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;
|
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;
|
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 strong_ordering 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 year_month_day operator+(const year_month_day& ymd, const months& dm) 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;
|
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
|
// 25.8.15, class year_month_day_last // C++20
|
||||||
class year_month_day_last;
|
class year_month_day_last;
|
||||||
|
|
||||||
constexpr bool operator==(const year_month_day_last& x,
|
constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
|
||||||
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 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 year_month_day_last
|
constexpr year_month_day_last
|
||||||
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
||||||
|
@ -11,13 +11,7 @@
|
|||||||
// class month_day;
|
// 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;
|
||||||
// Returns: x.month() == y.month() && x.day() == y.day().
|
// constexpr strong_comparison operator<=>(const month_day& x, const month_day& y) noexcept;
|
||||||
//
|
|
||||||
// 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().
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -26,46 +20,50 @@
|
|||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_comparisons.h"
|
#include "test_comparisons.h"
|
||||||
|
|
||||||
int main(int, char**)
|
constexpr bool test() {
|
||||||
{
|
using day = std::chrono::day;
|
||||||
using day = std::chrono::day;
|
using month = std::chrono::month;
|
||||||
using month = std::chrono::month;
|
using month_day = std::chrono::month_day;
|
||||||
using month_day = std::chrono::month_day;
|
|
||||||
|
|
||||||
AssertComparisonsAreNoexcept<month_day>();
|
assert(testOrder(
|
||||||
AssertComparisonsReturnBool<month_day>();
|
month_day{std::chrono::January, day{1}}, month_day{std::chrono::January, day{1}}, std::strong_ordering::equal));
|
||||||
|
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
month_day{std::chrono::January, day{1}},
|
month_day{std::chrono::January, day{1}}, month_day{std::chrono::January, day{2}}, std::strong_ordering::less));
|
||||||
month_day{std::chrono::January, day{1}},
|
|
||||||
true, false), "");
|
|
||||||
|
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
month_day{std::chrono::January, day{1}},
|
month_day{std::chrono::January, day{1}}, month_day{std::chrono::February, day{1}}, std::strong_ordering::less));
|
||||||
month_day{std::chrono::January, day{2}},
|
|
||||||
false, true), "");
|
|
||||||
|
|
||||||
static_assert( testComparisons(
|
// same day, different months
|
||||||
month_day{std::chrono::January, day{1}},
|
for (unsigned i = 1; i < 12; ++i)
|
||||||
month_day{std::chrono::February, day{1}},
|
for (unsigned j = 1; j < 12; ++j)
|
||||||
false, true), "");
|
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
|
// same month, different days
|
||||||
for (unsigned i = 1; i < 12; ++i)
|
for (unsigned i = 1; i < 31; ++i)
|
||||||
for (unsigned j = 1; j < 12; ++j)
|
for (unsigned j = 1; j < 31; ++j)
|
||||||
assert((testComparisons(
|
assert((testOrder(
|
||||||
month_day{month{i}, day{1}},
|
month_day{month{2}, day{i}},
|
||||||
month_day{month{j}, day{1}},
|
month_day{month{2}, day{j}},
|
||||||
i == j, i < j )));
|
i == j ? std::strong_ordering::equal
|
||||||
|
: i < j ? std::strong_ordering::less
|
||||||
|
: std::strong_ordering::greater)));
|
||||||
|
|
||||||
// same month, different days
|
return true;
|
||||||
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 )));
|
|
||||||
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,7 @@
|
|||||||
// class month;
|
// 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 strong_ordering 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;
|
|
||||||
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -25,24 +20,30 @@
|
|||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_comparisons.h"
|
#include "test_comparisons.h"
|
||||||
|
|
||||||
|
constexpr bool test() {
|
||||||
|
using month = std::chrono::month;
|
||||||
|
|
||||||
int main(int, char**)
|
// Validate invalid values. The range [0, 255] is guaranteed to be allowed.
|
||||||
{
|
assert(testOrderValues<month>(0U, 0U));
|
||||||
using month = std::chrono::month;
|
assert(testOrderValues<month>(0U, 1U));
|
||||||
|
assert(testOrderValues<month>(254U, 255U));
|
||||||
|
assert(testOrderValues<month>(255U, 255U));
|
||||||
|
|
||||||
AssertComparisonsAreNoexcept<month>();
|
// Validate some valid values.
|
||||||
AssertComparisonsReturnBool<month>();
|
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), "");
|
return true;
|
||||||
static_assert(testComparisonsValues<month>(0U, 1U), "");
|
}
|
||||||
|
|
||||||
// Some 'ok' values as well
|
int main(int, char**) {
|
||||||
static_assert(testComparisonsValues<month>( 5U, 5U), "");
|
using month = std::chrono::month;
|
||||||
static_assert(testComparisonsValues<month>( 5U, 10U), "");
|
AssertOrderAreNoexcept<month>();
|
||||||
|
AssertOrderReturn<std::strong_ordering, month>();
|
||||||
|
|
||||||
for (unsigned i = 1; i <= 12; ++i)
|
test();
|
||||||
for (unsigned j = 1; j <= 12; ++j)
|
static_assert(test());
|
||||||
assert(testComparisonsValues<month>(i, j));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,7 @@
|
|||||||
// class year;
|
// 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 strong_ordering 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;
|
|
||||||
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -25,24 +20,31 @@
|
|||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_comparisons.h"
|
#include "test_comparisons.h"
|
||||||
|
|
||||||
|
constexpr bool test() {
|
||||||
|
using year = std::chrono::year;
|
||||||
|
|
||||||
int main(int, char**)
|
// Validate valid value. The range [-32768, 32767] is guaranteed to be allowed.
|
||||||
{
|
assert(testOrderValues<year>(-32768, -32768));
|
||||||
using year = std::chrono::year;
|
assert(testOrderValues<year>(-32768, -32767));
|
||||||
|
// Largest positive
|
||||||
|
assert(testOrderValues<year>(32767, 32766));
|
||||||
|
assert(testOrderValues<year>(32767, 32767));
|
||||||
|
|
||||||
AssertComparisonsAreNoexcept<year>();
|
// Validate some valid values.
|
||||||
AssertComparisonsReturnBool<year>();
|
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), "");
|
return true;
|
||||||
static_assert(testComparisonsValues<year>(0,1), "");
|
}
|
||||||
|
|
||||||
// Some 'ok' values as well
|
int main(int, char**) {
|
||||||
static_assert(testComparisonsValues<year>( 5, 5), "");
|
using year = std::chrono::year;
|
||||||
static_assert(testComparisonsValues<year>( 5,10), "");
|
AssertOrderAreNoexcept<year>();
|
||||||
|
AssertOrderReturn<std::strong_ordering, year>();
|
||||||
for (int i = 1; i < 10; ++i)
|
|
||||||
for (int j = 1; j < 10; ++j)
|
test();
|
||||||
assert(testComparisonsValues<year>(i, j));
|
static_assert(test());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,7 @@
|
|||||||
// class year_month;
|
// 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;
|
||||||
// Returns: x.year() == y.year() && x.month() == y.month().
|
// constexpr strong_order operator<=>(const year_month& x, const year_month& y) noexcept;
|
||||||
//
|
|
||||||
// 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().
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -26,45 +20,56 @@
|
|||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_comparisons.h"
|
#include "test_comparisons.h"
|
||||||
|
|
||||||
int main(int, char**)
|
constexpr bool test() {
|
||||||
{
|
using year = std::chrono::year;
|
||||||
using year = std::chrono::year;
|
using month = std::chrono::month;
|
||||||
using month = std::chrono::month;
|
using year_month = std::chrono::year_month;
|
||||||
using year_month = std::chrono::year_month;
|
|
||||||
|
|
||||||
AssertComparisonsAreNoexcept<year_month>();
|
assert(testOrder(
|
||||||
AssertComparisonsReturnBool<year_month>();
|
year_month{year{1234}, std::chrono::January},
|
||||||
|
year_month{year{1234}, std::chrono::January},
|
||||||
|
std::strong_ordering::equal));
|
||||||
|
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month{year{1234}, std::chrono::January},
|
year_month{year{1234}, std::chrono::January},
|
||||||
year_month{year{1234}, std::chrono::January},
|
year_month{year{1234}, std::chrono::February},
|
||||||
true, false), "");
|
std::strong_ordering::less));
|
||||||
|
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month{year{1234}, std::chrono::January},
|
year_month{year{1234}, std::chrono::January},
|
||||||
year_month{year{1234}, std::chrono::February},
|
year_month{year{1235}, std::chrono::January},
|
||||||
false, true), "");
|
std::strong_ordering::less));
|
||||||
|
|
||||||
static_assert( testComparisons(
|
// same year, different months
|
||||||
year_month{year{1234}, std::chrono::January},
|
for (unsigned i = 1; i < 12; ++i)
|
||||||
year_month{year{1235}, std::chrono::January},
|
for (unsigned j = 1; j < 12; ++j)
|
||||||
false, true), "");
|
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
|
// same month, different years
|
||||||
for (unsigned i = 1; i < 12; ++i)
|
for (int i = -5; i < 5; ++i)
|
||||||
for (unsigned j = 1; j < 12; ++j)
|
for (int j = -5; j < 5; ++j)
|
||||||
assert((testComparisons(
|
assert((testOrder(
|
||||||
year_month{year{1234}, month{i}},
|
year_month{year{i}, std::chrono::January},
|
||||||
year_month{year{1234}, month{j}},
|
year_month{year{j}, std::chrono::January},
|
||||||
i == j, i < j )));
|
i == j ? std::strong_ordering::equal
|
||||||
|
: i < j ? std::strong_ordering::less
|
||||||
|
: std::strong_ordering::greater)));
|
||||||
|
|
||||||
// same month, different years
|
return true;
|
||||||
for (int i = 1000; i < 2000; ++i)
|
}
|
||||||
for (int j = 1000; j < 2000; ++j)
|
|
||||||
assert((testComparisons(
|
int main(int, char**) {
|
||||||
year_month{year{i}, std::chrono::January},
|
using year_month = std::chrono::year_month;
|
||||||
year_month{year{j}, std::chrono::January},
|
AssertOrderAreNoexcept<year_month>();
|
||||||
i == j, i < j )));
|
AssertOrderReturn<std::strong_ordering, year_month>();
|
||||||
|
|
||||||
return 0;
|
test();
|
||||||
|
static_assert(test());
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,7 @@
|
|||||||
// class year_month_day;
|
// class 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;
|
||||||
// Returns: x.year() == y.year() && x.month() == y.month().
|
// constexpr strong_ordering 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;
|
|
||||||
// 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()
|
|
||||||
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -29,91 +20,102 @@
|
|||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_comparisons.h"
|
#include "test_comparisons.h"
|
||||||
|
|
||||||
int main(int, char**)
|
constexpr bool test() {
|
||||||
{
|
using day = std::chrono::day;
|
||||||
using day = std::chrono::day;
|
using year = std::chrono::year;
|
||||||
using year = std::chrono::year;
|
using month = std::chrono::month;
|
||||||
using month = std::chrono::month;
|
using year_month_day = std::chrono::year_month_day;
|
||||||
using year_month_day = std::chrono::year_month_day;
|
|
||||||
|
|
||||||
AssertComparisonsAreNoexcept<year_month_day>();
|
constexpr month January = std::chrono::January;
|
||||||
AssertComparisonsReturnBool<year_month_day>();
|
constexpr month February = std::chrono::February;
|
||||||
|
|
||||||
constexpr month January = std::chrono::January;
|
assert(testOrder(
|
||||||
constexpr month February = std::chrono::February;
|
year_month_day{year{1234}, January, day{1}},
|
||||||
|
year_month_day{year{1234}, January, day{1}},
|
||||||
|
std::strong_ordering::equal));
|
||||||
|
|
||||||
static_assert( testComparisons(
|
// different day
|
||||||
year_month_day{year{1234}, January, day{1}},
|
assert(testOrder(
|
||||||
year_month_day{year{1234}, January, day{1}},
|
year_month_day{year{1234}, January, day{1}},
|
||||||
true, false), "");
|
year_month_day{year{1234}, January, day{2}},
|
||||||
|
std::strong_ordering::less));
|
||||||
|
|
||||||
// different day
|
// different month
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month_day{year{1234}, January, day{1}},
|
year_month_day{year{1234}, January, day{1}},
|
||||||
year_month_day{year{1234}, January, day{2}},
|
year_month_day{year{1234}, February, day{1}},
|
||||||
false, true), "");
|
std::strong_ordering::less));
|
||||||
|
|
||||||
// different month
|
// different year
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month_day{year{1234}, January, day{1}},
|
year_month_day{year{1234}, January, day{1}},
|
||||||
year_month_day{year{1234}, February, day{1}},
|
year_month_day{year{1235}, January, day{1}},
|
||||||
false, true), "");
|
std::strong_ordering::less));
|
||||||
|
|
||||||
// different year
|
// different month and day
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month_day{year{1234}, January, day{1}},
|
year_month_day{year{1234}, January, day{2}},
|
||||||
year_month_day{year{1235}, January, day{1}},
|
year_month_day{year{1234}, February, day{1}},
|
||||||
false, true), "");
|
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
|
// different year and day
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month_day{year{1234}, January, day{2}},
|
year_month_day{year{1234}, January, day{2}},
|
||||||
year_month_day{year{1234}, February, day{1}},
|
year_month_day{year{1235}, January, day{1}},
|
||||||
false, true), "");
|
std::strong_ordering::less));
|
||||||
|
|
||||||
// different year and month
|
// different year, month and day
|
||||||
static_assert( testComparisons(
|
assert(testOrder(
|
||||||
year_month_day{year{1234}, February, day{1}},
|
year_month_day{year{1234}, February, day{2}},
|
||||||
year_month_day{year{1235}, January, day{1}},
|
year_month_day{year{1235}, January, day{1}},
|
||||||
false, true), "");
|
std::strong_ordering::less));
|
||||||
|
|
||||||
// different year and day
|
// same year, different days
|
||||||
static_assert( testComparisons(
|
for (unsigned i = 1; i < 28; ++i)
|
||||||
year_month_day{year{1234}, January, day{2}},
|
for (unsigned j = 1; j < 28; ++j)
|
||||||
year_month_day{year{1235}, January, day{1}},
|
assert((testOrder(
|
||||||
false, true), "");
|
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
|
// same year, different months
|
||||||
static_assert( testComparisons(
|
for (unsigned i = 1; i < 12; ++i)
|
||||||
year_month_day{year{1234}, February, day{2}},
|
for (unsigned j = 1; j < 12; ++j)
|
||||||
year_month_day{year{1235}, January, day{1}},
|
assert((testOrder(
|
||||||
false, true), "");
|
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
|
return true;
|
||||||
for (unsigned i = 1; i < 28; ++i)
|
}
|
||||||
for (unsigned j = 1; j < 28; ++j)
|
|
||||||
assert((testComparisons(
|
int main(int, char**) {
|
||||||
year_month_day{year{1234}, January, day{i}},
|
using year_month_day = std::chrono::year_month_day;
|
||||||
year_month_day{year{1234}, January, day{j}},
|
AssertOrderAreNoexcept<year_month_day>();
|
||||||
i == j, i < j )));
|
AssertOrderReturn<std::strong_ordering, year_month_day>();
|
||||||
|
|
||||||
// same year, different months
|
test();
|
||||||
for (unsigned i = 1; i < 12; ++i)
|
static_assert(test());
|
||||||
for (unsigned j = 1; j < 12; ++j)
|
|
||||||
assert((testComparisons(
|
return 0;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user