I would like to have a type trait flatten_tuple_t which can create a flattened tuple type from an arbitrarily nested one. The following code snippet illustrates what is expected from flatten_tuple_t.
template <typename T>
struct flatten_tuple {
using type = T;
};
// The real implementation goes here
// ...
// ...
template <typename T>
using flatten_tuple_t = typename flatten_tuple<T>::type;
// Dummy classes
struct C1 {};
struct C2 {};
struct C3 {};
struct C4 {};
struct C5 {};
struct C6 {};
int main(int argc, char* argv[]) {
static_assert(
std::is_same_v<flatten_tuple_t<std::tuple<C6, C5, std::tuple<C4, std::tuple<C3>, C2>, C1>>,
std::tuple<C6, C5, C4, C3, C2, C1>>);
static_assert(std::is_same_v<flatten_tuple_t<std::tuple<std::tuple<std::tuple<C3>, C2>, C1>>,
std::tuple<C3, C2, C1>>);
}