Commit 98f9c8fc authored by Kenton Varda's avatar Kenton Varda

Fixes #80.

parent 9f21a77b
......@@ -286,6 +286,10 @@ TEST(Common, MinMaxValue) {
f = nan();
EXPECT_FALSE(f == f);
// `char`'s signedness is platform-specific.
EXPECT_LE(char(minValue), '\0');
EXPECT_GE(char(maxValue), '\x7f');
}
TEST(Common, Defer) {
......
......@@ -416,6 +416,13 @@ public:
_kJ_HANDLE_TYPE(long)
_kJ_HANDLE_TYPE(long long)
#undef _kJ_HANDLE_TYPE
inline constexpr operator char() const {
// `char` is different from both `signed char` and `unsigned char`, and may be signed or
// unsigned on different platforms. Ugh.
return char(-1) < 0 ? MaxValue_::maxSigned<char>()
: MaxValue_::maxUnsigned<char>();
}
};
class MinValue_ {
......@@ -439,6 +446,13 @@ public:
_kJ_HANDLE_TYPE(long)
_kJ_HANDLE_TYPE(long long)
#undef _kJ_HANDLE_TYPE
inline constexpr operator char() const {
// `char` is different from both `signed char` and `unsigned char`, and may be signed or
// unsigned on different platforms. Ugh.
return char(-1) < 0 ? MinValue_::minSigned<char>()
: MinValue_::minUnsigned<char>();
}
};
static constexpr MaxValue_ maxValue = MaxValue_();
......
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