Boost logo

Boost :

From: Jim Apple (japple_at_[hidden])
Date: 2003-12-24 19:27:50


--------------------------------------------------
#include <boost/function.hpp>
using namespace boost;
 

char f(int, int = 0) { return 'a'; };
function<void (int)> b = f;
 

int main() {
   b(1);
}
--------------------------------------------------

As I trace through this code, I see that we eventually get to

boost::detail::function::void_function_invoker1<char (*)(int, int),
void, int>::invoke(boost::detail::function::any_pointer, int>

which has a char (*f)(int,int) which it calls with only one argument.

How the heck does it do that? I certainly can't compile:

--------------------------------------------------
char f(int, int = 0) { return 'a'; };
char (*b)(int,int) = f;
 

int main() {
   b(1);
}
--------------------------------------------------

Jim


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