From 7b116ffe3b116ffc3c2089ca0b864ca7ebb1d28c Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Wed, 5 Jul 2017 10:48:49 -0700 Subject: [PATCH] logging: fix compiler compatibility for one more constexpr function Summary: Update LogLevel's operator+() to consist only of a single return statement. This is required for pre-C++14 compiler support. Reviewed By: yfeldblum Differential Revision: D5368256 fbshipit-source-id: 9ecbcde5edd1d0b3e7580d6263ad926e44908219 --- folly/experimental/logging/LogLevel.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/folly/experimental/logging/LogLevel.h b/folly/experimental/logging/LogLevel.h index 75f401b1..a3e0e34a 100644 --- a/folly/experimental/logging/LogLevel.h +++ b/folly/experimental/logging/LogLevel.h @@ -84,12 +84,11 @@ enum class LogLevel : uint32_t { * adjusted log level values. */ inline constexpr LogLevel operator+(LogLevel level, uint32_t value) { - auto newValue = static_cast(level) + value; // Cap the result at LogLevel::MAX_LEVEL - if (newValue > static_cast(LogLevel::MAX_LEVEL)) { - return LogLevel::MAX_LEVEL; - } - return static_cast(newValue); + return ((static_cast(level) + value) > + static_cast(LogLevel::MAX_LEVEL)) + ? LogLevel::MAX_LEVEL + : static_cast(static_cast(level) + value); } inline LogLevel& operator+=(LogLevel& level, uint32_t value) { level = level + value; -- 2.34.1