From 3aa6741b8c8682ff43cb28cbed476723f331a408 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 24 Aug 2018 14:01:53 +0300 Subject: [PATCH] Simplify error_code --- Utilities/types.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) 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))) {