右值参数真的是函数范围内的左值参数吗?

Is the r-value parameter really an l-value parameter inside the function scope?

我在实现 list class

的代码中发现了以下片段
    void push_front( const T & x ) { insert( begin( ), x ); }

    void push_front( T && x ) { insert( begin( ), std::move( x ) );}

现在我知道,如果我有一个函数将参数作为 r-value,该参数将在函数范围内 l-value(不是吗?)。

所以我可以用

替换之前的片段
void push_front( const T & x ) { insert( begin( ), x ); }

void push_front( T && x ) { push_front( x );}

第一个问题:我说的对吗?

第二个:考虑到第一个片段中的 r-value 参数是第二个函数中的 l-value 参数,Will std::move( x )l-valuer-value 和函数 push_front() 调用函数 insert() 或什么的 r-value 版本?

编辑::

这就是 insert() 的实现方式

    iterator insert( iterator itr, const T & x )
    {
        Node *p = itr.current;
        theSize++;
        return { p->prev = p->prev->next = new Node{ x, p->prev, p } };
    }


    iterator insert( iterator itr, T && x )
    {
        Node *p = itr.current;
        theSize++;
        return { p->prev = p->prev->next = new Node{ std::move( x ), p->prev, p } };
    }

定义Node

struct Node
    {
        private:
        T data;
        Node *prev;
        Node *next;

        Node( const T & d = T{ }, Node * p = nullptr,
        Node * n = nullptr )//It's possible because of const
        :data{ d }, prev{ p }, next{ n } { }

        Node( T && d, Node * p = nullptr, Node * n = nullptr )
        : data{ std::move( d ) }, prev{ p }, next{ n } { }
    };

I have a function taking a parameter as an r-value, that parameter will be l-value in the scope of the function

是的。一般情况下,所有右值引用变量都是左值,函数参数与否。

So I can replace the previous snippet by ...

是的,但是 push_front(T &&x) 将复制 x 而不是移动它。

Will std::move( x ) cast x from l-value to r-value and the function push_front()call the r-value version of the function insert()

是的。