Re: [sigc] How to use sigc::bind<>
- From: rsteinke w-link net
- To: Murray Cumming Comneon com, martin-ml hippogriff de, jcf tpg com au
- Cc: libsigc-list gnome org
- Subject: Re: [sigc] How to use sigc::bind<>
- Date: Sun, 09 Nov 2003 10:51:32 -0800
> From: Murray Cumming Comneon com
>
> > [mailto:libsigc-list-admin gnome org] On Behalf Of Jeff Franks
> > Martin Schulze wrote:
> >
> > > void bar(int,int);
> > > some_signal.connect(sigc::bind<0>(&bar,10,20));
> > > // binds two arguments at a time
> > >
> > > sigc::signal<void,int> other_signal;
> > > other_signal.connect(sigc::bind<0>(&bar,20));
> > > // binds to the last (second) argument of bar
> > > other_signal.connect(sigc::bind<1>(&bar,10));
> > > // binds to the first argument of bar
> > >
> > This is where I had confusion, bind<0> binds to the last
> > argument, not
> > the first, as zero might imply. I find the explanation bind<0> (zero)
> > binds to the last (second) argument of bar confusing. Compared with
> > bind<1> (first) binds to the first argument of bar, which sounds
> > logical. Initially I thought that the # in bind<#> meant that
> > you could
> > specify which argument position in the bound function the
> > bound argument
> > would be passed to, such as zero for the first, 1 for the
> > second, 2 for
> > the third, etc, like a zero-based index. That would leave bind<#> to
> > create a slot functor with one less argument, based on the remaining
> > arguments, as is required.
> >
> > I'm sure this will confuse many programmers.
>
> It confuses me.
Perhaps negative numbers could be used to indicate arguments at
the end of the slot (i.e., -1 for the last argument, -2 for the next-to-last,
etc.)?
Ron Steinke
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]