当前位置:网站首页>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 ).
边栏推荐
- 不同的数据驱动代码执行相同的测试场景
- Opencv+dlib realizes "matching" glasses for Mona Lisa
- [text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
- LeetCode:214. Shortest palindrome string
- Kratos ares microservice framework (III)
- [OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
- Nacos 的安装与服务的注册
- Leetcode problem solving 2.1.1
- Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment
- 一改测试步骤代码就全写 为什么不试试用 Yaml实现数据驱动?
猜你喜欢
Advanced Computer Network Review(3)——BBR
Redis之cluster集群
Advanced Computer Network Review(4)——Congestion Control of MPTCP
Selenium+pytest automated test framework practice (Part 2)
Advance Computer Network Review(1)——FatTree
Improved deep embedded clustering with local structure preservation (Idec)
UML圖記憶技巧
[OC-Foundation框架]-<字符串And日期与时间>
【文本生成】论文合集推荐丨 斯坦福研究者引入时间控制方法 长文本生成更流畅
Kratos战神微服务框架(一)
随机推荐
QML control type: Popup
Blue Bridge Cup_ Single chip microcomputer_ Measure the frequency of 555
LeetCode41——First Missing Positive——hashing in place & swap
Chapter 1 :Application of Artificial intelligence in Drug Design:Opportunity and Challenges
[OC-Foundation框架]---【集合数组】
Using label template to solve the problem of malicious input by users
xargs命令的基本用法
[OC foundation framework] - [set array]
Nacos 的安装与服务的注册
Advanced Computer Network Review(5)——COPE
Heap (priority queue) topic
Le modèle sentinelle de redis
Kratos战神微服务框架(二)
Notes 01
BMINF的後訓練量化實現
postman之参数化详解
KDD 2022 paper collection (under continuous update)
多元聚类分析
opencv+dlib实现给蒙娜丽莎“配”眼镜
A convolution substitution of attention mechanism