13 #ifndef __VE_RESULT_H__
14 #define __VE_RESULT_H__
23 template <
typename T,
typename E>
33 bool ok()
const {
return std::holds_alternative<T>(myItem); }
39 auto t = std::get_if<T>(&myItem);
48 auto t = std::get_if<E>(&myItem);
60 auto t = std::get_if<T>(&myItem);
78 instance_creation_failed,
79 extension_unavailable,
80 extension_not_enabled,
81 extension_name_collision,
84 failed_to_enumerate_devices,
85 failed_to_enumerate_device_extension_properties,
86 device_creation_failed,
87 vma_allocator_creation_failed,
88 image_creation_failed,
89 buffer_creation_failed,
93 ray_tracing_support_unavailable,
94 swift_shader_unavailable,
97 static constexpr Code code_from_vk_result(
VkResult);
98 static constexpr
const char *message_from_code(Code);
105 template <
typename... Args>
109 myMsg = UTmakeUnique<UT_WorkBuffer>();
110 myMsg->format(fmt, args...);
113 template <
typename... Args>
117 myMsg = UTmakeUnique<UT_WorkBuffer>();
118 myMsg->format(fmt, args...);
121 template <
typename... Args>
125 myMsg = UTmakeUnique<UT_WorkBuffer>();
126 myMsg->appendFormat(fmt, args...);
133 return message_from_code(myCode);
135 return myMsg->buffer();
143 fprintf(stderr,
"VkResult code: %d\n", myVkResult);
185 template <
typename T>
223 return c::out_of_host_memory;
225 return c::out_of_device_memory;
227 return c::memory_map_failed;
229 return c::layer_not_present;
231 return c::generic_error;
GLuint GLsizei const GLchar * message
VE_Result< std::monostate > VE_VoidResult
std::variant< T, E > myItem
VE_Result(VE_Error::Code c)
static constexpr Code code_from_vk_result(VkResult)
bool ok() const
Returns true if we have a valid result. Otherwise, we have an error.
static VE_Result< T > copyFrom(T t)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
VE_Error(const char *fmt, const Args &...args)
static VE_ResultBase< T, E > copyFrom(T t)
auto fprintf(std::FILE *f, const S &fmt, const T &...args) -> int
const char * message() const
VE_Error(Code c, VkResult r)
void appendFormat(const char *fmt, const Args &...args)
**If you just want to fire and args
static constexpr const char * message_from_code(Code)
VE_Error(Code c, const char *fmt, const Args &...args)