当前位置:网站首页>What is an R-value reference and what is the difference between it and an l-value?
What is an R-value reference and what is the difference between it and an l-value?
2022-07-06 09:14:00 【it_ xiangqiang】
Right value reference and left value
- The role of R-value reference
- The concepts of left and right values
- The difference between right and left references
The role of R-value reference
The right quotation is C++11 New features introduced in , It implements transfer semantics and precise delivery . Its main
The purpose has two aspects :
- Eliminate unnecessary copy of objects when two objects interact , Save computing and storage resources , Increase of efficiency .
- Can be more concise and clear definition of generic functions .
The concepts of left and right values
The left value : Can take address for expression 、 Or named objects / Variable . A persistent object that still exists after the end of an expression .
Right value : Cannot address an expression , Or anonymous objects . A temporary object that no longer exists at the end of an expression .
The difference between right and left references
- Left values can address , And right value can't .
- Left values can be assigned , Right values cannot be assigned , It can be used to assign values to left values .
- Left variable , The right value is immutable ( For foundation types only , The right value reference of user-defined type can be through member function
change ).
边栏推荐
- [oc]- < getting started with UI> -- common controls - prompt dialog box and wait for the prompt (circle)
- Pytest之收集用例规则与运行指定用例
- [text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
- Redis之cluster集群
- Le modèle sentinelle de redis
- [OC foundation framework] - string and date and time >
- Mongodb installation and basic operation
- 【shell脚本】——归档文件脚本
- Redis之五大基础数据结构深入、应用场景
- Mathematical modeling 2004b question (transmission problem)
猜你喜欢
Le modèle sentinelle de redis
UML图记忆技巧
postman之参数化详解
Mongodb installation and basic operation
BN folding and its quantification
LeetCode41——First Missing Positive——hashing in place & swap
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
CUDA implementation of self defined convolution attention operator
An article takes you to understand the working principle of selenium in detail
Blue Bridge Cup_ Single chip microcomputer_ PWM output
随机推荐
Mongodb installation and basic operation
BMINF的後訓練量化實現
go-redis之初始化连接
[OC-Foundation框架]--<Copy对象复制>
LeetCode:387. The first unique character in the string
[MySQL] limit implements paging
SAP ui5 date type sap ui. model. type. Analysis of the parsing format of date
CSP salary calculation
CUDA实现focal_loss
[OC]-<UI入门>--常用控件的学习
What is MySQL? What is the learning path of MySQL
Redis之Geospatial
使用标签模板解决用户恶意输入的问题
Le modèle sentinelle de redis
Compétences en mémoire des graphiques UML
七层网络体系结构
Intel distiller Toolkit - Quantitative implementation 1
[oc]- < getting started with UI> -- learning common controls
After reading the programmer's story, I can't help covering my chest...
UML图记忆技巧