Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-04-17 13:13:48


From: "Giovanni Bajo" <giovannibajo_at_[hidden]>
> My dream:
>
> template <class T, class U>
> void Foo(T parm1, U parm2)
> { ... }
>
> boost::bind(Foo, _1, _2)(20, 30); // call Foo<int,int>(20,30), type
> deduction at call-time

Can't do that currently. 'Foo' is not representable as a value. The closest
is

struct Foo
{
    template<class T, class U> void operator()(T, U);
};

bind(Foo(), _1, _2);

> On the other hand, I managed to store an explicit instantiation of a
> function template:
>
> // Foo defined as above
> boost::bind(Foo<int,int>, _1, _2)(20, 30);
>
> Of course, this is useful in different conditions (my dream would be to be
> able to have type deduction at call time, not at bind time). The doubt
here
> is that Comeau/EDG does not compile this (GCC does), since it fails
deducing
> the template parameters for bind.

The problem here is that EDG considers Foo<int, int> a set of overloaded
functions (even when it contains a single element.) You need to
disambiguate:

void (*f) (int, int) = Foo<int, int>;
bind(f, _1, _2);


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