-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
Qt Creator 4.10.2
-
None
-
The compiler is MSVC2017
Qt flags this static_assert as an error in the editor. The compiler is fine with it, and will only flag it if the constexpr else block is ever reached (which it currently isn't, in my code):
template <typename TypeOfValue>
static void PushValue(duk_context* ctx, TypeOfValue value) {
// Push value onto duktape stack
if constexpr (std::is_same<TypeOfValue, int>::value) {
// Push int
duk_push_int(ctx, value);
} else if constexpr (std::is_same<TypeOfValue, uint32_t>::value) {
// Push uint
duk_push_uint(ctx, value);
} else if constexpr (std::is_same<TypeOfValue, double>::value) {
// Push double
duk_push_number(ctx, value);
} else if constexpr (std::is_same<TypeOfValue, std::string>::value) {
// Push string
duk_push_number(ctx, value);
} else if constexpr (std::is_same<TypeOfValue, void*>::value) {
// Push pointer
duk_push_pointer(ctx, value);
} else {
// Unsupported value type
static_assert(false, "Unsupported value type");
}
}