mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-16 11:48:36 +12:00
rsx: Improve performance by using an integral type to indicate error
This commit is contained in:
parent
f6027719d2
commit
a272f3e3b9
3 changed files with 37 additions and 13 deletions
|
@ -5,13 +5,37 @@
|
|||
|
||||
namespace rsx
|
||||
{
|
||||
template <typename E>
|
||||
concept ErrorType = requires (E& e)
|
||||
{
|
||||
{ e.empty() } -> std::same_as<bool>;
|
||||
};
|
||||
namespace exception_utils
|
||||
{
|
||||
enum soft_exception_error_code
|
||||
{
|
||||
none = 0,
|
||||
range_exception = 1,
|
||||
invalid_enum = 2
|
||||
};
|
||||
|
||||
template <typename T, ErrorType E = std::string>
|
||||
struct soft_exception_t
|
||||
{
|
||||
soft_exception_error_code error = soft_exception_error_code::none;
|
||||
|
||||
soft_exception_t() = default;
|
||||
soft_exception_t(soft_exception_error_code code)
|
||||
: error(code) {}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return error == soft_exception_error_code::none;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
concept ErrorType = requires (E & e)
|
||||
{
|
||||
{ e.empty() } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template <typename T, ErrorType E = exception_utils::soft_exception_t>
|
||||
class expected
|
||||
{
|
||||
T value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue