I am wondering if there is any benefit to getting a reference to a vector prior to calling BOOST_FOREACH or whether a method call which returns a reference will be automatically used? For example which of the two following loops will be equivalent to the third loop?
vector<float>& my_method();
void main()
{
// LOOP 1 -------------------------------
vector<float>& temp_vector = my_method();
BOOST_FOREACH(float element, temp_vector)
cout << element << endl;
// LOOP 2 -------------------------------
vector<float> temp_vector = my_method();
BOOST_FOREACH(float element, temp_vector)
cout << element << endl;
// Which loop is this one most like? ----
BOOST_FOREACH(float element, my_method())
cout << element << endl;
}