Boost logo

Boost :

From: Giovanni Bajo (giovannibajo_at_[hidden])
Date: 2003-03-20 07:00:50


Hello,

template <typename CB>
void Foo(CB cb)
{
    int a=123, b=456;

    bind(cb, _1, _2)(a,b);
}

void Bar1(int) {}
void Bar2(int, int) {}

int main()
{
    Foo(Bar1);
    Foo(Bar2);
}

The above compiles on Comeau, but fails on VC7.1 and GCC 3.2.2.

- The failing compilers complain because they cannot deduce the return type
for bind(). Expliciting it via bind<void>() turns off a first level of
errors. Why does this happen? Which template machery is failing? Maybe is
there a way to workaround it?

- After that, they complain with "too many arguments for call through
pointers". I know that bind() silently skips exceeding arguments, but I
never got if this applies to arguments at bind-time or call-time. Anyway, if
it's really wrong, then Comeau should not accept it, should it?

By the way, I'd love if the above was legal (and working on relatively
standard-compliant compilers like the aboves). It lets me support different
types of callbacks with additional parameters that can be ignored completely
if the user doesn't need that bit of information.

Giovanni Bajo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk