Boost logo

Boost Users :

From: Sean Rhea (srhea_at_[hidden])
Date: 2006-02-14 12:19:35


All,

I've written what I thought was a pretty clever RPC server using bind
and templated functions to make server callbacks typesafe. It all
resolves around this one function:

   class rpc_server {
     ...
     template <class A, class R>
     void set_handler(int prog, int vers, int proc,
                      bool_t (*arg_fn)(XDR *, A*),
                      bool_t (*res_fn)(XDR *, R*),
                      function<void(A*,function<void(R*)>)> req_cb)
     {
       ...
     }
   }

The idea being that you pass it the program, version, and procedure
numbers, pointers to the xdr_ functions that encode/decode the
argument and response types, and a function object that takes a
pointer to the argument type and a callback to call with the result.
It should be really nice to use, as it makes sure your callback
handles the same types as the relevant encoding/decoding functions.

Currently, however, I can't get it to compile. The error from gcc
4.0.1 on OS X Tiger is:

g++ -c -g -I/usr/local/include/boost-1_33_1 -I.. rpc_server.cpp
rpc_server.cpp: In member function 'void rpc_server::set_handler(int,
int, int, int (*)(XDR*, A*), int (*)(XDR*, R*), boost::function<void
()(A*, boost::function<void ()(R*), std::allocator<void> >),
std::allocator<void> >) [with A = example_args, R = example_res]':
rpc_server.cpp:277: instantiated from here
rpc_server.cpp:171: error: cannot resolve overloaded function
'call_req' based on conversion to type 'int'
make: *** [rpc_server.o] Error 1

I've attached rpc_server.cpp.

Can anyone tell me why the compiler doesn't have the information it
needs? It seems to have figured out what types A and R are. What
else does it need to resolve call_req?

Thanks for your time,
Sean

-- 
           When I see the price that you pay / I don't wanna grow up
                                  -- Tom Waits






Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net