Aimed at a partial implementation of std::tuple
.
Relies on an unspecified property of the base class subobjects layout: it is assumed they get laid out trivially, in the order of derivation.
For such a case this implementation optimizes the layout, taking the alignment requirements of each type into account and minimizing padding:
static_assert(sizeof(tiny::tuple<bool, long, char, bool, int, bool>) == 16);
static_assert(sizeof(std::tuple<bool, long, char, bool, int, bool>) == 32);
Inspired by the two brilliant talks:
- Odin Holmes, "The fastest template metaprogramming in the West", code::dive '17
- Bartosz Milewski, "Haskell -- The Pseudocode Language for C++ Template Metaprogramming (Part 1)", BoostCon '13