AuroraRuntime/Include/auROXTL/auTryConstruct.hpp

37 lines
795 B
C++
Raw Normal View History

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTryConstruct.hpp
Date: 2022-3-25
Author: Reece
***/
#pragma once
2022-03-26 13:21:31 +00:00
struct AuCtorErrorTag
{
/*
Thy shall fulfill the following requirements:
operator bool() const;
static constexpr AuCtorErrorTag Failed ();
static constexpr AuCtorErrorTag Success();
2022-03-26 13:21:31 +00:00
*/
};
struct AuCtorCode_t : AuCtorErrorTag
{
2022-03-25 15:11:50 +00:00
bool value;
2022-03-26 13:21:31 +00:00
inline constexpr AuCtorCode_t()
{};
inline constexpr AuCtorCode_t(bool val) : value(val)
{};
2022-03-25 15:11:50 +00:00
operator bool() const
{
2022-03-25 15:11:50 +00:00
return value;
}
2022-03-25 15:11:50 +00:00
static constexpr AuCtorCode_t Failed () { return AuCtorCode_t {false}; }
static constexpr AuCtorCode_t Success() { return AuCtorCode_t {true}; }
2022-03-25 15:11:50 +00:00
};