From a7a982194e9484a9650103467a3d7408849ccc41 Mon Sep 17 00:00:00 2001 From: Reece Date: Sat, 26 Mar 2022 13:21:31 +0000 Subject: [PATCH] [+] AuCtorErrorTag --- Include/auROXTL/auTryConstruct.hpp | 18 +++++++++++++++++- Include/auROXTL/auTryConstructUtils.hpp | 6 +++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Include/auROXTL/auTryConstruct.hpp b/Include/auROXTL/auTryConstruct.hpp index 1d85ff63..11af0a27 100644 --- a/Include/auROXTL/auTryConstruct.hpp +++ b/Include/auROXTL/auTryConstruct.hpp @@ -7,10 +7,26 @@ ***/ #pragma once -struct AuCtorCode_t +struct AuCtorErrorTag +{ + /* + operator bool() const; + static constexpr AuCtorCode_t Failed (); + static constexpr AuCtorCode_t Success(); + */ +}; + +struct AuCtorCode_t : AuCtorErrorTag { bool value; + inline constexpr AuCtorCode_t() + {}; + + inline constexpr AuCtorCode_t(bool val) : value(val) + {}; + + operator bool() const { return value; diff --git a/Include/auROXTL/auTryConstructUtils.hpp b/Include/auROXTL/auTryConstructUtils.hpp index c9be2b81..a6f661fe 100644 --- a/Include/auROXTL/auTryConstructUtils.hpp +++ b/Include/auROXTL/auTryConstructUtils.hpp @@ -7,17 +7,17 @@ ***/ #pragma once -#define _AU_TRYCONTRUST_CHECKCODE AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v || AuIsBaseOf_v) +#define _AU_TRYCONTRUST_CHECKCODE AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v || AuIsBaseOf_v) template inline T AuTryConstruct(CtorCode_t &status, Args&& ... args) { - if constexpr (AuIsConstructible_v) + if constexpr (AuIsConstructible_v) { status = CtorCode_t::Failed(); return T(AuReference(status), AuForward(args)...); } - else if constexpr (AuIsConstructible_v) + else if constexpr (AuIsConstructible_v) { status = CtorCode_t::Failed(); return T(AuForward(args)..., AuReference(status));