sqlite_orm
sqlite_orm copied to clipboard
Example project 'nullable_enum_binding' cannot compile
This code is in error:
/**
* This is where sqlite_orm lib understands that your type is nullable - by
* specializing type_is_nullable<T> and deriving from std::true_type.
*/
template<>
struct type_is_nullable<Gender> : public std::true_type {
// this function must return whether value null or not (false is null). Don't forget to implement it
bool operator()(const Gender& g) const {
return g != Gender::None;
}
};
because type_is_nullable
is defined like so:
template<class T>
using type_is_nullable = polyfill::disjunction<
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
polyfill::is_specialization_of<T, std::optional>,
#endif
polyfill::is_specialization_of<T, std::unique_ptr>,
polyfill::is_specialization_of<T, std::shared_ptr>>;
The VS2022 gives this error:
alias cannot be redeclared as class
How can we define an enum as nullable? By using std::optional<Gender>
where Gender is an enum?