c++对象模型-the semantics of constructors
来源:互联网 发布:windows 安全性 编辑:程序博客网 时间:2024/05/22 07:49
1.default constructor 的构建,除了以下四种情况,啥都不做
1)带有default constructor的member class object:需要调用member的constructor
2)带有default constructor的base class :需要调用base的constructor
3)带有一个virual function 的class:需要正确初始化vptr
4)带有一个virual base class 的class : 需要正确初始化vbptr
2.copy constructor的构建操作
当用户没有声明copy constructor时,编译器根据class是否表现出bitwise copy semantics 决定是否生成copy constructor;下面四种情况下,class不展现出bitwise copy semantics:
1)当class内含一个member object 而后者的class 声明有一个copy constructor
2)当class的一个base class 有一个copy constructor
3)当class声明了一个或多个virtual functions:需要重新设定vptr
4)当class的派生自一个继承串链,其中有virtual base classes:需要重新设定vbptr
3.program transformation semantics
参数的初始化:void foo(X x0);
X xx;
foo(xx);
会被编译器改写为:
void foo(X &x0);
X _temp0;
_temp0.X::X(xx);
foo(_temp0);
返回值的初始化:X bar(){
X xx;
... //处理xx
return xx;
}
会被编译器改写为:void bar(X &_result){
X xx;
...//处理xx
_result.X::XX(xx);
return ;
}//在调用这个函数的地方做相应改变
Named Return Value(NRV):编译器可能优化的更彻底,copy consturctor都没有调用:
void bar(X &_result){
...//处理_result
return ;
}
- c++对象模型-the semantics of constructors
- 基本语言细节--《深度探索C++对象模型》--(2)The Semantics of Constructors--总结点
- 《深度探索C++对象模型》—构造函数语意学(The Semantics of constructors)
- C++对象模型(二):The Semantics of Copy Constructors(拷贝构造函数之编译背后的行为)
- 深度探索C++对象模型复习和学习 第二章:构造函数语义学(The Semantics of Constructors)
- c++对象模型-the semantics of data
- The Semantics of Constructors(构造语义学)
- C++对象模型(一):The Semantics of Constructors The Default Constructor (默认构造函数什么时候会被创建出来)
- Inside The C++ Object Model ---- The Semantics of Constructors
- c++对象模型-semantics of construction
- 基本语言细节--《深度探索C++对象模型》--(3)The Semantics of Data--总结点
- 基本语言细节--《深度探索C++对象模型》--(4)The Semantics of Function-总结点
- C++对象模型(五):The Semantics of Data Data语义学
- 《深度探索C++对象模型》—Function语意学(The Semantics of Function)
- C++构造函数语意学 - Constructor(The Semantics of Constructors)
- C++拷贝构造函数语意学 copy constructor(The Semantics of Constructors)
- The Semantics of Data
- The Semantics of Data
- 【SeekBar】Android 自定义漂亮的SeekBar样式
- 大楼扔鸡蛋问题(动态规划)
- 华为OJ--统计输入一串字符中数字,字母,空格及其他字符的个数
- C8_指针练习
- 【Spark】SparkContext源码解读
- c++对象模型-the semantics of constructors
- 使用蒲公英来做iOS测试应用的分发
- 接触式IC卡
- 200万房产税费是多少?
- AAC LATM - 14496-3部分摘要
- shell使用ssh交互登录
- MarkDown的使用、JAVA环境变量的配置、JAVA基础
- Kmeans
- Python Idle 无法显示行号(上)