AuROXTL/Include/auROXTL/auTryConstruct.hpp

37 lines
811 B
C++

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