Open jaskij opened 9 months ago
In my embedded project, I utilize std::optional heavily. Unfortunately, better_enum::optional doesn't have a built in conversion.
std::optional
better_enum::optional
I can see two options:
Here's a member conversion function I threw together quickly:
#if defined(__cpp_lib_optional) && (__cpp_lib_optional >= 201606L) BETTER_ENUMS_CONSTEXPR_ operator std::optional<T>() const { if(*this) {return {_value};} else {return std::nullopt;} } #endif
Thank you! Would you be willing to propose this as a PR?
Sure thing. I wasn't sure if that quickly put together operator was good enough, but if it is, I'll go ahead and submit a PR.
In my embedded project, I utilize
std::optional
heavily. Unfortunately,better_enum::optional
doesn't have a built in conversion.I can see two options:
better_enum::optional
withstd::optional
std::optional
Here's a member conversion function I threw together quickly: