What is the difference between auto and decltype(auto) when returning from a function?

前端 未结 2 1813
醉话见心
醉话见心 2020-12-12 19:24

I rarely see decltype(auto) but when I do it confuses me because it seems to do the same thing as auto when returning from a function.



        
2条回答
  •  遥遥无期
    2020-12-12 19:29

    auto returns what value-type would be deduced of you assigned the return clause to an auto variable. decltype(auto) returns what type you would get if you wrapped the return clause in decltype.

    auto returns by value, decltype maybe not.

提交回复
热议问题