I have read following questions:
- Template functors vs functions
- C++ Functors - and their uses
- C++ function template partial specialization?
And I understand what C++ functors
are good for. But I can't deduce what will happen if will do the following:
template <typename T, unsigned int state>
class Foo {
public:
static Foo_func() { /* Do something */ };
}
// Partial specialization:
// -- state == 1
template <typename T>
class Foo <T, 1> {
public:
static Foo_func() { /* Do something */ };
}
template <typename F>
void call_func(F func) {
// Do something... //
func();
// Do something... //
}
int main() {
Foo <double, /*state*/ 1> obj;
// Case 1:
call_func(obj.Foo_func);
// Case 2:
call_func(Foo<double, /*state*/ 1>::Foo_func);
}
In which scenario compiler will be able to inline Foo_func()
?