38 lines
956 B
C++
38 lines
956 B
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: auTryCall.hpp
|
||
|
Date: 2022-11-16
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
struct AuCallErrorTag
|
||
|
{
|
||
|
/*
|
||
|
Thy shall fulfill the following requirements:
|
||
|
operator bool() const;
|
||
|
static constexpr AuCallErrorTag Failed ();
|
||
|
static constexpr AuCallErrorTag Success();
|
||
|
*/
|
||
|
};
|
||
|
|
||
|
struct AuErrorCode_t : AuCallErrorTag
|
||
|
{
|
||
|
AuUInt32 uValue;
|
||
|
|
||
|
inline constexpr AuErrorCode_t()
|
||
|
{};
|
||
|
|
||
|
inline constexpr AuErrorCode_t(AuUInt32 uValue) : uValue(uValue)
|
||
|
{};
|
||
|
|
||
|
explicit inline operator bool() const
|
||
|
{
|
||
|
return bool(uValue == 0);
|
||
|
}
|
||
|
|
||
|
static constexpr AuErrorCode_t Failed () { return AuErrorCode_t { AuUInt32(1) << 31 }; }
|
||
|
static constexpr AuErrorCode_t Catch () { return AuErrorCode_t { (AuUInt32(1) << 31) | 1 }; }
|
||
|
static constexpr AuErrorCode_t Success() { return AuErrorCode_t { 0 }; }
|
||
|
};
|