std::tuple foreach implementation
Loki's solution does not enforce the order in which the function calls are performed, because the order in which function arguments are evaluated is unspecified. Here's a C++14 solution that ensures the function is called from left to right:

#include &lt;cstddef&gt;
#include &lt;tuple&gt;
#include &lt;utility&gt;

template &lt;typename Tuple, typename F, std::size_t ...Indices&gt;
void for_each_impl(Tuple&amp;&amp; tuple, F&amp;&amp; f, std::index_sequence&lt;Indices...&gt;) {
    using swallow = int[];
    (void)swallow{1,
        (f(std::get&lt;Indices&gt;(std::forward&lt;Tuple&gt;(tuple))), void(), int{})...
    };
}

template &lt;typename Tuple, typename F&gt;
void for_each(Tuple&amp;&amp; tuple, F&amp;&amp; f) {
    constexpr std::size_t N = std::tuple_size&lt;std::remove_reference_t&lt;Tuple&gt;&gt;::value;
    for_each_impl(std::forward&lt;Tuple&gt;(tuple), std::forward&lt;F&gt;(f),
                  std::make_index_sequence&lt;N&gt;{});
}


I use swallow{f(x)...} to force the evaluation order. It works because the order in which the arguments to a brace initializer are evaluated is the order in which they appear. You can then use it like:

#include &lt;iostream&gt;

int main() {
    for_each(std::make_tuple(1, '2', 3.3), [](auto x) {
        std::cout &lt;&lt; x &lt;&lt; std::endl;
    });
}


EDIT

I modified the code so it works on both GCC and Clang. Here's a more in-depth explanation of for_each_impl.

First, we make sure that we call f inside a braced initializer, so the evaluation order is from left to right:

using swallow = int[];
swallow{f(std::get&lt;Indices&gt;(tuple))...};


But then, what if f does not return an integer value? What if it returns void for example? So we use the comma operator to make sure the expression is an integer which can be used inside the braced initializer:

swallow{(f(std::get&lt;Indices&gt;(tuple)), int{})...};


The expression (f(stuff), int{})... is a parameter pack expansion. It expands to (f(stuff_1), int{}), (f(stuff_2), int{}), ..., (f(stuff_n), int{}), so each expression is really an int, except that some side effect has been performed before. Then, to avoid nasty overloads of the comma operator by whatever is returned by f, we insert a void between f(...) and int{}. Since operator,(SomeType, void) can't be overloaded, this ensures that the builtin operator, is used, which is what we want. This might seem overkill, but we do this in highly generic code where we must assume that f(...) could overload operator,:

swallow{(f(std::get&lt;Indices&gt;(tuple)), void(), int{})...};
                                      ^~~~ Make sure the builtin operator, is used


Then, what happens if for_each_impl is sent 0 arguments? We're gonna try to create a 0-sized array, so we must make sure the array always has at least one element in it. We use a dummy int for this:

swallow{1, (f(std::get&lt;Indices&gt;(tuple)), void(), int{})...};
        ^~~~ Now the array always has at least one element in it


We're almost done, but now there's an anoying compiler warning saying "You're creating a temporary array 'swallow' which is never used". To silence it, I cast the swallow{...} to void. Finally, just add perfect forwarding of the Tuple and you're done:

(void)swallow{1, (f(std::get&lt;Indices&gt;(std::forward&lt;Tuple&gt;(tuple))), void(), int{})...};
^^^^^^ Silence warning                ^^^^^^^^^^^^^^^^^^^ Perfect forwarding     


Note that the way I use std::forward here could be unsafe in other circumstances. This is because tuple could be double-moved-from if the function I forwarded it to had different characteristics. Consider:

swallow{f(function_that_moves_from_its_arg&lt;Indices&gt;(std::forward&lt;Tuple&gt;(tuple)))...};


Now, tuple might be moved-from several times:

swallow{
    f(function_that_moves_from_its_arg&lt;Index1&gt;(std::forward&lt;Tuple&gt;(tuple))), // move here
    f(function_that_moves_from_its_arg&lt;Index2&gt;(std::forward&lt;Tuple&gt;(tuple))), // move here
    f(function_that_moves_from_its_arg&lt;Index3&gt;(std::forward&lt;Tuple&gt;(tuple))), // move here
    ...
}


However, I know std::get is a friendly function and so there's should be no problem in doing this. There's an alternative way to do it "safely", but it involves using std::tuple_element and it's more complicated.