diff --git a/Utilities/types.h b/Utilities/types.h index 34913bb0d8..854ae27b39 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -905,26 +905,23 @@ struct error_code }; template - struct is_error> : std::false_type + struct is_error> : std::false_type { }; - // Not an error constructor - template - error_code(const ET& value, std::nullptr_t = nullptr) + // Common constructor + template + error_code(const ET& value) : value(static_cast(value)) { - } - - // Error constructor - template::value>> - error_code(const ET& value) - : value(error_report(fmt::get_type_info>(), fmt_unveil::get(value), nullptr, 0)) - { + if constexpr(is_error::value) + { + this->value = error_report(fmt::get_type_info>(), fmt_unveil::get(value), nullptr, 0); + } } // Error constructor (2 args) - template::value>> + template error_code(const ET& value, const T2& value2) : value(error_report(fmt::get_type_info>(), fmt_unveil::get(value), fmt::get_type_info>(), fmt_unveil::get(value2))) {