I have this private member function below, (part of class template, Heap) :
template <typename Task, typename Priority>
const size_t& Heap<Task, Priority>::parent_of(const size_t& index) const
{
    // ** warning C4172: returning address of local variable or temporary
    return (this_index-1)/2;
}
And i am calling it from other function, like below:
template <typename Task, typename Priority>
void Heap<Task, Priority>::bubble_up(const size_t&   start_index)
{
    ....
    if (priority_of(start_index) > priority_of((parent_of(start_index)))) 
    { 
        ... do work ...
        //call recursively the bubble_up
        bubble_up(parent_of(start_index));
    }
    ...
}
The problem is, with priority_of function argument index get corrupted or releases in the 2nd call of the recursion:
template <typename Task, typename Priority>
const Priority& Heap<Task, Priority>::priority_of(const size_t& index) const
{
    return vec.at(index).second;
}
Now, VS have warned me that i am returning address of local variable or temporary (rvalue) in function parent_of, which at the end, this behavior make sense, because when control exists/return from parent_of all local variables including function arguments released!
Now, when changing the function parent_of to return by value (not by const ref), things get to work!
I came from C++98, (so all the rvalue reference is not clear to me) the question is:
when and how should i use the rvalue reference (&&) to overcome this ? can i reference (including changing its value) this temp object allocated by the compiler and return reference to it (to be used as return value)?
 
    