在C++中,严格的自下而上分析如何暗示返回类型不用于重载分辨率?

ale*_*fox 7 c++ compiler-construction compilation

在Bjarne的书中,他说,

坚持严格的自下而上分析意味着返回类型不用于重载分辨率.

看起来"自下而上的分析"与编译器如何解析C++代码有关.

说这个是什么意思?

问候.

Ant*_*vin 8

"自下而上分析"特别意味着必须在包含exression的类型之前确定子表达式的类型,例如,如果我们有一个表达式g(f()),f()则必须在编译器启动重载决策之前确定其类型对g().如果我们有以下情况,则无法完成:

int f();
float f();

void g(float);

// Even though g() accepts only float, bottom-up analysis implies that 
// this information is not available during resolution of f().
g(f()); 
Run Code Online (Sandbox Code Playgroud)