Commit 0e4a41d0 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Make a few coersions to bool explicit

Summary: MSVC has warning 4800 which is triggered on implicit coercions to `bool` when not in use as the condition to a control-flow statement.

Reviewed By: yfeldblum

Differential Revision: D4518465

fbshipit-source-id: 858ab9e68215a2a667cb3ea55daf51b74368174d
parent 11505903
...@@ -99,7 +99,7 @@ class CpuId { ...@@ -99,7 +99,7 @@ class CpuId {
#define X(name, r, bit) \ #define X(name, r, bit) \
FOLLY_ALWAYS_INLINE bool name() const { \ FOLLY_ALWAYS_INLINE bool name() const { \
return (r) & (1U << bit); \ return ((r) & (1U << bit)) != 0; \
} }
// cpuid(1): Processor Info and Feature Bits. // cpuid(1): Processor Info and Feature Bits.
......
...@@ -244,7 +244,7 @@ inline StringPiece FormatArg::doSplitKey() { ...@@ -244,7 +244,7 @@ inline StringPiece FormatArg::doSplitKey() {
if (e[-1] == ']') { if (e[-1] == ']') {
--e; --e;
p = static_cast<const char*>(memchr(b, '[', size_t(e - b))); p = static_cast<const char*>(memchr(b, '[', size_t(e - b)));
enforce(p, "unmatched ']'"); enforce(p != nullptr, "unmatched ']'");
} else { } else {
p = static_cast<const char*>(memchr(b, '.', size_t(e - b))); p = static_cast<const char*>(memchr(b, '.', size_t(e - b)));
} }
......
...@@ -342,15 +342,29 @@ inline dynamic::IterableProxy<dynamic::const_item_iterator> dynamic::items() ...@@ -342,15 +342,29 @@ inline dynamic::IterableProxy<dynamic::const_item_iterator> dynamic::items()
} }
inline bool dynamic::isString() const { inline bool dynamic::isString() const {
return get_nothrow<std::string>(); return get_nothrow<std::string>() != nullptr;
} }
inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); } inline bool dynamic::isObject() const {
inline bool dynamic::isBool() const { return get_nothrow<bool>(); } return get_nothrow<ObjectImpl>() != nullptr;
inline bool dynamic::isArray() const { return get_nothrow<Array>(); } }
inline bool dynamic::isDouble() const { return get_nothrow<double>(); } inline bool dynamic::isBool() const {
inline bool dynamic::isInt() const { return get_nothrow<int64_t>(); } return get_nothrow<bool>() != nullptr;
inline bool dynamic::isNull() const { return get_nothrow<void*>(); } }
inline bool dynamic::isNumber() const { return isInt() || isDouble(); } inline bool dynamic::isArray() const {
return get_nothrow<Array>() != nullptr;
}
inline bool dynamic::isDouble() const {
return get_nothrow<double>() != nullptr;
}
inline bool dynamic::isInt() const {
return get_nothrow<int64_t>() != nullptr;
}
inline bool dynamic::isNull() const {
return get_nothrow<void*>() != nullptr;
}
inline bool dynamic::isNumber() const {
return isInt() || isDouble();
}
inline dynamic::Type dynamic::type() const { inline dynamic::Type dynamic::type() const {
return type_; return type_;
......
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