c++编译器对返回值的优化
当返回一个局部对象时,编译器对返回值的优化
编译器不同,优化程度不同,我的只能测试出两种情况,后续会对三种情况全部进行分析
理论上返回过程分析
编译器会对返回值过程进行优化,所以此阶段执行的代码效果可能存在不相同的情况
提示:以下是本篇文章正文内容,下面案例可供参考
一、理论返回过程和实际返回过程
首先,为了更加清楚明显的知道返回过程,新建了三个构造函数
,先上代码,然后再根据代码进行分析
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <string>
using namespace std;
class test {
public :
test () {
cout << "无参构造" << endl;
}
test (string s)