c++ - “clobber the lvalue”什么意思?
PHP中文网
PHP中文网 2017-04-17 13:13:16
0
2
873

《c++ primer》讲到右值引用绑定到左值的时候,用了clobber the lvalue这个词,这是什么意思?书中翻译为截断左值(我还是不懂),网上将clobber翻译为连续打击。

Binding an rvalue reference to an lvalue gives code that operates on the rvalue reference permission to clobber the lvalue. There are times, such as in our StrVec reallocate function in § 13.6.1 (p. 533), when we know it is safe to clobber an lvalue. By letting us do the cast, the language allows this usage. By forcing us to use a cast, the language tries to prevent us from doing so accidentally.

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
洪涛

That’s the literal meaning...
My understanding is that this lvalue is no longer used and has expired, so it is truncated through the rvalue and taken over. The value or other resources in memory corresponding to its name are not managed by it.
I feel like it’s not easy to say, I’m having a hard time expressing myself...

伊谢尔伦

Normally, rvalues ​​are not allowed to be bound to lvalues ​​(in function calls).
When the formal parameter of a template function is an rvalue reference, and if we instantiate it with an lvalue, in order to deal with this situation, C++ introduces an exception rule, so when When this happens, the compiler will deduce the template type parameter as an lvalue reference to the actual parameter.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template