C++ std::tuple order of destruction

I’ll offer a life lesson I’ve learned, rather than a direct answer, in response to your question: If you can formulate, for multiple alternatives, a reasonable argument for why that alternative should be the one mandated by the standard – then you should not assume any of them is mandated (even if one of them … Read more

Why is it not good to use recursive inheritance for std::tuple implementations?

A non-recursive implementation has better compile-time performance. Believe it or not, in a heavily used library facility like std::tuple, how it is implemented can impact (for better or worse), the compile times the client sees. Recursive implementations tend to produce compile times that are linear in the depth of recursion (or can be even worse). … Read more

How can you iterate over the elements of an std::tuple?

I have an answer based on Iterating over a Tuple: #include <tuple> #include <utility> #include <iostream> template<std::size_t I = 0, typename… Tp> inline typename std::enable_if<I == sizeof…(Tp), void>::type print(std::tuple<Tp…>& t) { } template<std::size_t I = 0, typename… Tp> inline typename std::enable_if<I < sizeof…(Tp), void>::type print(std::tuple<Tp…>& t) { std::cout << std::get<I>(t) << std::endl; print<I + 1, … Read more