Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing std::forward_as_tuple() result to multiple functions that may move from that object's rvalue-reference members?
    primarykey
    data
    text
    <p><strong>Edit: I think the most likely use case for what I'm asking about, is when creating a function that receives a tuple of rvalue-references from <code>std::forward_as_tuple()</code>.</strong></p> <p>The reason this question came to mind is because I was checking the <em>members</em> of objects passed to constructor initializers to see if they were rvalue-references (I'm open to advice telling me that this is wrong wrong wrong... hopefully followed by a rule of thumb to avoid this in the future, but that's what prompted the question). It occurred to me that, in a slightly different context, I might end up handing an object that has rvalue-reference members to multiple functions (or function objects), that I may or may not control, that may do moves from those members.</p> <pre><code>template&lt;typename... Args&gt; void my_func(std::tuple&lt;Args...&gt;&amp;&amp; tup) { //if tup's members are rvalue references, //and this function moves guts from tup members, then... func_i_dont_control(tup); //what happens here if moves are done on the same members? another_func_i_dont_control(std::move(tup)); } </code></pre> <p>I've looked at <a href="https://stackoverflow.com/questions/4774420/use-of-rvalue-reference-members">Use of rvalue reference members?</a>, along with some other discussions of rvalue reference members, but I'm not quite able to definitively sort this out.</p> <p>I'm not just asking what would happen, but whether this scenario should/could even happen at all, and what key rules to keep in mind when passing around objects containing rvalue-reference members.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload