tupleの実装記事の紹介
以下のページで2012年の時点でインデックスを割り振って多重継承するというアプローチが紹介されていたようです。ここまでtupleの実装について丁寧に解説してくれている記事もなかなか無いと思います。もっと早く知りたかった。
http://mitchnull.blogspot.jp/2012/06/c11-tuple-implementation-details-part-1.html
The non-recursive approach
The basic idea behind the non-recursive tuple implementation is that tuple elements are stored in TupleLeaf base classes, but whereas the recursive implementation uses a deep class hierarchy, we'll use multiple-inheritance. In pseudo-code:
template<typename T0, typename T1, ..., typename Tn> class PseudoTuple : TupleLeaf<0, T0>, TupleLeaf<1, T1>, ..., TupleLeaf<n, Tn> { ... };
Each leaf has an index, so that each base-class becomes unique even if the types they contain are identical, so we can access the nth element with a simple static_cast:
static_cast<TupleLeaf<0, T0>*>(this); // ... static_cast<TupleLeaf<n, Tn>*>(this);
しかし戻り値型を得る為に線形再帰のtuple_elementを使っているので要素アクセスが早いというわけではないみたいです。この点は型をtemplate argument deductionで得る方法の方が優れていますね。