Is this function's use of vector useless?
<p>I saw this earlier and it doesn't make any sense to me:</p>

<pre><code>void generate(std::vector&lt;float&gt; v)
{
 float f = generate_next_float();
 v.push_back(f);
}
</code></pre>

<p>If <code>v</code> was sent as a reference or a pointer, that would make sense. But instead it is sent by value, and therefore copied into the function, right? So anything done to <code>v</code> is immediately useless once the function terminates this <code>v</code> is out of scope, deleted. </p>

<p>Am I right?</p>

<p>That is, the function <code>generate_next_float()</code> might do something, so not useless, but the use of the <code>vector</code> here seems pointless. <code>f</code> does not depend on it, and nothing is returned.</p>
