[gjs] arg-inl: Use more constexpr functions and constexpr checks
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] arg-inl: Use more constexpr functions and constexpr checks
- Date: Sun, 23 Aug 2020 01:32:41 +0000 (UTC)
commit b0ea57d30c14268a16932cdf7589900b00f34fee
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Mon Aug 10 18:58:08 2020 +0200
arg-inl: Use more constexpr functions and constexpr checks
gi/arg-inl.h | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/gi/arg-inl.h b/gi/arg-inl.h
index 952260c5..06330884 100644
--- a/gi/arg-inl.h
+++ b/gi/arg-inl.h
@@ -166,19 +166,15 @@ inline void gjs_arg_unset(GIArgument* arg) {
// Implementation to store rounded (u)int64_t numbers into double
template <typename BigT>
-[[nodiscard]] inline BigT max_safe_big_number() {
+[[nodiscard]] inline constexpr BigT max_safe_big_number() {
return BigT(1) << std::numeric_limits<double>::digits;
}
template <typename BigT>
-[[nodiscard]] inline std::enable_if_t<std::is_signed_v<BigT>, BigT>
-min_safe_big_number() {
- return -(max_safe_big_number<BigT>()) + 1;
-}
+[[nodiscard]] inline constexpr BigT min_safe_big_number() {
+ if constexpr (std::is_signed_v<BigT>)
+ return -(max_safe_big_number<BigT>()) + 1;
-template <typename BigT>
-[[nodiscard]] inline std::enable_if_t<std::is_unsigned_v<BigT>, BigT>
-min_safe_big_number() {
return std::numeric_limits<BigT>::lowest();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]