Skip to main content

Show HN: Tiny:optional – a C++ optional that does not waste memory https://ift.tt/Y8KJGOm

Show HN: Tiny:optional – a C++ optional that does not waste memory tiny::optional is a header-only C++ library for x86/x64 intended to be a drop-in replacement for std::optional with the twist that it does not require additional memory for bools, floats, doubles and raw pointers. For example, a standard optional double has twice the size of a raw double because of 7 padding bytes after the internal bool. These wasted bytes can have a notable impact on performance in memory bound applications. On the other hand, a tiny::optional double has the size of a double by exploiting unused bit patterns. For other types such as integers, it allows to specify a "sentinel" value that represents the empty state, again causing the optional to have the same size as the underlying type. Quick example: https://ift.tt/NBtVCvc https://ift.tt/TOjmqQl October 17, 2022 at 05:26PM

Comments

Popular posts from this blog

Show HN: TPMouse - A Virtual Trackball for Windows, controlled from the homerow https://ift.tt/BtjAqD4

Show HN: TPMouse - A Virtual Trackball for Windows, controlled from the homerow Hello all, I apologize for the repost as the previous submission was made from an unfortunate timezone. I've been refining my app to the point that it's pretty much become an indispensable daily driver in my own workflow. Hoping to hear some critiques/feedbacks on its usability! https://ift.tt/p6HvZCc October 24, 2022 at 02:24AM