-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default sentinals for more types? #1
Comments
Thanks for your feedback! One of the major goals of this library was to have a drop-in replacement for But it is certainly possible to define another type besides |
Similar to tiny::optional, but its size is guaranteed to be equal to the payload. To this end, for integers it automatically swallows some value. If no sentinel can be selected automatically, a compilation error occurs. This type was proposed in issue #1
Similar to tiny::optional, but its size is guaranteed to be equal to the payload. To this end, for integers it automatically swallows some value. If no sentinel can be selected automatically, a compilation error occurs. This type was proposed in issue #1
@aardappel I implemented the new type |
@Sedeniono that is pretty awesome, very useful :) |
Love the concept of this library, but to me it would be more useful it would pretty much guarantee to have a sentinel for every
T
as opposed to use an extra bool fallback for some types. I'd rather it would error if a sentinel wasn't possible.In particular, default to
INT_MIN
and similar for all signed integer types, andMAX_UINT
and similar for all unsigned types. Obviously there's times when these values don't work but it will work for almost everything and means you can directly useoptional<T>
instead of needing a manual case foroptional<int, INT_MIN>
or whatever.-1
is used too often as an actual valid value.Also don't see why the sentinel for raw pointers isn't simply
nullptr
, the idea of having an optional value of an optional pointer. Makes these values also a bit more understandable in a debugger etc.The text was updated successfully, but these errors were encountered: