Const reference to temporary

前端 未结 1 403
一向
一向 2020-12-16 20:26

After reading this article on Herb Sutter\'s blog, I experimented a bit and ran into something that puzzles me. I am using Visual C++ 2005, but I would be surprised if this

相关标签:
1条回答
  • 2020-12-16 20:29

    This IS implementation dependent.

    The standard allows a copy to occur when binding a temporary to a const reference. In your case, VC++ performs a copy only when the constructor is implicitly defined. This is unexpected, but permitted.

    C++1x will fix this.

    0 讨论(0)
提交回复
热议问题