lvalue binding to rvalue reference

后端 未结 2 1915
青春惊慌失措
青春惊慌失措 2020-12-20 19:57

I am trying to understand how lvalues bind to rvalue references. Consider this code:

#include 

template
void f(T&&         


        
2条回答
  •  忘掉有多难
    2020-12-20 20:30

    Since T is a template argument, T&& becomes a forwarding-reference. Due to reference collapsing rules, f(T& &&) becomes f(T&) for lvalues and f(T &&) becomes f(T&&) for rvalues.

提交回复
热议问题