Can I suppose that, from the call stack point view, it’s the same to call a function like function1
int function1(T1 t1, T2 t2);
than to another like function2?
struct parameters_t
{
Wide<T1>::type t1;
Wide<T2>::type t2;
}
int function2(parameters_t p);
Where, Wide template wide T to the processor word length.
For example, for 32-bit processors:
template<typename T, bool b = sizeof(T) >=4 >
struct Wide
{
typedef T type;
};
template<typename T>
struct Wide<T,false>
{
typedef unsigned int type;
};
I need to do something like this:
typedef int (*function_t)(parameters_t);
function_t function = (function_t) &function1;
parameters_t params;
// initialize params
function(params);
Thanks!
Question 1. No the two function calls aren’t necessarily the same — calling conventions that push parameters right to left and left to right are both in wide use.
It sounds like you want to create a function that takes a variable number of a variable type of parameters. To do that, I’d have it take something like an
std::vector<boost:any>as its parameter.