Index: libcxx/include/chrono =================================================================== --- libcxx/include/chrono +++ libcxx/include/chrono @@ -798,6 +798,7 @@ #include #include #include +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -2729,6 +2730,89 @@ inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } +struct __undocumented { constexpr explicit __undocumented() noexcept = default; }; + +class _LIBCPP_TYPE_VIS link +{ +public: + link (link&&) = default; + link& operator= (link&&) = default; + + explicit link(string __nm, string __tg, __undocumented) : __name{__nm}, __target{__tg} {} + + string_view name() const noexcept { return __name; } + string_view target() const noexcept { return __target; } + +private: + string __name; + string __target; +}; + +inline bool operator==(const link& __lhs, const link& __rhs) noexcept {return __lhs.name() == __rhs.name();} +inline bool operator< (const link& __lhs, const link& __rhs) noexcept {return __lhs.name() < __rhs.name();} +inline bool operator!=(const link& __lhs, const link& __rhs) noexcept {return !(__lhs == __rhs);} +inline bool operator> (const link& __lhs, const link& __rhs) noexcept {return __rhs < __lhs;} +inline bool operator<=(const link& __lhs, const link& __rhs) noexcept {return !(__rhs < __lhs);} +inline bool operator>=(const link& __lhs, const link& __rhs) noexcept {return !(__lhs < __rhs);} + + +class _LIBCPP_TYPE_VIS leap { +public: + leap (const leap&) _NOEXCEPT = default; + leap& operator=(const leap&) _NOEXCEPT = default; + + explicit constexpr leap (const sys_seconds & __d, __undocumented) _NOEXCEPT : __date{__d} {} + + constexpr sys_seconds date() const noexcept { return __date; } + +private: + sys_seconds __date; +}; + + +inline constexpr bool operator==(const leap& __lhs, const leap& __rhs) noexcept {return __lhs.date() == __rhs.date();} +inline constexpr bool operator< (const leap& __lhs, const leap& __rhs) noexcept {return __lhs.date() < __rhs.date();} +inline constexpr bool operator!=(const leap& __lhs, const leap& __rhs) noexcept {return !(__lhs == __rhs);} +inline constexpr bool operator> (const leap& __lhs, const leap& __rhs) noexcept {return __rhs < __lhs;} +inline constexpr bool operator<=(const leap& __lhs, const leap& __rhs) noexcept {return !(__rhs < __lhs);} +inline constexpr bool operator>=(const leap& __lhs, const leap& __rhs) noexcept {return !(__lhs < __rhs);} + +template +constexpr bool operator==(const leap& __lhs, const sys_time<_Duration>& __rhs) noexcept { return __lhs.date() == __rhs; } + +template +constexpr bool operator==(const sys_time<_Duration>& __lhs, const leap& __rhs) noexcept { return __lhs == __rhs.date(); } + +template +constexpr bool operator< (const leap& __lhs, const sys_time<_Duration>& __rhs) noexcept { return __lhs.date() < __rhs; } + +template +constexpr bool operator< (const sys_time<_Duration>& __lhs, const leap& __rhs) noexcept { return __lhs < __rhs.date(); } + +template +constexpr bool operator!=(const leap& __lhs, const sys_time<_Duration>& __rhs) noexcept {return !(__lhs == __rhs);} + +template +constexpr bool operator!=(const sys_time<_Duration>& __lhs, const leap& __rhs) noexcept {return !(__lhs == __rhs);} + +template +constexpr bool operator> (const leap& __lhs, const sys_time<_Duration>& __rhs) noexcept {return (__rhs < __lhs);} + +template +constexpr bool operator> (const sys_time<_Duration>& __lhs, const leap& __rhs) noexcept {return (__rhs < __lhs);} + +template +constexpr bool operator<=(const leap& __lhs, const sys_time<_Duration>& __rhs) noexcept {return !(__rhs < __lhs);} + +template +constexpr bool operator<=(const sys_time<_Duration>& __lhs, const leap& __rhs) noexcept {return !(__rhs < __lhs);} + +template +constexpr bool operator>=(const leap& __lhs, const sys_time<_Duration>& __rhs) noexcept {return !(__lhs < __rhs);} + +template +constexpr bool operator>=(const sys_time<_Duration>& __lhs, const leap& __rhs) noexcept {return !(__lhs < __rhs);} + #endif // _LIBCPP_STD_VER > 17 } // chrono Index: libcxx/test/libcxx/utilities/time/time.zone/time.zone.leap/comparisons.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/libcxx/utilities/time/time.zone/time.zone.leap/comparisons.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// class leap; + +// inline explicit constexpr leap (const sys_seconds & __d, __undocumented) : __date{__d} /*?? noexcept*/ {} + +// bool operator==(const leap& x, const leap& y); +// bool operator!=(const leap& x, const leap& y); +// bool operator< (const leap& x, const leap& y); +// bool operator> (const leap& x, const leap& y); +// bool operator<=(const leap& x, const leap& y); +// bool operator>=(const leap& x, const leap& y); +// +// template +// bool operator==(const leap& x, const sys_time& y); +// template +// bool operator==(const sys_time& x, const leap& y); +// template +// bool operator!=(const leap& x, const sys_time& y); +// template +// bool operator!=(const sys_time& x, const leap& y); +// template +// bool operator< (const leap& x, const sys_time& y); +// template +// bool operator< (const sys_time& x, const leap& y); +// template +// bool operator> (const leap& x, const sys_time& y); +// template +// bool operator> (const sys_time& x, const leap& y); +// template +// bool operator<=(const leap& x, const sys_time& y); +// template +// bool operator<=(const sys_time& x, const leap& y); +// template +// bool operator>=(const leap& x, const sys_time& y); +// template +// bool operator>=(const sys_time& x, const leap& y); + + +#include +#include +#include + +#include "test_macros.h" +#include "test_comparisons.h" + + +int main() +{ + using leap = std::chrono::leap; + using seconds = std::chrono::seconds; + using hours = std::chrono::hours; + using sys_seconds = std::chrono::sys_seconds; + using ud = std::chrono::__undocumented; + + using sys_hours = std::chrono::sys_time; + + AssertComparisons6ReturnBool(); + AssertComparisons6AreNoexcept(); + + constexpr leap zero{sys_seconds{seconds{0}}, ud{}}; + constexpr leap one {sys_seconds{seconds{1}}, ud{}}; + constexpr leap two {sys_seconds{seconds{2}}, ud{}}; + + static_assert(testComparisons6(zero, zero, true, false)); + static_assert(testComparisons6(zero, one, false, true)); + assert(testComparisons6(zero, two, false, true)); + assert(testComparisons6(two, one, false, false)); + + constexpr sys_hours h0{hours{0}}; + constexpr sys_hours h1{hours{1}}; + + static_assert(testComparisons6(zero, h0, true, false)); + static_assert(testComparisons6(zero, h1, false, true)); + assert(testComparisons6(one, h0, false, false)); + assert(testComparisons6(one, h1, false, true)); +} Index: libcxx/test/libcxx/utilities/time/time.zone/time.zone.leap/ctor.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/libcxx/utilities/time/time.zone/time.zone.leap/ctor.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// class leap; + +// inline explicit constexpr leap (const sys_seconds & __d, __undocumented) : __date{__d} _NOEXCEPT {} +// constexpr sys_seconds date() const; + +#include +#include +#include + +#include "test_macros.h" + +int main() +{ + using leap = std::chrono::leap; + using seconds = std::chrono::seconds; + using sys_seconds = std::chrono::sys_seconds; + using ud = std::chrono::__undocumented; + + constexpr sys_seconds zero{seconds{0}}; + constexpr sys_seconds one {seconds{1}}; + + LIBCPP_ASSERT_NOEXCEPT(leap(zero, ud{})); + static_assert(leap(zero, ud{}).date() == zero, ""); + static_assert(leap(one, ud{}).date() != zero, ""); + + assert(leap(zero, ud{}).date() != one); + assert(leap(one, ud{}).date() == one); +} Index: libcxx/test/libcxx/utilities/time/time.zone/time.zone.link/comparisons.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/libcxx/utilities/time/time.zone/time.zone.link/comparisons.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// class link; + +// explicit link (const string & name, const string & target __undocumented); + +// bool operator==(const leap& x, const leap& y) noexcept; +// bool operator!=(const leap& x, const leap& y) noexcept; +// bool operator< (const leap& x, const leap& y) noexcept; +// bool operator> (const leap& x, const leap& y) noexcept; +// bool operator<=(const leap& x, const leap& y) noexcept; +// bool operator>=(const leap& x, const leap& y) noexcept; +// + + +#include +#include +#include + +#include "test_macros.h" +#include "test_comparisons.h" + + +int main() +{ + using link = std::chrono::link; + using ud = std::chrono::__undocumented; + + AssertComparisons6ReturnBool(); + AssertComparisons6AreNoexcept(); + + link aaa{"aaa", "t0", ud{}}; + link bbb{"bbb", "t1", ud{}}; + link ccc{"ccc", "t2", ud{}}; + + assert(testComparisons6(aaa, aaa, true, true)); + assert(testComparisons6(aaa, bbb, false, true)); + assert(testComparisons6(ccc, bbb, false, false)); +} Index: libcxx/test/libcxx/utilities/time/time.zone/time.zone.link/ctor.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/libcxx/utilities/time/time.zone/time.zone.link/ctor.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// class link; + +// explicit link (const string & name, const string & target __undocumented); +// string_view name() const noexcept; +// string_view target() const noexcept; + +#include +#include +#include + +#include "test_macros.h" + +int main() +{ + using link = std::chrono::link; + using ud = std::chrono::__undocumented; + + link zero{"name0", "target0", ud{}}; + link one {"name1", "target1", ud{}}; + + assert(zero.name() == "name0"); + assert(zero.target() == "target0"); + assert(one .name() == "name1"); + assert(one .target() == "target1"); +} Index: libcxx/test/std/utilities/time/time.zone/time.zone.leap/types.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/utilities/time/time.zone/time.zone.leap/types.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// class leap; + +// There's not a lot we can do with leap here, since it has no documented +// constructors. We just check the types and the noexcept-ness of the calls. + +// unspecified additional constructors +// constexpr sys_seconds date() const noexcept; + +#include +#include +#include + +#include "test_macros.h" +#include "test_comparisons.h" + +int main() +{ + using leap = std::chrono::leap; + using sys_seconds = std::chrono::sys_seconds; + + using sys_hours = std::chrono::sys_time; + + ASSERT_NOEXCEPT( std::declval().date()); + ASSERT_SAME_TYPE(sys_seconds, decltype(std::declval().date())); + + AssertComparisons6ReturnBool(); + AssertComparisons6AreNoexcept(); + AssertComparisons6ReturnBool(); + AssertComparisons6AreNoexcept(); +} Index: libcxx/test/std/utilities/time/time.zone/time.zone.link/types.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/utilities/time/time.zone/time.zone.link/types.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// class link; + +// There's not a lot we can do with link here, since it has no documented +// constructors. We just check the types and the noexcept-ness of the calls. + +// unspecified additional constructors +// string_view name() const noexcept; +// string_view target() const noexcept; + +#include +#include +#include + +#include "test_macros.h" +#include "test_comparisons.h" + +int main() +{ + using link = std::chrono::link; + + ASSERT_NOEXCEPT( std::declval().name()); + ASSERT_SAME_TYPE(std::string_view, decltype(std::declval().name())); + + ASSERT_NOEXCEPT( std::declval().target()); + ASSERT_SAME_TYPE(std::string_view, decltype(std::declval().target())); + + AssertComparisons6ReturnBool(); + AssertComparisons6AreNoexcept(); +}