[libcxx-commits] [PATCH] D129442: [libc++][chrono] Avoid tautological comparisions.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 12 10:15:48 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef25db495bdb: [libc++][chrono] Avoid tautological comparisions. (authored by Mordante).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129442/new/
https://reviews.llvm.org/D129442
Files:
libcxx/include/__chrono/year.h
Index: libcxx/include/__chrono/year.h
===================================================================
--- libcxx/include/__chrono/year.h
+++ libcxx/include/__chrono/year.h
@@ -12,6 +12,7 @@
#include <__chrono/duration.h>
#include <__config>
+#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -100,9 +101,11 @@
year& year::operator-=(const years& __dy) noexcept
{ *this = *this - __dy; return *this; }
-_LIBCPP_HIDE_FROM_ABI inline constexpr
-bool year::ok() const noexcept
-{ return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); }
+_LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
+ static_assert(static_cast<int>(std::numeric_limits<decltype(__y)>::max()) == static_cast<int>(max()));
+ return static_cast<int>(min()) <= __y;
+}
+
} // namespace chrono
_LIBCPP_END_NAMESPACE_STD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129442.444001.patch
Type: text/x-patch
Size: 887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220712/968530fb/attachment.bin>
More information about the libcxx-commits
mailing list