Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
Result.hpp
1
#pragma once
2
3
#include <variant>
4
5
namespace
Grindstone
{
6
template
<
typename
Value,
typename
Error>
7
struct
Result {
8
static_assert
(std::is_copy_constructible_v<Value>);
9
static_assert
(std::is_copy_assignable_v<Value>);
10
static_assert
(std::is_trivially_copyable_v<Error>);
11
12
Result() =
default
;
13
Result(Value val) : storage(val) {}
14
Result(Error err) : storage(err) {}
15
16
Value GetValue()
const
{
17
return
std::get<Value>(storage);
18
}
19
20
Error GetError()
const
{
21
return
std::get<Error>(storage);
22
}
23
24
bool
HasValue()
const
noexcept
{
25
return
std::holds_alternative<Value>(storage);
26
}
27
28
bool
HasError()
const
noexcept
{
29
return
std::holds_alternative<Error>(storage);
30
}
31
32
operator
bool()
const
noexcept
{
33
return
std::holds_alternative<Value>(storage);
34
}
35
36
std::variant<Value, Error> storage;
37
};
38
}
Grindstone
Definition
Assert.hpp:16
sources
code
Common
Result.hpp
Generated by
1.17.0