I'm trying to learn about boost mpl and I was wondering if something like this would be possible. Specifically, is it possible to conditionally typedef a function based on a template parameter? Something along the lines of this toy example:
template<typename arg1, typename arg2, typename rtype>
rtype getValue()
{
typedef boost::conditional<
// typedef boost::mpl::if_<
boost::is_same<rtype, double>,
double multiply(double a, double b),
int multiply(int a, int b)
> function;
function test;
return test(arg1::value, arg2::value);
}
I tried the above code and got the error that "template argument 2 is invalid". So I was wondering if there is a way to turn the function definition into a valid type since it is a valid typedef?
I am also aware there are many other ways to do this. I don't want a work around since this is an attempt to learn.