Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can't compile template with pointer to member function template argument

1057168Nov 27 2013 — edited Nov 28 2013

Hello,

The following code doesn't compile using "Sun C++ 5.10 SunOS_sparc 2009/06/03" with the following error:

line 15: Error: Could not find a match for MyCallback<Param, Callee, Function>(Test*, int) needed in main()

However the same code compiles using g++ or "Sun C++ 5.12 SunOS_sparc Patch 148506-09 2013/02/21".

It seems to me that it is a compiler bug. Is there a workaround? Is there a patch for 5.10? Otherwise what is the minimal version of the compiler that fixes this bug?

Thank you, Petr

template<typename Param, class Callee, void (Callee::*Function)(Param)>
void MyCallback(Callee* callee, Param param) {
  (callee->*Function)(param);
}

class Test {
public:
  void test(int x) {
    //std::cout << "test(" << x << ")" << std::endl;
  }
};

int main() {
  Test t;
  MyCallback<int, Test, &Test::test>(&t, 1);
  return 0;
}

This post has been answered by Steve.Clamage-Oracle on Nov 27 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 26 2013
Added on Nov 27 2013
2 comments
1,510 views