Hello, although this is not strictly a Boost-related question I wonder
whether
some of the utilities in Boost (enable_if, type_traits) can help me
solve the problem:
Say I've got the following template function
template<typename T>
void call_f(int x)
{
T t;
t.f(x);
}
whose purpose is to invoke t.f(x) on an object of type T:
struct foo
{
void f(int){}
};
struct bar
{
static void f(int){};
};
...
call_f<foo>(5);
call_f<bar>(5);
And now I'd like to optimize call_f's implementation by avoiding the
creation of the T object when it is not necessary (as in bar, whose memfun
f is static). The following will do for simple cases like foo and bar above:
template