I was messing around in Visual Studio and tried this modification: google::protobuf::Closure* closure = google::protobuf::NewCallback<ClosureTest,const DummyResponse*>(&ct, &ClosureTest::MethodWithArg, &dr);
and it worked. Is explicitly specifying the template parameters the preferred solution? On Aug 30, 11:29 pm, srlindemann <srlindem...@gmail.com> wrote: > I've been messing with the Service interface in C++ but have hit a few > bumps with the NewCallback method. Basically, the compiler (g++ 4.2.4 > on Ubuntu) seems to be unable to match my function call to one of the > template overloads---it then fails when it tries to match it to the > void(*)() signature. Is there something here I'm missing? I'm using > protobuf-2.2.0. > > Source (closure_trouble.cpp): > > #include <google/protobuf/service.h> > > class DummyResponse > { > > }; > > class ClosureTest > { > public: > void MethodWithArg(const DummyResponse* response) {} > > }; > > int main(int argc, char* argv[]) > { > ClosureTest ct; > DummyResponse dr; > > google::protobuf::Closure* closure = google::protobuf::NewCallback > (&ct, &ClosureTest::MethodWithArg, &dr); > return 0; > > } > > Command line: > m...@my-laptop:~/Programming/cpp/protio/protio_main/tests$ g++ -o > closure_trouble closure_trouble.cpp > closure_trouble.cpp: In function ‘int main(int, char**)’: > closure_trouble.cpp:18: error: cannot convert ‘ClosureTest*’ to ‘void > (*)()’ for argument ‘1’ to ‘google::protobuf::Closure* > google::protobuf::NewCallback(void (*)())’ > > Any thoughts? Thanks. > > (P.S. I tried a number of similar variations, such as a function > instead of a instance method, etc. Couldn't make anything work except > subclassing Closure.) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---