Commit 7b116ffe authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

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
parent fbeb95ac
...@@ -84,12 +84,11 @@ enum class LogLevel : uint32_t { ...@@ -84,12 +84,11 @@ enum class LogLevel : uint32_t {
* adjusted log level values. * adjusted log level values.
*/ */
inline constexpr LogLevel operator+(LogLevel level, uint32_t value) { inline constexpr LogLevel operator+(LogLevel level, uint32_t value) {
auto newValue = static_cast<uint32_t>(level) + value;
// Cap the result at LogLevel::MAX_LEVEL // Cap the result at LogLevel::MAX_LEVEL
if (newValue > static_cast<uint32_t>(LogLevel::MAX_LEVEL)) { return ((static_cast<uint32_t>(level) + value) >
return LogLevel::MAX_LEVEL; static_cast<uint32_t>(LogLevel::MAX_LEVEL))
} ? LogLevel::MAX_LEVEL
return static_cast<LogLevel>(newValue); : static_cast<LogLevel>(static_cast<uint32_t>(level) + value);
} }
inline LogLevel& operator+=(LogLevel& level, uint32_t value) { inline LogLevel& operator+=(LogLevel& level, uint32_t value) {
level = level + value; level = level + value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment