Handle pointer-to-member function values that are virtual functions.
[kdbg.git] / kdbg / testprogs / multibrkpt.cpp
blob7a718857996940c6a79956b501ff491973442fa2
1 #include <iostream>
2 using namespace std;
4 template<class T>
5 struct Templated
7 T val;
8 Templated(T aval) : val(aval) {
9 cout << __func__ << " Ctor" << endl;
11 ~Templated() {
12 cout << __func__ << " Dtor" << endl;
14 void PrintV() {
15 cout << __func__ << " val=" << val << endl;
17 virtual void PrintName(int,int) const {
18 cout << __func__ << endl;
22 struct MostDerived : Templated<int>, Templated<double>
24 MostDerived() : Templated<int>(12), Templated<double>(3.14) {
25 cout << "MostDerived Ctor" << endl;
27 ~MostDerived() {
28 cout << "MostDerived Dtor" << endl;
30 void PrintV() {
31 Templated<int>::PrintV();
32 Templated<double>::PrintV();
34 virtual void PrintName(int,int) const {
35 cout << __func__ << endl;
39 int main()
41 MostDerived bothobj;
43 // test "this adjustment"
44 void (Templated<int>::*pmf1)();
45 void (Templated<double>::*pmf2)();
46 void (MostDerived::*pmf3)();
47 void (MostDerived::*pmf4)(int,int) const;
48 pmf1 = static_cast<void (Templated<int>::*)()>(&MostDerived::PrintV);
49 // the following has a non-trivial "this adjustment"
50 pmf2 = static_cast<void (Templated<double>::*)()>(&MostDerived::PrintV);
51 pmf3 = &Templated<double>::PrintV;
52 pmf4 = &Templated<double>::PrintName;
54 bothobj.PrintV();
55 (bothobj.*pmf4)(2, -5);