-
-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Description
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:
- in C++17 and newer projects, replace
better_enum::optionalwithstd::optional - provide a conversion function to
std::optional
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;}
}
#endifaantron
Metadata
Metadata
Assignees
Labels
No labels