I was wondering if a function pointer pointing to an inline
function, will actually expand "inline" when the function pointer
is invoked.
#include <iostream>
#include <vector>
using namespace std;
const int MAX_FP_SIZE = 10;
typedef void (*fp)(int& i);
vector<fp> vfptr(0);
inline void incr_callback(i nt& i)
{
i++;
cout << "i is " << i << endl;
}
inline void decr_callback(i nt& i)
{
i--;
cout << "i is " << i << endl;
}
void
register_callba ck(fp fptr)
{
vfptr.push_back (fptr);
}
void
schedule_callba cks(void)
{
int i = 0;
vector<fp>::ite rator iter;
fp tmp_fp;
cout << "i is " << i << endl;
for (iter = vfptr.begin(); iter != vfptr.end(); iter++) {
tmp_fp = *iter;
tmp_fp(i);
}
}
int
main(void)
{
register_callba ck(incr_callbac k);
register_callba ck(decr_callbac k);
schedule_callba cks();
}
In the piece of code above, I would actually like tmp_fp(i) to expand
inline. I understand that such optimization is hard to achieve, but
are there any compilers out there that can do this?
TIA,
Balbir
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]