Boost logo

Boost Users :

Subject: Re: [Boost-users] [program_options] Possible to compose notifier to void void function?
From: Lars Viklund (zao_at_[hidden])
Date: 2013-04-13 08:10:46


On Fri, Apr 12, 2013 at 05:51:00PM -0500, Michael Powell wrote:
> Hello,
>
> Is it possible? Something like the example identified here:
>
> http://stackoverflow.com/questions/7125666/what-is-boostprogram-optionsnotify-for
>
> Except I'd like to hook up a void(void) notifier handler instead of the
> parameter.

notifier(f) expects anything callable with signature void(T).
A simple way of making a callable that can take more arguments is to use
boost::bind (or assumedly std::bind if you're fancy).

The callable that bind returns ignores any unused arguments, which in
the case of not having any placeholders at all is all of them.

void f() { std::cerr << "meep meep"; }

function<void (int,int,int)> fun = bind(&f);
fun(42, 3, 5);

-- 
Lars Viklund | zao_at_[hidden]

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