当前位置:网站首页>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]-<UI入门>--常用控件-UIButton
Redis之哨兵模式
多元聚类分析
Pytest parameterization some tips you don't know / pytest you don't know
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
KDD 2022 paper collection (under continuous update)
Redis之持久化实操(Linux版)
requests的深入刨析及封装调用
CUDA realizes focal_ loss
Advance Computer Network Review(1)——FatTree
随机推荐
LeetCode:221. Largest Square
BN折叠及其量化
Mise en œuvre de la quantification post - formation du bminf
[MySQL] limit implements paging
Pytest之收集用例规则与运行指定用例
Leetcode problem solving 2.1.1
【每日一题】搬运工 (DFS / DP)
[shell script] - archive file script
Mathematical modeling 2004b question (transmission problem)
UML圖記憶技巧
Go redis initialization connection
Post training quantification of bminf
Using label template to solve the problem of malicious input by users
Redis之持久化实操(Linux版)
什么是MySQL?MySql的学习之路是怎样的
go-redis之初始化連接
Kratos战神微服务框架(一)
Advanced Computer Network Review(4)——Congestion Control of MPTCP
CUDA实现focal_loss
Le modèle sentinelle de redis