Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-03-26 14:46:47


On Mon, 2007-03-26 at 20:31 +0200, Seweryn Habdank-Wojewódzki wrote:
> Hi!
>
> I have small piece of code and I do not know why it is not compiling -
> proper instantiation of function is not created.
>
> It means, why boost::function can not deduct types (code below).
>
> The problem is when type U is void. Can any one help me with it?
>
> Regards.
>
> template < typename T, typename U >
> void test ( boost::function<T(U)> & f );
[snip]
> boost::function<int (void)> h = &f3;
> boost::function<void (void)> i = &f4;

The problem is that "int(void)" is just an alternative spelling for
"int()", i.e., a function type for a function that takes no parameters
but returns an "int". A function type int() cannot match a template
parameter T(U), because there is nothing to match the "U".

  Cheers,
  Doug


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