Boost logo

Boost Users :

Subject: Re: [Boost-users] [xpressive] Calling a placeholder method from within an action?
From: Ami Ganguli (ami.ganguli_at_[hidden])
Date: 2009-10-08 10:40:07


On Thu, Oct 8, 2009 at 4:43 PM, Eric Niebler <eric_at_[hidden]> wrote:
> I'm not exactly sure what _placeholder is here, or what you mean by "using
> an object as a placeholder".

Thanks. I just meant that I was using the placeholder template to
pass in an external object. But you seem to have gotten the gist of
what I was trying to say anyway :-).

> I'm afraid not. But if you go the route of creating function object
> wrappers, then you can get a nice syntax at the call site:

Yeah, I think I've settled on something like that. And I'm going to
resort to a C-style pre-processor define to cut down on the
boilerplate code. Something like (untested):

  #define makeFunc( METHOD, PARAM ) \
  struct METHOD##func \
  { \
    typedef void result_type; \
    void operator()(Link *l, PARAM p) const \
    { \
      l->METHOD(p); \
    } \
  } \
  function<METHOD##func>::type METHOD const = {{}}

  makeFunc(setPort, int)
  [repeat the makeFunc for each method]

Cheers,
Ami.


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