mirror of
https://github.com/boostorg/python.git
synced 2026-01-21 17:12:22 +00:00
- Added a new function, no_override. When a member function is specified as "no_override", no virtual wrappers are generated for it, improving performance and letting the code more clean. - There was a bug in which the policy of virtual member functions was being ignored (patch by Roman Sulzhyk). [SVN r18814]
30 lines
443 B
C++
30 lines
443 B
C++
|
|
namespace virtual2 {
|
|
|
|
struct A
|
|
{
|
|
virtual int f() { return 0; }
|
|
virtual int f1() { return 10; }
|
|
virtual A* make_new() { return new A; }
|
|
};
|
|
|
|
struct B: A
|
|
{
|
|
virtual int f() { return 1; }
|
|
virtual int f2() { return 20; }
|
|
virtual A* make_new() { return new B; }
|
|
};
|
|
|
|
inline int call_fs(A*a)
|
|
{
|
|
int r = a->f1();
|
|
B* b = dynamic_cast<B*>(a);
|
|
return r + b->f2();
|
|
}
|
|
|
|
inline int call_f(A* a)
|
|
{
|
|
return a->f();
|
|
}
|
|
}
|