26 Mar
2007
26 Mar
'07
6:46 p.m.
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
& f ); [snip] boost::function h = &f3; boost::function 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