Return std::tuple and move semantics / copy elision : <p>I have the following factory function:</p>

<pre><code>auto factory() -&gt; std::tuple&lt;bool, std::vector&lt;int&gt;&gt;
{
    std::vector&lt;int&gt; vec;
    vec.push_back(1);
    vec.push_back(2);

    return { true, vec };
}

auto [b, vec] = factory();
</code></pre>

<p>In the return statement is <code>vec</code> considered an <code>xvalue</code> or <code>prvalue</code> and therefore moved or copy elided?</p>

<p>My guess is no, because the compiler, when list-initializing the <code>std::tuple</code> in the return statement, still doesn't know that vec is going to be destroyed. So maybe an explicit std::move is required:</p>

<pre><code>auto factory() -&gt; std::tuple&lt;bool, std::vector&lt;int&gt;&gt;
{
    ...
    return { true, std::move(vec) };
}

auto [b, vec] = factory();
</code></pre>

<p>Is it that really required?</p>
