Re: [sigc] How to use sigc::bind<>

Martin Schulze wrote:

  void bar(int,int);
    // binds two arguments at a time

  sigc::signal<void,int> other_signal;
    // binds to the last (second) argument of bar
    // 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.

Jeff Franks.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]