Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C++, how does strict bottom-up analysis imply that the return type is not used in overloading resolution?

In Bjarne's book, he said,

The insistence on strict bottom-up analysis implies that the return type is not used in overloading resolution.

It looks like that "bottom-up analysis" has sth to do with how the compiler parse the C++ codes.

What does he mean by saying this?

Regards.

like image 511
fececagec812 Avatar asked Aug 28 '14 12:08

fececagec812


1 Answers

"Bottom-up analysis" in particular means that the type of the sub-expression has to be determined before the type of containing exression, so for example if we have an expression g(f()) the type of f() has to be determined before the compiler starts the overload resolution for g(). This couldn't be done if we had:

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()); 
like image 169
Anton Savin Avatar answered Nov 08 '22 09:11

Anton Savin