Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created November 13, 2019 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinniefalco/f3f6f158014e8ba17c6022ebdbd18248 to your computer and use it in GitHub Desktop.
Save vinniefalco/f3f6f158014e8ba17c6022ebdbd18248 to your computer and use it in GitHub Desktop.
class string_impl
{
struct table
{
std::uint32_t size;
std::uint32_t capacity;
};
struct sbo
{
kind k;
char buf[
2*sizeof(table*)-sizeof(kind)];
};
struct pointer
{
kind k;
char pad[
sizeof(table*)-sizeof(kind)];
table* t;
};
union
{
sbo s_;
pointer p_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment