Assuming I have these two classes:
class Hello {
public:
virtual int doit() {
return 3;
}
};
class Wow : public Hello {
public:
virtual int doit() {
return 2;
}
};
int main(int argc, const char *argv[]) {
Hello *c = new Wow();
return c->doit();
}
As we all know, this code will be handled by late binding in C ++ implemented in LLVM IR Clang as follows:
; ...
%7 = bitcast %class.Wow* %5 to %class.Hello*
store %class.Hello* %7, %class.Hello** %c, align 8
%8 = load %class.Hello*, %class.Hello** %c, align 8
%9 = bitcast %class.Hello* %8 to i32 (%class.Hello*)***
%10 = load i32 (%class.Hello*)**, i32 (%class.Hello*)*** %9, align 8
%11 = getelementptr inbounds i32 (%class.Hello*)*, i32 (%class.Hello*)** %10, i64 0
%12 = load i32 (%class.Hello*)*, i32 (%class.Hello*)** %11, align 8
%13 = call i32 %12(%class.Hello* %8)
; ...
My question is: what if I want to create a function called check, for example, in a different namespace, for example:
namespace somewhereelse {
void check(Hello *c) {
}
void check(Wow *c) {
}
}
Could some last binding be applied to various function overloads?
source
share