Forwarding of return values. Is std::forward is needed?

后端 未结 3 1457
予麋鹿
予麋鹿 2021-02-03 21:00

I am writing library which wraps a lot of functions and methods from other library. To avoid coping of return values I am applying std::forward like so:

         


        
3条回答
  •  自闭症患者
    2021-02-03 21:47

    No you dont need to use std::forward better dont return r-value reference at all because it can prevent of NRVO optimization. You can read more about move semantics in this article: Article

提交回复
热议问题